@deck.gl/geo-layers 9.3.0-alpha.2 → 9.3.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist.min.js CHANGED
@@ -4,15 +4,15 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['deck'] = factory();
6
6
  else root['deck'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var i1=Object.create;var hn=Object.defineProperty;var a1=Object.getOwnPropertyDescriptor;var c1=Object.getOwnPropertyNames;var l1=Object.getPrototypeOf,f1=Object.prototype.hasOwnProperty;var u1=(t,e,r)=>e in t?hn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Ef=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var qe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),me=(t,e)=>{for(var r in e)hn(t,r,{get:e[r],enumerable:!0})},Ps=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of c1(e))!f1.call(t,s)&&s!==r&&hn(t,s,{get:()=>e[s],enumerable:!(n=a1(e,s))||n.enumerable});return t},bt=(t,e,r)=>(Ps(t,e,"default"),r&&Ps(r,e,"default")),D=(t,e,r)=>(r=t!=null?i1(l1(t)):{},Ps(e||!t||!t.__esModule?hn(r,"default",{value:t,enumerable:!0}):r,t)),h1=t=>Ps(hn({},"__esModule",{value:!0}),t);var zt=(t,e,r)=>(u1(t,typeof e!="symbol"?e+"":e,r),r);var je=qe((_3,Mf)=>{Mf.exports=globalThis.deck});var Je=qe((C3,Bf)=>{Bf.exports=globalThis.deck});var Zs=qe((j3,Hu)=>{Hu.exports=globalThis.h3||{}});var Kt=qe((IL,Hh)=>{Hh.exports=globalThis.loaders});var bc=qe((kd,Jn)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof Ef=="function"&&typeof Jn=="object"&&Jn&&Jn.exports?Jn.exports=e():(t.dcodeIO=t.dcodeIO||{}).Long=e()})(kd,function(){"use strict";function t(T,g,S){this.low=T|0,this.high=g|0,this.unsigned=!!S}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function e(T){return(T&&T.__isLong__)===!0}t.isLong=e;var r={},n={};function s(T,g){var S,F,R;return g?(T>>>=0,(R=0<=T&&T<256)&&(F=n[T],F)?F:(S=i(T,(T|0)<0?-1:0,!0),R&&(n[T]=S),S)):(T|=0,(R=-128<=T&&T<128)&&(F=r[T],F)?F:(S=i(T,T<0?-1:0,!1),R&&(r[T]=S),S))}t.fromInt=s;function o(T,g){if(isNaN(T)||!isFinite(T))return g?y:m;if(g){if(T<0)return y;if(T>=d)return C}else{if(T<=-p)return v;if(T+1>=p)return B}return T<0?o(-T,g).neg():i(T%h|0,T/h|0,g)}t.fromNumber=o;function i(T,g,S){return new t(T,g,S)}t.fromBits=i;var a=Math.pow;function c(T,g,S){if(T.length===0)throw Error("empty string");if(T==="NaN"||T==="Infinity"||T==="+Infinity"||T==="-Infinity")return m;if(typeof g=="number"?(S=g,g=!1):g=!!g,S=S||10,S<2||36<S)throw RangeError("radix");var F;if((F=T.indexOf("-"))>0)throw Error("interior hyphen");if(F===0)return c(T.substring(1),g,S).neg();for(var R=o(a(S,8)),L=m,G=0;G<T.length;G+=8){var W=Math.min(8,T.length-G),z=parseInt(T.substring(G,G+W),S);if(W<8){var te=o(a(S,W));L=L.mul(te).add(o(z))}else L=L.mul(R),L=L.add(o(z))}return L.unsigned=g,L}t.fromString=c;function l(T){return T instanceof t?T:typeof T=="number"?o(T):typeof T=="string"?c(T):i(T.low,T.high,T.unsigned)}t.fromValue=l;var f=1<<16,u=1<<24,h=f*f,d=h*h,p=d/2,A=s(u),m=s(0);t.ZERO=m;var y=s(0,!0);t.UZERO=y;var b=s(1);t.ONE=b;var E=s(1,!0);t.UONE=E;var M=s(-1);t.NEG_ONE=M;var B=i(-1,2147483647,!1);t.MAX_VALUE=B;var C=i(-1,-1,!0);t.MAX_UNSIGNED_VALUE=C;var v=i(0,-2147483648,!1);t.MIN_VALUE=v;var _=t.prototype;return _.toInt=function(){return this.unsigned?this.low>>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},_.toString=function(g){if(g=g||10,g<2||36<g)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(v)){var S=o(g),F=this.div(S),R=F.mul(S).sub(this);return F.toString(g)+R.toInt().toString(g)}else return"-"+this.neg().toString(g);for(var L=o(a(g,6),this.unsigned),G=this,W="";;){var z=G.div(L),te=G.sub(z.mul(L)).toInt()>>>0,K=te.toString(g);if(G=z,G.isZero())return K+W;for(;K.length<6;)K="0"+K;W=""+K+W}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(v)?64:this.neg().getNumBitsAbs();for(var g=this.high!=0?this.high:this.low,S=31;S>0&&!(g&1<<S);S--);return this.high!=0?S+33:S+1},_.isZero=function(){return this.high===0&&this.low===0},_.isNegative=function(){return!this.unsigned&&this.high<0},_.isPositive=function(){return this.unsigned||this.high>=0},_.isOdd=function(){return(this.low&1)===1},_.isEven=function(){return(this.low&1)===0},_.equals=function(g){return e(g)||(g=l(g)),this.unsigned!==g.unsigned&&this.high>>>31===1&&g.high>>>31===1?!1:this.high===g.high&&this.low===g.low},_.eq=_.equals,_.notEquals=function(g){return!this.eq(g)},_.neq=_.notEquals,_.lessThan=function(g){return this.comp(g)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(g){return this.comp(g)<=0},_.lte=_.lessThanOrEqual,_.greaterThan=function(g){return this.comp(g)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(g){return this.comp(g)>=0},_.gte=_.greaterThanOrEqual,_.compare=function(g){if(e(g)||(g=l(g)),this.eq(g))return 0;var S=this.isNegative(),F=g.isNegative();return S&&!F?-1:!S&&F?1:this.unsigned?g.high>>>0>this.high>>>0||g.high===this.high&&g.low>>>0>this.low>>>0?-1:1:this.sub(g).isNegative()?-1:1},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(v)?v:this.not().add(b)},_.neg=_.negate,_.add=function(g){e(g)||(g=l(g));var S=this.high>>>16,F=this.high&65535,R=this.low>>>16,L=this.low&65535,G=g.high>>>16,W=g.high&65535,z=g.low>>>16,te=g.low&65535,K=0,Y=0,$=0,_e=0;return _e+=L+te,$+=_e>>>16,_e&=65535,$+=R+z,Y+=$>>>16,$&=65535,Y+=F+W,K+=Y>>>16,Y&=65535,K+=S+G,K&=65535,i($<<16|_e,K<<16|Y,this.unsigned)},_.subtract=function(g){return e(g)||(g=l(g)),this.add(g.neg())},_.sub=_.subtract,_.multiply=function(g){if(this.isZero()||(e(g)||(g=l(g)),g.isZero()))return m;if(this.eq(v))return g.isOdd()?v:m;if(g.eq(v))return this.isOdd()?v:m;if(this.isNegative())return g.isNegative()?this.neg().mul(g.neg()):this.neg().mul(g).neg();if(g.isNegative())return this.mul(g.neg()).neg();if(this.lt(A)&&g.lt(A))return o(this.toNumber()*g.toNumber(),this.unsigned);var S=this.high>>>16,F=this.high&65535,R=this.low>>>16,L=this.low&65535,G=g.high>>>16,W=g.high&65535,z=g.low>>>16,te=g.low&65535,K=0,Y=0,$=0,_e=0;return _e+=L*te,$+=_e>>>16,_e&=65535,$+=R*te,Y+=$>>>16,$&=65535,$+=L*z,Y+=$>>>16,$&=65535,Y+=F*te,K+=Y>>>16,Y&=65535,Y+=R*z,K+=Y>>>16,Y&=65535,Y+=L*W,K+=Y>>>16,Y&=65535,K+=S*te+F*z+R*W+L*G,K&=65535,i($<<16|_e,K<<16|Y,this.unsigned)},_.mul=_.multiply,_.divide=function(g){if(e(g)||(g=l(g)),g.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?y:m;var S,F,R;if(this.unsigned){if(g.unsigned||(g=g.toUnsigned()),g.gt(this))return y;if(g.gt(this.shru(1)))return E;R=y}else{if(this.eq(v)){if(g.eq(b)||g.eq(M))return v;if(g.eq(v))return b;var L=this.shr(1);return S=L.div(g).shl(1),S.eq(m)?g.isNegative()?b:M:(F=this.sub(g.mul(S)),R=S.add(F.div(g)),R)}else if(g.eq(v))return this.unsigned?y:m;if(this.isNegative())return g.isNegative()?this.neg().div(g.neg()):this.neg().div(g).neg();if(g.isNegative())return this.div(g.neg()).neg();R=m}for(F=this;F.gte(g);){S=Math.max(1,Math.floor(F.toNumber()/g.toNumber()));for(var G=Math.ceil(Math.log(S)/Math.LN2),W=G<=48?1:a(2,G-48),z=o(S),te=z.mul(g);te.isNegative()||te.gt(F);)S-=W,z=o(S,this.unsigned),te=z.mul(g);z.isZero()&&(z=b),R=R.add(z),F=F.sub(te)}return R},_.div=_.divide,_.modulo=function(g){return e(g)||(g=l(g)),this.sub(this.div(g).mul(g))},_.mod=_.modulo,_.not=function(){return i(~this.low,~this.high,this.unsigned)},_.and=function(g){return e(g)||(g=l(g)),i(this.low&g.low,this.high&g.high,this.unsigned)},_.or=function(g){return e(g)||(g=l(g)),i(this.low|g.low,this.high|g.high,this.unsigned)},_.xor=function(g){return e(g)||(g=l(g)),i(this.low^g.low,this.high^g.high,this.unsigned)},_.shiftLeft=function(g){return e(g)&&(g=g.toInt()),(g&=63)===0?this:g<32?i(this.low<<g,this.high<<g|this.low>>>32-g,this.unsigned):i(0,this.low<<g-32,this.unsigned)},_.shl=_.shiftLeft,_.shiftRight=function(g){return e(g)&&(g=g.toInt()),(g&=63)===0?this:g<32?i(this.low>>>g|this.high<<32-g,this.high>>g,this.unsigned):i(this.high>>g-32,this.high>=0?0:-1,this.unsigned)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(g){if(e(g)&&(g=g.toInt()),g&=63,g===0)return this;var S=this.high;if(g<32){var F=this.low;return i(F>>>g|S<<32-g,S>>>g,this.unsigned)}else return g===32?i(S,0,this.unsigned):i(S>>>g-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},_.toBytes=function(T){return T?this.toBytesLE():this.toBytesBE()},_.toBytesLE=function(){var T=this.high,g=this.low;return[g&255,g>>>8&255,g>>>16&255,g>>>24&255,T&255,T>>>8&255,T>>>16&255,T>>>24&255]},_.toBytesBE=function(){var T=this.high,g=this.low;return[T>>>24&255,T>>>16&255,T>>>8&255,T&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255]},t})});var Rc=qe((bG,Sp)=>{Sp.exports=globalThis.luma});var zo=qe((EG,Ip)=>{Ip.exports=globalThis.deck});var Uc=qe((eU,Vp)=>{Vp.exports=globalThis.luma});var E0=qe((Oz,b0)=>{b0.exports=globalThis.deck});var F0=qe(ff=>{ff.read=function(t,e,r,n,s){var o,i,a=s*8-n-1,c=(1<<a)-1,l=c>>1,f=-7,u=r?s-1:0,h=r?-1:1,d=t[e+u];for(u+=h,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=o*256+t[e+u],u+=h,f-=8);for(i=o&(1<<-f)-1,o>>=-f,f+=n;f>0;i=i*256+t[e+u],u+=h,f-=8);if(o===0)o=1-l;else{if(o===c)return i?NaN:(d?-1:1)*(1/0);i=i+Math.pow(2,n),o=o-l}return(d?-1:1)*i*Math.pow(2,o-n)};ff.write=function(t,e,r,n,s,o){var i,a,c,l=o*8-s-1,f=(1<<l)-1,u=f>>1,h=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,A=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=f):(i=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-i))<1&&(i--,c*=2),i+u>=1?e+=h/c:e+=h*Math.pow(2,1-u),e*c>=2&&(i++,c/=2),i+u>=f?(a=0,i=f):i+u>=1?(a=(e*c-1)*Math.pow(2,s),i=i+u):(a=e*Math.pow(2,u-1)*Math.pow(2,s),i=0));s>=8;t[r+d]=a&255,d+=p,a/=256,s-=8);for(i=i<<s|a,l+=s;l>0;t[r+d]=i&255,d+=p,i/=256,l-=8);t[r+d-p]|=A*128}});var G0=qe((_5,D0)=>{"use strict";D0.exports=J;var Vi=F0();function J(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}J.Varint=0;J.Fixed64=1;J.Bytes=2;J.Fixed32=5;var uf=(1<<16)*(1<<16),R0=1/uf,Rw=12,N0=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");J.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),s=n>>3,o=this.pos;this.type=n&7,t(s,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Hi(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=O0(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Hi(this.buf,this.pos)+Hi(this.buf,this.pos+4)*uf;return this.pos+=8,t},readSFixed64:function(){var t=Hi(this.buf,this.pos)+O0(this.buf,this.pos+4)*uf;return this.pos+=8,t},readFloat:function(){var t=Vi.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Vi.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,n;return n=e[this.pos++],r=n&127,n<128||(n=e[this.pos++],r|=(n&127)<<7,n<128)||(n=e[this.pos++],r|=(n&127)<<14,n<128)||(n=e[this.pos++],r|=(n&127)<<21,n<128)?r:(n=e[this.pos],r|=(n&15)<<28,Pw(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=Rw&&N0?Xw(this.buf,e,t):Ww(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==J.Bytes)return t.push(this.readVarint(e));var r=Tt(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==J.Bytes)return t.push(this.readSVarint());var e=Tt(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==J.Bytes)return t.push(this.readBoolean());var e=Tt(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==J.Bytes)return t.push(this.readFloat());var e=Tt(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==J.Bytes)return t.push(this.readDouble());var e=Tt(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==J.Bytes)return t.push(this.readFixed32());var e=Tt(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==J.Bytes)return t.push(this.readSFixed32());var e=Tt(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==J.Bytes)return t.push(this.readFixed64());var e=Tt(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==J.Bytes)return t.push(this.readSFixed64());var e=Tt(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===J.Varint)for(;this.buf[this.pos++]>127;);else if(e===J.Bytes)this.pos=this.readVarint()+this.pos;else if(e===J.Fixed32)this.pos+=4;else if(e===J.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),un(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),un(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),un(this.buf,t&-1,this.pos),un(this.buf,Math.floor(t*R0),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),un(this.buf,t&-1,this.pos),un(this.buf,Math.floor(t*R0),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){Ow(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=Yw(this.buf,t,this.pos);var r=this.pos-e;r>=128&&P0(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Vi.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Vi.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var n=this.pos-r;n>=128&&P0(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,J.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Gw,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Uw,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,zw,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Vw,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Hw,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,kw,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,qw,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,jw,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Jw,e)},writeBytesField:function(t,e){this.writeTag(t,J.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,J.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,J.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,J.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,J.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,J.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,J.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,J.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,J.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,J.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};function Pw(t,e,r){var n=r.buf,s,o;if(o=n[r.pos++],s=(o&112)>>4,o<128||(o=n[r.pos++],s|=(o&127)<<3,o<128)||(o=n[r.pos++],s|=(o&127)<<10,o<128)||(o=n[r.pos++],s|=(o&127)<<17,o<128)||(o=n[r.pos++],s|=(o&127)<<24,o<128)||(o=n[r.pos++],s|=(o&1)<<31,o<128))return fn(t,s,e);throw new Error("Expected varint not more than 10 bytes")}function Tt(t){return t.type===J.Bytes?t.readVarint()+t.pos:t.pos+1}function fn(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function Ow(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(r=~(-t%4294967296),n=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,n=n+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),Nw(r,n,e),Dw(n,e)}function Nw(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function Dw(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function P0(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(n);for(var s=r.pos-1;s>=t;s--)r.buf[s+n]=r.buf[s]}function Gw(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function Uw(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function Vw(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function Hw(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function zw(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function kw(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function qw(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function jw(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function Jw(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function Hi(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function un(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function O0(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Ww(t,e,r){for(var n="",s=e;s<r;){var o=t[s],i=null,a=o>239?4:o>223?3:o>191?2:1;if(s+a>r)break;var c,l,f;a===1?o<128&&(i=o):a===2?(c=t[s+1],(c&192)===128&&(i=(o&31)<<6|c&63,i<=127&&(i=null))):a===3?(c=t[s+1],l=t[s+2],(c&192)===128&&(l&192)===128&&(i=(o&15)<<12|(c&63)<<6|l&63,(i<=2047||i>=55296&&i<=57343)&&(i=null))):a===4&&(c=t[s+1],l=t[s+2],f=t[s+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(i=(o&15)<<18|(c&63)<<12|(l&63)<<6|f&63,(i<=65535||i>=1114112)&&(i=null))),i===null?(i=65533,a=1):i>65535&&(i-=65536,n+=String.fromCharCode(i>>>10&1023|55296),i=56320|i&1023),n+=String.fromCharCode(i),s+=a}return n}function Xw(t,e,r){return N0.decode(t.subarray(e,r))}function Yw(t,e,r){for(var n=0,s,o;n<e.length;n++){if(s=e.charCodeAt(n),s>55295&&s<57344)if(o)if(s<56320){t[r++]=239,t[r++]=191,t[r++]=189,o=s;continue}else s=o-55296<<10|s-56320|65536,o=null;else{s>56319||n+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):o=s;continue}else o&&(t[r++]=239,t[r++]=191,t[r++]=189,o=null);s<128?t[r++]=s:(s<2048?t[r++]=s>>6|192:(s<65536?t[r++]=s>>12|224:(t[r++]=s>>18|240,t[r++]=s>>12&63|128),t[r++]=s>>6&63|128),t[r++]=s&63|128)}return r}});var Rs={};me(Rs,{A5Layer:()=>Vh,GeohashLayer:()=>o1,GreatCircleLayer:()=>zd,H3ClusterLayer:()=>Cp,H3HexagonLayer:()=>Ho,MVTLayer:()=>t1,QuadkeyLayer:()=>rp,S2Layer:()=>ep,TerrainLayer:()=>T0,Tile3DLayer:()=>h0,TileLayer:()=>lr,TripsLayer:()=>Mp,_GeoCellLayer:()=>Oe,_Tile2DHeader:()=>ar,_Tileset2D:()=>cr,_WMSLayer:()=>Hr,_getURLFromTemplate:()=>at});var et={},_f=D(je(),1);bt(et,D(je(),1));if(!_f.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");bt(Rs,et);var Cf=D(Je(),1),ji=D(je(),1),d1={...ji.PolygonLayer.defaultProps},dn=class extends Cf.CompositeLayer{indexToBounds(){return null}renderLayers(){let{elevationScale:e,extruded:r,wireframe:n,filled:s,stroked:o,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:h,getElevation:d,getFillColor:p,getLineColor:A,getLineWidth:m}=this.props,{updateTriggers:y,material:b,transitions:E}=this.props,M=this.getSubLayerClass("cell",ji.PolygonLayer),{updateTriggers:B,...C}=this.indexToBounds()||{};return new M({filled:s,wireframe:n,extruded:r,elevationScale:e,stroked:o,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:h,material:b,transitions:E,getElevation:d,getFillColor:p,getLineColor:A,getLineWidth:m},this.getSubLayerProps({id:"cell",updateTriggers:y&&{...B,getElevation:y.getElevation,getFillColor:y.getFillColor,getLineColor:y.getLineColor,getLineWidth:y.getLineWidth}}),C)}};dn.layerName="GeoCellLayer";dn.defaultProps=d1;var Oe=dn;var p1=Object.defineProperty,An=(t,e)=>{for(var r in e)p1(t,r,{get:e[r],enumerable:!0})},Te={};An(Te,{ARRAY_TYPE:()=>ne,EPSILON:()=>pe,RANDOM:()=>kt,equals:()=>x1,setMatrixArrayType:()=>m1,toRadian:()=>A1});var pe=1e-6,ne=typeof Float32Array<"u"?Float32Array:Array,kt=Math.random;function m1(t){ne=t}var g1=Math.PI/180;function A1(t){return t*g1}function x1(t,e){return Math.abs(t-e)<=pe*Math.max(1,Math.abs(t),Math.abs(e))}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var qt={};An(qt,{LDU:()=>O1,add:()=>N1,adjoint:()=>S1,clone:()=>T1,copy:()=>b1,create:()=>y1,determinant:()=>I1,equals:()=>G1,exactEquals:()=>D1,frob:()=>P1,fromRotation:()=>L1,fromScaling:()=>F1,fromValues:()=>M1,identity:()=>E1,invert:()=>C1,mul:()=>H1,multiply:()=>Xf,multiplyScalar:()=>U1,multiplyScalarAndAdd:()=>V1,rotate:()=>w1,scale:()=>v1,set:()=>_1,str:()=>R1,sub:()=>z1,subtract:()=>Yf,transpose:()=>B1});function y1(){var t=new ne(4);return ne!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function T1(t){var e=new ne(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function b1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function E1(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t}function M1(t,e,r,n){var s=new ne(4);return s[0]=t,s[1]=e,s[2]=r,s[3]=n,s}function _1(t,e,r,n,s){return t[0]=e,t[1]=r,t[2]=n,t[3]=s,t}function B1(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t}function C1(t,e){var r=e[0],n=e[1],s=e[2],o=e[3],i=r*o-s*n;return i?(i=1/i,t[0]=o*i,t[1]=-n*i,t[2]=-s*i,t[3]=r*i,t):null}function S1(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t}function I1(t){return t[0]*t[3]-t[2]*t[1]}function Xf(t,e,r){var n=e[0],s=e[1],o=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*a+o*c,t[1]=s*a+i*c,t[2]=n*l+o*f,t[3]=s*l+i*f,t}function w1(t,e,r){var n=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*a,t[1]=s*c+i*a,t[2]=n*-a+o*c,t[3]=s*-a+i*c,t}function v1(t,e,r){var n=e[0],s=e[1],o=e[2],i=e[3],a=r[0],c=r[1];return t[0]=n*a,t[1]=s*a,t[2]=o*c,t[3]=i*c,t}function L1(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t}function F1(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t}function R1(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function P1(t){return Math.hypot(t[0],t[1],t[2],t[3])}function O1(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]}function N1(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function Yf(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function D1(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function G1(t,e){var r=t[0],n=t[1],s=t[2],o=t[3],i=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-i)<=pe*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=pe*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-c)<=pe*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(o-l)<=pe*Math.max(1,Math.abs(o),Math.abs(l))}function U1(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function V1(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}var H1=Xf,z1=Yf;function k1(){var t=new ne(9);return ne!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}var Yi={};An(Yi,{add:()=>rx,calculateW:()=>jA,clone:()=>ZA,conjugate:()=>YA,copy:()=>ex,create:()=>Qi,dot:()=>uu,equals:()=>cx,exactEquals:()=>ax,exp:()=>au,fromEuler:()=>KA,fromMat3:()=>lu,fromValues:()=>$A,getAngle:()=>HA,getAxisAngle:()=>VA,identity:()=>UA,invert:()=>XA,len:()=>ox,length:()=>hu,lerp:()=>sx,ln:()=>cu,mul:()=>nx,multiply:()=>iu,normalize:()=>ia,pow:()=>JA,random:()=>WA,rotateX:()=>zA,rotateY:()=>kA,rotateZ:()=>qA,rotationTo:()=>lx,scale:()=>fu,set:()=>tx,setAxes:()=>ux,setAxisAngle:()=>ou,slerp:()=>qs,sqlerp:()=>fx,sqrLen:()=>ix,squaredLength:()=>du,str:()=>QA});var w={};An(w,{add:()=>W1,angle:()=>dA,bezier:()=>oA,ceil:()=>X1,clone:()=>q1,copy:()=>j1,create:()=>sa,cross:()=>ks,dist:()=>bA,distance:()=>eu,div:()=>TA,divide:()=>$f,dot:()=>oa,equals:()=>AA,exactEquals:()=>gA,floor:()=>Y1,forEach:()=>_A,fromValues:()=>Ki,hermite:()=>sA,inverse:()=>rA,len:()=>su,length:()=>Kf,lerp:()=>nA,max:()=>Q1,min:()=>K1,mul:()=>yA,multiply:()=>Zf,negate:()=>tA,normalize:()=>nu,random:()=>iA,rotateX:()=>fA,rotateY:()=>uA,rotateZ:()=>hA,round:()=>Z1,scale:()=>$1,scaleAndAdd:()=>eA,set:()=>J1,sqrDist:()=>EA,sqrLen:()=>MA,squaredDistance:()=>tu,squaredLength:()=>ru,str:()=>mA,sub:()=>xA,subtract:()=>Qf,transformMat3:()=>cA,transformMat4:()=>aA,transformQuat:()=>lA,zero:()=>pA});function sa(){var t=new ne(3);return ne!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function q1(t){var e=new ne(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Kf(t){var e=t[0],r=t[1],n=t[2];return Math.hypot(e,r,n)}function Ki(t,e,r){var n=new ne(3);return n[0]=t,n[1]=e,n[2]=r,n}function j1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function J1(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function W1(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Qf(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Zf(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function $f(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function X1(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function Y1(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function K1(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function Q1(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function Z1(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function $1(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function eA(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function eu(t,e){var r=e[0]-t[0],n=e[1]-t[1],s=e[2]-t[2];return Math.hypot(r,n,s)}function tu(t,e){var r=e[0]-t[0],n=e[1]-t[1],s=e[2]-t[2];return r*r+n*n+s*s}function ru(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function tA(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function rA(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function nu(t,e){var r=e[0],n=e[1],s=e[2],o=r*r+n*n+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function oa(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ks(t,e,r){var n=e[0],s=e[1],o=e[2],i=r[0],a=r[1],c=r[2];return t[0]=s*c-o*a,t[1]=o*i-n*c,t[2]=n*a-s*i,t}function nA(t,e,r,n){var s=e[0],o=e[1],i=e[2];return t[0]=s+n*(r[0]-s),t[1]=o+n*(r[1]-o),t[2]=i+n*(r[2]-i),t}function sA(t,e,r,n,s,o){var i=o*o,a=i*(2*o-3)+1,c=i*(o-2)+o,l=i*(o-1),f=i*(3-2*o);return t[0]=e[0]*a+r[0]*c+n[0]*l+s[0]*f,t[1]=e[1]*a+r[1]*c+n[1]*l+s[1]*f,t[2]=e[2]*a+r[2]*c+n[2]*l+s[2]*f,t}function oA(t,e,r,n,s,o){var i=1-o,a=i*i,c=o*o,l=a*i,f=3*o*a,u=3*c*i,h=c*o;return t[0]=e[0]*l+r[0]*f+n[0]*u+s[0]*h,t[1]=e[1]*l+r[1]*f+n[1]*u+s[1]*h,t[2]=e[2]*l+r[2]*f+n[2]*u+s[2]*h,t}function iA(t,e){e=e||1;var r=kt()*2*Math.PI,n=kt()*2-1,s=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*s,t[1]=Math.sin(r)*s,t[2]=n*e,t}function aA(t,e,r){var n=e[0],s=e[1],o=e[2],i=r[3]*n+r[7]*s+r[11]*o+r[15];return i=i||1,t[0]=(r[0]*n+r[4]*s+r[8]*o+r[12])/i,t[1]=(r[1]*n+r[5]*s+r[9]*o+r[13])/i,t[2]=(r[2]*n+r[6]*s+r[10]*o+r[14])/i,t}function cA(t,e,r){var n=e[0],s=e[1],o=e[2];return t[0]=n*r[0]+s*r[3]+o*r[6],t[1]=n*r[1]+s*r[4]+o*r[7],t[2]=n*r[2]+s*r[5]+o*r[8],t}function lA(t,e,r){var n=r[0],s=r[1],o=r[2],i=r[3],a=e[0],c=e[1],l=e[2],f=s*l-o*c,u=o*a-n*l,h=n*c-s*a,d=s*h-o*u,p=o*f-n*h,A=n*u-s*f,m=i*2;return f*=m,u*=m,h*=m,d*=2,p*=2,A*=2,t[0]=a+f+d,t[1]=c+u+p,t[2]=l+h+A,t}function fA(t,e,r,n){var s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0],o[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),o[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function uA(t,e,r,n){var s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),o[1]=s[1],o[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function hA(t,e,r,n){var s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),o[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),o[2]=s[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function dA(t,e){var r=t[0],n=t[1],s=t[2],o=e[0],i=e[1],a=e[2],c=Math.sqrt(r*r+n*n+s*s),l=Math.sqrt(o*o+i*i+a*a),f=c*l,u=f&&oa(t,e)/f;return Math.acos(Math.min(Math.max(u,-1),1))}function pA(t){return t[0]=0,t[1]=0,t[2]=0,t}function mA(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function gA(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function AA(t,e){var r=t[0],n=t[1],s=t[2],o=e[0],i=e[1],a=e[2];return Math.abs(r-o)<=pe*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-i)<=pe*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(s-a)<=pe*Math.max(1,Math.abs(s),Math.abs(a))}var xA=Qf,yA=Zf,TA=$f,bA=eu,EA=tu,su=Kf,MA=ru,_A=function(){var t=sa();return function(e,r,n,s,o,i){var a,c;for(r||(r=3),n||(n=0),s?c=Math.min(s*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],o(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();function BA(){var t=new ne(4);return ne!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function CA(t){var e=new ne(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function SA(t,e,r,n){var s=new ne(4);return s[0]=t,s[1]=e,s[2]=r,s[3]=n,s}function IA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function wA(t,e,r,n,s){return t[0]=e,t[1]=r,t[2]=n,t[3]=s,t}function vA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function LA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function FA(t){var e=t[0],r=t[1],n=t[2],s=t[3];return Math.hypot(e,r,n,s)}function RA(t){var e=t[0],r=t[1],n=t[2],s=t[3];return e*e+r*r+n*n+s*s}function PA(t,e){var r=e[0],n=e[1],s=e[2],o=e[3],i=r*r+n*n+s*s+o*o;return i>0&&(i=1/Math.sqrt(i)),t[0]=r*i,t[1]=n*i,t[2]=s*i,t[3]=o*i,t}function OA(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function NA(t,e,r,n){var s=e[0],o=e[1],i=e[2],a=e[3];return t[0]=s+n*(r[0]-s),t[1]=o+n*(r[1]-o),t[2]=i+n*(r[2]-i),t[3]=a+n*(r[3]-a),t}function DA(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function GA(t,e){var r=t[0],n=t[1],s=t[2],o=t[3],i=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-i)<=pe*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=pe*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-c)<=pe*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(o-l)<=pe*Math.max(1,Math.abs(o),Math.abs(l))}var I3=function(){var t=BA();return function(e,r,n,s,o,i){var a,c;for(r||(r=4),n||(n=0),s?c=Math.min(s*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],o(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();function Qi(){var t=new ne(4);return ne!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function UA(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function ou(t,e,r){r=r*.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function VA(t,e){var r=Math.acos(e[3])*2,n=Math.sin(r/2);return n>pe?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r}function HA(t,e){var r=uu(t,e);return Math.acos(2*r*r-1)}function iu(t,e,r){var n=e[0],s=e[1],o=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+i*a+s*l-o*c,t[1]=s*f+i*c+o*a-n*l,t[2]=o*f+i*l+n*c-s*a,t[3]=i*f-n*a-s*c-o*l,t}function zA(t,e,r){r*=.5;var n=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=s*c+o*a,t[2]=o*c-s*a,t[3]=i*c-n*a,t}function kA(t,e,r){r*=.5;var n=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-o*a,t[1]=s*c+i*a,t[2]=o*c+n*a,t[3]=i*c-s*a,t}function qA(t,e,r){r*=.5;var n=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*a,t[1]=s*c-n*a,t[2]=o*c+i*a,t[3]=i*c-o*a,t}function jA(t,e){var r=e[0],n=e[1],s=e[2];return t[0]=r,t[1]=n,t[2]=s,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-s*s)),t}function au(t,e){var r=e[0],n=e[1],s=e[2],o=e[3],i=Math.sqrt(r*r+n*n+s*s),a=Math.exp(o),c=i>0?a*Math.sin(i)/i:0;return t[0]=r*c,t[1]=n*c,t[2]=s*c,t[3]=a*Math.cos(i),t}function cu(t,e){var r=e[0],n=e[1],s=e[2],o=e[3],i=Math.sqrt(r*r+n*n+s*s),a=i>0?Math.atan2(i,o)/i:0;return t[0]=r*a,t[1]=n*a,t[2]=s*a,t[3]=.5*Math.log(r*r+n*n+s*s+o*o),t}function JA(t,e,r){return cu(t,e),fu(t,t,r),au(t,t),t}function qs(t,e,r,n){var s=e[0],o=e[1],i=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],h,d,p,A,m;return d=s*c+o*l+i*f+a*u,d<0&&(d=-d,c=-c,l=-l,f=-f,u=-u),1-d>pe?(h=Math.acos(d),p=Math.sin(h),A=Math.sin((1-n)*h)/p,m=Math.sin(n*h)/p):(A=1-n,m=n),t[0]=A*s+m*c,t[1]=A*o+m*l,t[2]=A*i+m*f,t[3]=A*a+m*u,t}function WA(t){var e=kt(),r=kt(),n=kt(),s=Math.sqrt(1-e),o=Math.sqrt(e);return t[0]=s*Math.sin(2*Math.PI*r),t[1]=s*Math.cos(2*Math.PI*r),t[2]=o*Math.sin(2*Math.PI*n),t[3]=o*Math.cos(2*Math.PI*n),t}function XA(t,e){var r=e[0],n=e[1],s=e[2],o=e[3],i=r*r+n*n+s*s+o*o,a=i?1/i:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-s*a,t[3]=o*a,t}function YA(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function lu(t,e){var r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var s=0;e[4]>e[0]&&(s=1),e[8]>e[s*3+s]&&(s=2);var o=(s+1)%3,i=(s+2)%3;n=Math.sqrt(e[s*3+s]-e[o*3+o]-e[i*3+i]+1),t[s]=.5*n,n=.5/n,t[3]=(e[o*3+i]-e[i*3+o])*n,t[o]=(e[o*3+s]+e[s*3+o])*n,t[i]=(e[i*3+s]+e[s*3+i])*n}return t}function KA(t,e,r,n){var s=.5*Math.PI/180;e*=s,r*=s,n*=s;var o=Math.sin(e),i=Math.cos(e),a=Math.sin(r),c=Math.cos(r),l=Math.sin(n),f=Math.cos(n);return t[0]=o*c*f-i*a*l,t[1]=i*a*f+o*c*l,t[2]=i*c*l-o*a*f,t[3]=i*c*f+o*a*l,t}function QA(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var ZA=CA,$A=SA,ex=IA,tx=wA,rx=vA,nx=iu,fu=LA,uu=OA,sx=NA,hu=FA,ox=hu,du=RA,ix=du,ia=PA,ax=DA,cx=GA,lx=function(){var t=sa(),e=Ki(1,0,0),r=Ki(0,1,0);return function(n,s,o){var i=oa(s,o);return i<-.999999?(ks(t,e,s),su(t)<1e-6&&ks(t,r,s),nu(t,t),ou(n,t,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(ks(t,s,o),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+i,ia(n,n))}}(),fx=function(){var t=Qi(),e=Qi();return function(r,n,s,o,i,a){return qs(t,n,i,a),qs(e,s,o,a),qs(r,t,e,2*a*(1-a)),r}}(),ux=function(){var t=k1();return function(e,r,n,s){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=s[0],t[4]=s[1],t[7]=s[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],ia(e,lu(e,t))}}(),P={};An(P,{add:()=>gx,angle:()=>Nx,ceil:()=>Ax,clone:()=>hx,copy:()=>px,create:()=>pu,cross:()=>Ix,dist:()=>jx,distance:()=>xu,div:()=>qx,divide:()=>Au,dot:()=>Sx,equals:()=>Vx,exactEquals:()=>Ux,floor:()=>xx,forEach:()=>Xx,fromValues:()=>dx,inverse:()=>Bx,len:()=>Hx,length:()=>Tu,lerp:()=>wx,max:()=>Tx,min:()=>yx,mul:()=>kx,multiply:()=>gu,negate:()=>_x,normalize:()=>Cx,random:()=>vx,rotate:()=>Ox,round:()=>bx,scale:()=>Ex,scaleAndAdd:()=>Mx,set:()=>mx,sqrDist:()=>Jx,sqrLen:()=>Wx,squaredDistance:()=>yu,squaredLength:()=>bu,str:()=>Gx,sub:()=>zx,subtract:()=>mu,transformMat2:()=>Lx,transformMat2d:()=>Fx,transformMat3:()=>Rx,transformMat4:()=>Px,zero:()=>Dx});function pu(){var t=new ne(2);return ne!=Float32Array&&(t[0]=0,t[1]=0),t}function hx(t){var e=new ne(2);return e[0]=t[0],e[1]=t[1],e}function dx(t,e){var r=new ne(2);return r[0]=t,r[1]=e,r}function px(t,e){return t[0]=e[0],t[1]=e[1],t}function mx(t,e,r){return t[0]=e,t[1]=r,t}function gx(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function mu(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function gu(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function Au(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function Ax(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function xx(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function yx(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function Tx(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function bx(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t}function Ex(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function Mx(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t}function xu(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.hypot(r,n)}function yu(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function Tu(t){var e=t[0],r=t[1];return Math.hypot(e,r)}function bu(t){var e=t[0],r=t[1];return e*e+r*r}function _x(t,e){return t[0]=-e[0],t[1]=-e[1],t}function Bx(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function Cx(t,e){var r=e[0],n=e[1],s=r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t}function Sx(t,e){return t[0]*e[0]+t[1]*e[1]}function Ix(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t}function wx(t,e,r,n){var s=e[0],o=e[1];return t[0]=s+n*(r[0]-s),t[1]=o+n*(r[1]-o),t}function vx(t,e){e=e||1;var r=kt()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function Lx(t,e,r){var n=e[0],s=e[1];return t[0]=r[0]*n+r[2]*s,t[1]=r[1]*n+r[3]*s,t}function Fx(t,e,r){var n=e[0],s=e[1];return t[0]=r[0]*n+r[2]*s+r[4],t[1]=r[1]*n+r[3]*s+r[5],t}function Rx(t,e,r){var n=e[0],s=e[1];return t[0]=r[0]*n+r[3]*s+r[6],t[1]=r[1]*n+r[4]*s+r[7],t}function Px(t,e,r){var n=e[0],s=e[1];return t[0]=r[0]*n+r[4]*s+r[12],t[1]=r[1]*n+r[5]*s+r[13],t}function Ox(t,e,r,n){var s=e[0]-r[0],o=e[1]-r[1],i=Math.sin(n),a=Math.cos(n);return t[0]=s*a-o*i+r[0],t[1]=s*i+o*a+r[1],t}function Nx(t,e){var r=t[0],n=t[1],s=e[0],o=e[1],i=Math.sqrt(r*r+n*n)*Math.sqrt(s*s+o*o),a=i&&(r*s+n*o)/i;return Math.acos(Math.min(Math.max(a,-1),1))}function Dx(t){return t[0]=0,t[1]=0,t}function Gx(t){return"vec2("+t[0]+", "+t[1]+")"}function Ux(t,e){return t[0]===e[0]&&t[1]===e[1]}function Vx(t,e){var r=t[0],n=t[1],s=e[0],o=e[1];return Math.abs(r-s)<=pe*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-o)<=pe*Math.max(1,Math.abs(n),Math.abs(o))}var Hx=Tu,zx=mu,kx=gu,qx=Au,jx=xu,Jx=yu,Wx=bu,Xx=function(){var t=pu();return function(e,r,n,s,o,i){var a,c;for(r||(r=2),n||(n=0),s?c=Math.min(s*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],o(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}}(),Xs=(1+Math.sqrt(5))/2,w3=2*Math.PI,js=2*Math.PI/5,tt=Math.PI/5,Sf=Math.PI/10,Yx=2*Math.atan(Xs),Zi=Math.PI-Yx,v3=-.5*Math.PI+Math.acos(-1/Math.sqrt(3-Xs)),Ys=(Math.sqrt(5)-1)/2,Kx=3-Math.sqrt(5),Qx=Math.sqrt(3-Xs),L3=Math.sqrt(3)*Qx/Xs;Te.setMatrixArrayType(Float64Array);var aa=class $i{constructor(e){this.vertices=e,this.isWindingCorrect()||this.vertices.reverse()}getArea(){let e=0,r=this.vertices.length;for(let n=0;n<r;n++){let s=(n+1)%r;e+=(this.vertices[s][0]-this.vertices[n][0])*(this.vertices[s][1]+this.vertices[n][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(let r of this.vertices)P.scale(r,r,e);return this}rotate180(){for(let e of this.vertices)P.negate(e,e);return this}reflectY(){for(let e of this.vertices)e[1]=-e[1];return this.vertices.reverse(),this}translate(e){for(let r of this.vertices)P.add(r,r,e);return this}transform(e){for(let r of this.vertices)P.transformMat2(r,r,e);return this}transform2d(e){for(let r of this.vertices)P.transformMat2d(r,r,e);return this}clone(){return new $i(this.vertices.map(r=>P.clone(r)))}getCenter(){let e=this.vertices.length;return this.vertices.reduce((n,s)=>[n[0]+s[0]/e,n[1]+s[1]/e],[0,0])}containsPoint(e){if(!this.isWindingCorrect())throw new Error("Pentagon is not counter-clockwise");let r=this.vertices.length,n=1;for(let s=0;s<r;s++){let o=this.vertices[s],i=this.vertices[(s+1)%r],a=o[0]-i[0],c=o[1]-i[1],l=e[0]-o[0],f=e[1]-o[1],u=a*f-c*l;if(u<0){let h=Math.sqrt(l*l+f*f);n=Math.min(n,u/h)}}return n}splitEdges(e){if(e<=1)return this;let r=[],n=this.vertices.length;for(let s=0;s<n;s++){let o=this.vertices[s],i=this.vertices[(s+1)%n];r.push(P.clone(o));for(let a=1;a<e;a++){let c=a/e,l=P.create();P.lerp(l,o,i,c),r.push(l)}}return new $i(r)}};Te.setMatrixArrayType(Float64Array);var Eu=[0,0],Mu=[0,1],jt=[.7885966681787006,1.6149108024237764],_u=[1.6171013659387945,1.054928690397459],Bu=[Math.cos(Sf),Math.sin(Sf)],Zx=2*P.length(jt)*Math.cos(tt),$x=tt-Math.atan2(jt[1],jt[0]),ey=2*Ys/Zx;[Eu,Mu,jt,_u,Bu].forEach(t=>{P.scale(t,t,ey),P.rotate(t,t,[0,0],$x)});var ty=new aa([Eu,Mu,jt,_u,Bu]),Cu=Math.atan2(jt[1],jt[0])-tt,ry=[0,0],Js=Ys/Math.cos(tt),If=Cu+tt,Ws=[Js*Math.cos(If),Js*Math.sin(If)],wf=Cu-tt,gn=[Js*Math.cos(wf),Js*Math.sin(wf)],Su=new aa([ry,Ws,gn]),Iu=qt.fromValues(Ws[0],Ws[1],gn[0],gn[1]),F3=qt.invert(qt.create(),Iu),ny=new Float64Array([-.0022392098386786394,21308606513250217e-22,-2559257686421274e-24,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32]),sy=new Float64Array([.0022392089963541657,28831978048607556e-22,508622073997266e-23,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]),oy=class{applyCoefficients(t,e){let r=Math.sin(t),n=Math.cos(t),s=2*(n-r)*(n+r),o,i;return o=s*e[5]+e[4],i=s*o+e[3],o=s*i-o+e[2],i=s*o-i+e[1],o=s*i-o+e[0],t+2*r*n*o}forward(t){return this.applyCoefficients(t,ny)}inverse(t){return this.applyCoefficients(t,sy)}};Te.setMatrixArrayType(Float64Array);var wu=new oy;function vf(t){return t*(Math.PI/180)}function Lf(t){return t*(180/Math.PI)}function Ff(t){let e=P.length(t),r=Math.atan2(t[1],t[0]);return[e,r]}function iy([t,e]){let r=t*Math.cos(e),n=t*Math.sin(e);return[r,n]}function ay(t,[e,r,n]){let s=[e[0]-n[0],e[1]-n[1]],o=[n[0]-r[0],n[1]-r[1]],i=[t[0]-n[0],t[1]-n[1]],a=o[0]*s[1]-o[1]*s[0],c=(o[0]*i[1]-o[1]*i[0])/a,l=(s[0]*i[1]-s[1]*i[0])/a,f=1-(c+l);return[c,l,f]}function cy(t,[e,r,n]){return[t[0]*e[0]+t[1]*r[0]+t[2]*n[0],t[0]*e[1]+t[1]*r[1]+t[2]*n[1]]}function ea(t){let e=Math.atan2(t[1],t[0]),r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),n=Math.acos(t[2]/r);return[e,n]}function Sr([t,e]){let r=Math.sin(e),n=r*Math.cos(t),s=r*Math.sin(t),o=Math.cos(e);return[n,s,o]}var vu=93;function ly([t,e]){let r=vf(t+vu),n=vf(e),s=wu.forward(n),o=Math.PI/2-s;return[r,o]}function Lu([t,e]){let r=Lf(t)-vu,n=Math.PI/2-e,s=wu.inverse(n),o=Lf(s);return[r,o]}function fy(t){let e=t.map(o=>Sr(ly(o))),r=w.create();for(let o of e)w.add(r,r,o);w.normalize(r,r);let[n,s]=Lu(ea(r));return(s>89.99||s<-89.99)&&(n=t[0][0]),n=((n+180)%360+360)%360-180,t.map(o=>{let[i,a]=o;for(;i-n>180;)i=i-360;for(;i-n<-180;)i=i+360;return[i,a]})}Te.setMatrixArrayType(Float64Array);var Ks=Math.sqrt(5),Qs=Math.sqrt(.2),Fu=Math.sqrt((1-Qs)/2),Ru=Math.sqrt((1+Qs)/2),Os=.5,Rf=Math.sqrt((2.5-Ks)/10),Pf=Math.sqrt((2.5+Ks)/10),Of=Math.sqrt((1+Qs)/8),Nf=Math.sqrt((1-Qs)/8),Df=Math.sqrt((3-Ks)/8),Gf=Math.sqrt((3+Ks)/8),uy=[[0,0],[Fu,0],[Rf,Os],[-Of,Df],[-Of,-Df],[Rf,-Os],[-Ru,0],[-Nf,-Gf],[Pf,-Os],[Pf,Os],[-Nf,Gf],[0,0]],hy=uy.map(([t,e])=>[-e,t]),Ns=hy.map((t,e)=>e===0?[0,0,0,1]:e===11?[0,-1,0,0]:[...t,0,e<6?Ru:Fu]);Te.setMatrixArrayType(Float64Array);var Pu=["vu","uw","vw","vw","vw"],pn=["wu","uw","vw","vu","uw"],Ji=["wu","uv","wv","wu","uw"],Ds=["vu","uv","wv","wu","uw"],dy=[Pu,Ds,Ji,pn,Ji,Ds,Ji,pn,pn,pn,Ds,Ds],py=[4,2,3,2,0,4,3,2,2,0,3,0],Uf=[0,1,2,4,3,5,7,8,6,11,10,9],We=[];function my(){Gs([0,0],0,Ns[0]);for(let t=0;t<5;t++){let e=t*js,r=e+tt;Gs([e,Zi],tt,Ns[t+1]),Gs([r,Math.PI-Zi],tt,Ns[(t+3)%5+6])}Gs([0,Math.PI],0,Ns[11])}var _r=0;function Gs(t,e,r){if(_r>11)throw new Error(`Too many origins: ${_r}`);let n=Yi.create();Yi.conjugate(n,r);let s={id:_r,axis:t,quat:r,inverseQuat:n,angle:e,orientation:dy[_r],firstQuintant:py[_r]};We.push(s),_r++}my();We.sort((t,e)=>Uf.indexOf(t.id)-Uf.indexOf(e.id));We.forEach((t,e)=>t.id=e);function gy(t,e){let r=e.orientation,n=r===Pu||r===pn?-1:1,s=(t-e.firstQuintant+5)%5,o=r[s];return{quintant:(e.firstQuintant+n*s+5)%5,orientation:o}}var Ay=class{forward([t,e]){return[Math.tan(e),t]}inverse([t,e]){return[e,Math.atan(t)]}},Br=w.create(),mn=w.create(),Vf=w.create(),Hf=w.create();function Wi(t,e){w.lerp(Br,t,e,.5),w.normalize(Br,Br),w.cross(Br,t,Br);let r=w.length(Br);if(r<1e-8){let n=w.subtract(w.create(),t,e);return .5*w.length(n)}return r}function xy(t,e,r){return w.cross(mn,e,r),w.dot(t,mn)}function yy(t,e,r,n,s){w.cross(mn,n,s);let o=w.dot(e,mn),i=w.dot(r,mn);return w.scale(Vf,e,i),w.scale(Hf,r,o),w.sub(t,Hf,Vf)}function ta(t,e,r,n){let s=w.angle(e,r);if(s<1e-12)return w.lerp(t,e,r,n);let o=Math.sin((1-n)*s)/Math.sin(s),i=Math.sin(n*s)/Math.sin(s),a=w.scale(w.create(),e,o),c=w.scale(w.create(),r,i);return w.add(t,a,c)}Te.setMatrixArrayType(Float64Array);var Us=w.create(),Vs=w.create(),Hs=w.create(),Cr=w.create(),Ty=class{constructor(t){this._area=null,this.vertices=t,Object.freeze(this.vertices)}getBoundary(t=1,e=!0){let r=[],n=this.vertices.length;for(let s=0;s<n*t;s++){let o=s/t;r.push(this.slerp(o))}return e&&r.push(r[0]),r}slerp(t){let e=this.vertices.length,r=t%1,n=Math.floor(t%e),s=(n+1)%e;return ta(w.create(),this.vertices[n],this.vertices[s],r)}getTransformedVertices(t){let e=this.vertices.length,r=Math.floor(t%e),n=(r+1)%e,s=(r+e-1)%e,o=w.clone(this.vertices[r]),i=w.clone(this.vertices[n]),a=w.clone(this.vertices[s]);return w.sub(i,i,o),w.sub(a,a,o),[o,i,a]}containsPoint(t){let e=this.vertices.length,r=1/0;for(let n=0;n<e;n++){let[s,o,i]=this.getTransformedVertices(n),a=w.sub(w.create(),t,s);w.normalize(a,a),w.normalize(o,o),w.normalize(i,i);let c=w.cross(w.create(),o,a),l=w.cross(w.create(),a,i),f=w.dot(s,c),u=w.dot(s,l);r=Math.min(r,f,u)}return r}getTriangleArea(t,e,r){w.lerp(Us,e,r,.5),w.lerp(Vs,r,t,.5),w.lerp(Hs,t,e,.5),w.normalize(Us,Us),w.normalize(Vs,Vs),w.normalize(Hs,Hs);let n=xy(Us,Vs,Hs),s=Math.max(-1,Math.min(1,n));return Math.abs(s)<1e-8?2*s:Math.asin(s)*2}getArea(){return this._area===null&&(this._area=this._getArea()),this._area}_getArea(){if(this.vertices.length<3)return 0;if(this.vertices.length===3)return this._area=this.getTriangleArea(this.vertices[0],this.vertices[1],this.vertices[2]),this._area;w.set(Cr,0,0,0);for(let e of this.vertices)w.add(Cr,Cr,e);w.normalize(Cr,Cr);let t=0;for(let e=0;e<this.vertices.length;e++){let r=this.vertices[e],n=this.vertices[(e+1)%this.vertices.length],s=this.getTriangleArea(Cr,r,n);isNaN(s)||(t+=s)}return this._area=t,this._area}isWindingCorrect(){if(!(this.getArea()>0))debugger}};Te.setMatrixArrayType(Float64Array);var zs=class extends Ty{constructor(t){if(t.length!==3)throw new Error("SphericalTriangleShape requires exactly 3 vertices");super(t)}};Te.setMatrixArrayType(Float64Array);var by=class{forward(t,e,r){let[n,s,o]=e,i=new zs([n,s,o]),a=w.subtract(w.create(),t,n);w.normalize(a,a);let c=yy(w.create(),n,a,s,o);w.normalize(c,c);let l=Wi(n,t)/Wi(n,c),f=i.getArea(),u=l/f,h=[1-l,u*new zs([n,c,o]).getArea(),u*new zs([n,s,c]).getArea()];return cy(h,r)}inverse(t,e,r){let[n,s,o]=r,i=new zs([n,s,o]),a=ay(t,e),c=1-1e-14;if(a[0]>c)return n;if(a[1]>c)return s;if(a[2]>c)return o;let l=w.create();w.cross(l,s,o);let f=i.getArea(),u=1-a[0],d=a[2]/u*f,p=Math.sin(d),A=Math.sin(d/2),m=2*A*A,y=w.dot(n,s),b=w.dot(s,o),E=w.dot(o,n),M=w.length(l),B=w.dot(n,l),C=p*B+m*(y*b-E),v=m*M*(1+y),_=2/Math.acos(b)*Math.atan2(v,C),T=ta(w.create(),s,o,_),g=Wi(n,T),S=this.safeAcos(u*g)/this.safeAcos(g);return ta([0,0,0],n,T,S)}safeAcos(t){return t<.001?2*t+t*t*t/3:Math.acos(1-2*t*t)}};Te.setMatrixArrayType(Float64Array);var Ie=-1,ye=1,Ey=([t,e])=>P.fromValues(t-e,e),ra=P.fromValues(1,0),na=P.fromValues(0,1),zf=P.negate(P.create(),ra),kf=P.negate(P.create(),na),Xi=P.fromValues(0,0),My=(t,[e,r])=>{let n=Xi,s=Xi;switch(e===ye&&r===ye?(n=ra,s=na):e===Ie&&r===ye?(n=kf,s=zf):e===ye&&r===Ie?(n=na,s=ra):e===Ie&&r===Ie&&(n=zf,s=kf),t){case 0:return Xi;case 1:return n;case 2:return P.add(P.create(),s,n);case 3:return P.scaleAndAdd(P.create(),s,n,2);default:throw new Error(`Invalid Quaternary value: ${t}`)}},qf=t=>[[ye,ye],[ye,Ie],[ye,ye],[Ie,ye]][t],jf=P.fromValues(-1,1);function Ou(t){return Array.from({length:t.length},(e,r)=>t.indexOf(r))}var Nu=[0,1,3,4,5,6,7,2],Du=[0,1,2,7,3,4,5,6],R3=Ou(Nu),P3=Ou(Du),_y=(t,e,r,n,s)=>{if(e<=0)return;let o=t[e]||0,i=t[e-1],a=r[0]+r[1],c=!0,l=!0;if(n!==(a===0)?(c=o===1||o===2,l=o===1):(c=o<2,l=o===0),!c)return;let f=l?i:i+4,u=s[f];t[e-1]=u%4,t[e]=(o+4+Math.floor(u/4)-Math.floor(f/4))%4},By=(t,e,r)=>{let n=BigInt(t),s=r==="vu"||r==="wu"||r==="vw",o=r==="wv"||r==="vw",i=r==="wu"||r==="uw";s&&(n=(1n<<BigInt(2*e))-n-1n);let a=Cy(n,e,o,i);if(i){let{offset:[c,l],flips:[f,u]}=a;a.offset=[l,c],f===Ie&&P.add(a.offset,a.offset,jf),u===Ie&&P.subtract(a.offset,a.offset,jf)}if(o){let{offset:[c,l],flips:f}=a,u=(1<<e)-(c+l);f[0]=-f[0],a.offset[1]=u,a.flips=f}return a},Cy=(t,e,r,n)=>{let s=P.create(),o=[ye,ye],i=BigInt(t),a=[];for(;i>0n||a.length<e;)a.push(Number(i%4n)),i=i>>2n;let c=n?Du:Nu;for(let f=a.length-1;f>=0;f--)_y(a,f,o,r,c),P.multiply(o,o,qf(a[f]));o[0]=ye,o[1]=ye;for(let f=a.length-1;f>=0;f--){P.scale(s,s,2);let u=My(a[f],o);P.add(s,s,u),P.multiply(o,o,qf(a[f]))}let l=a[0]||0;return{flips:o,k:l,offset:Ey(s)}};Te.setMatrixArrayType(Float64Array);var Sy=!1,Iy=P.clone(gn),wy=P.negate(P.create(),gn),ca=[0,1,2,3,4].map(t=>{let e=qt.create();return qt.fromRotation(e,js*t),e}),Jf=P.create();function vy(t,e,r){let n=(Sy?Su:ty).clone();P.transformMat2(Jf,r.offset,Iu),r.flips[0]===ye&&r.flips[1]===Ie&&n.rotate180();let{k:s}=r,o=r.flips[0]+r.flips[1];return((o===-2||o===2)&&s>1||o===0&&(s===0||s===3))&&n.reflectY(),r.flips[0]===Ie&&r.flips[1]===Ie?n.rotate180():r.flips[0]===Ie?n.translate(wy):r.flips[1]===Ie&&n.translate(Iy),n.translate(Jf),n.scale(1/2**t),n.transform(ca[e]),n}function Gu(t){let e=Su.clone();return e.transform(ca[t]),e}function Ly(){let t=[];for(let e of ca)t.push(P.transformMat2(P.create(),Ws,e));return t.reverse(),new aa(t)}Te.setMatrixArrayType(Float64Array);var Fy=class{constructor(){if(this.vertices=[],this.invocations=0,this.addFaceCenters(),this.addVertices(),this.addMidpoints(),this.vertices.length!==62)throw new Error("Failed to construct CRS: vertices length is not 62");Object.freeze(this.vertices)}getVertex(t){this.invocations++,this.invocations===1e4&&console.warn("Too many CRS invocations, results should be cached");for(let e of this.vertices)if(w.distance(t,e)<1e-5)return e;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){We.forEach(t=>this.add(Sr(t.axis)))}addVertices(){let t=Math.atan(Kx);for(let e of We)for(let r=0;r<5;r++){let n=(2*r+1)*Math.PI/5,s=Sr([n+e.angle,t]);w.transformQuat(s,s,e.quat),this.add(s)}}addMidpoints(){let t=Math.atan(Ys);for(let e of We)for(let r=0;r<5;r++){let n=2*r*Math.PI/5,s=Sr([n+e.angle,t]);w.transformQuat(s,s,e.quat),this.add(s)}}add(t){let e=w.normalize(w.create(),t);return this.vertices.find(n=>w.distance(e,n)<1e-5)?!1:(this.vertices.push(e),!0)}};Te.setMatrixArrayType(Float64Array);var Ry=new Fy,Py=class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.polyhedral=new by,this.gnomonic=new Ay}forward(t,e){let r=We[e],n=Sr(t),s=w.create();w.transformQuat(s,n,r.inverseQuat);let o=ea(s),i=this.gnomonic.forward(o);i[1]=i[1]-r.angle;let a=this.getFaceTriangleIndex(i),c=this.shouldReflect(i),l=this.getFaceTriangle(a,c,!1),f=this.getSphericalTriangle(a,e,c);return this.polyhedral.forward(n,f,l)}inverse(t,e){let r=Ff(t),n=this.getFaceTriangleIndex(r),s=this.shouldReflect(r),o=this.getFaceTriangle(n,s,!1),i=this.getSphericalTriangle(n,e,s),a=this.polyhedral.inverse(t,o,i);return ea(a)}shouldReflect(t){let[e,r]=t;return iy([e,this.normalizeGamma(r)])[0]>Ys}getFaceTriangleIndex([t,e]){return(Math.floor(e/tt)+10)%10}getFaceTriangle(t,e=!1,r=!1){let n=t;return e&&(n+=r?20:10),this.faceTriangles[n]?this.faceTriangles[n]:(this.faceTriangles[n]=e?this._getReflectedFaceTriangle(t,r):this._getFaceTriangle(t),Object.freeze(this.faceTriangles[n]),this.faceTriangles[n])}_getFaceTriangle(t){let e=Math.floor((t+1)/2)%5,[r,n,s]=Gu(e).getVertices(),o=P.create();return P.lerp(o,n,s,.5),t%2===0?[r,o,n]:[r,s,o]}_getReflectedFaceTriangle(t,e=!1){let[r,n,s]=this._getFaceTriangle(t).map(a=>P.clone(a)),o=t%2===0;P.negate(r,r);let i=o?n:s;return P.scaleAndAdd(r,r,i,e?1+1/Math.cos(Zi):2),[r,s,n]}getSphericalTriangle(t,e,r=!1){let n=10*e+t;return r&&(n+=120),this.sphericalTriangles[n]?this.sphericalTriangles[n]:(this.sphericalTriangles[n]=this._getSphericalTriangle(t,e,r),Object.freeze(this.sphericalTriangles[n]),this.sphericalTriangles[n])}_getSphericalTriangle(t,e,r=!1){let n=We[e];return this.getFaceTriangle(t,r,!0).map(i=>{let[a,c]=Ff(i),l=[a,c+n.angle],f=Sr(this.gnomonic.inverse(l));return w.transformQuat(f,f,n.quat),Ry.getVertex(f)})}normalizeGamma(t){let e=t/js,r=Math.round(e);return(e-r)*js}},Ir=2,Oy=30,Ny=58n,Dy=0x3ffffffffffffffn;function Gy(t){let e=Oy-1,r=t>>1n;for(;e>-1&&(r&0b1n)===0n;)e-=1,r=r>>(e<Ir?1n:2n);return e}function Uy(t){let e=Gy(t);if(e===-1)return{origin:We[0],segment:0,S:0n,resolution:e};let r=Number(t>>58n),n,s;if(e===0)n=We[r],s=0;else{let l=Math.floor(r/5);n=We[l],s=(r+n.firstQuintant)%5}if(!n)throw new Error(`Could not parse origin: ${r}`);if(e<Ir)return{origin:n,segment:s,S:0n,resolution:e};let o=e-Ir+1,i=BigInt(2*o),a=Ny-i,c=(t&Dy)>>a;return{origin:n,segment:s,S:c,resolution:e}}Te.setMatrixArrayType(Float64Array);var O3=qt.create(),Vy=new Py;function Hy({S:t,segment:e,origin:r,resolution:n}){let{quintant:s,orientation:o}=gy(e,r);if(n===Ir-1)return Gu(s);if(n===Ir-2)return Ly();let i=n-Ir+1,a=By(t,i,o);return vy(i,s,a)}function Uu(t,{closedRing:e=!0,segments:r="auto"}={closedRing:!0,segments:"auto"}){let{S:n,segment:s,origin:o,resolution:i}=Uy(t);r==="auto"&&(r=Math.max(1,Math.pow(2,6-i)));let u=Hy({S:n,segment:s,origin:o,resolution:i}).splitEdges(r).getVertices().map(d=>Vy.inverse(d,o.id)).map(d=>Lu(d)),h=fy(u);return e&&h.push(h[0]),h.reverse(),h}function Vu(t){return BigInt(`0x${t}`)}var Wf=63710072e-1,N3=4*Math.PI*Wf*Wf;Te.setMatrixArrayType(Float64Array);var Bn=D(Zs(),1);var zy=1/Math.PI*180,ky=1/180*Math.PI,qy={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...qy}};var Q=globalThis.mathgl.config;function la(t,{precision:e=Q.precision}={}){return t=jy(t),`${parseFloat(t.toPrecision(e))}`}function we(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function fa(t){return zu(t)}function ua(t){return ve(t)}function zu(t,e){return ha(t,r=>r*ky,e)}function ve(t,e){return ha(t,r=>r*zy,e)}function $s(t,e,r){return ha(t,n=>Math.max(e,Math.min(r,n)))}function Et(t,e,r){return we(t)?t.map((n,s)=>Et(n,e[s],r)):r*e+(1-r)*t}function be(t,e,r){let n=Q.EPSILON;r&&(Q.EPSILON=r);try{if(t===e)return!0;if(we(t)&&we(e)){if(t.length!==e.length)return!1;for(let s=0;s<t.length;++s)if(!be(t[s],e[s]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=Q.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{Q.EPSILON=n}}function jy(t){return Math.round(t/Q.EPSILON)*Q.EPSILON}function Jy(t){return t.clone?t.clone():new Array(t.length)}function ha(t,e,r){if(we(t)){let n=t;r=r||Jy(n);for(let s=0;s<r.length&&s<n.length;++s){let o=typeof t=="number"?t:t[s];r[s]=e(o,s,r)}return r}return e(t)}var Mt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:we(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Q)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+la(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!be(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let s=0;s<this.ELEMENTS;++s){let o=e[s],i=typeof r=="number"?r:r[s];this[s]=o+n*(i-o)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(Q.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function Wy(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function V(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function _t(t,e,r=""){if(Q.debug&&!Wy(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function fe(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var Bt=class extends Mt{get x(){return this[0]}set x(e){this[0]=V(e)}get y(){return this[1]}set y(e){this[1]=V(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let n=0;n<this.ELEMENTS;++n){let s=this[n]-e[n];r+=s*s}return V(r)}dot(e){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*e[n];return V(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return fe(e>=0&&e<this.ELEMENTS,"index is out of range"),V(this[e])}setComponent(e,r){return fe(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var ee=typeof Float32Array<"u"?Float32Array:Array,xn=Math.random;function wr(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var rv=Math.PI/180;function Xy(){let t=new ee(2);return ee!=Float32Array&&(t[0]=0,t[1]=0),t}function ku(t,e,r){let n=e[0],s=e[1];return t[0]=r[0]*n+r[2]*s,t[1]=r[1]*n+r[3]*s,t}function qu(t,e,r){let n=e[0],s=e[1];return t[0]=r[0]*n+r[2]*s+r[4],t[1]=r[1]*n+r[3]*s+r[5],t}function eo(t,e,r){let n=e[0],s=e[1];return t[0]=r[0]*n+r[3]*s+r[6],t[1]=r[1]*n+r[4]*s+r[7],t}function to(t,e,r){let n=e[0],s=e[1];return t[0]=r[0]*n+r[4]*s+r[12],t[1]=r[1]*n+r[5]*s+r[13],t}var nv=function(){let t=Xy();return function(e,r,n,s,o,i){let a,c;for(r||(r=2),n||(n=0),s?c=Math.min(s*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],o(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}}();function ro(t,e,r){let n=e[0],s=e[1],o=r[3]*n+r[7]*s||1;return t[0]=(r[0]*n+r[4]*s)/o,t[1]=(r[1]*n+r[5]*s)/o,t}function no(t,e,r){let n=e[0],s=e[1],o=e[2],i=r[3]*n+r[7]*s+r[11]*o||1;return t[0]=(r[0]*n+r[4]*s+r[8]*o)/i,t[1]=(r[1]*n+r[5]*s+r[9]*o)/i,t[2]=(r[2]*n+r[6]*s+r[10]*o)/i,t}function ju(t,e,r){let n=e[0],s=e[1];return t[0]=r[0]*n+r[2]*s,t[1]=r[1]*n+r[3]*s,t[2]=e[2],t}function Ju(t,e,r){let n=e[0],s=e[1];return t[0]=r[0]*n+r[2]*s,t[1]=r[1]*n+r[3]*s,t[2]=e[2],t[3]=e[3],t}function so(t,e,r){let n=e[0],s=e[1],o=e[2];return t[0]=r[0]*n+r[3]*s+r[6]*o,t[1]=r[1]*n+r[4]*s+r[7]*o,t[2]=r[2]*n+r[5]*s+r[8]*o,t[3]=e[3],t}var Jt=class extends Bt{constructor(e=0,r=0){super(2),we(e)&&arguments.length===1?this.copy(e):(Q.debug&&(V(e),V(r)),this[0]=e,this[1]=r)}set(e,r){return this[0]=e,this[1]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return Q.debug&&(V(e.x),V(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return to(this,this,e),this.check()}transformAsVector(e){return ro(this,this,e),this.check()}transformByMatrix3(e){return eo(this,this,e),this.check()}transformByMatrix2x3(e){return qu(this,this,e),this.check()}transformByMatrix2(e){return ku(this,this,e),this.check()}};var Yt={};me(Yt,{add:()=>Zy,angle:()=>Aa,bezier:()=>uT,ceil:()=>$y,clone:()=>Yy,copy:()=>Ky,create:()=>oo,cross:()=>Wt,dist:()=>TT,distance:()=>Qu,div:()=>yT,divide:()=>Ku,dot:()=>yn,equals:()=>gT,exactEquals:()=>mT,floor:()=>eT,forEach:()=>MT,fromValues:()=>io,hermite:()=>fT,inverse:()=>aT,len:()=>xa,length:()=>Wu,lerp:()=>cT,max:()=>rT,min:()=>tT,mul:()=>xT,multiply:()=>Yu,negate:()=>iT,normalize:()=>da,random:()=>hT,rotateX:()=>pa,rotateY:()=>ma,rotateZ:()=>ga,round:()=>nT,scale:()=>sT,scaleAndAdd:()=>oT,set:()=>Qy,slerp:()=>lT,sqrDist:()=>bT,sqrLen:()=>ET,squaredDistance:()=>Zu,squaredLength:()=>$u,str:()=>pT,sub:()=>AT,subtract:()=>Xu,transformMat3:()=>Tn,transformMat4:()=>Xt,transformQuat:()=>bn,zero:()=>dT});function oo(){let t=new ee(3);return ee!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Yy(t){let e=new ee(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Wu(t){let e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function io(t,e,r){let n=new ee(3);return n[0]=t,n[1]=e,n[2]=r,n}function Ky(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Qy(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function Zy(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Xu(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Yu(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Ku(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function $y(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function eT(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function tT(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function rT(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function nT(t,e){return t[0]=wr(e[0]),t[1]=wr(e[1]),t[2]=wr(e[2]),t}function sT(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function oT(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function Qu(t,e){let r=e[0]-t[0],n=e[1]-t[1],s=e[2]-t[2];return Math.sqrt(r*r+n*n+s*s)}function Zu(t,e){let r=e[0]-t[0],n=e[1]-t[1],s=e[2]-t[2];return r*r+n*n+s*s}function $u(t){let e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function iT(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function aT(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function da(t,e){let r=e[0],n=e[1],s=e[2],o=r*r+n*n+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function yn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Wt(t,e,r){let n=e[0],s=e[1],o=e[2],i=r[0],a=r[1],c=r[2];return t[0]=s*c-o*a,t[1]=o*i-n*c,t[2]=n*a-s*i,t}function cT(t,e,r,n){let s=e[0],o=e[1],i=e[2];return t[0]=s+n*(r[0]-s),t[1]=o+n*(r[1]-o),t[2]=i+n*(r[2]-i),t}function lT(t,e,r,n){let s=Math.acos(Math.min(Math.max(yn(e,r),-1),1)),o=Math.sin(s),i=Math.sin((1-n)*s)/o,a=Math.sin(n*s)/o;return t[0]=i*e[0]+a*r[0],t[1]=i*e[1]+a*r[1],t[2]=i*e[2]+a*r[2],t}function fT(t,e,r,n,s,o){let i=o*o,a=i*(2*o-3)+1,c=i*(o-2)+o,l=i*(o-1),f=i*(3-2*o);return t[0]=e[0]*a+r[0]*c+n[0]*l+s[0]*f,t[1]=e[1]*a+r[1]*c+n[1]*l+s[1]*f,t[2]=e[2]*a+r[2]*c+n[2]*l+s[2]*f,t}function uT(t,e,r,n,s,o){let i=1-o,a=i*i,c=o*o,l=a*i,f=3*o*a,u=3*c*i,h=c*o;return t[0]=e[0]*l+r[0]*f+n[0]*u+s[0]*h,t[1]=e[1]*l+r[1]*f+n[1]*u+s[1]*h,t[2]=e[2]*l+r[2]*f+n[2]*u+s[2]*h,t}function hT(t,e){e=e===void 0?1:e;let r=xn()*2*Math.PI,n=xn()*2-1,s=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*s,t[1]=Math.sin(r)*s,t[2]=n*e,t}function Xt(t,e,r){let n=e[0],s=e[1],o=e[2],i=r[3]*n+r[7]*s+r[11]*o+r[15];return i=i||1,t[0]=(r[0]*n+r[4]*s+r[8]*o+r[12])/i,t[1]=(r[1]*n+r[5]*s+r[9]*o+r[13])/i,t[2]=(r[2]*n+r[6]*s+r[10]*o+r[14])/i,t}function Tn(t,e,r){let n=e[0],s=e[1],o=e[2];return t[0]=n*r[0]+s*r[3]+o*r[6],t[1]=n*r[1]+s*r[4]+o*r[7],t[2]=n*r[2]+s*r[5]+o*r[8],t}function bn(t,e,r){let n=r[0],s=r[1],o=r[2],i=r[3],a=e[0],c=e[1],l=e[2],f=s*l-o*c,u=o*a-n*l,h=n*c-s*a,d=s*h-o*u,p=o*f-n*h,A=n*u-s*f,m=i*2;return f*=m,u*=m,h*=m,d*=2,p*=2,A*=2,t[0]=a+f+d,t[1]=c+u+p,t[2]=l+h+A,t}function pa(t,e,r,n){let s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0],o[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),o[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function ma(t,e,r,n){let s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),o[1]=s[1],o[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function ga(t,e,r,n){let s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),o[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),o[2]=s[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Aa(t,e){let r=t[0],n=t[1],s=t[2],o=e[0],i=e[1],a=e[2],c=Math.sqrt((r*r+n*n+s*s)*(o*o+i*i+a*a)),l=c&&yn(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function dT(t){return t[0]=0,t[1]=0,t[2]=0,t}function pT(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function mT(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function gT(t,e){let r=t[0],n=t[1],s=t[2],o=e[0],i=e[1],a=e[2];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var AT=Xu,xT=Yu,yT=Ku,TT=Qu,bT=Zu,xa=Wu,ET=$u,MT=function(){let t=oo();return function(e,r,n,s,o,i){let a,c;for(r||(r=3),n||(n=0),s?c=Math.min(s*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],o(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var ya=[0,0,0],ao,x=class extends Bt{static get ZERO(){return ao||(ao=new x(0,0,0),Object.freeze(ao)),ao}constructor(e=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&we(e)?this.copy(e):(Q.debug&&(V(e),V(r),V(n)),this[0]=e,this[1]=r,this[2]=n)}set(e,r,n){return this[0]=e,this[1]=r,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Q.debug&&(V(e.x),V(e.y),V(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=V(e)}angle(e){return Aa(this,e)}cross(e){return Wt(this,this,e),this.check()}rotateX({radians:e,origin:r=ya}){return pa(this,this,r,e),this.check()}rotateY({radians:e,origin:r=ya}){return ma(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=ya}){return ga(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Xt(this,this,e),this.check()}transformAsVector(e){return no(this,this,e),this.check()}transformByMatrix3(e){return Tn(this,this,e),this.check()}transformByMatrix2(e){return ju(this,this,e),this.check()}transformByQuaternion(e){return bn(this,this,e),this.check()}};var co,Lr=class extends Bt{static get ZERO(){return co||(co=new Lr(0,0,0,0),Object.freeze(co)),co}constructor(e=0,r=0,n=0,s=0){super(-0,-0,-0,-0),we(e)&&arguments.length===1?this.copy(e):(Q.debug&&(V(e),V(r),V(n),V(s)),this[0]=e,this[1]=r,this[2]=n,this[3]=s)}set(e,r,n,s){return this[0]=e,this[1]=r,this[2]=n,this[3]=s,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return Q.debug&&(V(e.x),V(e.y),V(e.z),V(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=V(e)}get w(){return this[3]}set w(e){this[3]=V(e)}transform(e){return Xt(this,this,e),this.check()}transformByMatrix3(e){return so(this,this,e),this.check()}transformByMatrix2(e){return Ju(this,this,e),this.check()}transformByQuaternion(e){return bn(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}};var Fr=class extends Mt{toString(){let e="[";if(Q.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=V(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let s=0;s<this.RANK;++s)r[s]=this[n+s];return r}setColumn(e,r){let n=e*this.RANK;for(let s=0;s<this.RANK;++s)this[n+s]=r[s];return this}};function eh(){let t=new ee(9);return ee!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function th(t,e){if(t===e){let r=e[1],n=e[2],s=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=s}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function rh(t,e){let r=e[0],n=e[1],s=e[2],o=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=f*i-a*l,h=-f*o+a*c,d=l*o-i*c,p=r*u+n*h+s*d;return p?(p=1/p,t[0]=u*p,t[1]=(-f*n+s*l)*p,t[2]=(a*n-s*i)*p,t[3]=h*p,t[4]=(f*r-s*c)*p,t[5]=(-a*r+s*o)*p,t[6]=d*p,t[7]=(-l*r+n*c)*p,t[8]=(i*r-n*o)*p,t):null}function nh(t){let e=t[0],r=t[1],n=t[2],s=t[3],o=t[4],i=t[5],a=t[6],c=t[7],l=t[8];return e*(l*o-i*c)+r*(-l*s+i*a)+n*(c*s-o*a)}function Ta(t,e,r){let n=e[0],s=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=r[0],d=r[1],p=r[2],A=r[3],m=r[4],y=r[5],b=r[6],E=r[7],M=r[8];return t[0]=h*n+d*i+p*l,t[1]=h*s+d*a+p*f,t[2]=h*o+d*c+p*u,t[3]=A*n+m*i+y*l,t[4]=A*s+m*a+y*f,t[5]=A*o+m*c+y*u,t[6]=b*n+E*i+M*l,t[7]=b*s+E*a+M*f,t[8]=b*o+E*c+M*u,t}function sh(t,e,r){let n=e[0],s=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=r[0],d=r[1];return t[0]=n,t[1]=s,t[2]=o,t[3]=i,t[4]=a,t[5]=c,t[6]=h*n+d*i+l,t[7]=h*s+d*a+f,t[8]=h*o+d*c+u,t}function oh(t,e,r){let n=e[0],s=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=Math.sin(r),d=Math.cos(r);return t[0]=d*n+h*i,t[1]=d*s+h*a,t[2]=d*o+h*c,t[3]=d*i-h*n,t[4]=d*a-h*s,t[5]=d*c-h*o,t[6]=l,t[7]=f,t[8]=u,t}function ba(t,e,r){let n=r[0],s=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=s*e[3],t[4]=s*e[4],t[5]=s*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function ih(t,e){let r=e[0],n=e[1],s=e[2],o=e[3],i=r+r,a=n+n,c=s+s,l=r*i,f=n*i,u=n*a,h=s*i,d=s*a,p=s*c,A=o*i,m=o*a,y=o*c;return t[0]=1-u-p,t[3]=f-y,t[6]=h+m,t[1]=f+y,t[4]=1-l-p,t[7]=d-A,t[2]=h-m,t[5]=d+A,t[8]=1-l-u,t}var Ea;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(Ea||(Ea={}));var BT=Object.freeze([1,0,0,0,1,0,0,0,1]),j=class extends Fr{static get IDENTITY(){return ST()}static get ZERO(){return CT()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Ea}constructor(e,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):r.length>0?this.copy([e,...r]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(BT)}fromObject(e){return this.check()}fromQuaternion(e){return ih(this,e),this.check()}set(e,r,n,s,o,i,a,c,l){return this[0]=e,this[1]=r,this[2]=n,this[3]=s,this[4]=o,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,n,s,o,i,a,c,l){return this[0]=e,this[1]=s,this[2]=a,this[3]=r,this[4]=o,this[5]=c,this[6]=n,this[7]=i,this[8]=l,this.check()}determinant(){return nh(this)}transpose(){return th(this,this),this.check()}invert(){return rh(this,this),this.check()}multiplyLeft(e){return Ta(this,e,this),this.check()}multiplyRight(e){return Ta(this,this,e),this.check()}rotate(e){return oh(this,this,e),this.check()}scale(e){return Array.isArray(e)?ba(this,this,e):ba(this,this,[e,e]),this.check()}translate(e){return sh(this,this,e),this.check()}transform(e,r){let n;switch(e.length){case 2:n=eo(r||[-0,-0],e,this);break;case 3:n=Tn(r||[-0,-0,-0],e,this);break;case 4:n=so(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return _t(n,e.length),n}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}},lo,fo=null;function CT(){return lo||(lo=new j([0,0,0,0,0,0,0,0,0]),Object.freeze(lo)),lo}function ST(){return fo||(fo=new j,Object.freeze(fo)),fo}var Mn={};me(Mn,{add:()=>ZT,adjoint:()=>RT,clone:()=>wT,copy:()=>vT,create:()=>IT,decompose:()=>kT,determinant:()=>Ba,equals:()=>rb,exactEquals:()=>tb,frob:()=>QT,fromQuat:()=>Fa,fromQuat2:()=>VT,fromRotation:()=>NT,fromRotationTranslation:()=>ch,fromRotationTranslationScale:()=>qT,fromRotationTranslationScaleOrigin:()=>jT,fromScaling:()=>OT,fromTranslation:()=>PT,fromValues:()=>LT,fromXRotation:()=>DT,fromYRotation:()=>GT,fromZRotation:()=>UT,frustum:()=>Ra,getRotation:()=>zT,getScaling:()=>lh,getTranslation:()=>HT,identity:()=>ah,invert:()=>_a,lookAt:()=>Na,mul:()=>nb,multiply:()=>En,multiplyScalar:()=>$T,multiplyScalarAndAdd:()=>eb,ortho:()=>Oa,orthoNO:()=>uh,orthoZO:()=>XT,perspective:()=>Pa,perspectiveFromFieldOfView:()=>WT,perspectiveNO:()=>fh,perspectiveZO:()=>JT,rotate:()=>Ia,rotateX:()=>wa,rotateY:()=>va,rotateZ:()=>La,scale:()=>Sa,set:()=>FT,str:()=>KT,sub:()=>sb,subtract:()=>hh,targetTo:()=>YT,translate:()=>Ca,transpose:()=>Ma});function IT(){let t=new ee(16);return ee!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function wT(t){let e=new ee(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function vT(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function LT(t,e,r,n,s,o,i,a,c,l,f,u,h,d,p,A){let m=new ee(16);return m[0]=t,m[1]=e,m[2]=r,m[3]=n,m[4]=s,m[5]=o,m[6]=i,m[7]=a,m[8]=c,m[9]=l,m[10]=f,m[11]=u,m[12]=h,m[13]=d,m[14]=p,m[15]=A,m}function FT(t,e,r,n,s,o,i,a,c,l,f,u,h,d,p,A,m){return t[0]=e,t[1]=r,t[2]=n,t[3]=s,t[4]=o,t[5]=i,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=u,t[11]=h,t[12]=d,t[13]=p,t[14]=A,t[15]=m,t}function ah(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ma(t,e){if(t===e){let r=e[1],n=e[2],s=e[3],o=e[6],i=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=o,t[11]=e[14],t[12]=s,t[13]=i,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function _a(t,e){let r=e[0],n=e[1],s=e[2],o=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],d=e[11],p=e[12],A=e[13],m=e[14],y=e[15],b=r*a-n*i,E=r*c-s*i,M=r*l-o*i,B=n*c-s*a,C=n*l-o*a,v=s*l-o*c,_=f*A-u*p,T=f*m-h*p,g=f*y-d*p,S=u*m-h*A,F=u*y-d*A,R=h*y-d*m,L=b*R-E*F+M*S+B*g-C*T+v*_;return L?(L=1/L,t[0]=(a*R-c*F+l*S)*L,t[1]=(s*F-n*R-o*S)*L,t[2]=(A*v-m*C+y*B)*L,t[3]=(h*C-u*v-d*B)*L,t[4]=(c*g-i*R-l*T)*L,t[5]=(r*R-s*g+o*T)*L,t[6]=(m*M-p*v-y*E)*L,t[7]=(f*v-h*M+d*E)*L,t[8]=(i*F-a*g+l*_)*L,t[9]=(n*g-r*F-o*_)*L,t[10]=(p*C-A*M+y*b)*L,t[11]=(u*M-f*C-d*b)*L,t[12]=(a*T-i*S-c*_)*L,t[13]=(r*S-n*T+s*_)*L,t[14]=(A*E-p*B-m*b)*L,t[15]=(f*B-u*E+h*b)*L,t):null}function RT(t,e){let r=e[0],n=e[1],s=e[2],o=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],d=e[11],p=e[12],A=e[13],m=e[14],y=e[15],b=r*a-n*i,E=r*c-s*i,M=r*l-o*i,B=n*c-s*a,C=n*l-o*a,v=s*l-o*c,_=f*A-u*p,T=f*m-h*p,g=f*y-d*p,S=u*m-h*A,F=u*y-d*A,R=h*y-d*m;return t[0]=a*R-c*F+l*S,t[1]=s*F-n*R-o*S,t[2]=A*v-m*C+y*B,t[3]=h*C-u*v-d*B,t[4]=c*g-i*R-l*T,t[5]=r*R-s*g+o*T,t[6]=m*M-p*v-y*E,t[7]=f*v-h*M+d*E,t[8]=i*F-a*g+l*_,t[9]=n*g-r*F-o*_,t[10]=p*C-A*M+y*b,t[11]=u*M-f*C-d*b,t[12]=a*T-i*S-c*_,t[13]=r*S-n*T+s*_,t[14]=A*E-p*B-m*b,t[15]=f*B-u*E+h*b,t}function Ba(t){let e=t[0],r=t[1],n=t[2],s=t[3],o=t[4],i=t[5],a=t[6],c=t[7],l=t[8],f=t[9],u=t[10],h=t[11],d=t[12],p=t[13],A=t[14],m=t[15],y=e*i-r*o,b=e*a-n*o,E=r*a-n*i,M=l*p-f*d,B=l*A-u*d,C=f*A-u*p,v=e*C-r*B+n*M,_=o*C-i*B+a*M,T=l*E-f*b+u*y,g=d*E-p*b+A*y;return c*v-s*_+m*T-h*g}function En(t,e,r){let n=e[0],s=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=e[9],d=e[10],p=e[11],A=e[12],m=e[13],y=e[14],b=e[15],E=r[0],M=r[1],B=r[2],C=r[3];return t[0]=E*n+M*a+B*u+C*A,t[1]=E*s+M*c+B*h+C*m,t[2]=E*o+M*l+B*d+C*y,t[3]=E*i+M*f+B*p+C*b,E=r[4],M=r[5],B=r[6],C=r[7],t[4]=E*n+M*a+B*u+C*A,t[5]=E*s+M*c+B*h+C*m,t[6]=E*o+M*l+B*d+C*y,t[7]=E*i+M*f+B*p+C*b,E=r[8],M=r[9],B=r[10],C=r[11],t[8]=E*n+M*a+B*u+C*A,t[9]=E*s+M*c+B*h+C*m,t[10]=E*o+M*l+B*d+C*y,t[11]=E*i+M*f+B*p+C*b,E=r[12],M=r[13],B=r[14],C=r[15],t[12]=E*n+M*a+B*u+C*A,t[13]=E*s+M*c+B*h+C*m,t[14]=E*o+M*l+B*d+C*y,t[15]=E*i+M*f+B*p+C*b,t}function Ca(t,e,r){let n=r[0],s=r[1],o=r[2],i,a,c,l,f,u,h,d,p,A,m,y;return e===t?(t[12]=e[0]*n+e[4]*s+e[8]*o+e[12],t[13]=e[1]*n+e[5]*s+e[9]*o+e[13],t[14]=e[2]*n+e[6]*s+e[10]*o+e[14],t[15]=e[3]*n+e[7]*s+e[11]*o+e[15]):(i=e[0],a=e[1],c=e[2],l=e[3],f=e[4],u=e[5],h=e[6],d=e[7],p=e[8],A=e[9],m=e[10],y=e[11],t[0]=i,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=u,t[6]=h,t[7]=d,t[8]=p,t[9]=A,t[10]=m,t[11]=y,t[12]=i*n+f*s+p*o+e[12],t[13]=a*n+u*s+A*o+e[13],t[14]=c*n+h*s+m*o+e[14],t[15]=l*n+d*s+y*o+e[15]),t}function Sa(t,e,r){let n=r[0],s=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ia(t,e,r,n){let s=n[0],o=n[1],i=n[2],a=Math.sqrt(s*s+o*o+i*i),c,l,f,u,h,d,p,A,m,y,b,E,M,B,C,v,_,T,g,S,F,R,L,G;return a<1e-6?null:(a=1/a,s*=a,o*=a,i*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,u=e[0],h=e[1],d=e[2],p=e[3],A=e[4],m=e[5],y=e[6],b=e[7],E=e[8],M=e[9],B=e[10],C=e[11],v=s*s*f+c,_=o*s*f+i*l,T=i*s*f-o*l,g=s*o*f-i*l,S=o*o*f+c,F=i*o*f+s*l,R=s*i*f+o*l,L=o*i*f-s*l,G=i*i*f+c,t[0]=u*v+A*_+E*T,t[1]=h*v+m*_+M*T,t[2]=d*v+y*_+B*T,t[3]=p*v+b*_+C*T,t[4]=u*g+A*S+E*F,t[5]=h*g+m*S+M*F,t[6]=d*g+y*S+B*F,t[7]=p*g+b*S+C*F,t[8]=u*R+A*L+E*G,t[9]=h*R+m*L+M*G,t[10]=d*R+y*L+B*G,t[11]=p*R+b*L+C*G,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function wa(t,e,r){let n=Math.sin(r),s=Math.cos(r),o=e[4],i=e[5],a=e[6],c=e[7],l=e[8],f=e[9],u=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*s+l*n,t[5]=i*s+f*n,t[6]=a*s+u*n,t[7]=c*s+h*n,t[8]=l*s-o*n,t[9]=f*s-i*n,t[10]=u*s-a*n,t[11]=h*s-c*n,t}function va(t,e,r){let n=Math.sin(r),s=Math.cos(r),o=e[0],i=e[1],a=e[2],c=e[3],l=e[8],f=e[9],u=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s-l*n,t[1]=i*s-f*n,t[2]=a*s-u*n,t[3]=c*s-h*n,t[8]=o*n+l*s,t[9]=i*n+f*s,t[10]=a*n+u*s,t[11]=c*n+h*s,t}function La(t,e,r){let n=Math.sin(r),s=Math.cos(r),o=e[0],i=e[1],a=e[2],c=e[3],l=e[4],f=e[5],u=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s+l*n,t[1]=i*s+f*n,t[2]=a*s+u*n,t[3]=c*s+h*n,t[4]=l*s-o*n,t[5]=f*s-i*n,t[6]=u*s-a*n,t[7]=h*s-c*n,t}function PT(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function OT(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function NT(t,e,r){let n=r[0],s=r[1],o=r[2],i=Math.sqrt(n*n+s*s+o*o),a,c,l;return i<1e-6?null:(i=1/i,n*=i,s*=i,o*=i,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=n*n*l+a,t[1]=s*n*l+o*c,t[2]=o*n*l-s*c,t[3]=0,t[4]=n*s*l-o*c,t[5]=s*s*l+a,t[6]=o*s*l+n*c,t[7]=0,t[8]=n*o*l+s*c,t[9]=s*o*l-n*c,t[10]=o*o*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function DT(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function GT(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function UT(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ch(t,e,r){let n=e[0],s=e[1],o=e[2],i=e[3],a=n+n,c=s+s,l=o+o,f=n*a,u=n*c,h=n*l,d=s*c,p=s*l,A=o*l,m=i*a,y=i*c,b=i*l;return t[0]=1-(d+A),t[1]=u+b,t[2]=h-y,t[3]=0,t[4]=u-b,t[5]=1-(f+A),t[6]=p+m,t[7]=0,t[8]=h+y,t[9]=p-m,t[10]=1-(f+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function VT(t,e){let r=new ee(3),n=-e[0],s=-e[1],o=-e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=n*n+s*s+o*o+i*i;return u>0?(r[0]=(a*i+f*n+c*o-l*s)*2/u,r[1]=(c*i+f*s+l*n-a*o)*2/u,r[2]=(l*i+f*o+a*s-c*n)*2/u):(r[0]=(a*i+f*n+c*o-l*s)*2,r[1]=(c*i+f*s+l*n-a*o)*2,r[2]=(l*i+f*o+a*s-c*n)*2),ch(t,e,r),t}function HT(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function lh(t,e){let r=e[0],n=e[1],s=e[2],o=e[4],i=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+n*n+s*s),t[1]=Math.sqrt(o*o+i*i+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function zT(t,e){let r=new ee(3);lh(r,e);let n=1/r[0],s=1/r[1],o=1/r[2],i=e[0]*n,a=e[1]*s,c=e[2]*o,l=e[4]*n,f=e[5]*s,u=e[6]*o,h=e[8]*n,d=e[9]*s,p=e[10]*o,A=i+f+p,m=0;return A>0?(m=Math.sqrt(A+1)*2,t[3]=.25*m,t[0]=(u-d)/m,t[1]=(h-c)/m,t[2]=(a-l)/m):i>f&&i>p?(m=Math.sqrt(1+i-f-p)*2,t[3]=(u-d)/m,t[0]=.25*m,t[1]=(a+l)/m,t[2]=(h+c)/m):f>p?(m=Math.sqrt(1+f-i-p)*2,t[3]=(h-c)/m,t[0]=(a+l)/m,t[1]=.25*m,t[2]=(u+d)/m):(m=Math.sqrt(1+p-i-f)*2,t[3]=(a-l)/m,t[0]=(h+c)/m,t[1]=(u+d)/m,t[2]=.25*m),t}function kT(t,e,r,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];let s=n[0],o=n[1],i=n[2],a=n[4],c=n[5],l=n[6],f=n[8],u=n[9],h=n[10];r[0]=Math.sqrt(s*s+o*o+i*i),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+u*u+h*h);let d=1/r[0],p=1/r[1],A=1/r[2],m=s*d,y=o*p,b=i*A,E=a*d,M=c*p,B=l*A,C=f*d,v=u*p,_=h*A,T=m+M+_,g=0;return T>0?(g=Math.sqrt(T+1)*2,t[3]=.25*g,t[0]=(B-v)/g,t[1]=(C-b)/g,t[2]=(y-E)/g):m>M&&m>_?(g=Math.sqrt(1+m-M-_)*2,t[3]=(B-v)/g,t[0]=.25*g,t[1]=(y+E)/g,t[2]=(C+b)/g):M>_?(g=Math.sqrt(1+M-m-_)*2,t[3]=(C-b)/g,t[0]=(y+E)/g,t[1]=.25*g,t[2]=(B+v)/g):(g=Math.sqrt(1+_-m-M)*2,t[3]=(y-E)/g,t[0]=(C+b)/g,t[1]=(B+v)/g,t[2]=.25*g),t}function qT(t,e,r,n){let s=e[0],o=e[1],i=e[2],a=e[3],c=s+s,l=o+o,f=i+i,u=s*c,h=s*l,d=s*f,p=o*l,A=o*f,m=i*f,y=a*c,b=a*l,E=a*f,M=n[0],B=n[1],C=n[2];return t[0]=(1-(p+m))*M,t[1]=(h+E)*M,t[2]=(d-b)*M,t[3]=0,t[4]=(h-E)*B,t[5]=(1-(u+m))*B,t[6]=(A+y)*B,t[7]=0,t[8]=(d+b)*C,t[9]=(A-y)*C,t[10]=(1-(u+p))*C,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function jT(t,e,r,n,s){let o=e[0],i=e[1],a=e[2],c=e[3],l=o+o,f=i+i,u=a+a,h=o*l,d=o*f,p=o*u,A=i*f,m=i*u,y=a*u,b=c*l,E=c*f,M=c*u,B=n[0],C=n[1],v=n[2],_=s[0],T=s[1],g=s[2],S=(1-(A+y))*B,F=(d+M)*B,R=(p-E)*B,L=(d-M)*C,G=(1-(h+y))*C,W=(m+b)*C,z=(p+E)*v,te=(m-b)*v,K=(1-(h+A))*v;return t[0]=S,t[1]=F,t[2]=R,t[3]=0,t[4]=L,t[5]=G,t[6]=W,t[7]=0,t[8]=z,t[9]=te,t[10]=K,t[11]=0,t[12]=r[0]+_-(S*_+L*T+z*g),t[13]=r[1]+T-(F*_+G*T+te*g),t[14]=r[2]+g-(R*_+W*T+K*g),t[15]=1,t}function Fa(t,e){let r=e[0],n=e[1],s=e[2],o=e[3],i=r+r,a=n+n,c=s+s,l=r*i,f=n*i,u=n*a,h=s*i,d=s*a,p=s*c,A=o*i,m=o*a,y=o*c;return t[0]=1-u-p,t[1]=f+y,t[2]=h-m,t[3]=0,t[4]=f-y,t[5]=1-l-p,t[6]=d+A,t[7]=0,t[8]=h+m,t[9]=d-A,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ra(t,e,r,n,s,o,i){let a=1/(r-e),c=1/(s-n),l=1/(o-i);return t[0]=o*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(s+n)*c,t[10]=(i+o)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=i*o*2*l,t[15]=0,t}function fh(t,e,r,n,s){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let i=1/(n-s);t[10]=(s+n)*i,t[14]=2*s*n*i}else t[10]=-1,t[14]=-2*n;return t}var Pa=fh;function JT(t,e,r,n,s){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let i=1/(n-s);t[10]=s*i,t[14]=s*n*i}else t[10]=-1,t[14]=-n;return t}function WT(t,e,r,n){let s=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),i=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(i+a),l=2/(s+o);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((i-a)*c*.5),t[9]=(s-o)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function uh(t,e,r,n,s,o,i){let a=1/(e-r),c=1/(n-s),l=1/(o-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+n)*c,t[14]=(i+o)*l,t[15]=1,t}var Oa=uh;function XT(t,e,r,n,s,o,i){let a=1/(e-r),c=1/(n-s),l=1/(o-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+n)*c,t[14]=o*l,t[15]=1,t}function Na(t,e,r,n){let s,o,i,a,c,l,f,u,h,d,p=e[0],A=e[1],m=e[2],y=n[0],b=n[1],E=n[2],M=r[0],B=r[1],C=r[2];return Math.abs(p-M)<1e-6&&Math.abs(A-B)<1e-6&&Math.abs(m-C)<1e-6?ah(t):(u=p-M,h=A-B,d=m-C,s=1/Math.sqrt(u*u+h*h+d*d),u*=s,h*=s,d*=s,o=b*d-E*h,i=E*u-y*d,a=y*h-b*u,s=Math.sqrt(o*o+i*i+a*a),s?(s=1/s,o*=s,i*=s,a*=s):(o=0,i=0,a=0),c=h*a-d*i,l=d*o-u*a,f=u*i-h*o,s=Math.sqrt(c*c+l*l+f*f),s?(s=1/s,c*=s,l*=s,f*=s):(c=0,l=0,f=0),t[0]=o,t[1]=c,t[2]=u,t[3]=0,t[4]=i,t[5]=l,t[6]=h,t[7]=0,t[8]=a,t[9]=f,t[10]=d,t[11]=0,t[12]=-(o*p+i*A+a*m),t[13]=-(c*p+l*A+f*m),t[14]=-(u*p+h*A+d*m),t[15]=1,t)}function YT(t,e,r,n){let s=e[0],o=e[1],i=e[2],a=n[0],c=n[1],l=n[2],f=s-r[0],u=o-r[1],h=i-r[2],d=f*f+u*u+h*h;d>0&&(d=1/Math.sqrt(d),f*=d,u*=d,h*=d);let p=c*h-l*u,A=l*f-a*h,m=a*u-c*f;return d=p*p+A*A+m*m,d>0&&(d=1/Math.sqrt(d),p*=d,A*=d,m*=d),t[0]=p,t[1]=A,t[2]=m,t[3]=0,t[4]=u*m-h*A,t[5]=h*p-f*m,t[6]=f*A-u*p,t[7]=0,t[8]=f,t[9]=u,t[10]=h,t[11]=0,t[12]=s,t[13]=o,t[14]=i,t[15]=1,t}function KT(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function QT(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function ZT(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function hh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function $T(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function eb(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function tb(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function rb(t,e){let r=t[0],n=t[1],s=t[2],o=t[3],i=t[4],a=t[5],c=t[6],l=t[7],f=t[8],u=t[9],h=t[10],d=t[11],p=t[12],A=t[13],m=t[14],y=t[15],b=e[0],E=e[1],M=e[2],B=e[3],C=e[4],v=e[5],_=e[6],T=e[7],g=e[8],S=e[9],F=e[10],R=e[11],L=e[12],G=e[13],W=e[14],z=e[15];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(n-E)<=1e-6*Math.max(1,Math.abs(n),Math.abs(E))&&Math.abs(s-M)<=1e-6*Math.max(1,Math.abs(s),Math.abs(M))&&Math.abs(o-B)<=1e-6*Math.max(1,Math.abs(o),Math.abs(B))&&Math.abs(i-C)<=1e-6*Math.max(1,Math.abs(i),Math.abs(C))&&Math.abs(a-v)<=1e-6*Math.max(1,Math.abs(a),Math.abs(v))&&Math.abs(c-_)<=1e-6*Math.max(1,Math.abs(c),Math.abs(_))&&Math.abs(l-T)<=1e-6*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(f-g)<=1e-6*Math.max(1,Math.abs(f),Math.abs(g))&&Math.abs(u-S)<=1e-6*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-F)<=1e-6*Math.max(1,Math.abs(h),Math.abs(F))&&Math.abs(d-R)<=1e-6*Math.max(1,Math.abs(d),Math.abs(R))&&Math.abs(p-L)<=1e-6*Math.max(1,Math.abs(p),Math.abs(L))&&Math.abs(A-G)<=1e-6*Math.max(1,Math.abs(A),Math.abs(G))&&Math.abs(m-W)<=1e-6*Math.max(1,Math.abs(m),Math.abs(W))&&Math.abs(y-z)<=1e-6*Math.max(1,Math.abs(y),Math.abs(z))}var nb=En,sb=hh;function ob(){let t=new ee(4);return ee!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function dh(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function ph(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function mh(t){let e=t[0],r=t[1],n=t[2],s=t[3];return Math.sqrt(e*e+r*r+n*n+s*s)}function gh(t){let e=t[0],r=t[1],n=t[2],s=t[3];return e*e+r*r+n*n+s*s}function Ah(t,e){let r=e[0],n=e[1],s=e[2],o=e[3],i=r*r+n*n+s*s+o*o;return i>0&&(i=1/Math.sqrt(i)),t[0]=r*i,t[1]=n*i,t[2]=s*i,t[3]=o*i,t}function xh(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function yh(t,e,r,n){let s=e[0],o=e[1],i=e[2],a=e[3];return t[0]=s+n*(r[0]-s),t[1]=o+n*(r[1]-o),t[2]=i+n*(r[2]-i),t[3]=a+n*(r[3]-a),t}function Th(t,e,r){let n=e[0],s=e[1],o=e[2],i=e[3];return t[0]=r[0]*n+r[4]*s+r[8]*o+r[12]*i,t[1]=r[1]*n+r[5]*s+r[9]*o+r[13]*i,t[2]=r[2]*n+r[6]*s+r[10]*o+r[14]*i,t[3]=r[3]*n+r[7]*s+r[11]*o+r[15]*i,t}function bh(t,e,r){let n=e[0],s=e[1],o=e[2],i=r[0],a=r[1],c=r[2],l=r[3],f=l*n+a*o-c*s,u=l*s+c*n-i*o,h=l*o+i*s-a*n,d=-i*n-a*s-c*o;return t[0]=f*l+d*-i+u*-c-h*-a,t[1]=u*l+d*-a+h*-i-f*-c,t[2]=h*l+d*-c+f*-a-u*-i,t[3]=e[3],t}var Ov=function(){let t=ob();return function(e,r,n,s,o,i){let a,c;for(r||(r=4),n||(n=0),s?c=Math.min(s*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],o(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var Ua;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Ua||(Ua={}));var ab=45*Math.PI/180,cb=1,Da=.1,Ga=500,lb=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),O=class extends Fr{static get IDENTITY(){return ub()}static get ZERO(){return fb()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ua}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,s,o,i,a,c,l,f,u,h,d,p,A,m){return this[0]=e,this[1]=r,this[2]=n,this[3]=s,this[4]=o,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=u,this[11]=h,this[12]=d,this[13]=p,this[14]=A,this[15]=m,this.check()}setRowMajor(e,r,n,s,o,i,a,c,l,f,u,h,d,p,A,m){return this[0]=e,this[1]=o,this[2]=l,this[3]=d,this[4]=r,this[5]=i,this[6]=f,this[7]=p,this[8]=n,this[9]=a,this[10]=u,this[11]=A,this[12]=s,this[13]=c,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(lb)}fromObject(e){return this.check()}fromQuaternion(e){return Fa(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:s,top:o,near:i=Da,far:a=Ga}=e;return a===1/0?hb(this,r,n,s,o,i):Ra(this,r,n,s,o,i,a),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:s=[0,1,0]}=e;return Na(this,r,n,s),this.check()}ortho(e){let{left:r,right:n,bottom:s,top:o,near:i=Da,far:a=Ga}=e;return Oa(this,r,n,s,o,i,a),this.check()}orthographic(e){let{fovy:r=ab,aspect:n=cb,focalDistance:s=1,near:o=Da,far:i=Ga}=e;Eh(r);let a=r/2,c=s*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:o,far:i})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:s=.1,far:o=500}=e;return Eh(r),Pa(this,r,n,s,o),this.check()}determinant(){return Ba(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),s=1/n[0],o=1/n[1],i=1/n[2];return e[0]=this[0]*s,e[1]=this[1]*o,e[2]=this[2]*i,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*o,e[6]=this[6]*i,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*o,e[10]=this[10]*i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),s=1/n[0],o=1/n[1],i=1/n[2];return e[0]=this[0]*s,e[1]=this[1]*o,e[2]=this[2]*i,e[3]=this[4]*s,e[4]=this[5]*o,e[5]=this[6]*i,e[6]=this[8]*s,e[7]=this[9]*o,e[8]=this[10]*i,e}transpose(){return Ma(this,this),this.check()}invert(){return _a(this,this),this.check()}multiplyLeft(e){return En(this,e,this),this.check()}multiplyRight(e){return En(this,this,e),this.check()}rotateX(e){return wa(this,this,e),this.check()}rotateY(e){return va(this,this,e),this.check()}rotateZ(e){return La(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return Ia(this,this,e,r),this.check()}scale(e){return Sa(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Ca(this,this,e),this.check()}transform(e,r){return e.length===4?(r=Th(r||[-0,-0,-0,-0],e,this),_t(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,s;switch(n){case 2:s=to(r||[-0,-0],e,this);break;case 3:s=Xt(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return _t(s,e.length),s}transformAsVector(e,r){let n;switch(e.length){case 2:n=ro(r||[-0,-0],e,this);break;case 3:n=no(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return _t(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},uo,ho;function fb(){return uo||(uo=new O([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(uo)),uo}function ub(){return ho||(ho=new O,Object.freeze(ho)),ho}function Eh(t){if(t>Math.PI*2)throw Error("expected radians")}function hb(t,e,r,n,s,o){let i=2*o/(r-e),a=2*o/(s-n),c=(r+e)/(r-e),l=(s+n)/(s-n),f=-1,u=-1,h=-2*o;return t[0]=i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=u,t[12]=0,t[13]=0,t[14]=h,t[15]=0,t}function Mh(){let t=new ee(4);return ee!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function _h(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Va(t,e,r){r=r*.5;let n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function Ha(t,e,r){let n=e[0],s=e[1],o=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+i*a+s*l-o*c,t[1]=s*f+i*c+o*a-n*l,t[2]=o*f+i*l+n*c-s*a,t[3]=i*f-n*a-s*c-o*l,t}function Bh(t,e,r){r*=.5;let n=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=s*c+o*a,t[2]=o*c-s*a,t[3]=i*c-n*a,t}function Ch(t,e,r){r*=.5;let n=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-o*a,t[1]=s*c+i*a,t[2]=o*c+n*a,t[3]=i*c-s*a,t}function Sh(t,e,r){r*=.5;let n=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*a,t[1]=s*c-n*a,t[2]=o*c+i*a,t[3]=i*c-o*a,t}function Ih(t,e){let r=e[0],n=e[1],s=e[2];return t[0]=r,t[1]=n,t[2]=s,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-s*s)),t}function _n(t,e,r,n){let s=e[0],o=e[1],i=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],h,d,p,A,m;return h=s*c+o*l+i*f+a*u,h<0&&(h=-h,c=-c,l=-l,f=-f,u=-u),1-h>1e-6?(d=Math.acos(h),m=Math.sin(d),p=Math.sin((1-n)*d)/m,A=Math.sin(n*d)/m):(p=1-n,A=n),t[0]=p*s+A*c,t[1]=p*o+A*l,t[2]=p*i+A*f,t[3]=p*a+A*u,t}function wh(t,e){let r=e[0],n=e[1],s=e[2],o=e[3],i=r*r+n*n+s*s+o*o,a=i?1/i:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-s*a,t[3]=o*a,t}function vh(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function za(t,e){let r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{let s=0;e[4]>e[0]&&(s=1),e[8]>e[s*3+s]&&(s=2);let o=(s+1)%3,i=(s+2)%3;n=Math.sqrt(e[s*3+s]-e[o*3+o]-e[i*3+i]+1),t[s]=.5*n,n=.5/n,t[3]=(e[o*3+i]-e[i*3+o])*n,t[o]=(e[o*3+s]+e[s*3+o])*n,t[i]=(e[i*3+s]+e[s*3+i])*n}return t}var Lh=dh;var Fh=ph,Rh=xh,Ph=yh,Oh=mh;var Nh=gh;var Dh=Ah;var Gh=function(){let t=oo(),e=io(1,0,0),r=io(0,1,0);return function(n,s,o){let i=yn(s,o);return i<-.999999?(Wt(t,e,s),xa(t)<1e-6&&Wt(t,r,s),da(t,t),Va(n,t,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Wt(t,s,o),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+i,Dh(n,n))}}(),Yv=function(){let t=Mh(),e=Mh();return function(r,n,s,o,i,a){return _n(t,n,i,a),_n(e,s,o,a),_n(r,t,e,2*a*(1-a)),r}}(),Kv=function(){let t=eh();return function(e,r,n,s){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=s[0],t[4]=s[1],t[7]=s[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],Dh(e,za(e,t))}}();var db=[0,0,0,1],rt=class extends Mt{constructor(e=0,r=0,n=0,s=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,n,s)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,n,s){return this[0]=e,this[1]=r,this[2]=n,this[3]=s,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return za(this,e),this.check()}fromAxisRotation(e,r){return Va(this,e,r),this.check()}identity(){return _h(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=V(e)}get y(){return this[1]}set y(e){this[1]=V(e)}get z(){return this[2]}set z(e){this[2]=V(e)}get w(){return this[3]}set w(e){this[3]=V(e)}len(){return Oh(this)}lengthSquared(){return Nh(this)}dot(e){return Rh(this,e)}rotationTo(e,r){return Gh(this,e,r),this.check()}add(e){return Lh(this,this,e),this.check()}calculateW(){return Ih(this,this),this.check()}conjugate(){return vh(this,this),this.check()}invert(){return wh(this,this),this.check()}lerp(e,r,n){return n===void 0?this.lerp(this,e,r):(Ph(this,e,r,n),this.check())}multiplyRight(e){return Ha(this,this,e),this.check()}multiplyLeft(e){return Ha(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return Bh(this,this,e),this.check()}rotateY(e){return Ch(this,this,e),this.check()}rotateZ(e){return Sh(this,this,e),this.check()}scale(e){return Fh(this,this,e),this.check()}slerp(e,r,n){let s,o,i;switch(arguments.length){case 1:({start:s=db,target:o,ratio:i}=e);break;case 2:s=this,o=e,i=r;break;default:s=e,o=r,i=n}return _n(this,s,o,i),this.check()}transformVector4(e,r=new Lr){return bh(r,e,this),_t(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var Ne={};me(Ne,{EPSILON1:()=>pb,EPSILON10:()=>Mb,EPSILON11:()=>_b,EPSILON12:()=>Bb,EPSILON13:()=>Cb,EPSILON14:()=>Sb,EPSILON15:()=>Ib,EPSILON16:()=>wb,EPSILON17:()=>vb,EPSILON18:()=>Lb,EPSILON19:()=>Fb,EPSILON2:()=>mb,EPSILON20:()=>Rb,EPSILON3:()=>gb,EPSILON4:()=>Ab,EPSILON5:()=>xb,EPSILON6:()=>yb,EPSILON7:()=>Tb,EPSILON8:()=>bb,EPSILON9:()=>Eb,PI_OVER_FOUR:()=>Ob,PI_OVER_SIX:()=>Nb,PI_OVER_TWO:()=>Pb,TWO_PI:()=>Db});var pb=.1,mb=.01,gb=.001,Ab=1e-4,xb=1e-5,yb=1e-6,Tb=1e-7,bb=1e-8,Eb=1e-9,Mb=1e-10,_b=1e-11,Bb=1e-12,Cb=1e-13,Sb=1e-14,Ib=1e-15,wb=1e-16,vb=1e-17,Lb=1e-18,Fb=1e-19,Rb=1e-20,Pb=Math.PI/2,Ob=Math.PI/4,Nb=Math.PI/6,Db=Math.PI*2;function po(t,e){e=e===void 0?t[0][0]:e;for(let r of t){let n=r[0]-e;n>180?r[0]-=360:n<-180&&(r[0]+=360)}}function Gb(t,e,r){let[n,s]=(0,Bn.cellToLatLng)(t),o=e.length;po(e,s);let i=e[0]===e[o-1]?o-1:o;for(let a=0;a<i;a++)e[a][0]=Et(s,e[a][0],r),e[a][1]=Et(n,e[a][1],r)}function Uh(t,e,r){let n=t(e,r),[s,o]=(0,Bn.cellToLatLng)(n);return[o,s]}function ka(t,e=1){let r=(0,Bn.cellToBoundary)(t,!0);return e!==1?Gb(t,r,e):po(r),r}function mo(t){let e=new Float64Array(t.length*2),r=0;for(let n of t)e[r++]=n[0],e[r++]=n[1];return e}var Ub={getPentagon:{type:"accessor",value:t=>t.pentagon}},Cn=class extends Oe{indexToBounds(){let{data:e,getPentagon:r}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(n,s)=>{let o=r(n,s),i=Uu(typeof o=="string"?Vu(o):o,{closedRing:!0,segments:"auto"});return mo(i)}}}};Cn.layerName="A5Layer";Cn.defaultProps=Ub;var Vh=Cn;var ir=D(Je(),1),Ud=D(je(),1),Vd=D(Kt(),1);function Vb(t){return typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t}function go(t){if(Array.isArray(t))return t.map(e=>go(e));if(t&&typeof t=="object"){let e={};for(let[r,n]of Object.entries(t))e[Vb(r)]=go(n);return e}return t}var zh=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Hb=zh+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",zb="["+zh+"]["+Hb+"]*",kb=new RegExp("^"+zb+"$");function Ao(t,e){let r=[],n=e.exec(t);for(;n;){let s=[];s.startIndex=e.lastIndex-n[0].length;let o=n.length;for(let i=0;i<o;i++)s.push(n[i]);r.push(s),n=e.exec(t)}return r}var Rr=function(t){let e=kb.exec(t);return!(e===null||typeof e>"u")};function kh(t){return typeof t<"u"}var qb={allowBooleanAttributes:!1,unpairedTags:[]};function Xh(t,e){e=Object.assign({},qb,e);let r=[],n=!1,s=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let o=0;o<t.length;o++)if(t[o]==="<"&&t[o+1]==="?"){if(o+=2,o=jh(t,o),o.err)return o}else if(t[o]==="<"){let i=o;if(o++,t[o]==="!"){o=Jh(t,o);continue}else{let a=!1;t[o]==="/"&&(a=!0,o++);let c="";for(;o<t.length&&t[o]!==">"&&t[o]!==" "&&t[o]!==" "&&t[o]!==`
8
- `&&t[o]!=="\r";o++)c+=t[o];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),o--),!Zb(c)){let u;return c.trim().length===0?u="Invalid space after '<'.":u="Tag '"+c+"' is an invalid name.",se("InvalidTag",u,Ee(t,o))}let l=Wb(t,o);if(l===!1)return se("InvalidAttr","Attributes for '"+c+"' have open quote.",Ee(t,o));let f=l.value;if(o=l.index,f[f.length-1]==="/"){let u=o-f.length;f=f.substring(0,f.length-1);let h=Wh(f,e);if(h===!0)n=!0;else return se(h.err.code,h.err.msg,Ee(t,u+h.err.line))}else if(a)if(l.tagClosed){if(f.trim().length>0)return se("InvalidTag","Closing tag '"+c+"' can't have attributes or invalid starting.",Ee(t,i));if(r.length===0)return se("InvalidTag","Closing tag '"+c+"' has not been opened.",Ee(t,i));{let u=r.pop();if(c!==u.tagName){let h=Ee(t,u.tagStartPos);return se("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+c+"'.",Ee(t,i))}r.length==0&&(s=!0)}}else return se("InvalidTag","Closing tag '"+c+"' doesn't have proper closing.",Ee(t,o));else{let u=Wh(f,e);if(u!==!0)return se(u.err.code,u.err.msg,Ee(t,o-f.length+u.err.line));if(s===!0)return se("InvalidXml","Multiple possible root nodes found.",Ee(t,o));e.unpairedTags.indexOf(c)!==-1||r.push({tagName:c,tagStartPos:i}),n=!0}for(o++;o<t.length;o++)if(t[o]==="<")if(t[o+1]==="!"){o++,o=Jh(t,o);continue}else if(t[o+1]==="?"){if(o=jh(t,++o),o.err)return o}else break;else if(t[o]==="&"){let u=Kb(t,o);if(u==-1)return se("InvalidChar","char '&' is not expected.",Ee(t,o));o=u}else if(s===!0&&!qh(t[o]))return se("InvalidXml","Extra text at the end",Ee(t,o));t[o]==="<"&&o--}}else{if(qh(t[o]))continue;return se("InvalidChar","char '"+t[o]+"' is not expected.",Ee(t,o))}if(n){if(r.length==1)return se("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",Ee(t,r[0].tagStartPos));if(r.length>0)return se("InvalidXml","Invalid '"+JSON.stringify(r.map(o=>o.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return se("InvalidXml","Start tag expected.",1);return!0}function qh(t){return t===" "||t===" "||t===`
9
- `||t==="\r"}function jh(t,e){let r=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){let n=t.substr(r,e-r);if(e>5&&n==="xml")return se("InvalidXml","XML declaration allowed only at the start of the document.",Ee(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Jh(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let r=1;for(e+=8;e<t.length;e++)if(t[e]==="<")r++;else if(t[e]===">"&&(r--,r===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}var jb='"',Jb="'";function Wb(t,e){let r="",n="",s=!1;for(;e<t.length;e++){if(t[e]===jb||t[e]===Jb)n===""?n=t[e]:n!==t[e]||(n="");else if(t[e]===">"&&n===""){s=!0;break}r+=t[e]}return n!==""?!1:{value:r,index:e,tagClosed:s}}var Xb=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Wh(t,e){let r=Ao(t,Xb),n={};for(let s=0;s<r.length;s++){if(r[s][1].length===0)return se("InvalidAttr","Attribute '"+r[s][2]+"' has no space in starting.",Sn(r[s]));if(r[s][3]!==void 0&&r[s][4]===void 0)return se("InvalidAttr","Attribute '"+r[s][2]+"' is without value.",Sn(r[s]));if(r[s][3]===void 0&&!e.allowBooleanAttributes)return se("InvalidAttr","boolean attribute '"+r[s][2]+"' is not allowed.",Sn(r[s]));let o=r[s][2];if(!Qb(o))return se("InvalidAttr","Attribute '"+o+"' is an invalid name.",Sn(r[s]));if(!n.hasOwnProperty(o))n[o]=1;else return se("InvalidAttr","Attribute '"+o+"' is repeated.",Sn(r[s]))}return!0}function Yb(t,e){let r=/\d/;for(t[e]==="x"&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(r))break}return-1}function Kb(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Yb(t,e);let r=0;for(;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(t[e]===";")break;return-1}return e}function se(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function Qb(t){return Rr(t)}function Zb(t){return Rr(t)}function Ee(t,e){let r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function Sn(t){return t.startIndex+t[1].length}var $b={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t},captureMetaData:!1};function Yh(t){return typeof t=="boolean"?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:typeof t=="object"&&t!==null?{enabled:t.enabled!==!1,maxEntitySize:t.maxEntitySize??1e4,maxExpansionDepth:t.maxExpansionDepth??10,maxTotalExpansions:t.maxTotalExpansions??1e3,maxExpandedLength:t.maxExpandedLength??1e5,allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null}:Yh(!0)}var Kh=function(t){let e=Object.assign({},$b,t);return e.processEntities=Yh(e.processEntities),e};var xo;typeof Symbol!="function"?xo="@@xmlMetadata":xo=Symbol("XML Node Metadata");var Le=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,r){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:r})}addChild(e,r){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,[":@"]:e[":@"]}):this.child.push({[e.tagname]:e.child}),r!==void 0&&(this.child[this.child.length-1][xo]={startIndex:r})}static getMetaDataSymbol(){return xo}};var wn=class{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,r){let n={};if(e[r+3]==="O"&&e[r+4]==="C"&&e[r+5]==="T"&&e[r+6]==="Y"&&e[r+7]==="P"&&e[r+8]==="E"){r=r+9;let s=1,o=!1,i=!1,a="";for(;r<e.length;r++)if(e[r]==="<"&&!i){if(o&&Qt(e,"!ENTITY",r)){r+=7;let c,l;if([c,l,r]=this.readEntityExp(e,r+1,this.suppressValidationErr),l.indexOf("&")===-1){let f=c.replace(/[.\-+*:]/g,"\\.");n[c]={regx:RegExp(`&${f};`,"g"),val:l}}}else if(o&&Qt(e,"!ELEMENT",r)){r+=8;let{index:c}=this.readElementExp(e,r+1);r=c}else if(o&&Qt(e,"!ATTLIST",r))r+=8;else if(o&&Qt(e,"!NOTATION",r)){r+=9;let{index:c}=this.readNotationExp(e,r+1,this.suppressValidationErr);r=c}else if(Qt(e,"!--",r))i=!0;else throw new Error("Invalid DOCTYPE");s++,a=""}else if(e[r]===">"){if(i?e[r-1]==="-"&&e[r-2]==="-"&&(i=!1,s--):s--,s===0)break}else e[r]==="["?o=!0:a+=e[r];if(s!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:r}}readEntityExp(e,r){r=Be(e,r);let n="";for(;r<e.length&&!/\s/.test(e[r])&&e[r]!=='"'&&e[r]!=="'";)n+=e[r],r++;if(In(n),r=Be(e,r),!this.suppressValidationErr){if(e.substring(r,r+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[r]==="%")throw new Error("Parameter entities are not supported")}let s="";if([r,s]=this.readIdentifierVal(e,r,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize&&s.length>this.options.maxEntitySize)throw new Error(`Entity "${n}" size (${s.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return r--,[n,s,r]}readNotationExp(e,r){r=Be(e,r);let n="";for(;r<e.length&&!/\s/.test(e[r]);)n+=e[r],r++;!this.suppressValidationErr&&In(n),r=Be(e,r);let s=e.substring(r,r+6).toUpperCase();if(!this.suppressValidationErr&&s!=="SYSTEM"&&s!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);r+=s.length,r=Be(e,r);let o=null,i=null;if(s==="PUBLIC")[r,o]=this.readIdentifierVal(e,r,"publicIdentifier"),r=Be(e,r),(e[r]==='"'||e[r]==="'")&&([r,i]=this.readIdentifierVal(e,r,"systemIdentifier"));else if(s==="SYSTEM"&&([r,i]=this.readIdentifierVal(e,r,"systemIdentifier"),!this.suppressValidationErr&&!i))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:o,systemIdentifier:i,index:--r}}readIdentifierVal(e,r,n){let s="",o=e[r];if(o!=='"'&&o!=="'")throw new Error(`Expected quoted string, found "${o}"`);for(r++;r<e.length&&e[r]!==o;)s+=e[r],r++;if(e[r]!==o)throw new Error(`Unterminated ${n} value`);return r++,[r,s]}readElementExp(e,r){r=Be(e,r);let n="";for(;r<e.length&&!/\s/.test(e[r]);)n+=e[r],r++;if(!this.suppressValidationErr&&!Rr(n))throw new Error(`Invalid element name: "${n}"`);r=Be(e,r);let s="";if(e[r]==="E"&&Qt(e,"MPTY",r))r+=4;else if(e[r]==="A"&&Qt(e,"NY",r))r+=2;else if(e[r]==="("){for(r++;r<e.length&&e[r]!==")";)s+=e[r],r++;if(e[r]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[r]}"`);return{elementName:n,contentModel:s.trim(),index:r}}readAttlistExp(e,r){r=Be(e,r);let n="";for(;r<e.length&&!/\s/.test(e[r]);)n+=e[r],r++;In(n),r=Be(e,r);let s="";for(;r<e.length&&!/\s/.test(e[r]);)s+=e[r],r++;if(!In(s))throw new Error(`Invalid attribute name: "${s}"`);r=Be(e,r);let o="";if(e.substring(r,r+8).toUpperCase()==="NOTATION"){if(o="NOTATION",r+=8,r=Be(e,r),e[r]!=="(")throw new Error(`Expected '(', found "${e[r]}"`);r++;let a=[];for(;r<e.length&&e[r]!==")";){let c="";for(;r<e.length&&e[r]!=="|"&&e[r]!==")";)c+=e[r],r++;if(c=c.trim(),!In(c))throw new Error(`Invalid notation name: "${c}"`);a.push(c),e[r]==="|"&&(r++,r=Be(e,r))}if(e[r]!==")")throw new Error("Unterminated list of notations");r++,o+=" ("+a.join("|")+")"}else{for(;r<e.length&&!/\s/.test(e[r]);)o+=e[r],r++;let a=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!a.includes(o.toUpperCase()))throw new Error(`Invalid attribute type: "${o}"`)}r=Be(e,r);let i="";return e.substring(r,r+8).toUpperCase()==="#REQUIRED"?(i="#REQUIRED",r+=8):e.substring(r,r+7).toUpperCase()==="#IMPLIED"?(i="#IMPLIED",r+=7):[r,i]=this.readIdentifierVal(e,r,"ATTLIST"),{elementName:n,attributeName:s,attributeType:o,defaultValue:i,index:r}}},Be=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function Qt(t,e,r){for(let n=0;n<e.length;n++)if(e[n]!==t[r+n+1])return!1;return!0}function In(t){if(Rr(t))return t;throw new Error(`Invalid entity name ${t}`)}var eE=/^[-+]?0x[a-fA-F0-9]+$/,tE=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,rE={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function qa(t,e={}){if(e=Object.assign({},rE,e),!t||typeof t!="string")return t;let r=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(r))return t;if(t==="0")return 0;if(e.hex&&eE.test(r))return iE(r,16);if(r.includes("e")||r.includes("E"))return sE(t,r,e);{let n=tE.exec(r);if(n){let s=n[1]||"",o=n[2],i=oE(n[3]),a=s?t[o.length+1]===".":t[o.length]===".";if(!e.leadingZeros&&(o.length>1||o.length===1&&!a))return t;{let c=Number(r),l=String(c);if(c===0)return c;if(l.search(/[eE]/)!==-1)return e.eNotation?c:t;if(r.indexOf(".")!==-1)return l==="0"||l===i||l===`${s}${i}`?c:t;let f=o?i:r;return o?f===l||s+f===l?c:t:f===l||f===s+l?c:t}}else return t}}var nE=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function sE(t,e,r){if(!r.eNotation)return t;let n=e.match(nE);if(n){let s=n[1]||"",o=n[3].indexOf("e")===-1?"E":"e",i=n[2],a=s?t[i.length+1]===o:t[i.length]===o;return i.length>1&&a?t:i.length===1&&(n[3].startsWith(`.${o}`)||n[3][0]===o)?Number(e):r.leadingZeros&&!a?(e=(n[1]||"")+n[3],Number(e)):t}else return t}function oE(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substring(0,t.length-1))),t}function iE(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function ja(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(let r of t)if(typeof r=="string"&&e===r||r instanceof RegExp&&r.test(e))return!0}:()=>!1}var vn=class{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(r,n)=>Qh(n,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(r,n)=>Qh(n,16,"&#x")}},this.addExternalEntities=aE,this.parseXml=hE,this.parseTextData=cE,this.resolveNameSpace=lE,this.buildAttributesMap=uE,this.isItStopNode=gE,this.replaceEntitiesValue=pE,this.readStopNodeData=xE,this.saveTextToParentTag=mE,this.addChild=dE,this.ignoreAttributesFn=ja(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let r=0;r<this.options.stopNodes.length;r++){let n=this.options.stopNodes[r];typeof n=="string"&&(n.startsWith("*.")?this.stopNodesWildcard.add(n.substring(2)):this.stopNodesExact.add(n))}}}};function aE(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let n=e[r],s=n.replace(/[.\-+*:]/g,"\\.");this.lastEntities[n]={regex:new RegExp("&"+s+";","g"),val:t[n]}}}function cE(t,e,r,n,s,o,i){if(t!==void 0&&(this.options.trimValues&&!n&&(t=t.trim()),t.length>0)){i||(t=this.replaceEntitiesValue(t,e,r));let a=this.options.tagValueProcessor(e,t,r,s,o);return a==null?t:typeof a!=typeof t||a!==t?a:this.options.trimValues?Wa(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?Wa(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function lE(t){if(this.options.removeNSPrefix){let e=t.split(":"),r=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=r+e[1])}return t}var fE=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function uE(t,e,r){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){let n=Ao(t,fE),s=n.length,o={};for(let i=0;i<s;i++){let a=this.resolveNameSpace(n[i][1]);if(this.ignoreAttributesFn(a,e))continue;let c=n[i][4],l=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(l=this.options.transformAttributeName(l)),l==="__proto__"&&(l="#__proto__"),c!==void 0){this.options.trimValues&&(c=c.trim()),c=this.replaceEntitiesValue(c,r,e);let f=this.options.attributeValueProcessor(a,c,e);f==null?o[l]=c:typeof f!=typeof c||f!==c?o[l]=f:o[l]=Wa(c,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(o[l]=!0)}if(!Object.keys(o).length)return;if(this.options.attributesGroupName){let i={};return i[this.options.attributesGroupName]=o,i}return o}}var hE=function(t){t=t.replace(/\r\n?/g,`
10
- `);let e=new Le("!xml"),r=e,n="",s="";this.entityExpansionCount=0,this.currentExpandedLength=0;let o=new wn(this.options.processEntities);for(let i=0;i<t.length;i++)if(t[i]==="<")if(t[i+1]==="/"){let c=Zt(t,">",i,"Closing Tag is not closed."),l=t.substring(i+2,c).trim();if(this.options.removeNSPrefix){let h=l.indexOf(":");h!==-1&&(l=l.substr(h+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),r&&(n=this.saveTextToParentTag(n,r,s));let f=s.substring(s.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);let u=0;f&&this.options.unpairedTags.indexOf(f)!==-1?(u=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=s.lastIndexOf("."),s=s.substring(0,u),r=this.tagsNodeStack.pop(),n="",i=c}else if(t[i+1]==="?"){let c=Ja(t,i,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,r,s),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){let l=new Le(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,s,c.tagName)),this.addChild(r,l,s,i)}i=c.closeIndex+1}else if(t.substr(i+1,3)==="!--"){let c=Zt(t,"-->",i+4,"Comment is not closed.");if(this.options.commentPropName){let l=t.substring(i+4,c-2);n=this.saveTextToParentTag(n,r,s),r.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}i=c}else if(t.substr(i+1,2)==="!D"){let c=o.readDocType(t,i);this.docTypeEntities=c.entities,i=c.i}else if(t.substr(i+1,2)==="!["){let c=Zt(t,"]]>",i,"CDATA is not closed.")-2,l=t.substring(i+9,c);n=this.saveTextToParentTag(n,r,s);let f=this.parseTextData(l,r.tagname,s,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):r.add(this.options.textNodeName,f),i=c+2}else{let c=Ja(t,i,this.options.removeNSPrefix),l=c.tagName,f=c.rawTagName,u=c.tagExp,h=c.attrExpPresent,d=c.closeIndex;if(this.options.transformTagName){let m=this.options.transformTagName(l);u===l&&(u=m),l=m}r&&n&&r.tagname!=="!xml"&&(n=this.saveTextToParentTag(n,r,s,!1));let p=r;p&&this.options.unpairedTags.indexOf(p.tagname)!==-1&&(r=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),l!==e.tagname&&(s+=s?"."+l:l);let A=i;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,s,l)){let m="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),s=s.substr(0,s.length-1),u=l):u=u.substr(0,u.length-1),i=c.closeIndex;else if(this.options.unpairedTags.indexOf(l)!==-1)i=c.closeIndex;else{let b=this.readStopNodeData(t,f,d+1);if(!b)throw new Error(`Unexpected end of ${f}`);i=b.i,m=b.tagContent}let y=new Le(l);l!==u&&h&&(y[":@"]=this.buildAttributesMap(u,s,l)),m&&(m=this.parseTextData(m,l,s,!0,h,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),y.add(this.options.textNodeName,m),this.addChild(r,y,s,A)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){if(l[l.length-1]==="/"?(l=l.substr(0,l.length-1),s=s.substr(0,s.length-1),u=l):u=u.substr(0,u.length-1),this.options.transformTagName){let y=this.options.transformTagName(l);u===l&&(u=y),l=y}let m=new Le(l);l!==u&&h&&(m[":@"]=this.buildAttributesMap(u,s,l)),this.addChild(r,m,s,A),s=s.substr(0,s.lastIndexOf("."))}else{let m=new Le(l);this.tagsNodeStack.push(r),l!==u&&h&&(m[":@"]=this.buildAttributesMap(u,s,l)),this.addChild(r,m,s,A),r=m}n="",i=d}}else n+=t[i];return e.child};function dE(t,e,r,n){this.options.captureMetaData||(n=void 0);let s=this.options.updateTag(e.tagname,r,e[":@"]);s===!1||(typeof s=="string"&&(e.tagname=s),t.addChild(e,n))}var pE=function(t,e,r){if(t.indexOf("&")===-1)return t;let n=this.options.processEntities;if(!n.enabled||n.allowedTags&&!n.allowedTags.includes(e)||n.tagFilter&&!n.tagFilter(e,r))return t;for(let s in this.docTypeEntities){let o=this.docTypeEntities[s],i=t.match(o.regx);if(i){if(this.entityExpansionCount+=i.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n.maxTotalExpansions}`);let a=t.length;if(t=t.replace(o.regx,o.val),n.maxExpandedLength&&(this.currentExpandedLength+=t.length-a,this.currentExpandedLength>n.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n.maxExpandedLength}`)}}if(t.indexOf("&")===-1)return t;for(let s in this.lastEntities){let o=this.lastEntities[s];t=t.replace(o.regex,o.val)}if(t.indexOf("&")===-1)return t;if(this.options.htmlEntities)for(let s in this.htmlEntities){let o=this.htmlEntities[s];t=t.replace(o.regex,o.val)}return t=t.replace(this.ampEntity.regex,this.ampEntity.val),t};function mE(t,e,r,n){return t&&(n===void 0&&(n=e.child.length===0),t=this.parseTextData(t,e.tagname,r,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,n),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function gE(t,e,r,n){return!!(e&&e.has(n)||t&&t.has(r))}function AE(t,e,r=">"){let n,s="";for(let o=e;o<t.length;o++){let i=t[o];if(n)i===n&&(n="");else if(i==='"'||i==="'")n=i;else if(i===r[0])if(r[1]){if(t[o+1]===r[1])return{data:s,index:o}}else return{data:s,index:o};else i===" "&&(i=" ");s+=i}}function Zt(t,e,r,n){let s=t.indexOf(e,r);if(s===-1)throw new Error(n);return s+e.length-1}function Ja(t,e,r,n=">"){let s=AE(t,e+1,n);if(!s)return;let o=s.data,i=s.index,a=o.search(/\s/),c=o,l=!0;a!==-1&&(c=o.substring(0,a),o=o.substring(a+1).trimStart());let f=c;if(r){let u=c.indexOf(":");u!==-1&&(c=c.substr(u+1),l=c!==s.data.substr(u+1))}return{tagName:c,tagExp:o,closeIndex:i,attrExpPresent:l,rawTagName:f}}function xE(t,e,r){let n=r,s=1;for(;r<t.length;r++)if(t[r]==="<")if(t[r+1]==="/"){let o=Zt(t,">",r,`${e} is not closed`);if(t.substring(r+2,o).trim()===e&&(s--,s===0))return{tagContent:t.substring(n,r),i:o};r=o}else if(t[r+1]==="?")r=Zt(t,"?>",r+1,"StopNode is not closed.");else if(t.substr(r+1,3)==="!--")r=Zt(t,"-->",r+3,"StopNode is not closed.");else if(t.substr(r+1,2)==="![")r=Zt(t,"]]>",r,"StopNode is not closed.")-2;else{let o=Ja(t,r,">");o&&((o&&o.tagName)===e&&o.tagExp[o.tagExp.length-1]!=="/"&&s++,r=o.closeIndex)}}function Wa(t,e,r){if(e&&typeof t=="string"){let n=t.trim();return n==="true"?!0:n==="false"?!1:qa(t,r)}else return kh(t)?t:""}function Qh(t,e,r){let n=Number.parseInt(t,e);return n>=0&&n<=1114111?String.fromCodePoint(n):r+t+";"}var Xa=Le.getMetaDataSymbol();function Ya(t,e){return Zh(t,e)}function Zh(t,e,r){let n,s={};for(let o=0;o<t.length;o++){let i=t[o],a=yE(i),c="";if(r===void 0?c=a:c=r+"."+a,a===e.textNodeName)n===void 0?n=i[a]:n+=""+i[a];else{if(a===void 0)continue;if(i[a]){let l=Zh(i[a],e,c),f=bE(l,e);i[Xa]!==void 0&&(l[Xa]=i[Xa]),i[":@"]?TE(l,i[":@"],c,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),s[a]!==void 0&&s.hasOwnProperty(a)?(Array.isArray(s[a])||(s[a]=[s[a]]),s[a].push(l)):e.isArray(a,c,f)?s[a]=[l]:s[a]=l}}}return typeof n=="string"?n.length>0&&(s[e.textNodeName]=n):n!==void 0&&(s[e.textNodeName]=n),s}function yE(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let n=e[r];if(n!==":@")return n}}function TE(t,e,r,n){if(e){let s=Object.keys(e),o=s.length;for(let i=0;i<o;i++){let a=s[i];n.isArray(a,r+"."+a,!0,!0)?t[a]=[e[a]]:t[a]=e[a]}}}function bE(t,e){let{textNodeName:r}=e,n=Object.keys(t).length;return!!(n===0||n===1&&(t[r]||typeof t[r]=="boolean"||t[r]===0))}var Pr=class{constructor(e){this.externalEntities={},this.options=Kh(e)}parse(e,r){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let o=Xh(e,r);if(o!==!0)throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`)}let n=new vn(this.options);n.addExternalEntities(this.externalEntities);let s=n.parseXml(e);return this.options.preserveOrder||s===void 0?s:Ya(s,this.options)}addEntity(e,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=r}static getMetaDataSymbol(){return Le.getMetaDataSymbol()}};function Ka(t,e){if(e?._parser&&e._parser!=="fast-xml-parser")throw new Error(e?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:e?.removeNSPrefix,textNodeName:e?.textNodeName,isArray:(s,o,i,a)=>Boolean(e?.arrayPaths?.some(l=>o===l)),...e?._fastXML},n=EE(t,r);return e?.uncapitalizeKeys?go(n):n}function EE(t,e){return new Pr({ignoreAttributes:!1,attributeNamePrefix:"",...e}).parse(t)}var ME="4.4.0-alpha.18",Xe={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:ME,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:_E,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(t,e)=>Ka(new TextDecoder().decode(t),{...Xe.options.xml,...e?.xml}),parseTextSync:(t,e)=>Ka(t,{...Xe.options.xml,...e?.xml})};function _E(t){return t.startsWith("<?xml")}async function Fe(t,e,r,n){return n._parse(t,e,r,n)}function H(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var nt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},BE=nt.self||nt.window||nt.global||{},CE=nt.window||nt.self||nt.global||{},SE=nt.global||nt.self||nt.window||{},IE=nt.document||{};var Ln=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var $h=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),wE=$h&&parseFloat($h[1])||0;var yo=globalThis,vE=globalThis.document||{},To=globalThis.process||{},LE=globalThis.console,fF=globalThis.navigator||{};function ed(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}function $t(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||ed()}var Qa="4.1.1";function Or(t,e){if(!t)throw new Error(e||"Assertion failed")}function Za(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return Or(Number.isFinite(e)&&e>=0),e}function td(t){let{logLevel:e,message:r}=t;t.logLevel=Za(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let s=typeof t.message;return Or(s==="string"||s==="object"),Object.assign(t,{args:n},t.opts)}var er=()=>{},bo=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...n){return this._log("log",e,r,n)}info(e,r,...n){return this._log("info",e,r,n)}once(e,r,...n){return this._log("once",e,r,n,{once:!0})}_log(e,r,n,s,o={}){let i=td({logLevel:r,message:n,args:this._buildArgs(r,n,s),opts:o});return this._createLogFunction(e,i,o)}_buildArgs(e,r,n){return[e,r,...n]}_createLogFunction(e,r,n){if(!this._shouldLog(r.logLevel))return er;let s=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&s!==void 0){if(this._onceCache.has(s))return er;this._onceCache.add(s)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=Za(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function RE(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Eo=class{constructor(e,r,n="sessionStorage"){this.storage=RE(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function rd(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function nd(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var Mo;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Mo||(Mo={}));var PE=10;function sd(t){return typeof t!="string"?t:(t=t.toUpperCase(),Mo[t]||Mo.WHITE)}function od(t,e,r){return!$t&&typeof t=="string"&&(e&&(t=`\x1B[${sd(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${sd(r)+PE}m${t}\x1B[49m`)),t}function id(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),s=t;for(let o of n){let i=s[o];typeof i=="function"&&(e.find(a=>o===a)||(s[o]=i.bind(t)))}}function Nr(){let t;if($t()&&yo.performance)t=yo?.performance?.now?.();else if("hrtime"in To){let e=To?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Dr={debug:$t()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},$a={enabled:!0,level:0},ft=class extends bo{constructor({id:e}={id:""}){super({level:0}),this.VERSION=Qa,this._startTs=Nr(),this._deltaTs=Nr(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Eo(`__probe-${this.id}__`,{[this.id]:$a}),this.timeStamp(`${this.id} started`),id(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Nr()-this._startTs).toPrecision(10))}getDelta(){return Number((Nr()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:Dr.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:Dr.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...n){return this._log("log",e,r,n,{method:Dr.log,time:!0,once:!0})}log(e,r,...n){return this._log("log",e,r,n,{method:Dr.debug})}info(e,r,...n){return this._log("info",e,r,n,{method:console.info})}once(e,r,...n){return this._log("once",e,r,n,{method:Dr.debug||Dr.info,once:!0})}table(e,r,n){return r?this._log("table",e,r,n&&[n]||[],{method:console.table||er,tag:NE(r)}):er}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||er})}group(e,r,n={collapsed:!1}){let s=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:s})}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||er})}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let n=r.method;Or(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Nr();let s=OE(this.id,r.message,r);return n.bind(console,s,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration($a),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...$a};this._storage.setConfiguration({[this.id]:{...r,...e}})}};ft.VERSION=Qa;function OE(t,e,r){if(typeof e=="string"){let n=r.time?nd(rd(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=od(e,r.color,r.background)}return e}function NE(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var ec=new ft({id:"@probe.gl/log"});var tc="4.4.0-alpha.18",DE=tc[0]>="0"&&tc[0]<="9"?`v${tc}`:"";function GE(){let t=new ft({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=DE,globalThis.probe||={},globalThis.probe.loaders=t,t}var rc=GE();var ad=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer;function Fn(t,e){return cd(t||{},e)}function cd(t,e,r=0){if(r>3)return e;let n={...t};for(let[s,o]of Object.entries(e))o&&typeof o=="object"&&!Array.isArray(o)?n[s]=cd(n[s]||{},e[s],r+1):n[s]=e[s];return n}function nc(t){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t)}function sc(t){return globalThis.loaders?.modules?.[t]||null}function UE(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.0-alpha.18"),globalThis._loadersgl_.version}var ld=UE();function fd(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var st={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},KF=st.self||st.window||st.global||{},QF=st.window||st.self||st.global||{},ZF=st.global||st.self||st.window||{},$F=st.document||{};var ut=typeof process!="object"||String(process)!=="[object process]"||process.browser,Rn=typeof importScripts=="function",eR=typeof window<"u"&&typeof window.orientation<"u",ud=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),tR=ud&&parseFloat(ud[1])||0;var oc={};function Pn(t={}){let e=t.useLocalLibraries??t.core?.useLocalLibraries,r=t.CDN??t.core?.CDN,n=t.modules;return{...e!==void 0?{useLocalLibraries:e}:{},...r!==void 0?{CDN:r}:{},...n!==void 0?{modules:n}:{}}}async function De(t,e=null,r={},n=null){return e&&(t=hd(t,e,r,n)),oc[t]=oc[t]||VE(t),await oc[t]}function hd(t,e,r={},n=null){if(r?.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!r.useLocalLibraries&&t.startsWith("http"))return t;n=n||t;let s=r.modules||{};return s[n]?s[n]:ut?r.CDN?(fd(r.CDN.startsWith("http")),`${r.CDN}/${e}@${ld}/dist/libs/${n}`):Rn?`../src/libs/${n}`:`modules/${e}/src/libs/${n}`:`modules/${e}/dist/libs/${n}`}async function VE(t){if(t.endsWith("wasm"))return await zE(t);if(!ut){let{requireFromFile:r}=globalThis.loaders||{};try{let n=await r?.(t);return n||!t.includes("/dist/libs/")?n:await r?.(t.replace("/dist/libs/","/src/libs/"))}catch(n){if(t.includes("/dist/libs/"))try{return await r?.(t.replace("/dist/libs/","/src/libs/"))}catch{}return console.error(n),null}}if(Rn)return importScripts(t);let e=await kE(t);return HE(e,t)}function HE(t,e){if(!ut){let{requireFromString:n}=globalThis.loaders||{};return n?.(t,e)}if(Rn)return eval.call(globalThis,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function zE(t){let{readFileAsArrayBuffer:e}=globalThis.loaders||{};if(ut||!e||t.startsWith("http"))return await(await fetch(t)).arrayBuffer();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${t}`)}}async function kE(t){let{readFileAsText:e}=globalThis.loaders||{};if(ut||!e||t.startsWith("http"))return await(await fetch(t)).text();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${t}`)}}function pd(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?dd(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?dd(t,0,e):""}function dd(t,e,r){if(t.byteLength<=e+r)return"";let n=new DataView(t),s="";for(let o=0;o<r;o++)s+=String.fromCharCode(n.getUint8(e+o));return s}function ic(t){try{return JSON.parse(t)}catch{throw new Error(`Failed to parse JSON from data starting with "${pd(t)}"`)}}function On(...t){let e=t,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let n=e.reduce((i,a)=>i+a.length,0),s=new r(n),o=0;for(let i of e)s.set(i,o),o+=i.length;return s}function tr(t,e,r){let n=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(n).buffer}function Ct(t,e){return H(t>=0),H(e>0),t+(e-1)&~(e-1)}function ac(t,e,r){let n;if(t instanceof ArrayBuffer)n=new Uint8Array(t);else{let s=t.byteOffset,o=t.byteLength;n=new Uint8Array(t.buffer||t.arrayBuffer,s,o)}return e.set(n,r),r+Ct(n.byteLength,4)}function Nn(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var rr=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Nn(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Nn()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var St=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,s=this.stats[r];return s||(e instanceof rr?s=e:s=new rr(r,n),this.stats[r]=s),s}};var qE="Queued Requests",jE="Active Requests",JE="Cancelled Requests",WE="Queued Requests Ever",XE="Active Requests Ever",YE={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},It=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...YE,...e},this.stats=new St({id:this.props.id}),this.stats.get(qE),this.stats.get(jE),this.stats.get(JE),this.stats.get(WE),this.stats.get(XE)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},s=new Promise(o=>(n.resolve=o,n));return this.requestQueue.push(n),this.requestMap.set(e,s),this._issueNewRequests(),s}_issueRequest(e){let{handle:r,resolve:n}=e,s=!1,o=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({done:o}):Promise.resolve({done:o})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var KE="",md={};function gd(t){for(let e in md)if(t.startsWith(e)){let r=md[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${KE}${t}`),t}function wt(t){if(t instanceof ArrayBuffer)return t;if(ad(t))return Dn(t);let{buffer:e,byteOffset:r,byteLength:n}=t;return e instanceof ArrayBuffer&&r===0&&n===e.byteLength?e:Dn(e,r,n)}function Dn(t,e=0,r=t.byteLength-e){let n=new Uint8Array(t,e,r),s=new Uint8Array(n.length);return s.set(n),s.buffer}var vt={};me(vt,{dirname:()=>ZE,filename:()=>QE,join:()=>$E,resolve:()=>eM});function Ad(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function QE(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function ZE(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function $E(...t){let e="/";return t=t.map((r,n)=>(n&&(r=r.replace(new RegExp(`^${e}`),"")),n!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function eM(...t){let e=[];for(let o=0;o<t.length;o++)e[o]=t[o];let r="",n=!1,s;for(let o=e.length-1;o>=-1&&!n;o--){let i;o>=0?i=e[o]:(s===void 0&&(s=Ad()),i=s),i.length!==0&&(r=`${i}/${r}`,n=i.charCodeAt(0)===Gn)}return r=tM(r,!n),n?`/${r}`:r.length>0?r:"."}var Gn=47,cc=46;function tM(t,e){let r="",n=-1,s=0,o,i=!1;for(let a=0;a<=t.length;++a){if(a<t.length)o=t.charCodeAt(a);else{if(o===Gn)break;o=Gn}if(o===Gn){if(!(n===a-1||s===1))if(n!==a-1&&s===2){if(r.length<2||!i||r.charCodeAt(r.length-1)!==cc||r.charCodeAt(r.length-2)!==cc){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Gn;--l);if(l!==c){r=l===-1?"":r.slice(0,l),n=a,s=0,i=!1;continue}}else if(r.length===2||r.length===1){r="",n=a,s=0,i=!1;continue}}e&&(r.length>0?r+="/..":r="..",i=!0)}else{let c=t.slice(n+1,a);r.length>0?r+=`/${c}`:r=c,i=!1}n=a,s=0}else o===cc&&s!==-1?++s:s=-1}return r}var lc=class{optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(e,r,n){n?this.options=Fn({...n,core:lc.defaultOptions},r):this.options={...r},this.data=e,this.url=typeof e=="string"?gd(e):"",this.loadOptions={...this.options.core?.loadOptions},this.fetch=rM(this.loadOptions)}setProps(e){this.options=Object.assign(this.options,e),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}},Gr=lc;zt(Gr,"defaultOptions",{core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}});function rM(t){let e=t?.core?.fetch;if(e&&typeof e=="function")return(n,s)=>e(n,s);let r=t?.fetch;return r&&typeof r!="function"?n=>fetch(n,r):n=>fetch(n)}var Lt=class{};zt(Lt,"type","template"),zt(Lt,"testURL",e=>!1);function xd(t,e){let r=Xe.parseTextSync?.(t,e),n=r?.ServiceExceptionReport?.ServiceException||r?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return typeof n=="string"?n:n.value||n.code||"Unknown error"}var nM="4.4.0-alpha.18",Un={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:nM,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:sM,options:{wms:{throwOnError:!1}},parse:async(t,e)=>fc(new TextDecoder().decode(t),e),parseSync:(t,e)=>fc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>fc(t,e)};function sM(t){return t.startsWith("<?xml")}function fc(t,e){let r={...Un.options.wms,...e?.wms},n=xd(t,r),s=r.minimalErrors?n:`WMS Service error: ${n}`;if(r.throwOnError)throw new Error(s);return s}function nr(t){return Array.isArray(t)?t:t?[t]:[]}function Vn(t){let e=nr(t);return e.length>0&&e.every(r=>typeof r=="string")?e:[]}function Hn(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseFloat(t);default:return}}function _o(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseInt(t,10);default:return}}function sr(t){switch(t){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function uc(t,e){let r=Xe.parseTextSync?.(t,e),n=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,s=oM(n);if(e?.inheritedLayerProps)for(let o of s.layers)Td(o,null);return e?.includeRawJSON&&(s.json=n),e?.includeXMLText&&(s.xml=t),s}function oM(t){let e={version:String(t.version||""),name:String(t.Service?.Name||"unnamed"),title:t.Service?.Title?String(t.Service?.Title):void 0,abstract:t.Service?.Abstract?String(t.Service?.Abstract):void 0,keywords:Vn(t.Service?.KeywordList?.Keyword),fees:t.Service?.Fees?JSON.stringify(t.Service?.Fees):void 0,accessConstraints:t.Service?.AccessConstraints?JSON.stringify(t.Service?.AccessConstraints):void 0,layerLimit:_o(t.Service?.LayerLimit),maxWidth:_o(t.Service?.maxWidth),maxHeight:_o(t.Service?.maxHeight),layers:[],requests:iM(t.Capability?.Request),exceptions:aM(t.Exception)},r=nr(t.Capability?.Layer);for(let n of r)e.layers.push(yd(n));for(let[n,s]of Object.entries(e))s===void 0&&delete e[n];return e}function iM(t){let e={};for(let[r,n]of Object.entries(t||{})){let s=Vn(n?.Format);e[r]={mimeTypes:s}}return e}function aM(t){if(nr(t?.Format).length>0)return{mimeTypes:Vn(t)}}function yd(t){let e={title:String(t?.Title||""),name:t?.Name&&String(t?.Name),abstract:t?.Name&&String(t?.Abstract),keywords:Vn(t.KeywordList?.Keyword)},r=t?.CRS||t?.SRS;r&&Array.isArray(r)&&r.every(l=>typeof l=="string")&&(e.crs=r);let n=t?.EX_GeographicBoundingBox&&cM(t?.EX_GeographicBoundingBox);n&&(e.geographicBoundingBox=n),n=t?.LatLonBoundingBox&&lM(t?.LatLonBoundingBox),n&&(e.geographicBoundingBox=n);let s=t?.BoundingBox&&fM(t?.BoundingBox);s&&s.length>0&&(e.boundingBoxes=s);let i=nr(t?.Dimension).map(l=>hM(l));i.length&&(e.dimensions=i),t?.opaque&&(e.opaque=sr(t?.opaque)),t?.cascaded&&(e.cascaded=sr(t?.cascaded)),t?.queryable&&(e.queryable=sr(t?.queryable));let a=nr(t?.Layer),c=[];for(let l of a)c.push(yd(l));c.length>0&&(e.layers=c);for(let[l,f]of Object.entries(e))f===void 0&&delete e[l];return e}function cM(t){let{westBoundLongitude:e,northBoundLatitude:r,eastBoundLongitude:n,southBoundLatitude:s}=t;return[[e,s],[n,r]]}function lM(t){let{minx:e,miny:r,maxx:n,maxy:s}=t;return[[e,r],[n,s]]}function fM(t){return nr(t).map(r=>uM(r))}function uM(t){let{CRS:e,SRS:r,minx:n,miny:s,maxx:o,maxy:i,resx:a,resy:c}=t,l={crs:e||r,boundingBox:[[Hn(n),Hn(s)],[Hn(o),Hn(i)]]};return a&&(l.xResolution=a),c&&(l.yResolution=c),l}function hM(t){let{name:e,units:r,value:n}=t,s={name:e,units:r,extent:n};return t.unitSymbol&&(s.unitSymbol=t.unitSymbol),t.default&&(s.defaultValue=t.default),t.multipleValues&&(s.multipleValues=sr(t.multipleValues)),t.nearestValue&&(s.nearestValue=sr(t.nearestValue)),t.current&&(s.current=sr(t.current)),s}function Td(t,e){e?.geographicBoundingBox&&!t.geographicBoundingBox&&(t.geographicBoundingBox=[...e.geographicBoundingBox]),e?.crs&&!t.crs&&(t.crs=[...e.crs]),e?.boundingBoxes&&!t.boundingBoxes&&(t.boundingBoxes=[...e.boundingBoxes]),e?.dimensions&&!t.dimensions&&(t.dimensions=[...e.dimensions]);for(let r of t.layers||[])Td(r,t)}var dM="4.4.0-alpha.18",Ur={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:dM,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:pM,options:{wms:{}},parse:async(t,e)=>uc(new TextDecoder().decode(t),e?.wms),parseTextSync:(t,e)=>uc(t,e?.wms)};function pM(t){return t.startsWith("<?xml")}function hc(t,e){let n=(Xe.parseTextSync?.(t,e)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(n)?n:[n]).map(o=>mM(o))}}function mM(t){return{attributes:t||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var bd={...Ur,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(t,e)=>hc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>hc(t,e)};function dc(t,e){return Xe.parseTextSync?.(t,e)}var Ed={...Ur,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(t,e)=>dc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>dc(t,e)};var Md="4.4.0-alpha.18";var gM=globalThis.loaders?.parseImageNode,pc=typeof Image<"u",mc=typeof ImageBitmap<"u",AM=Boolean(gM),gc=Ln?!0:AM;function _d(t){switch(t){case"auto":return mc||pc||gc;case"imagebitmap":return mc;case"image":return pc;case"data":return gc;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function Bd(){if(mc)return"imagebitmap";if(pc)return"image";if(gc)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Cd(t){let e=xM(t);if(!e)throw new Error("Not an image");return e}function zn(t){switch(Cd(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function xM(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var yM=/^data:image\/svg\+xml/,TM=/\.svg((\?|#).*)?$/;function Bo(t){return t&&(yM.test(t)||TM.test(t))}function Sd(t,e){if(Bo(e)){let n=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return Ac(t,e)}function Ac(t,e){if(Bo(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function Co(t,e,r){let n=Sd(t,r),s=self.URL||self.webkitURL,o=typeof n!="string"&&s.createObjectURL(n);try{return await bM(o||n,e)}finally{o&&s.revokeObjectURL(o)}}async function bM(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((n,s)=>{try{r.onload=()=>n(r),r.onerror=o=>{let i=o instanceof Error?o.message:"error";s(new Error(i))}}catch(o){s(o)}})}var Id=!0;async function wd(t,e,r){let n;Bo(r)?n=await Co(t,e,r):n=Ac(t,r);let s=e&&e.imagebitmap;return await EM(n,s)}async function EM(t,e=null){if((MM(e)||!Id)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),Id=!1}return await createImageBitmap(t)}function MM(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function vd(t){return!SM(t,"ftyp",4)||!(t[8]&96)?null:_M(t)}function _M(t){switch(BM(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function BM(t,e,r){return String.fromCharCode(...t.slice(e,r))}function CM(t){return[...t].map(e=>e.charCodeAt(0))}function SM(t,e,r=0){let n=CM(e);for(let s=0;s<n.length;++s)if(n[s]!==t[s+r])return!1;return!0}var ot=!1,kn=!0;function or(t){let e=qn(t);return wM(e)||FM(e)||vM(e)||LM(e)||IM(e)}function IM(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=vd(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function wM(t){let e=qn(t);return e.byteLength>=24&&e.getUint32(0,ot)===2303741511?{mimeType:"image/png",width:e.getUint32(16,ot),height:e.getUint32(20,ot)}:null}function vM(t){let e=qn(t);return e.byteLength>=10&&e.getUint32(0,ot)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,kn),height:e.getUint16(8,kn)}:null}function LM(t){let e=qn(t);return e.byteLength>=14&&e.getUint16(0,ot)===16973&&e.getUint32(2,kn)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,kn),height:e.getUint32(22,kn)}:null}function FM(t){let e=qn(t);if(!(e.byteLength>=3&&e.getUint16(0,ot)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:s}=RM(),o=2;for(;o+9<e.byteLength;){let i=e.getUint16(o,ot);if(s.has(i))return{mimeType:"image/jpeg",height:e.getUint16(o+5,ot),width:e.getUint16(o+7,ot)};if(!n.has(i))return null;o+=2,o+=e.getUint16(o,ot)}return null}function RM(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function qn(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function Ld(t,e){let{mimeType:r}=or(t)||{},n=globalThis.loaders?.parseImageNode;return H(n),await n(t,r)}async function Fd(t,e,r){e=e||{};let s=(e.image||{}).type||"auto",{url:o}=r||{},i=PM(s),a;switch(i){case"imagebitmap":a=await wd(t,e,o);break;case"image":a=await Co(t,e,o);break;case"data":a=await Ld(t,e);break;default:H(!1)}return s==="data"&&(a=zn(a)),a}function PM(t){switch(t){case"auto":case"data":return Bd();default:return _d(t),t}}var OM=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],NM=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],DM={image:{type:"auto",decode:!0}},Vr={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:Md,mimeTypes:NM,extensions:OM,parse:Fd,tests:[t=>Boolean(or(new DataView(t)))],options:DM};var xc={};function yc(t){if(xc[t]===void 0){let e=Ln?UM(t):GM(t);xc[t]=e}return xc[t]}function GM(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&r.includes(t)}function UM(t){switch(t){case"image/avif":case"image/webp":return VM(t);default:return!0}}function VM(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}var Io={name:"Web Map Service (OGC WMS)",id:"wms",module:"wms",version:"0.0.0",extensions:[],mimeTypes:[],type:"wms",fromUrl:!0,fromBlob:!1,defaultOptions:{wms:{}},testURL:t=>t.toLowerCase().includes("wms"),createDataSource:(t,e)=>new So(t,e)},So=class extends Gr{substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e,r){super(e,r,Io.defaultOptions),this.substituteCRS84=r.wms?.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...r.wmsParameters,...r.wms?.wmsParameters},this.vendorParameters=r.wms?.vendorParameters||r.vendorParameters||{}}async getMetadata(){let e=await this.getCapabilities();return this.normalizeMetadata(e)}async getImage(e){let{boundingBox:r,bbox:n,...s}=e,o={bbox:r?[...r[0],...r[1]]:n,...s};return await this.getMap(o)}normalizeMetadata(e){return e}async getCapabilities(e,r){let n=this.getCapabilitiesURL(e,r),s=await this.fetch(n),o=await s.arrayBuffer();this._checkResponse(s,o);let i=await Ur.parse(o,this.loadOptions);return this.capabilities=i,i}async getMap(e,r){let n=this.getMapURL(e,r),s=await this.fetch(n),o=await s.arrayBuffer();this._checkResponse(s,o);try{return await Vr.parse(o,this.loadOptions)}catch{throw this._parseError(o)}}async getFeatureInfo(e,r){let n=this.getFeatureInfoURL(e,r),s=await this.fetch(n),o=await s.arrayBuffer();return this._checkResponse(s,o),await bd.parse(o,this.loadOptions)}async getFeatureInfoText(e,r){let n=this.getFeatureInfoURL(e,r),s=await this.fetch(n),o=await s.arrayBuffer();return this._checkResponse(s,o),new TextDecoder().decode(o)}async describeLayer(e,r){let n=this.describeLayerURL(e,r),s=await this.fetch(n),o=await s.arrayBuffer();return this._checkResponse(s,o),await Ed.parse(o,this.loadOptions)}async getLegendGraphic(e,r){let n=this.getLegendGraphicURL(e,r),s=await this.fetch(n),o=await s.arrayBuffer();this._checkResponse(s,o);try{return await Vr.parse(o,this.loadOptions)}catch{throw this._parseError(o)}}getCapabilitiesURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetCapabilities",n,r)}getMapURL(e,r){e=this._getWMS130Parameters(e);let n={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetMap",n,r)}getFeatureInfoURL(e,r){e=this._getWMS130Parameters(e);let{boundingBox:n,bbox:s}=e;e.bbox=n?[...n[0],...n[1]]:s;let o={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",o,r)}describeLayerURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("DescribeLayer",n,r)}getLegendGraphicURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetLegendGraphic",n,r)}_parseWMSUrl(e){let[r,n]=e.split("?"),s=n.split("&"),o={};for(let i of s){let[a,c]=i.split("=");o[a]=c}return{url:r,parameters:o}}_getWMSUrl(e,r,n){let s=this.url,o=!0,i={service:"WMS",version:r.version,request:e,...r,...this.vendorParameters,...n},a=["transparent","time","elevation"];for(let[c,l]of Object.entries(i))(!a.includes(c)||l)&&(s+=o?"?":"&",o=!1,s+=this._getURLParameter(c,l,r));return encodeURI(s)}_getWMS130Parameters(e){let r={...e};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(e,r,n){switch(e){case"crs":n.version!=="1.3.0"?e="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":n.version==="1.3.0"&&(e="crs");break;case"bbox":let s=this._flipBoundingBox(r,n);s&&(r=s);break;case"x":n.version==="1.3.0"&&(e="i");break;case"y":n.version==="1.3.0"&&(e="j");break;default:}return e=e.toUpperCase(),Array.isArray(r)?`${e}=${r.join(",")}`:`${e}=${r?String(r):""}`}_flipBoundingBox(e,r){if(!Array.isArray(e)||e.length!==4)return null;let n=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),s=e;return n?[s[1],s[0],s[3],s[2]]:s}async _fetchArrayBuffer(e){let r=await this.fetch(e),n=await r.arrayBuffer();return this._checkResponse(r,n),n}_checkResponse(e,r){let n=e.headers["content-type"];if(!e.ok||Un.mimeTypes.includes(n)){let s=Fn(this.loadOptions,{wms:{throwOnError:!0}}),o=Un.parseSync?.(r,s);throw new Error(o)}}_parseError(e){let r=Un.parseSync?.(e,this.options.core?.loadOptions);return new Error(r)}};function wo(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var Ye=Math.PI,Nd=Ye/4,Rd=Ye/180,Pd=180/Ye,vo=512;function ht(t){let[e,r]=t;wo(Number.isFinite(e)),wo(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let n=e*Rd,s=r*Rd,o=vo*(n+Ye)/(2*Ye),i=vo*(Ye+Math.log(Math.tan(Nd+s*.5)))/(2*Ye);return[o,i]}function dt(t){let[e,r]=t,n=e/vo*(2*Ye)-Ye,s=2*(Math.atan(Math.exp(r/vo*(2*Ye)-Ye))-Nd);return[n*Pd,s*Pd]}var GO=Math.PI/180;var Gd=6378137*Math.PI;function Tc(t){let e=ht(t);return e[0]=(e[0]/256-1)*Gd,e[1]=(e[1]/256-1)*Gd,e}var r_={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(t,e)=>console.error(e,t)}},Hr=class extends ir.CompositeLayer{get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:e,props:r,oldProps:n}){let{viewport:s}=this.context;e.dataChanged||r.serviceType!==n.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(s,"image source changed"),0)):(0,ir._deepEqual)(r.layers,n.layers,1)?e.viewportChanged&&this.debounce(()=>this.loadImage(s,"viewport changed")):this.debounce(()=>this.loadImage(s,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:e,image:r,lastRequestParameters:n}=this.state;return r&&new Ud.BitmapLayer({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:n.srs==="EPSG:4326"?ir.COORDINATE_SYSTEM.LNGLAT:ir.COORDINATE_SYSTEM.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,r){let{lastRequestParameters:n}=this.state;return n?await this.state.imageSource.getFeatureInfoText?.({...n,query_layers:n.layers,x:e,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(e){if(e.data instanceof Lt)return e.data;if(typeof e.data=="string")return(0,Vd.createDataSource)(e.data,[Io],{core:{type:e.serviceType,loadOptions:e.loadOptions}});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:e}=this.state;try{this.state.loadCounter++;let r=await e.getMetadata();this.state.imageSource===e&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(e,r){let{layers:n,serviceType:s}=this.props;if(s==="wms"&&n.length===0)return;let o=e.getBounds(),{width:i,height:a}=e,c=this.getRequestId(),{srs:l}=this.props;l==="auto"&&(l=e.resolution?"EPSG:4326":"EPSG:3857");let f={width:i,height:a,boundingBox:[[o[0],o[1]],[o[2],o[3]]],layers:n,crs:l};if(l==="EPSG:3857"){let u=Tc([o[0],o[1]]),h=Tc([o[2],o[3]]);f.boundingBox=[u,h]}try{this.state.loadCounter++,this.props.onImageLoadStart(c);let u=await this.state.imageSource.getImage(f);this.state.lastRequestId<c&&(this.getCurrentLayer()?.props.onImageLoad(c),this.setState({image:u,bounds:o,lastRequestParameters:f,lastRequestId:c}))}catch(u){this.raiseError(u,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(c,u)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(e,r=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>e(),r)}};Hr.layerName="WMSLayer";Hr.defaultProps=r_;var Hd=D(je(),1),n_={getHeight:{type:"accessor",value:0},greatCircle:!0},jn=class extends Hd.ArcLayer{};jn.layerName="GreatCircleLayer";jn.defaultProps=n_;var zd=jn;var Lo=D(bc(),1),s_=3,o_=30,i_=2*o_+1,qd=180/Math.PI;function Jd(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function jd(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function Wd(t){return[jd(t[0]),jd(t[1])]}function Xd(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function Yd([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*qd,n*qd]}function Kd(t){let e=Lo.default.fromString(t,!0,10).toString(2);for(;e.length<s_+i_;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),s=e.substring(3,r),o=s.length/2,i=Lo.default.fromString(n,!0,2).toString(10),a=Lo.default.fromString(s,!0,2).toString(4);for(;a.length<o;)a="0"+a;return`${i}/${a}`}function a_(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let s=e[0];e[0]=e[1],e[1]=s}}function Qd(t){let e=t.split("/"),r=parseInt(e[0],10),n=e[1],s=n.length,o=[0,0],i;for(let a=s-1;a>=0;a--){i=s-a;let c=n[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,i-1);a_(u,o,l,f),o[0]+=u*l,o[1]+=u*f}if(r%2===1){let a=o[0];o[0]=o[1],o[1]=a}return{face:r,ij:o,level:i}}var Zd=D(bc(),1);function c_(t){let e=t.padEnd(16,"0");return Zd.default.fromString(e,16)}var l_=100;function f_({face:t,ij:e,level:r}){let n=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(l_*Math.pow(2,-r))),o=new Float64Array(4*s*2+2),i=0,a=0;for(let c=0;c<4;c++){let l=n[c].slice(0),f=n[c+1],u=(f[0]-l[0])/s,h=(f[1]-l[1])/s;for(let d=0;d<s;d++){l[0]+=u,l[1]+=h;let p=Jd(e,r,l),A=Wd(p),m=Xd(t,A),y=Yd(m);Math.abs(y[1])>89.999&&(y[0]=a);let b=y[0]-a;y[0]+=b>180?-360:b<-180?360:0,o[i++]=y[0],o[i++]=y[1],a=y[0]}}return o[i++]=o[0],o[i++]=o[1],o}function u_(t){if(typeof t=="string"){if(t.indexOf("/")>0)return t;t=c_(t)}return Kd(t.toString())}function $d(t){let e=u_(t),r=Qd(e);return f_(r)}var h_={getS2Token:{type:"accessor",value:t=>t.token}},Wn=class extends Oe{indexToBounds(){let{data:e,getS2Token:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(n,s)=>$d(r(n,s))}}};Wn.layerName="S2Layer";Wn.defaultProps=h_;var ep=Wn;var Ec=512;function d_(t,e){let r=0,n=0,s=1<<t.length,o=s/Ec;for(let i=0;i<t.length;i++){s>>=1;let a=parseInt(t[i]);a%2&&(r|=s),a>1&&(n|=s)}return[[r/o,Ec-n/o],[(r+e)/o,Ec-(n+e)/o]]}function tp(t,e=1){let[r,n]=d_(t,e),[s,o]=dt(r),[i,a]=dt(n);return[i,o,i,a,s,a,s,o,i,o]}var p_={getQuadkey:{type:"accessor",value:t=>t.quadkey}},Xn=class extends Oe{indexToBounds(){let{data:e,extruded:r,getQuadkey:n}=this.props,s=r?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(o,i)=>tp(n(o,i),s),updateTriggers:{getPolygon:s}}}};Xn.layerName="QuadkeyLayer";Xn.defaultProps=p_;var rp=Xn;var Uo=D(Je(),1),yp=D(je(),1);var ar=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,requestScheduler:r,onLoad:n,onError:s}){let{index:o,id:i,bbox:a,userData:c,zoom:l}=this,f=this._loaderId;this._abortController=new AbortController;let{signal:u}=this._abortController,h=await r.scheduleRequest(this,A=>A.isSelected?1:-1);if(!h){this._isCancelled=!0;return}if(this._isCancelled){h.done();return}let d=null,p;try{d=await e({index:o,id:i,bbox:a,userData:c,zoom:l,signal:u})}catch(A){p=A||!0}finally{h.done()}if(f===this._loaderId){if(this._loader=void 0,this.content=d,this._isCancelled&&!d){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,p?s(p,this):n(this)}}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};var Qn=D(Je(),1);var oe={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var np=new x,m_=new x,Ft=class{constructor(e=[0,0,0],r=[0,0,0],n){n=n||np.copy(e).add(r).scale(.5),this.center=new x(n),this.halfDiagonal=new x(r).subtract(this.center),this.minimum=new x(e),this.maximum=new x(r)}clone(){return new Ft(this.minimum,this.maximum,this.center)}equals(e){return this===e||Boolean(e)&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){let{halfDiagonal:r}=this,n=m_.from(e.normal),s=r.x*Math.abs(n.x)+r.y*Math.abs(n.y)+r.z*Math.abs(n.z),o=this.center.dot(n)+e.distance;return o-s>0?oe.INSIDE:o+s<0?oe.OUTSIDE:oe.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=np.from(e).subtract(this.center),{halfDiagonal:n}=this,s=0,o;return o=Math.abs(r.x)-n.x,o>0&&(s+=o*o),o=Math.abs(r.y)-n.y,o>0&&(s+=o*o),o=Math.abs(r.z)-n.z,o>0&&(s+=o*o),s}};var Yn=new x,sp=new x,Ge=class{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new x,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=Yn.from(r),this.center=new x().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new Ge(this.center,this.radius)}union(e){let r=this.center,n=this.radius,s=e.center,o=e.radius,i=Yn.copy(s).subtract(r),a=i.magnitude();if(n>=a+o)return this.clone();if(o>=a+n)return e.clone();let c=(n+a+o)*.5;return sp.copy(i).scale((-n+c)/a).add(r),this.center.copy(sp),this.radius=c,this}expand(e){let n=Yn.from(e).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(e){this.center.transform(e);let r=Mn.getScaling(Yn,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let n=Yn.from(e).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(e){let r=this.center,n=this.radius,o=e.normal.dot(r)+e.distance;return o<-n?oe.OUTSIDE:o<n?oe.INTERSECTING:oe.INSIDE}};var g_=new x,A_=new x,Fo=new x,Ro=new x,Po=new x,x_=new x,y_=new x,pt={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},Ke=class{constructor(e=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new x().from(e),this.halfAxes=new j(r)}get halfSize(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new x(e).len(),new x(r).len(),new x(n).len()]}get quaternion(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),s=new x(e).normalize(),o=new x(r).normalize(),i=new x(n).normalize();return new rt().fromMatrix3(new j([...s,...o,...i]))}fromCenterHalfSizeQuaternion(e,r,n){let s=new rt(n),o=new j().fromQuaternion(s);return o[0]=o[0]*r[0],o[1]=o[1]*r[0],o[2]=o[2]*r[0],o[3]=o[3]*r[1],o[4]=o[4]*r[1],o[5]=o[5]*r[1],o[6]=o[6]*r[2],o[7]=o[7]*r[2],o[8]=o[8]*r[2],this.center=new x().from(e),this.halfAxes=o,this}clone(){return new Ke(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new Ge){let r=this.halfAxes,n=r.getColumn(0,Fo),s=r.getColumn(1,Ro),o=r.getColumn(2,Po),i=g_.copy(n).add(s).add(o);return e.center.copy(this.center),e.radius=i.magnitude(),e}intersectPlane(e){let r=this.center,n=e.normal,s=this.halfAxes,o=n.x,i=n.y,a=n.z,c=Math.abs(o*s[pt.COLUMN0ROW0]+i*s[pt.COLUMN0ROW1]+a*s[pt.COLUMN0ROW2])+Math.abs(o*s[pt.COLUMN1ROW0]+i*s[pt.COLUMN1ROW1]+a*s[pt.COLUMN1ROW2])+Math.abs(o*s[pt.COLUMN2ROW0]+i*s[pt.COLUMN2ROW1]+a*s[pt.COLUMN2ROW2]),l=n.dot(r)+e.distance;return l<=-c?oe.OUTSIDE:l>=c?oe.INSIDE:oe.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=A_.from(e).subtract(this.center),n=this.halfAxes,s=n.getColumn(0,Fo),o=n.getColumn(1,Ro),i=n.getColumn(2,Po),a=s.magnitude(),c=o.magnitude(),l=i.magnitude();s.normalize(),o.normalize(),i.normalize();let f=0,u;return u=Math.abs(r.dot(s))-a,u>0&&(f+=u*u),u=Math.abs(r.dot(o))-c,u>0&&(f+=u*u),u=Math.abs(r.dot(i))-l,u>0&&(f+=u*u),f}computePlaneDistances(e,r,n=[-0,-0]){let s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,i=this.center,a=this.halfAxes,c=a.getColumn(0,Fo),l=a.getColumn(1,Ro),f=a.getColumn(2,Po),u=x_.copy(c).add(l).add(f).add(i),h=y_.copy(u).subtract(e),d=r.dot(h);return s=Math.min(d,s),o=Math.max(d,o),u.copy(i).add(c).add(l).subtract(f),h.copy(u).subtract(e),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),u.copy(i).add(c).subtract(l).add(f),h.copy(u).subtract(e),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),u.copy(i).add(c).subtract(l).subtract(f),h.copy(u).subtract(e),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),i.copy(u).subtract(c).add(l).add(f),h.copy(u).subtract(e),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),i.copy(u).subtract(c).add(l).subtract(f),h.copy(u).subtract(e),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),i.copy(u).subtract(c).subtract(l).add(f),h.copy(u).subtract(e),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),i.copy(u).subtract(c).subtract(l).subtract(f),h.copy(u).subtract(e),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),n[0]=s,n[1]=o,n}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,Fo);r.transformAsPoint(e);let n=this.halfAxes.getColumn(1,Ro);n.transformAsPoint(e);let s=this.halfAxes.getColumn(2,Po);return s.transformAsPoint(e),this.halfAxes=new j([...r,...n,...s]),this}getTransform(){throw new Error("not implemented")}};var op=new x,ip=new x,ue=class{constructor(e=[0,0,1],r=0){this.normal=new x,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return fe(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=op.from(e),this.normal.from(r).normalize();let n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,r,n,s){return this.normal.set(e,r,n),fe(be(this.normal.len(),1)),this.distance=s,this}clone(){return new ue(this.normal,this.distance)}equals(e){return be(this.distance,e.distance)&&be(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=ip.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,r)}projectPointOntoPlane(e,r=[0,0,0]){let n=op.from(e),s=this.getPointDistance(n),o=ip.copy(this.normal).scale(s);return n.subtract(o).to(r)}};var ap=[new x([1,0,0]),new x([0,1,0]),new x([0,0,1])],cp=new x,T_=new x,ae=class{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*ap.length;let r=e.center,n=e.radius,s=0;for(let o of ap){let i=this.planes[s],a=this.planes[s+1];i||(i=this.planes[s]=new ue),a||(a=this.planes[s+1]=new ue);let c=cp.copy(o).scale(-n).add(r);i.fromPointNormal(c,o);let l=cp.copy(o).scale(n).add(r),f=T_.copy(o).negate();a.fromPointNormal(l,f),s+=2}return this}computeVisibility(e){let r=oe.INSIDE;for(let n of this.planes)switch(e.intersectPlane(n)){case oe.OUTSIDE:return oe.OUTSIDE;case oe.INTERSECTING:r=oe.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(fe(Number.isFinite(r),"parentPlaneMask is required."),r===ae.MASK_OUTSIDE||r===ae.MASK_INSIDE)return r;let n=ae.MASK_INSIDE,s=this.planes;for(let o=0;o<this.planes.length;++o){let i=o<31?1<<o:0;if(o<31&&!(r&i))continue;let a=s[o],c=e.intersectPlane(a);if(c===oe.OUTSIDE)return ae.MASK_OUTSIDE;c===oe.INTERSECTING&&(n|=i)}return n}};ae.MASK_OUTSIDE=4294967295;ae.MASK_INSIDE=0;ae.MASK_INDETERMINATE=2147483647;var eD=new x,tD=new x,rD=new x,nD=new x,sD=new x;var fD=new x,uD=new x,hD=new x,dD=new x,pD=new x,mD=new x,gD=new x,AD=new x,xD=new x,yD=new x,TD=new x,bD=new x;var it=new j,E_=new j,M_=new j,Oo=new j,lp=new j;function Bc(t,e={}){let r=Ne.EPSILON20,n=10,s=0,o=0,i=E_,a=M_;i.identity(),a.copy(t);let c=r*__(a);for(;o<n&&B_(a)>c;)C_(a,Oo),lp.copy(Oo).transpose(),a.multiplyRight(Oo),a.multiplyLeft(lp),i.multiplyRight(Oo),++s>2&&(++o,s=0);return e.unitary=i.toTarget(e.unitary),e.diagonal=a.toTarget(e.diagonal),e}function __(t){let e=0;for(let r=0;r<9;++r){let n=t[r];e+=n*n}return Math.sqrt(e)}var Mc=[1,0,0],_c=[2,2,1];function B_(t){let e=0;for(let r=0;r<3;++r){let n=t[it.getElementIndex(_c[r],Mc[r])];e+=2*n*n}return Math.sqrt(e)}function C_(t,e){let r=Ne.EPSILON15,n=0,s=1;for(let l=0;l<3;++l){let f=Math.abs(t[it.getElementIndex(_c[l],Mc[l])]);f>n&&(s=l,n=f)}let o=Mc[s],i=_c[s],a=1,c=0;if(Math.abs(t[it.getElementIndex(i,o)])>r){let l=t[it.getElementIndex(i,i)],f=t[it.getElementIndex(o,o)],u=t[it.getElementIndex(i,o)],h=(l-f)/2/u,d;h<0?d=-1/(-h+Math.sqrt(1+h*h)):d=1/(h+Math.sqrt(1+h*h)),a=1/Math.sqrt(1+d*d),c=d*a}return j.IDENTITY.to(e),e[it.getElementIndex(o,o)]=e[it.getElementIndex(i,i)]=a,e[it.getElementIndex(i,o)]=c,e[it.getElementIndex(o,i)]=-c,e}var Rt=new x,S_=new x,I_=new x,w_=new x,v_=new x,L_=new j,F_={diagonal:new j,unitary:new j};function Kn(t,e=new Ke){if(!t||t.length===0)return e.halfAxes=new j([0,0,0,0,0,0,0,0,0]),e.center=new x,e;let r=t.length,n=new x(0,0,0);for(let T of t)n.add(T);let s=1/r;n.multiplyByScalar(s);let o=0,i=0,a=0,c=0,l=0,f=0;for(let T of t){let g=Rt.copy(T).subtract(n);o+=g.x*g.x,i+=g.x*g.y,a+=g.x*g.z,c+=g.y*g.y,l+=g.y*g.z,f+=g.z*g.z}o*=s,i*=s,a*=s,c*=s,l*=s,f*=s;let u=L_;u[0]=o,u[1]=i,u[2]=a,u[3]=i,u[4]=c,u[5]=l,u[6]=a,u[7]=l,u[8]=f;let{unitary:h}=Bc(u,F_),d=e.halfAxes.copy(h),p=d.getColumn(0,I_),A=d.getColumn(1,w_),m=d.getColumn(2,v_),y=-Number.MAX_VALUE,b=-Number.MAX_VALUE,E=-Number.MAX_VALUE,M=Number.MAX_VALUE,B=Number.MAX_VALUE,C=Number.MAX_VALUE;for(let T of t)Rt.copy(T),y=Math.max(Rt.dot(p),y),b=Math.max(Rt.dot(A),b),E=Math.max(Rt.dot(m),E),M=Math.min(Rt.dot(p),M),B=Math.min(Rt.dot(A),B),C=Math.min(Rt.dot(m),C);p=p.multiplyByScalar(.5*(M+y)),A=A.multiplyByScalar(.5*(B+b)),m=m.multiplyByScalar(.5*(C+E)),e.center.copy(p).add(A).add(m);let v=S_.set(y-M,b-B,E-C).multiplyByScalar(.5),_=new j([v[0],0,0,0,v[1],0,0,0,v[2]]);return e.halfAxes.multiplyRight(_),e}var zr=512,fp=3,up=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],hp=up.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),R_=hp.concat([[.25,.5],[.75,.5]]),Pt=class{constructor(e,r,n){this.x=e,this.y=r,this.z=n}get children(){if(!this._children){let e=this.x*2,r=this.y*2,n=this.z+1;this._children=[new Pt(e,r,n),new Pt(e,r+1,n),new Pt(e+1,r,n),new Pt(e+1,r+1,n)]}return this._children}update(e){let{viewport:r,cullingVolume:n,elevationBounds:s,minZ:o,maxZ:i,bounds:a,offset:c,project:l}=e,f=this.getBoundingVolume(s,c,l);if(a&&!this.insideBounds(a)||n.computeVisibility(f)<0)return!1;if(!this.childVisible){let{z:h}=this;if(h<i&&h>=o){let d=f.distanceTo(r.cameraPosition)*r.scale/r.height;h+=Math.floor(Math.log2(d))}if(h>=i)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let h of this.children)h.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(let r of this._children)r.getSelected(e);return e}insideBounds([e,r,n,s]){let o=Math.pow(2,this.z),i=zr/o;return this.x*i<n&&this.y*i<s&&(this.x+1)*i>e&&(this.y+1)*i>r}getBoundingVolume(e,r,n){if(n){let c=this.z<1?R_:this.z<2?hp:up,l=[];for(let f of c){let u=No(this.x+f[0],this.y+f[1],this.z);u[2]=e[0],l.push(n(u)),e[0]!==e[1]&&(u[2]=e[1],l.push(n(u)))}return Kn(l)}let s=Math.pow(2,this.z),o=zr/s,i=this.x*o+r*zr,a=zr-(this.y+1)*o;return new Ft([i,a,e[0]],[i+o,a+o,e[1]])}};function dp(t,e,r,n){let s=t instanceof Qn._GlobeViewport&&t.resolution?t.projectPosition:null,o=Object.values(t.getFrustumPlanes()).map(({normal:d,distance:p})=>new ue(d.clone().negate(),p)),i=new ae(o),a=t.distanceScales.unitsPerMeter[2],c=r&&r[0]*a||0,l=r&&r[1]*a||0,f=t instanceof Qn.WebMercatorViewport&&t.pitch<=60?e:0;if(n){let[d,p,A,m]=n,y=ht([d,m]),b=ht([A,p]);n=[y[0],zr-y[1],b[0],zr-b[1]]}let u=new Pt(0,0,0),h={viewport:t,project:s,cullingVolume:i,elevationBounds:[c,l],minZ:f,maxZ:e,bounds:n,offset:0};if(u.update(h),t instanceof Qn.WebMercatorViewport&&t.subViewports&&t.subViewports.length>1){for(h.offset=-1;u.update(h)&&!(--h.offset<-fp););for(h.offset=1;u.update(h)&&!(++h.offset>fp););}return u.getSelected()}var mt=512,P_=[-1/0,-1/0,1/0,1/0],Ot={type:"object",value:null,validate:(t,e)=>e.optional&&t===null||typeof t=="string"||Array.isArray(t)&&t.every(r=>typeof r=="string"),equal:(t,e)=>{if(t===e)return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;let r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}};function Do(t,e){let r=[e.transformAsPoint([t[0],t[1]]),e.transformAsPoint([t[2],t[1]]),e.transformAsPoint([t[0],t[3]]),e.transformAsPoint([t[2],t[3]])];return[Math.min(...r.map(s=>s[0])),Math.min(...r.map(s=>s[1])),Math.max(...r.map(s=>s[0])),Math.max(...r.map(s=>s[1]))]}function O_(t){return Math.abs(t.split("").reduce((e,r)=>(e<<5)-e+r.charCodeAt(0)|0,0))}function at(t,e){if(!t||!t.length)return null;let{index:r,id:n}=e;if(Array.isArray(t)){let o=O_(n)%t.length;t=t[o]}let s=t;for(let o of Object.keys(r)){let i=new RegExp(`{${o}}`,"g");s=s.replace(i,String(r[o]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(s=s.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),s}function N_(t,e,r){let n;if(e&&e.length===2){let[s,o]=e,i=t.getBounds({z:s}),a=t.getBounds({z:o});n=[Math.min(i[0],a[0]),Math.min(i[1],a[1]),Math.max(i[2],a[2]),Math.max(i[3],a[3])]}else n=t.getBounds();return t.isGeospatial?[Math.max(n[0],r[0]),Math.max(n[1],r[1]),Math.min(n[2],r[2]),Math.min(n[3],r[3])]:[Math.max(Math.min(n[0],r[2]),r[0]),Math.max(Math.min(n[1],r[3]),r[1]),Math.min(Math.max(n[2],r[0]),r[2]),Math.min(Math.max(n[3],r[1]),r[3])]}function mp({viewport:t,z:e,cullRect:r}){return(t.subViewports||[t]).map(s=>Cc(s,e||0,r))}function Cc(t,e,r){if(!Array.isArray(e)){let o=r.x-t.x,i=r.y-t.y,{width:a,height:c}=r,l={targetZ:e},f=t.unproject([o,i],l),u=t.unproject([o+a,i],l),h=t.unproject([o,i+c],l),d=t.unproject([o+a,i+c],l);return[Math.min(f[0],u[0],h[0],d[0]),Math.min(f[1],u[1],h[1],d[1]),Math.max(f[0],u[0],h[0],d[0]),Math.max(f[1],u[1],h[1],d[1])]}let n=Cc(t,e[0],r),s=Cc(t,e[1],r);return[Math.min(n[0],s[0]),Math.min(n[1],s[1]),Math.max(n[2],s[2]),Math.max(n[3],s[3])]}function D_(t,e,r){return r?Do(t,r).map(s=>s*e/mt):t.map(n=>n*e/mt)}function Sc(t,e){return Math.pow(2,t)*mt/e}function No(t,e,r){let n=Sc(r,mt),s=t/n*360-180,o=Math.PI-2*Math.PI*e/n,i=180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)));return[s,i]}function pp(t,e,r,n){let s=Sc(r,n);return[t/s*mt,e/s*mt]}function Ic(t,e,r,n,s=mt){if(t.isGeospatial){let[l,f]=No(e,r,n),[u,h]=No(e+1,r+1,n);return{west:l,north:f,east:u,south:h}}let[o,i]=pp(e,r,n,s),[a,c]=pp(e+1,r+1,n,s);return{left:o,top:i,right:a,bottom:c}}function G_(t,e,r,n,s){let o=N_(t,null,n),i=Sc(e,r),[a,c,l,f]=D_(o,i,s),u=[];for(let h=Math.floor(a);h<l;h++)for(let d=Math.floor(c);d<f;d++)u.push({x:h,y:d,z:e});return u}function wc({viewport:t,maxZoom:e,minZoom:r,zRange:n,extent:s,tileSize:o=mt,modelMatrix:i,modelMatrixInverse:a,zoomOffset:c=0}){let l=t.isGeospatial?Math.round(t.zoom+Math.log2(mt/o))+c:Math.ceil(t.zoom)+c;if(typeof r=="number"&&Number.isFinite(r)&&l<r){if(!s)return[];l=r}typeof e=="number"&&Number.isFinite(e)&&l>e&&(l=e);let f=s;return i&&a&&s&&!t.isGeospatial&&(f=Do(s,i)),t.isGeospatial?dp(t,l,n,s):G_(t,l,o,f||P_,a)}function vc(t){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(t)}function Lc(t){return Number.isFinite(t.west)&&Number.isFinite(t.north)&&Number.isFinite(t.east)&&Number.isFinite(t.south)}function gp(t){let e={},r;return n=>{for(let s in n)if(!U_(n[s],e[s])){r=t(n),e=n;break}return r}}function U_(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}return!1}var Ap=1,Go=2,V_="never",H_="no-overlap",Zn="best-available",z_=5,k_={[Zn]:j_,[H_]:J_,[V_]:()=>{}},q_={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}},cr=class{constructor(e){this._getCullBounds=gp(mp),this.opts={...q_,...e},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize!==null&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new It({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new O,this._modelMatrixInverse=new O}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return this._selectedTiles!==null&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom))}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let e of this._cache.keys()){let r=this._cache.get(e);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(e):r.setNeedsReload()}}update(e,{zRange:r,modelMatrix:n}={zRange:null,modelMatrix:null}){let s=n?new O(n):new O,o=!s.equals(this._modelMatrix);if(!this._viewport||!e.equals(this._viewport)||!be(this._zRange,r)||o){o&&(this._modelMatrixInverse=s.clone().invert(),this._modelMatrix=s),this._viewport=e,this._zRange=r;let a=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:r,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=a.map(c=>this._getTile(c,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(a=>this._getTile(a.index,!0)));let i=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),i&&this._frameNumber++,this._frameNumber}isTileVisible(e,r,n){if(!e.isVisible)return!1;if(r&&this._viewport){let s=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:o}=e;for(let[i,a,c,l]of s){let f;if("west"in o)f=o.west<c&&o.east>i&&o.south<l&&o.north>a;else{if(n&&!O.IDENTITY.equals(n)){let[d,p,A,m]=Do([o.left,o.top,o.right,o.bottom],n);o={left:d,top:p,right:A,bottom:m}}let u=Math.min(o.top,o.bottom),h=Math.max(o.top,o.bottom);f=o.left<c&&o.right>i&&u<l&&h>a}if(f)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:r,minZoom:n,zRange:s,modelMatrix:o,modelMatrixInverse:i}){let{tileSize:a,extent:c,zoomOffset:l}=this.opts;return wc({viewport:e,maxZoom:r,minZoom:n,zRange:s,tileSize:a,extent:c,modelMatrix:o,modelMatrixInverse:i,zoomOffset:l})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){let{tileSize:r}=this.opts;return{bbox:Ic(this._viewport,e.x,e.y,e.z,r)}}getParentIndex(e){let r=Math.floor(e.x/2),n=Math.floor(e.y/2),s=e.z-1;return{x:r,y:n,z:s}}updateTileStates(){let e=this.opts.refinementStrategy||Zn,r=new Array(this._cache.size),n=0;for(let s of this._cache.values())r[n++]=s.isVisible,s.isSelected=!1,s.isVisible=!1;for(let s of this._selectedTiles)s.isSelected=!0,s.isVisible=!0;(typeof e=="function"?e:k_[e])(Array.from(this._cache.values())),n=0;for(let s of this._cache.values())if(r[n++]!==s.isVisible)return!0;return!1}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=[],n=0;for(let s of this._cache.values())s.isLoading&&(n++,!s.isSelected&&!s.isVisible&&r.push(s));for(;e>0&&n>e&&r.length>0;)r.shift().abort(),n--}_rebuildTree(){let{_cache:e}=this;for(let r of e.values())r.parent=null,r.children&&(r.children.length=0);for(let r of e.values()){let n=this._getNearestAncestor(r);r.parent=n,n?.children&&n.children.push(r)}}_resizeCache(){let{_cache:e,opts:r}=this,n=r.maxCacheSize??(r.maxCacheByteSize!==null?1/0:z_*this.selectedTiles.length),s=r.maxCacheByteSize??1/0;if(e.size>n||this._cacheByteSize>s){for(let[i,a]of e)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize!==null?a.byteLength:0,e.delete(i),this.opts.onTileUnload?.(a)),e.size<=n&&this._cacheByteSize<=s)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((i,a)=>i.zoom-a.zoom),this._dirty=!1)}_getTile(e,r){let n=this.getTileId(e),s=this._cache.get(n),o=!1;return!s&&r?(s=new ar(e),Object.assign(s,this.getTileMetadata(s.index)),Object.assign(s,{id:n,zoom:this.getTileZoom(s.index)}),o=!0,this._cache.set(n,s),this._dirty=!0):s&&s.needsReload&&(o=!0),s&&o&&s.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),s}_getNearestAncestor(e){let{_minZoom:r=0}=this,n=e.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let s=this._getTile(n);if(s)return s}return null}};function j_(t){for(let e of t)e.state=0;for(let e of t)e.isSelected&&!xp(e)&&Fc(e);for(let e of t)e.isVisible=Boolean(e.state&Go)}function J_(t){for(let r of t)r.state=0;for(let r of t)r.isSelected&&xp(r);let e=Array.from(t).sort((r,n)=>r.zoom-n.zoom);for(let r of e)if(r.isVisible=Boolean(r.state&Go),r.children&&(r.isVisible||r.state&Ap))for(let n of r.children)n.state=Ap;else r.isSelected&&Fc(r)}function xp(t){let e=t;for(;e;){if(e.isLoaded||e.content)return e.state|=Go,!0;e=e.parent}return!1}function Fc(t){for(let e of t.children)e.isLoaded||e.content?e.state|=Go:Fc(e)}var W_={TilesetClass:cr,data:{type:"data",value:[]},dataComparator:Ot.equal,renderSubLayers:{type:"function",value:t=>new yp.GeoJsonLayer(t)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:t=>console.error(t)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:Zn,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0},$n=class extends Uo.CompositeLayer{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&e.layers&&e.layers.every(r=>r.isLoaded)))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:r}=this.state,n=e.propsOrDataChanged||e.updateTriggersChanged,s=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);r?n&&(r.setOptions(this._getTilesetOptions()),s?r.reloadAll():r.tiles.forEach(o=>{o.layers=null})):(r=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:r})),this._updateTileset()}_getTilesetOptions(){let{tileSize:e,maxCacheSize:r,maxCacheByteSize:n,refinementStrategy:s,extent:o,maxZoom:i,minZoom:a,maxRequests:c,debounceTime:l,zoomOffset:f}=this.props;return{maxCacheSize:r,maxCacheByteSize:n,maxZoom:i,minZoom:a,tileSize:e,refinementStrategy:s,extent:o,maxRequests:c,debounceTime:l,zoomOffset:f,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let e=this.state.tileset,{zRange:r,modelMatrix:n}=this.props,s=e.update(this.context.viewport,{zRange:r,modelMatrix:n}),{isLoaded:o}=e,i=this.state.isLoaded!==o,a=this.state.frameNumber!==s;o&&(i||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:s}),this.state.isLoaded=o}_onViewportLoad(){let{tileset:e}=this.state,{onViewportLoad:r}=this.props;r&&r(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,r){this.props.onTileError(e),r.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){let{data:r,getTileData:n,fetch:s}=this.props,{signal:o}=e;return e.url=typeof r=="string"||Array.isArray(r)?at(r,e):null,n?n(e):s&&e.url?s(e.url,{propName:"data",layer:this,signal:o}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){let r=e.sourceLayer,n=r.props.tile,s=e.info;return s.picked&&(s.tile=n),s.sourceTile=n,s.sourceTileSubLayer=r,s}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){return this.state.tileset.tiles.map(e=>{let r=this.getSubLayerPropsByTile(e);if(!(!e.isLoaded&&!e.content))if(e.layers)r&&e.layers[0]&&Object.keys(r).some(n=>e.layers[0].props[n]!==r[n])&&(e.layers=e.layers.map(n=>n.clone(r)));else{let n=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:e.id,updateTriggers:this.props.updateTriggers}),data:e.content,_offset:0,tile:e});e.layers=(0,Uo._flatten)(n,Boolean).map(s=>s.clone({tile:e,...r}))}return e.layers})}filterSubLayer({layer:e,cullRect:r}){let{tile:n}=e.props,{modelMatrix:s}=this.props;return this.state.tileset.isTileVisible(n,r,s?new O(s):null)}};$n.defaultProps=W_;$n.layerName="TileLayer";var lr=$n;var Ep=D(je(),1);var Tp=`uniform tripsUniforms {
7
+ "use strict";var __exports__=(()=>{var f1=Object.create;var mn=Object.defineProperty;var u1=Object.getOwnPropertyDescriptor;var h1=Object.getOwnPropertyNames;var p1=Object.getPrototypeOf,d1=Object.prototype.hasOwnProperty;var m1=(t,e,r)=>e in t?mn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Ef=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var Je=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xe=(t,e)=>{for(var r in e)mn(t,r,{get:e[r],enumerable:!0})},No=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of h1(e))!d1.call(t,o)&&o!==r&&mn(t,o,{get:()=>e[o],enumerable:!(n=u1(e,o))||n.enumerable});return t},_t=(t,e,r)=>(No(t,e,"default"),r&&No(r,e,"default")),D=(t,e,r)=>(r=t!=null?f1(p1(t)):{},No(e||!t||!t.__esModule?mn(r,"default",{value:t,enumerable:!0}):r,t)),g1=t=>No(mn({},"__esModule",{value:!0}),t);var qt=(t,e,r)=>(m1(t,typeof e!="symbol"?e+"":e,r),r);var We=Je((Xv,_f)=>{_f.exports=globalThis.deck});var Xe=Je((Kv,Sf)=>{Sf.exports=globalThis.deck});var $o=Je((mw,Vu)=>{Vu.exports=globalThis.h3||{}});var Zt=Je(($L,Vh)=>{Vh.exports=globalThis.loaders});var Ec=Je((kp,Yn)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof Ef=="function"&&typeof Yn=="object"&&Yn&&Yn.exports?Yn.exports=e():(t.dcodeIO=t.dcodeIO||{}).Long=e()})(kp,function(){"use strict";function t(y,g,B){this.low=y|0,this.high=g|0,this.unsigned=!!B}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function e(y){return(y&&y.__isLong__)===!0}t.isLong=e;var r={},n={};function o(y,g){var B,L,F;return g?(y>>>=0,(F=0<=y&&y<256)&&(L=n[y],L)?L:(B=i(y,(y|0)<0?-1:0,!0),F&&(n[y]=B),B)):(y|=0,(F=-128<=y&&y<128)&&(L=r[y],L)?L:(B=i(y,y<0?-1:0,!1),F&&(r[y]=B),B))}t.fromInt=o;function s(y,g){if(isNaN(y)||!isFinite(y))return g?b:m;if(g){if(y<0)return b;if(y>=p)return C}else{if(y<=-d)return v;if(y+1>=d)return S}return y<0?s(-y,g).neg():i(y%h|0,y/h|0,g)}t.fromNumber=s;function i(y,g,B){return new t(y,g,B)}t.fromBits=i;var a=Math.pow;function c(y,g,B){if(y.length===0)throw Error("empty string");if(y==="NaN"||y==="Infinity"||y==="+Infinity"||y==="-Infinity")return m;if(typeof g=="number"?(B=g,g=!1):g=!!g,B=B||10,B<2||36<B)throw RangeError("radix");var L;if((L=y.indexOf("-"))>0)throw Error("interior hyphen");if(L===0)return c(y.substring(1),g,B).neg();for(var F=s(a(B,8)),w=m,U=0;U<y.length;U+=8){var W=Math.min(8,y.length-U),z=parseInt(y.substring(U,U+W),B);if(W<8){var re=s(a(B,W));w=w.mul(re).add(s(z))}else w=w.mul(F),w=w.add(s(z))}return w.unsigned=g,w}t.fromString=c;function l(y){return y instanceof t?y:typeof y=="number"?s(y):typeof y=="string"?c(y):i(y.low,y.high,y.unsigned)}t.fromValue=l;var f=1<<16,u=1<<24,h=f*f,p=h*h,d=p/2,A=o(u),m=o(0);t.ZERO=m;var b=o(0,!0);t.UZERO=b;var T=o(1);t.ONE=T;var E=o(1,!0);t.UONE=E;var _=o(-1);t.NEG_ONE=_;var S=i(-1,2147483647,!1);t.MAX_VALUE=S;var C=i(-1,-1,!0);t.MAX_UNSIGNED_VALUE=C;var v=i(0,-2147483648,!1);t.MIN_VALUE=v;var M=t.prototype;return M.toInt=function(){return this.unsigned?this.low>>>0:this.low},M.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},M.toString=function(g){if(g=g||10,g<2||36<g)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(v)){var B=s(g),L=this.div(B),F=L.mul(B).sub(this);return L.toString(g)+F.toInt().toString(g)}else return"-"+this.neg().toString(g);for(var w=s(a(g,6),this.unsigned),U=this,W="";;){var z=U.div(w),re=U.sub(z.mul(w)).toInt()>>>0,K=re.toString(g);if(U=z,U.isZero())return K+W;for(;K.length<6;)K="0"+K;W=""+K+W}},M.getHighBits=function(){return this.high},M.getHighBitsUnsigned=function(){return this.high>>>0},M.getLowBits=function(){return this.low},M.getLowBitsUnsigned=function(){return this.low>>>0},M.getNumBitsAbs=function(){if(this.isNegative())return this.eq(v)?64:this.neg().getNumBitsAbs();for(var g=this.high!=0?this.high:this.low,B=31;B>0&&!(g&1<<B);B--);return this.high!=0?B+33:B+1},M.isZero=function(){return this.high===0&&this.low===0},M.isNegative=function(){return!this.unsigned&&this.high<0},M.isPositive=function(){return this.unsigned||this.high>=0},M.isOdd=function(){return(this.low&1)===1},M.isEven=function(){return(this.low&1)===0},M.equals=function(g){return e(g)||(g=l(g)),this.unsigned!==g.unsigned&&this.high>>>31===1&&g.high>>>31===1?!1:this.high===g.high&&this.low===g.low},M.eq=M.equals,M.notEquals=function(g){return!this.eq(g)},M.neq=M.notEquals,M.lessThan=function(g){return this.comp(g)<0},M.lt=M.lessThan,M.lessThanOrEqual=function(g){return this.comp(g)<=0},M.lte=M.lessThanOrEqual,M.greaterThan=function(g){return this.comp(g)>0},M.gt=M.greaterThan,M.greaterThanOrEqual=function(g){return this.comp(g)>=0},M.gte=M.greaterThanOrEqual,M.compare=function(g){if(e(g)||(g=l(g)),this.eq(g))return 0;var B=this.isNegative(),L=g.isNegative();return B&&!L?-1:!B&&L?1:this.unsigned?g.high>>>0>this.high>>>0||g.high===this.high&&g.low>>>0>this.low>>>0?-1:1:this.sub(g).isNegative()?-1:1},M.comp=M.compare,M.negate=function(){return!this.unsigned&&this.eq(v)?v:this.not().add(T)},M.neg=M.negate,M.add=function(g){e(g)||(g=l(g));var B=this.high>>>16,L=this.high&65535,F=this.low>>>16,w=this.low&65535,U=g.high>>>16,W=g.high&65535,z=g.low>>>16,re=g.low&65535,K=0,Y=0,ee=0,Be=0;return Be+=w+re,ee+=Be>>>16,Be&=65535,ee+=F+z,Y+=ee>>>16,ee&=65535,Y+=L+W,K+=Y>>>16,Y&=65535,K+=B+U,K&=65535,i(ee<<16|Be,K<<16|Y,this.unsigned)},M.subtract=function(g){return e(g)||(g=l(g)),this.add(g.neg())},M.sub=M.subtract,M.multiply=function(g){if(this.isZero()||(e(g)||(g=l(g)),g.isZero()))return m;if(this.eq(v))return g.isOdd()?v:m;if(g.eq(v))return this.isOdd()?v:m;if(this.isNegative())return g.isNegative()?this.neg().mul(g.neg()):this.neg().mul(g).neg();if(g.isNegative())return this.mul(g.neg()).neg();if(this.lt(A)&&g.lt(A))return s(this.toNumber()*g.toNumber(),this.unsigned);var B=this.high>>>16,L=this.high&65535,F=this.low>>>16,w=this.low&65535,U=g.high>>>16,W=g.high&65535,z=g.low>>>16,re=g.low&65535,K=0,Y=0,ee=0,Be=0;return Be+=w*re,ee+=Be>>>16,Be&=65535,ee+=F*re,Y+=ee>>>16,ee&=65535,ee+=w*z,Y+=ee>>>16,ee&=65535,Y+=L*re,K+=Y>>>16,Y&=65535,Y+=F*z,K+=Y>>>16,Y&=65535,Y+=w*W,K+=Y>>>16,Y&=65535,K+=B*re+L*z+F*W+w*U,K&=65535,i(ee<<16|Be,K<<16|Y,this.unsigned)},M.mul=M.multiply,M.divide=function(g){if(e(g)||(g=l(g)),g.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?b:m;var B,L,F;if(this.unsigned){if(g.unsigned||(g=g.toUnsigned()),g.gt(this))return b;if(g.gt(this.shru(1)))return E;F=b}else{if(this.eq(v)){if(g.eq(T)||g.eq(_))return v;if(g.eq(v))return T;var w=this.shr(1);return B=w.div(g).shl(1),B.eq(m)?g.isNegative()?T:_:(L=this.sub(g.mul(B)),F=B.add(L.div(g)),F)}else if(g.eq(v))return this.unsigned?b:m;if(this.isNegative())return g.isNegative()?this.neg().div(g.neg()):this.neg().div(g).neg();if(g.isNegative())return this.div(g.neg()).neg();F=m}for(L=this;L.gte(g);){B=Math.max(1,Math.floor(L.toNumber()/g.toNumber()));for(var U=Math.ceil(Math.log(B)/Math.LN2),W=U<=48?1:a(2,U-48),z=s(B),re=z.mul(g);re.isNegative()||re.gt(L);)B-=W,z=s(B,this.unsigned),re=z.mul(g);z.isZero()&&(z=T),F=F.add(z),L=L.sub(re)}return F},M.div=M.divide,M.modulo=function(g){return e(g)||(g=l(g)),this.sub(this.div(g).mul(g))},M.mod=M.modulo,M.not=function(){return i(~this.low,~this.high,this.unsigned)},M.and=function(g){return e(g)||(g=l(g)),i(this.low&g.low,this.high&g.high,this.unsigned)},M.or=function(g){return e(g)||(g=l(g)),i(this.low|g.low,this.high|g.high,this.unsigned)},M.xor=function(g){return e(g)||(g=l(g)),i(this.low^g.low,this.high^g.high,this.unsigned)},M.shiftLeft=function(g){return e(g)&&(g=g.toInt()),(g&=63)===0?this:g<32?i(this.low<<g,this.high<<g|this.low>>>32-g,this.unsigned):i(0,this.low<<g-32,this.unsigned)},M.shl=M.shiftLeft,M.shiftRight=function(g){return e(g)&&(g=g.toInt()),(g&=63)===0?this:g<32?i(this.low>>>g|this.high<<32-g,this.high>>g,this.unsigned):i(this.high>>g-32,this.high>=0?0:-1,this.unsigned)},M.shr=M.shiftRight,M.shiftRightUnsigned=function(g){if(e(g)&&(g=g.toInt()),g&=63,g===0)return this;var B=this.high;if(g<32){var L=this.low;return i(L>>>g|B<<32-g,B>>>g,this.unsigned)}else return g===32?i(B,0,this.unsigned):i(B>>>g-32,0,this.unsigned)},M.shru=M.shiftRightUnsigned,M.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},M.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},M.toBytes=function(y){return y?this.toBytesLE():this.toBytesBE()},M.toBytesLE=function(){var y=this.high,g=this.low;return[g&255,g>>>8&255,g>>>16&255,g>>>24&255,y&255,y>>>8&255,y>>>16&255,y>>>24&255]},M.toBytesBE=function(){var y=this.high,g=this.low;return[y>>>24&255,y>>>16&255,y>>>8&255,y&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255]},t})});var Pc=Je((jU,Bd)=>{Bd.exports=globalThis.luma});var zs=Je((JU,Id)=>{Id.exports=globalThis.deck});var Hc=Je((MG,Hd)=>{Hd.exports=globalThis.luma});var C0=Je((fk,S0)=>{S0.exports=globalThis.deck});var O0=Je(ff=>{ff.read=function(t,e,r,n,o){var s,i,a=o*8-n-1,c=(1<<a)-1,l=c>>1,f=-7,u=r?o-1:0,h=r?-1:1,p=t[e+u];for(u+=h,s=p&(1<<-f)-1,p>>=-f,f+=a;f>0;s=s*256+t[e+u],u+=h,f-=8);for(i=s&(1<<-f)-1,s>>=-f,f+=n;f>0;i=i*256+t[e+u],u+=h,f-=8);if(s===0)s=1-l;else{if(s===c)return i?NaN:(p?-1:1)*(1/0);i=i+Math.pow(2,n),s=s-l}return(p?-1:1)*i*Math.pow(2,s-n)};ff.write=function(t,e,r,n,o,s){var i,a,c,l=s*8-o-1,f=(1<<l)-1,u=f>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,d=n?1:-1,A=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=f):(i=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-i))<1&&(i--,c*=2),i+u>=1?e+=h/c:e+=h*Math.pow(2,1-u),e*c>=2&&(i++,c/=2),i+u>=f?(a=0,i=f):i+u>=1?(a=(e*c-1)*Math.pow(2,o),i=i+u):(a=e*Math.pow(2,u-1)*Math.pow(2,o),i=0));o>=8;t[r+p]=a&255,p+=d,a/=256,o-=8);for(i=i<<o|a,l+=o;l>0;t[r+p]=i&255,p+=d,i/=256,l-=8);t[r+p-d]|=A*128}});var z0=Je(($k,V0)=>{"use strict";V0.exports=J;var Vi=O0();function J(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}J.Varint=0;J.Fixed64=1;J.Bytes=2;J.Fixed32=5;var uf=(1<<16)*(1<<16),D0=1/uf,nv=12,H0=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");J.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),o=n>>3,s=this.pos;this.type=n&7,t(o,e,this),this.pos===s&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=zi(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=G0(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=zi(this.buf,this.pos)+zi(this.buf,this.pos+4)*uf;return this.pos+=8,t},readSFixed64:function(){var t=zi(this.buf,this.pos)+G0(this.buf,this.pos+4)*uf;return this.pos+=8,t},readFloat:function(){var t=Vi.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Vi.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,n;return n=e[this.pos++],r=n&127,n<128||(n=e[this.pos++],r|=(n&127)<<7,n<128)||(n=e[this.pos++],r|=(n&127)<<14,n<128)||(n=e[this.pos++],r|=(n&127)<<21,n<128)?r:(n=e[this.pos],r|=(n&15)<<28,ov(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=nv&&H0?xv(this.buf,e,t):Av(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==J.Bytes)return t.push(this.readVarint(e));var r=Et(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==J.Bytes)return t.push(this.readSVarint());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==J.Bytes)return t.push(this.readBoolean());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==J.Bytes)return t.push(this.readFloat());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==J.Bytes)return t.push(this.readDouble());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==J.Bytes)return t.push(this.readFixed32());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==J.Bytes)return t.push(this.readSFixed32());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==J.Bytes)return t.push(this.readFixed64());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==J.Bytes)return t.push(this.readSFixed64());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===J.Varint)for(;this.buf[this.pos++]>127;);else if(e===J.Bytes)this.pos=this.readVarint()+this.pos;else if(e===J.Fixed32)this.pos+=4;else if(e===J.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),dn(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),dn(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),dn(this.buf,t&-1,this.pos),dn(this.buf,Math.floor(t*D0),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),dn(this.buf,t&-1,this.pos),dn(this.buf,Math.floor(t*D0),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){sv(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=bv(this.buf,t,this.pos);var r=this.pos-e;r>=128&&U0(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Vi.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Vi.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var n=this.pos-r;n>=128&&U0(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,J.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,cv,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,lv,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,hv,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,fv,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,uv,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,pv,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,dv,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,mv,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,gv,e)},writeBytesField:function(t,e){this.writeTag(t,J.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,J.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,J.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,J.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,J.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,J.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,J.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,J.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,J.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,J.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};function ov(t,e,r){var n=r.buf,o,s;if(s=n[r.pos++],o=(s&112)>>4,s<128||(s=n[r.pos++],o|=(s&127)<<3,s<128)||(s=n[r.pos++],o|=(s&127)<<10,s<128)||(s=n[r.pos++],o|=(s&127)<<17,s<128)||(s=n[r.pos++],o|=(s&127)<<24,s<128)||(s=n[r.pos++],o|=(s&1)<<31,s<128))return pn(t,o,e);throw new Error("Expected varint not more than 10 bytes")}function Et(t){return t.type===J.Bytes?t.readVarint()+t.pos:t.pos+1}function pn(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function sv(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(r=~(-t%4294967296),n=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,n=n+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),iv(r,n,e),av(n,e)}function iv(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function av(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function U0(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(n);for(var o=r.pos-1;o>=t;o--)r.buf[o+n]=r.buf[o]}function cv(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function lv(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function fv(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function uv(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function hv(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function pv(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function dv(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function mv(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function gv(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function zi(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function dn(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function G0(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Av(t,e,r){for(var n="",o=e;o<r;){var s=t[o],i=null,a=s>239?4:s>223?3:s>191?2:1;if(o+a>r)break;var c,l,f;a===1?s<128&&(i=s):a===2?(c=t[o+1],(c&192)===128&&(i=(s&31)<<6|c&63,i<=127&&(i=null))):a===3?(c=t[o+1],l=t[o+2],(c&192)===128&&(l&192)===128&&(i=(s&15)<<12|(c&63)<<6|l&63,(i<=2047||i>=55296&&i<=57343)&&(i=null))):a===4&&(c=t[o+1],l=t[o+2],f=t[o+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(i=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,(i<=65535||i>=1114112)&&(i=null))),i===null?(i=65533,a=1):i>65535&&(i-=65536,n+=String.fromCharCode(i>>>10&1023|55296),i=56320|i&1023),n+=String.fromCharCode(i),o+=a}return n}function xv(t,e,r){return H0.decode(t.subarray(e,r))}function bv(t,e,r){for(var n=0,o,s;n<e.length;n++){if(o=e.charCodeAt(n),o>55295&&o<57344)if(s)if(o<56320){t[r++]=239,t[r++]=191,t[r++]=189,s=o;continue}else o=s-55296<<10|o-56320|65536,s=null;else{o>56319||n+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):s=o;continue}else s&&(t[r++]=239,t[r++]=191,t[r++]=189,s=null);o<128?t[r++]=o:(o<2048?t[r++]=o>>6|192:(o<65536?t[r++]=o>>12|224:(t[r++]=o>>18|240,t[r++]=o>>12&63|128),t[r++]=o>>6&63|128),t[r++]=o&63|128)}return r}});var Po={};xe(Po,{A5Layer:()=>Hh,GeohashLayer:()=>l1,GreatCircleLayer:()=>zp,H3ClusterLayer:()=>Cd,H3HexagonLayer:()=>Vs,MVTLayer:()=>s1,QuadkeyLayer:()=>rd,S2Layer:()=>ed,TerrainLayer:()=>M0,Tile3DLayer:()=>g0,TileLayer:()=>ur,TripsLayer:()=>_d,_GeoCellLayer:()=>De,_Tile2DHeader:()=>lr,_Tileset2D:()=>fr,_WMSLayer:()=>qr,_getURLFromTemplate:()=>lt});var rt={},Mf=D(We(),1);_t(rt,D(We(),1));if(!Mf.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");_t(Po,rt);var Cf=D(Xe(),1),Ji=D(We(),1),A1={...Ji.PolygonLayer.defaultProps},gn=class extends Cf.CompositeLayer{indexToBounds(){return null}renderLayers(){let{elevationScale:e,extruded:r,wireframe:n,filled:o,stroked:s,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:h,getElevation:p,getFillColor:d,getLineColor:A,getLineWidth:m}=this.props,{updateTriggers:b,material:T,transitions:E}=this.props,_=this.getSubLayerClass("cell",Ji.PolygonLayer),{updateTriggers:S,...C}=this.indexToBounds()||{};return new _({filled:o,wireframe:n,extruded:r,elevationScale:e,stroked:s,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:h,material:T,transitions:E,getElevation:p,getFillColor:d,getLineColor:A,getLineWidth:m},this.getSubLayerProps({id:"cell",updateTriggers:b&&{...S,getElevation:b.getElevation,getFillColor:b.getFillColor,getLineColor:b.getLineColor,getLineWidth:b.getLineWidth}}),C)}};gn.layerName="GeoCellLayer";gn.defaultProps=A1;var De=gn;var x1=Object.defineProperty,yn=(t,e)=>{for(var r in e)x1(t,r,{get:e[r],enumerable:!0})},_e={};yn(_e,{ARRAY_TYPE:()=>oe,EPSILON:()=>me,RANDOM:()=>jt,equals:()=>E1,setMatrixArrayType:()=>b1,toRadian:()=>T1});var me=1e-6,oe=typeof Float32Array<"u"?Float32Array:Array,jt=Math.random;function b1(t){oe=t}var y1=Math.PI/180;function T1(t){return t*y1}function E1(t,e){return Math.abs(t-e)<=me*Math.max(1,Math.abs(t),Math.abs(e))}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Jt={};yn(Jt,{LDU:()=>G1,add:()=>H1,adjoint:()=>w1,clone:()=>M1,copy:()=>S1,create:()=>_1,determinant:()=>L1,equals:()=>z1,exactEquals:()=>V1,frob:()=>U1,fromRotation:()=>N1,fromScaling:()=>O1,fromValues:()=>B1,identity:()=>C1,invert:()=>v1,mul:()=>j1,multiply:()=>Xf,multiplyScalar:()=>k1,multiplyScalarAndAdd:()=>q1,rotate:()=>F1,scale:()=>P1,set:()=>I1,str:()=>D1,sub:()=>J1,subtract:()=>Yf,transpose:()=>R1});function _1(){var t=new oe(4);return oe!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function M1(t){var e=new oe(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function S1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function C1(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t}function B1(t,e,r,n){var o=new oe(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=n,o}function I1(t,e,r,n,o){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t}function R1(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t}function v1(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=r*s-o*n;return i?(i=1/i,t[0]=s*i,t[1]=-n*i,t[2]=-o*i,t[3]=r*i,t):null}function w1(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t}function L1(t){return t[0]*t[3]-t[2]*t[1]}function Xf(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*a+s*c,t[1]=o*a+i*c,t[2]=n*l+s*f,t[3]=o*l+i*f,t}function F1(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*a,t[1]=o*c+i*a,t[2]=n*-a+s*c,t[3]=o*-a+i*c,t}function P1(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1];return t[0]=n*a,t[1]=o*a,t[2]=s*c,t[3]=i*c,t}function N1(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t}function O1(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t}function D1(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function U1(t){return Math.hypot(t[0],t[1],t[2],t[3])}function G1(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]}function H1(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function Yf(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function V1(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function z1(t,e){var r=t[0],n=t[1],o=t[2],s=t[3],i=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-i)<=me*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=me*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(o-c)<=me*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(s-l)<=me*Math.max(1,Math.abs(s),Math.abs(l))}function k1(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function q1(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}var j1=Xf,J1=Yf;function W1(){var t=new oe(9);return oe!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}var Ki={};yn(Ki,{add:()=>ix,calculateW:()=>YA,clone:()=>rx,conjugate:()=>$A,copy:()=>ox,create:()=>Zi,dot:()=>uu,equals:()=>hx,exactEquals:()=>ux,exp:()=>au,fromEuler:()=>ex,fromMat3:()=>lu,fromValues:()=>nx,getAngle:()=>jA,getAxisAngle:()=>qA,identity:()=>kA,invert:()=>ZA,len:()=>lx,length:()=>hu,lerp:()=>cx,ln:()=>cu,mul:()=>ax,multiply:()=>iu,normalize:()=>aa,pow:()=>KA,random:()=>QA,rotateX:()=>JA,rotateY:()=>WA,rotateZ:()=>XA,rotationTo:()=>px,scale:()=>fu,set:()=>sx,setAxes:()=>mx,setAxisAngle:()=>su,slerp:()=>jo,sqlerp:()=>dx,sqrLen:()=>fx,squaredLength:()=>pu,str:()=>tx});var R={};yn(R,{add:()=>Q1,angle:()=>AA,bezier:()=>lA,ceil:()=>Z1,clone:()=>X1,copy:()=>Y1,create:()=>sa,cross:()=>qo,dist:()=>SA,distance:()=>eu,div:()=>MA,divide:()=>$f,dot:()=>ia,equals:()=>TA,exactEquals:()=>yA,floor:()=>$1,forEach:()=>IA,fromValues:()=>Qi,hermite:()=>cA,inverse:()=>iA,len:()=>ou,length:()=>Kf,lerp:()=>aA,max:()=>tA,min:()=>eA,mul:()=>_A,multiply:()=>Zf,negate:()=>sA,normalize:()=>nu,random:()=>fA,rotateX:()=>dA,rotateY:()=>mA,rotateZ:()=>gA,round:()=>rA,scale:()=>nA,scaleAndAdd:()=>oA,set:()=>K1,sqrDist:()=>CA,sqrLen:()=>BA,squaredDistance:()=>tu,squaredLength:()=>ru,str:()=>bA,sub:()=>EA,subtract:()=>Qf,transformMat3:()=>hA,transformMat4:()=>uA,transformQuat:()=>pA,zero:()=>xA});function sa(){var t=new oe(3);return oe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function X1(t){var e=new oe(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Kf(t){var e=t[0],r=t[1],n=t[2];return Math.hypot(e,r,n)}function Qi(t,e,r){var n=new oe(3);return n[0]=t,n[1]=e,n[2]=r,n}function Y1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function K1(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function Q1(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Qf(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Zf(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function $f(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function Z1(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function $1(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function eA(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function tA(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function rA(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function nA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function oA(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function eu(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return Math.hypot(r,n,o)}function tu(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return r*r+n*n+o*o}function ru(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function sA(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function iA(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function nu(t,e){var r=e[0],n=e[1],o=e[2],s=r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function ia(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function qo(t,e,r){var n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2];return t[0]=o*c-s*a,t[1]=s*i-n*c,t[2]=n*a-o*i,t}function aA(t,e,r,n){var o=e[0],s=e[1],i=e[2];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t}function cA(t,e,r,n,o,s){var i=s*s,a=i*(2*s-3)+1,c=i*(s-2)+s,l=i*(s-1),f=i*(3-2*s);return t[0]=e[0]*a+r[0]*c+n[0]*l+o[0]*f,t[1]=e[1]*a+r[1]*c+n[1]*l+o[1]*f,t[2]=e[2]*a+r[2]*c+n[2]*l+o[2]*f,t}function lA(t,e,r,n,o,s){var i=1-s,a=i*i,c=s*s,l=a*i,f=3*s*a,u=3*c*i,h=c*s;return t[0]=e[0]*l+r[0]*f+n[0]*u+o[0]*h,t[1]=e[1]*l+r[1]*f+n[1]*u+o[1]*h,t[2]=e[2]*l+r[2]*f+n[2]*u+o[2]*h,t}function fA(t,e){e=e||1;var r=jt()*2*Math.PI,n=jt()*2-1,o=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=n*e,t}function uA(t,e,r){var n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s+r[15];return i=i||1,t[0]=(r[0]*n+r[4]*o+r[8]*s+r[12])/i,t[1]=(r[1]*n+r[5]*o+r[9]*s+r[13])/i,t[2]=(r[2]*n+r[6]*o+r[10]*s+r[14])/i,t}function hA(t,e,r){var n=e[0],o=e[1],s=e[2];return t[0]=n*r[0]+o*r[3]+s*r[6],t[1]=n*r[1]+o*r[4]+s*r[7],t[2]=n*r[2]+o*r[5]+s*r[8],t}function pA(t,e,r){var n=r[0],o=r[1],s=r[2],i=r[3],a=e[0],c=e[1],l=e[2],f=o*l-s*c,u=s*a-n*l,h=n*c-o*a,p=o*h-s*u,d=s*f-n*h,A=n*u-o*f,m=i*2;return f*=m,u*=m,h*=m,p*=2,d*=2,A*=2,t[0]=a+f+p,t[1]=c+u+d,t[2]=l+h+A,t}function dA(t,e,r,n){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),s[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function mA(t,e,r,n){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),s[1]=o[1],s[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function gA(t,e,r,n){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),s[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function AA(t,e){var r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2],c=Math.sqrt(r*r+n*n+o*o),l=Math.sqrt(s*s+i*i+a*a),f=c*l,u=f&&ia(t,e)/f;return Math.acos(Math.min(Math.max(u,-1),1))}function xA(t){return t[0]=0,t[1]=0,t[2]=0,t}function bA(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function yA(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function TA(t,e){var r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2];return Math.abs(r-s)<=me*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-i)<=me*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(o-a)<=me*Math.max(1,Math.abs(o),Math.abs(a))}var EA=Qf,_A=Zf,MA=$f,SA=eu,CA=tu,ou=Kf,BA=ru,IA=function(){var t=sa();return function(e,r,n,o,s,i){var a,c;for(r||(r=3),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();function RA(){var t=new oe(4);return oe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function vA(t){var e=new oe(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function wA(t,e,r,n){var o=new oe(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=n,o}function LA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function FA(t,e,r,n,o){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t}function PA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function NA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function OA(t){var e=t[0],r=t[1],n=t[2],o=t[3];return Math.hypot(e,r,n,o)}function DA(t){var e=t[0],r=t[1],n=t[2],o=t[3];return e*e+r*r+n*n+o*o}function UA(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=r*i,t[1]=n*i,t[2]=o*i,t[3]=s*i,t}function GA(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function HA(t,e,r,n){var o=e[0],s=e[1],i=e[2],a=e[3];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t[3]=a+n*(r[3]-a),t}function VA(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function zA(t,e){var r=t[0],n=t[1],o=t[2],s=t[3],i=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-i)<=me*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=me*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(o-c)<=me*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(s-l)<=me*Math.max(1,Math.abs(s),Math.abs(l))}var Zv=function(){var t=RA();return function(e,r,n,o,s,i){var a,c;for(r||(r=4),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();function Zi(){var t=new oe(4);return oe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function kA(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function su(t,e,r){r=r*.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function qA(t,e){var r=Math.acos(e[3])*2,n=Math.sin(r/2);return n>me?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r}function jA(t,e){var r=uu(t,e);return Math.acos(2*r*r-1)}function iu(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+i*a+o*l-s*c,t[1]=o*f+i*c+s*a-n*l,t[2]=s*f+i*l+n*c-o*a,t[3]=i*f-n*a-o*c-s*l,t}function JA(t,e,r){r*=.5;var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=o*c+s*a,t[2]=s*c-o*a,t[3]=i*c-n*a,t}function WA(t,e,r){r*=.5;var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-s*a,t[1]=o*c+i*a,t[2]=s*c+n*a,t[3]=i*c-o*a,t}function XA(t,e,r){r*=.5;var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*a,t[1]=o*c-n*a,t[2]=s*c+i*a,t[3]=i*c-s*a,t}function YA(t,e){var r=e[0],n=e[1],o=e[2];return t[0]=r,t[1]=n,t[2]=o,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-o*o)),t}function au(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=Math.sqrt(r*r+n*n+o*o),a=Math.exp(s),c=i>0?a*Math.sin(i)/i:0;return t[0]=r*c,t[1]=n*c,t[2]=o*c,t[3]=a*Math.cos(i),t}function cu(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=Math.sqrt(r*r+n*n+o*o),a=i>0?Math.atan2(i,s)/i:0;return t[0]=r*a,t[1]=n*a,t[2]=o*a,t[3]=.5*Math.log(r*r+n*n+o*o+s*s),t}function KA(t,e,r){return cu(t,e),fu(t,t,r),au(t,t),t}function jo(t,e,r,n){var o=e[0],s=e[1],i=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],h,p,d,A,m;return p=o*c+s*l+i*f+a*u,p<0&&(p=-p,c=-c,l=-l,f=-f,u=-u),1-p>me?(h=Math.acos(p),d=Math.sin(h),A=Math.sin((1-n)*h)/d,m=Math.sin(n*h)/d):(A=1-n,m=n),t[0]=A*o+m*c,t[1]=A*s+m*l,t[2]=A*i+m*f,t[3]=A*a+m*u,t}function QA(t){var e=jt(),r=jt(),n=jt(),o=Math.sqrt(1-e),s=Math.sqrt(e);return t[0]=o*Math.sin(2*Math.PI*r),t[1]=o*Math.cos(2*Math.PI*r),t[2]=s*Math.sin(2*Math.PI*n),t[3]=s*Math.cos(2*Math.PI*n),t}function ZA(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s,a=i?1/i:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-o*a,t[3]=s*a,t}function $A(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function lu(t,e){var r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var o=0;e[4]>e[0]&&(o=1),e[8]>e[o*3+o]&&(o=2);var s=(o+1)%3,i=(o+2)%3;n=Math.sqrt(e[o*3+o]-e[s*3+s]-e[i*3+i]+1),t[o]=.5*n,n=.5/n,t[3]=(e[s*3+i]-e[i*3+s])*n,t[s]=(e[s*3+o]+e[o*3+s])*n,t[i]=(e[i*3+o]+e[o*3+i])*n}return t}function ex(t,e,r,n){var o=.5*Math.PI/180;e*=o,r*=o,n*=o;var s=Math.sin(e),i=Math.cos(e),a=Math.sin(r),c=Math.cos(r),l=Math.sin(n),f=Math.cos(n);return t[0]=s*c*f-i*a*l,t[1]=i*a*f+s*c*l,t[2]=i*c*l-s*a*f,t[3]=i*c*f+s*a*l,t}function tx(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var rx=vA,nx=wA,ox=LA,sx=FA,ix=PA,ax=iu,fu=NA,uu=GA,cx=HA,hu=OA,lx=hu,pu=DA,fx=pu,aa=UA,ux=VA,hx=zA,px=function(){var t=sa(),e=Qi(1,0,0),r=Qi(0,1,0);return function(n,o,s){var i=ia(o,s);return i<-.999999?(qo(t,e,o),ou(t)<1e-6&&qo(t,r,o),nu(t,t),su(n,t,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(qo(t,o,s),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+i,aa(n,n))}}(),dx=function(){var t=Zi(),e=Zi();return function(r,n,o,s,i,a){return jo(t,n,i,a),jo(e,o,s,a),jo(r,t,e,2*a*(1-a)),r}}(),mx=function(){var t=W1();return function(e,r,n,o){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=o[0],t[4]=o[1],t[7]=o[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],aa(e,lu(e,t))}}(),P={};yn(P,{add:()=>yx,angle:()=>Hx,ceil:()=>Tx,clone:()=>gx,copy:()=>xx,create:()=>du,cross:()=>Lx,dist:()=>Yx,distance:()=>xu,div:()=>Xx,divide:()=>Au,dot:()=>wx,equals:()=>qx,exactEquals:()=>kx,floor:()=>Ex,forEach:()=>Zx,fromValues:()=>Ax,inverse:()=>Rx,len:()=>jx,length:()=>yu,lerp:()=>Fx,max:()=>Mx,min:()=>_x,mul:()=>Wx,multiply:()=>gu,negate:()=>Ix,normalize:()=>vx,random:()=>Px,rotate:()=>Gx,round:()=>Sx,scale:()=>Cx,scaleAndAdd:()=>Bx,set:()=>bx,sqrDist:()=>Kx,sqrLen:()=>Qx,squaredDistance:()=>bu,squaredLength:()=>Tu,str:()=>zx,sub:()=>Jx,subtract:()=>mu,transformMat2:()=>Nx,transformMat2d:()=>Ox,transformMat3:()=>Dx,transformMat4:()=>Ux,zero:()=>Vx});function du(){var t=new oe(2);return oe!=Float32Array&&(t[0]=0,t[1]=0),t}function gx(t){var e=new oe(2);return e[0]=t[0],e[1]=t[1],e}function Ax(t,e){var r=new oe(2);return r[0]=t,r[1]=e,r}function xx(t,e){return t[0]=e[0],t[1]=e[1],t}function bx(t,e,r){return t[0]=e,t[1]=r,t}function yx(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function mu(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function gu(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function Au(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function Tx(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function Ex(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function _x(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function Mx(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function Sx(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t}function Cx(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function Bx(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t}function xu(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.hypot(r,n)}function bu(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function yu(t){var e=t[0],r=t[1];return Math.hypot(e,r)}function Tu(t){var e=t[0],r=t[1];return e*e+r*r}function Ix(t,e){return t[0]=-e[0],t[1]=-e[1],t}function Rx(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function vx(t,e){var r=e[0],n=e[1],o=r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t}function wx(t,e){return t[0]*e[0]+t[1]*e[1]}function Lx(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t}function Fx(t,e,r,n){var o=e[0],s=e[1];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t}function Px(t,e){e=e||1;var r=jt()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function Nx(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t}function Ox(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o+r[4],t[1]=r[1]*n+r[3]*o+r[5],t}function Dx(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[3]*o+r[6],t[1]=r[1]*n+r[4]*o+r[7],t}function Ux(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}function Gx(t,e,r,n){var o=e[0]-r[0],s=e[1]-r[1],i=Math.sin(n),a=Math.cos(n);return t[0]=o*a-s*i+r[0],t[1]=o*i+s*a+r[1],t}function Hx(t,e){var r=t[0],n=t[1],o=e[0],s=e[1],i=Math.sqrt(r*r+n*n)*Math.sqrt(o*o+s*s),a=i&&(r*o+n*s)/i;return Math.acos(Math.min(Math.max(a,-1),1))}function Vx(t){return t[0]=0,t[1]=0,t}function zx(t){return"vec2("+t[0]+", "+t[1]+")"}function kx(t,e){return t[0]===e[0]&&t[1]===e[1]}function qx(t,e){var r=t[0],n=t[1],o=e[0],s=e[1];return Math.abs(r-o)<=me*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-s)<=me*Math.max(1,Math.abs(n),Math.abs(s))}var jx=yu,Jx=mu,Wx=gu,Xx=Au,Yx=xu,Kx=bu,Qx=Tu,Zx=function(){var t=du();return function(e,r,n,o,s,i){var a,c;for(r||(r=2),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],s(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}}(),Yo=(1+Math.sqrt(5))/2,$v=2*Math.PI,Jo=2*Math.PI/5,nt=Math.PI/5,Bf=Math.PI/10,$x=2*Math.atan(Yo),$i=Math.PI-$x,ew=-.5*Math.PI+Math.acos(-1/Math.sqrt(3-Yo)),Ko=(Math.sqrt(5)-1)/2,eb=3-Math.sqrt(5),tb=Math.sqrt(3-Yo),tw=Math.sqrt(3)*tb/Yo;_e.setMatrixArrayType(Float64Array);var ca=class ea{constructor(e){this.vertices=e,this.isWindingCorrect()||this.vertices.reverse()}getArea(){let e=0,r=this.vertices.length;for(let n=0;n<r;n++){let o=(n+1)%r;e+=(this.vertices[o][0]-this.vertices[n][0])*(this.vertices[o][1]+this.vertices[n][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(let r of this.vertices)P.scale(r,r,e);return this}rotate180(){for(let e of this.vertices)P.negate(e,e);return this}reflectY(){for(let e of this.vertices)e[1]=-e[1];return this.vertices.reverse(),this}translate(e){for(let r of this.vertices)P.add(r,r,e);return this}transform(e){for(let r of this.vertices)P.transformMat2(r,r,e);return this}transform2d(e){for(let r of this.vertices)P.transformMat2d(r,r,e);return this}clone(){return new ea(this.vertices.map(r=>P.clone(r)))}getCenter(){let e=this.vertices.length;return this.vertices.reduce((n,o)=>[n[0]+o[0]/e,n[1]+o[1]/e],[0,0])}containsPoint(e){if(!this.isWindingCorrect())throw new Error("Pentagon is not counter-clockwise");let r=this.vertices.length,n=1;for(let o=0;o<r;o++){let s=this.vertices[o],i=this.vertices[(o+1)%r],a=s[0]-i[0],c=s[1]-i[1],l=e[0]-s[0],f=e[1]-s[1],u=a*f-c*l;if(u<0){let h=Math.sqrt(l*l+f*f);n=Math.min(n,u/h)}}return n}splitEdges(e){if(e<=1)return this;let r=[],n=this.vertices.length;for(let o=0;o<n;o++){let s=this.vertices[o],i=this.vertices[(o+1)%n];r.push(P.clone(s));for(let a=1;a<e;a++){let c=a/e,l=P.create();P.lerp(l,s,i,c),r.push(l)}}return new ea(r)}};_e.setMatrixArrayType(Float64Array);var Eu=[0,0],_u=[0,1],Wt=[.7885966681787006,1.6149108024237764],Mu=[1.6171013659387945,1.054928690397459],Su=[Math.cos(Bf),Math.sin(Bf)],rb=2*P.length(Wt)*Math.cos(nt),nb=nt-Math.atan2(Wt[1],Wt[0]),ob=2*Ko/rb;[Eu,_u,Wt,Mu,Su].forEach(t=>{P.scale(t,t,ob),P.rotate(t,t,[0,0],nb)});var sb=new ca([Eu,_u,Wt,Mu,Su]),Cu=Math.atan2(Wt[1],Wt[0])-nt,ib=[0,0],Wo=Ko/Math.cos(nt),If=Cu+nt,Xo=[Wo*Math.cos(If),Wo*Math.sin(If)],Rf=Cu-nt,bn=[Wo*Math.cos(Rf),Wo*Math.sin(Rf)],Bu=new ca([ib,Xo,bn]),Iu=Jt.fromValues(Xo[0],Xo[1],bn[0],bn[1]),rw=Jt.invert(Jt.create(),Iu),ab=new Float64Array([-.0022392098386786394,21308606513250217e-22,-2559257686421274e-24,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32]),cb=new Float64Array([.0022392089963541657,28831978048607556e-22,508622073997266e-23,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]),lb=class{applyCoefficients(t,e){let r=Math.sin(t),n=Math.cos(t),o=2*(n-r)*(n+r),s,i;return s=o*e[5]+e[4],i=o*s+e[3],s=o*i-s+e[2],i=o*s-i+e[1],s=o*i-s+e[0],t+2*r*n*s}forward(t){return this.applyCoefficients(t,ab)}inverse(t){return this.applyCoefficients(t,cb)}};_e.setMatrixArrayType(Float64Array);var Ru=new lb;function vf(t){return t*(Math.PI/180)}function wf(t){return t*(180/Math.PI)}function Lf(t){let e=P.length(t),r=Math.atan2(t[1],t[0]);return[e,r]}function fb([t,e]){let r=t*Math.cos(e),n=t*Math.sin(e);return[r,n]}function ub(t,[e,r,n]){let o=[e[0]-n[0],e[1]-n[1]],s=[n[0]-r[0],n[1]-r[1]],i=[t[0]-n[0],t[1]-n[1]],a=s[0]*o[1]-s[1]*o[0],c=(s[0]*i[1]-s[1]*i[0])/a,l=(o[0]*i[1]-o[1]*i[0])/a,f=1-(c+l);return[c,l,f]}function hb(t,[e,r,n]){return[t[0]*e[0]+t[1]*r[0]+t[2]*n[0],t[0]*e[1]+t[1]*r[1]+t[2]*n[1]]}function ta(t){let e=Math.atan2(t[1],t[0]),r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),n=Math.acos(t[2]/r);return[e,n]}function vr([t,e]){let r=Math.sin(e),n=r*Math.cos(t),o=r*Math.sin(t),s=Math.cos(e);return[n,o,s]}var vu=93;function pb([t,e]){let r=vf(t+vu),n=vf(e),o=Ru.forward(n),s=Math.PI/2-o;return[r,s]}function wu([t,e]){let r=wf(t)-vu,n=Math.PI/2-e,o=Ru.inverse(n),s=wf(o);return[r,s]}function db(t){let e=t.map(s=>vr(pb(s))),r=R.create();for(let s of e)R.add(r,r,s);R.normalize(r,r);let[n,o]=wu(ta(r));return(o>89.99||o<-89.99)&&(n=t[0][0]),n=((n+180)%360+360)%360-180,t.map(s=>{let[i,a]=s;for(;i-n>180;)i=i-360;for(;i-n<-180;)i=i+360;return[i,a]})}_e.setMatrixArrayType(Float64Array);var Qo=Math.sqrt(5),Zo=Math.sqrt(.2),Lu=Math.sqrt((1-Zo)/2),Fu=Math.sqrt((1+Zo)/2),Oo=.5,Ff=Math.sqrt((2.5-Qo)/10),Pf=Math.sqrt((2.5+Qo)/10),Nf=Math.sqrt((1+Zo)/8),Of=Math.sqrt((1-Zo)/8),Df=Math.sqrt((3-Qo)/8),Uf=Math.sqrt((3+Qo)/8),mb=[[0,0],[Lu,0],[Ff,Oo],[-Nf,Df],[-Nf,-Df],[Ff,-Oo],[-Fu,0],[-Of,-Uf],[Pf,-Oo],[Pf,Oo],[-Of,Uf],[0,0]],gb=mb.map(([t,e])=>[-e,t]),Do=gb.map((t,e)=>e===0?[0,0,0,1]:e===11?[0,-1,0,0]:[...t,0,e<6?Fu:Lu]);_e.setMatrixArrayType(Float64Array);var Pu=["vu","uw","vw","vw","vw"],An=["wu","uw","vw","vu","uw"],Wi=["wu","uv","wv","wu","uw"],Uo=["vu","uv","wv","wu","uw"],Ab=[Pu,Uo,Wi,An,Wi,Uo,Wi,An,An,An,Uo,Uo],xb=[4,2,3,2,0,4,3,2,2,0,3,0],Gf=[0,1,2,4,3,5,7,8,6,11,10,9],Ye=[];function bb(){Go([0,0],0,Do[0]);for(let t=0;t<5;t++){let e=t*Jo,r=e+nt;Go([e,$i],nt,Do[t+1]),Go([r,Math.PI-$i],nt,Do[(t+3)%5+6])}Go([0,Math.PI],0,Do[11])}var Br=0;function Go(t,e,r){if(Br>11)throw new Error(`Too many origins: ${Br}`);let n=Ki.create();Ki.conjugate(n,r);let o={id:Br,axis:t,quat:r,inverseQuat:n,angle:e,orientation:Ab[Br],firstQuintant:xb[Br]};Ye.push(o),Br++}bb();Ye.sort((t,e)=>Gf.indexOf(t.id)-Gf.indexOf(e.id));Ye.forEach((t,e)=>t.id=e);function yb(t,e){let r=e.orientation,n=r===Pu||r===An?-1:1,o=(t-e.firstQuintant+5)%5,s=r[o];return{quintant:(e.firstQuintant+n*o+5)%5,orientation:s}}var Tb=class{forward([t,e]){return[Math.tan(e),t]}inverse([t,e]){return[e,Math.atan(t)]}},Ir=R.create(),xn=R.create(),Hf=R.create(),Vf=R.create();function Xi(t,e){R.lerp(Ir,t,e,.5),R.normalize(Ir,Ir),R.cross(Ir,t,Ir);let r=R.length(Ir);if(r<1e-8){let n=R.subtract(R.create(),t,e);return .5*R.length(n)}return r}function Eb(t,e,r){return R.cross(xn,e,r),R.dot(t,xn)}function _b(t,e,r,n,o){R.cross(xn,n,o);let s=R.dot(e,xn),i=R.dot(r,xn);return R.scale(Hf,e,i),R.scale(Vf,r,s),R.sub(t,Vf,Hf)}function ra(t,e,r,n){let o=R.angle(e,r);if(o<1e-12)return R.lerp(t,e,r,n);let s=Math.sin((1-n)*o)/Math.sin(o),i=Math.sin(n*o)/Math.sin(o),a=R.scale(R.create(),e,s),c=R.scale(R.create(),r,i);return R.add(t,a,c)}_e.setMatrixArrayType(Float64Array);var Ho=R.create(),Vo=R.create(),zo=R.create(),Rr=R.create(),Mb=class{constructor(t){this._area=null,this.vertices=t,Object.freeze(this.vertices)}getBoundary(t=1,e=!0){let r=[],n=this.vertices.length;for(let o=0;o<n*t;o++){let s=o/t;r.push(this.slerp(s))}return e&&r.push(r[0]),r}slerp(t){let e=this.vertices.length,r=t%1,n=Math.floor(t%e),o=(n+1)%e;return ra(R.create(),this.vertices[n],this.vertices[o],r)}getTransformedVertices(t){let e=this.vertices.length,r=Math.floor(t%e),n=(r+1)%e,o=(r+e-1)%e,s=R.clone(this.vertices[r]),i=R.clone(this.vertices[n]),a=R.clone(this.vertices[o]);return R.sub(i,i,s),R.sub(a,a,s),[s,i,a]}containsPoint(t){let e=this.vertices.length,r=1/0;for(let n=0;n<e;n++){let[o,s,i]=this.getTransformedVertices(n),a=R.sub(R.create(),t,o);R.normalize(a,a),R.normalize(s,s),R.normalize(i,i);let c=R.cross(R.create(),s,a),l=R.cross(R.create(),a,i),f=R.dot(o,c),u=R.dot(o,l);r=Math.min(r,f,u)}return r}getTriangleArea(t,e,r){R.lerp(Ho,e,r,.5),R.lerp(Vo,r,t,.5),R.lerp(zo,t,e,.5),R.normalize(Ho,Ho),R.normalize(Vo,Vo),R.normalize(zo,zo);let n=Eb(Ho,Vo,zo),o=Math.max(-1,Math.min(1,n));return Math.abs(o)<1e-8?2*o:Math.asin(o)*2}getArea(){return this._area===null&&(this._area=this._getArea()),this._area}_getArea(){if(this.vertices.length<3)return 0;if(this.vertices.length===3)return this._area=this.getTriangleArea(this.vertices[0],this.vertices[1],this.vertices[2]),this._area;R.set(Rr,0,0,0);for(let e of this.vertices)R.add(Rr,Rr,e);R.normalize(Rr,Rr);let t=0;for(let e=0;e<this.vertices.length;e++){let r=this.vertices[e],n=this.vertices[(e+1)%this.vertices.length],o=this.getTriangleArea(Rr,r,n);isNaN(o)||(t+=o)}return this._area=t,this._area}isWindingCorrect(){if(!(this.getArea()>0))debugger}};_e.setMatrixArrayType(Float64Array);var ko=class extends Mb{constructor(t){if(t.length!==3)throw new Error("SphericalTriangleShape requires exactly 3 vertices");super(t)}};_e.setMatrixArrayType(Float64Array);var Sb=class{forward(t,e,r){let[n,o,s]=e,i=new ko([n,o,s]),a=R.subtract(R.create(),t,n);R.normalize(a,a);let c=_b(R.create(),n,a,o,s);R.normalize(c,c);let l=Xi(n,t)/Xi(n,c),f=i.getArea(),u=l/f,h=[1-l,u*new ko([n,c,s]).getArea(),u*new ko([n,o,c]).getArea()];return hb(h,r)}inverse(t,e,r){let[n,o,s]=r,i=new ko([n,o,s]),a=ub(t,e),c=1-1e-14;if(a[0]>c)return n;if(a[1]>c)return o;if(a[2]>c)return s;let l=R.create();R.cross(l,o,s);let f=i.getArea(),u=1-a[0],p=a[2]/u*f,d=Math.sin(p),A=Math.sin(p/2),m=2*A*A,b=R.dot(n,o),T=R.dot(o,s),E=R.dot(s,n),_=R.length(l),S=R.dot(n,l),C=d*S+m*(b*T-E),v=m*_*(1+b),M=2/Math.acos(T)*Math.atan2(v,C),y=ra(R.create(),o,s,M),g=Xi(n,y),B=this.safeAcos(u*g)/this.safeAcos(g);return ra([0,0,0],n,y,B)}safeAcos(t){return t<.001?2*t+t*t*t/3:Math.acos(1-2*t*t)}};_e.setMatrixArrayType(Float64Array);var we=-1,Ee=1,Cb=([t,e])=>P.fromValues(t-e,e),na=P.fromValues(1,0),oa=P.fromValues(0,1),zf=P.negate(P.create(),na),kf=P.negate(P.create(),oa),Yi=P.fromValues(0,0),Bb=(t,[e,r])=>{let n=Yi,o=Yi;switch(e===Ee&&r===Ee?(n=na,o=oa):e===we&&r===Ee?(n=kf,o=zf):e===Ee&&r===we?(n=oa,o=na):e===we&&r===we&&(n=zf,o=kf),t){case 0:return Yi;case 1:return n;case 2:return P.add(P.create(),o,n);case 3:return P.scaleAndAdd(P.create(),o,n,2);default:throw new Error(`Invalid Quaternary value: ${t}`)}},qf=t=>[[Ee,Ee],[Ee,we],[Ee,Ee],[we,Ee]][t],jf=P.fromValues(-1,1);function Nu(t){return Array.from({length:t.length},(e,r)=>t.indexOf(r))}var Ou=[0,1,3,4,5,6,7,2],Du=[0,1,2,7,3,4,5,6],nw=Nu(Ou),ow=Nu(Du),Ib=(t,e,r,n,o)=>{if(e<=0)return;let s=t[e]||0,i=t[e-1],a=r[0]+r[1],c=!0,l=!0;if(n!==(a===0)?(c=s===1||s===2,l=s===1):(c=s<2,l=s===0),!c)return;let f=l?i:i+4,u=o[f];t[e-1]=u%4,t[e]=(s+4+Math.floor(u/4)-Math.floor(f/4))%4},Rb=(t,e,r)=>{let n=BigInt(t),o=r==="vu"||r==="wu"||r==="vw",s=r==="wv"||r==="vw",i=r==="wu"||r==="uw";o&&(n=(1n<<BigInt(2*e))-n-1n);let a=vb(n,e,s,i);if(i){let{offset:[c,l],flips:[f,u]}=a;a.offset=[l,c],f===we&&P.add(a.offset,a.offset,jf),u===we&&P.subtract(a.offset,a.offset,jf)}if(s){let{offset:[c,l],flips:f}=a,u=(1<<e)-(c+l);f[0]=-f[0],a.offset[1]=u,a.flips=f}return a},vb=(t,e,r,n)=>{let o=P.create(),s=[Ee,Ee],i=BigInt(t),a=[];for(;i>0n||a.length<e;)a.push(Number(i%4n)),i=i>>2n;let c=n?Du:Ou;for(let f=a.length-1;f>=0;f--)Ib(a,f,s,r,c),P.multiply(s,s,qf(a[f]));s[0]=Ee,s[1]=Ee;for(let f=a.length-1;f>=0;f--){P.scale(o,o,2);let u=Bb(a[f],s);P.add(o,o,u),P.multiply(s,s,qf(a[f]))}let l=a[0]||0;return{flips:s,k:l,offset:Cb(o)}};_e.setMatrixArrayType(Float64Array);var wb=!1,Lb=P.clone(bn),Fb=P.negate(P.create(),bn),la=[0,1,2,3,4].map(t=>{let e=Jt.create();return Jt.fromRotation(e,Jo*t),e}),Jf=P.create();function Pb(t,e,r){let n=(wb?Bu:sb).clone();P.transformMat2(Jf,r.offset,Iu),r.flips[0]===Ee&&r.flips[1]===we&&n.rotate180();let{k:o}=r,s=r.flips[0]+r.flips[1];return((s===-2||s===2)&&o>1||s===0&&(o===0||o===3))&&n.reflectY(),r.flips[0]===we&&r.flips[1]===we?n.rotate180():r.flips[0]===we?n.translate(Fb):r.flips[1]===we&&n.translate(Lb),n.translate(Jf),n.scale(1/2**t),n.transform(la[e]),n}function Uu(t){let e=Bu.clone();return e.transform(la[t]),e}function Nb(){let t=[];for(let e of la)t.push(P.transformMat2(P.create(),Xo,e));return t.reverse(),new ca(t)}_e.setMatrixArrayType(Float64Array);var Ob=class{constructor(){if(this.vertices=[],this.invocations=0,this.addFaceCenters(),this.addVertices(),this.addMidpoints(),this.vertices.length!==62)throw new Error("Failed to construct CRS: vertices length is not 62");Object.freeze(this.vertices)}getVertex(t){this.invocations++,this.invocations===1e4&&console.warn("Too many CRS invocations, results should be cached");for(let e of this.vertices)if(R.distance(t,e)<1e-5)return e;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){Ye.forEach(t=>this.add(vr(t.axis)))}addVertices(){let t=Math.atan(eb);for(let e of Ye)for(let r=0;r<5;r++){let n=(2*r+1)*Math.PI/5,o=vr([n+e.angle,t]);R.transformQuat(o,o,e.quat),this.add(o)}}addMidpoints(){let t=Math.atan(Ko);for(let e of Ye)for(let r=0;r<5;r++){let n=2*r*Math.PI/5,o=vr([n+e.angle,t]);R.transformQuat(o,o,e.quat),this.add(o)}}add(t){let e=R.normalize(R.create(),t);return this.vertices.find(n=>R.distance(e,n)<1e-5)?!1:(this.vertices.push(e),!0)}};_e.setMatrixArrayType(Float64Array);var Db=new Ob,Ub=class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.polyhedral=new Sb,this.gnomonic=new Tb}forward(t,e){let r=Ye[e],n=vr(t),o=R.create();R.transformQuat(o,n,r.inverseQuat);let s=ta(o),i=this.gnomonic.forward(s);i[1]=i[1]-r.angle;let a=this.getFaceTriangleIndex(i),c=this.shouldReflect(i),l=this.getFaceTriangle(a,c,!1),f=this.getSphericalTriangle(a,e,c);return this.polyhedral.forward(n,f,l)}inverse(t,e){let r=Lf(t),n=this.getFaceTriangleIndex(r),o=this.shouldReflect(r),s=this.getFaceTriangle(n,o,!1),i=this.getSphericalTriangle(n,e,o),a=this.polyhedral.inverse(t,s,i);return ta(a)}shouldReflect(t){let[e,r]=t;return fb([e,this.normalizeGamma(r)])[0]>Ko}getFaceTriangleIndex([t,e]){return(Math.floor(e/nt)+10)%10}getFaceTriangle(t,e=!1,r=!1){let n=t;return e&&(n+=r?20:10),this.faceTriangles[n]?this.faceTriangles[n]:(this.faceTriangles[n]=e?this._getReflectedFaceTriangle(t,r):this._getFaceTriangle(t),Object.freeze(this.faceTriangles[n]),this.faceTriangles[n])}_getFaceTriangle(t){let e=Math.floor((t+1)/2)%5,[r,n,o]=Uu(e).getVertices(),s=P.create();return P.lerp(s,n,o,.5),t%2===0?[r,s,n]:[r,o,s]}_getReflectedFaceTriangle(t,e=!1){let[r,n,o]=this._getFaceTriangle(t).map(a=>P.clone(a)),s=t%2===0;P.negate(r,r);let i=s?n:o;return P.scaleAndAdd(r,r,i,e?1+1/Math.cos($i):2),[r,o,n]}getSphericalTriangle(t,e,r=!1){let n=10*e+t;return r&&(n+=120),this.sphericalTriangles[n]?this.sphericalTriangles[n]:(this.sphericalTriangles[n]=this._getSphericalTriangle(t,e,r),Object.freeze(this.sphericalTriangles[n]),this.sphericalTriangles[n])}_getSphericalTriangle(t,e,r=!1){let n=Ye[e];return this.getFaceTriangle(t,r,!0).map(i=>{let[a,c]=Lf(i),l=[a,c+n.angle],f=vr(this.gnomonic.inverse(l));return R.transformQuat(f,f,n.quat),Db.getVertex(f)})}normalizeGamma(t){let e=t/Jo,r=Math.round(e);return(e-r)*Jo}},wr=2,Gb=30,Hb=58n,Vb=0x3ffffffffffffffn;function zb(t){let e=Gb-1,r=t>>1n;for(;e>-1&&(r&0b1n)===0n;)e-=1,r=r>>(e<wr?1n:2n);return e}function kb(t){let e=zb(t);if(e===-1)return{origin:Ye[0],segment:0,S:0n,resolution:e};let r=Number(t>>58n),n,o;if(e===0)n=Ye[r],o=0;else{let l=Math.floor(r/5);n=Ye[l],o=(r+n.firstQuintant)%5}if(!n)throw new Error(`Could not parse origin: ${r}`);if(e<wr)return{origin:n,segment:o,S:0n,resolution:e};let s=e-wr+1,i=BigInt(2*s),a=Hb-i,c=(t&Vb)>>a;return{origin:n,segment:o,S:c,resolution:e}}_e.setMatrixArrayType(Float64Array);var sw=Jt.create(),qb=new Ub;function jb({S:t,segment:e,origin:r,resolution:n}){let{quintant:o,orientation:s}=yb(e,r);if(n===wr-1)return Uu(o);if(n===wr-2)return Nb();let i=n-wr+1,a=Rb(t,i,s);return Pb(i,o,a)}function Gu(t,{closedRing:e=!0,segments:r="auto"}={closedRing:!0,segments:"auto"}){let{S:n,segment:o,origin:s,resolution:i}=kb(t);r==="auto"&&(r=Math.max(1,Math.pow(2,6-i)));let u=jb({S:n,segment:o,origin:s,resolution:i}).splitEdges(r).getVertices().map(p=>qb.inverse(p,s.id)).map(p=>wu(p)),h=db(u);return e&&h.push(h[0]),h.reverse(),h}function Hu(t){return BigInt(`0x${t}`)}var Wf=63710072e-1,iw=4*Math.PI*Wf*Wf;_e.setMatrixArrayType(Float64Array);var In=D($o(),1);var Jb=1/Math.PI*180,Wb=1/180*Math.PI,Xb={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Xb}};var Q=globalThis.mathgl.config;function fa(t,{precision:e=Q.precision}={}){return t=Yb(t),`${parseFloat(t.toPrecision(e))}`}function Le(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function ua(t){return zu(t)}function ha(t){return Fe(t)}function zu(t,e){return pa(t,r=>r*Wb,e)}function Fe(t,e){return pa(t,r=>r*Jb,e)}function es(t,e,r){return pa(t,n=>Math.max(e,Math.min(r,n)))}function Mt(t,e,r){return Le(t)?t.map((n,o)=>Mt(n,e[o],r)):r*e+(1-r)*t}function Me(t,e,r){let n=Q.EPSILON;r&&(Q.EPSILON=r);try{if(t===e)return!0;if(Le(t)&&Le(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!Me(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=Q.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{Q.EPSILON=n}}function Yb(t){return Math.round(t/Q.EPSILON)*Q.EPSILON}function Kb(t){return t.clone?t.clone():new Array(t.length)}function pa(t,e,r){if(Le(t)){let n=t;r=r||Kb(n);for(let o=0;o<r.length&&o<n.length;++o){let s=typeof t=="number"?t:t[o];r[o]=e(s,o,r)}return r}return e(t)}var St=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Le(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Q)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+fa(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Me(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let s=e[o],i=typeof r=="number"?r:r[o];this[o]=s+n*(i-s)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(Q.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function Qb(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function H(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function Ct(t,e,r=""){if(Q.debug&&!Qb(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function ue(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var Bt=class extends St{get x(){return this[0]}set x(e){this[0]=H(e)}get y(){return this[1]}set y(e){this[1]=H(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let n=0;n<this.ELEMENTS;++n){let o=this[n]-e[n];r+=o*o}return H(r)}dot(e){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*e[n];return H(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return ue(e>=0&&e<this.ELEMENTS,"index is out of range"),H(this[e])}setComponent(e,r){return ue(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var te=typeof Float32Array<"u"?Float32Array:Array,Tn=Math.random;function Lr(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var Cw=Math.PI/180;function Zb(){let t=new te(2);return te!=Float32Array&&(t[0]=0,t[1]=0),t}function ku(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t}function qu(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o+r[4],t[1]=r[1]*n+r[3]*o+r[5],t}function ts(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[3]*o+r[6],t[1]=r[1]*n+r[4]*o+r[7],t}function rs(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}var Bw=function(){let t=Zb();return function(e,r,n,o,s,i){let a,c;for(r||(r=2),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],s(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}}();function ns(t,e,r){let n=e[0],o=e[1],s=r[3]*n+r[7]*o||1;return t[0]=(r[0]*n+r[4]*o)/s,t[1]=(r[1]*n+r[5]*o)/s,t}function os(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s||1;return t[0]=(r[0]*n+r[4]*o+r[8]*s)/i,t[1]=(r[1]*n+r[5]*o+r[9]*s)/i,t[2]=(r[2]*n+r[6]*o+r[10]*s)/i,t}function ju(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t[2]=e[2],t}function Ju(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t[2]=e[2],t[3]=e[3],t}function ss(t,e,r){let n=e[0],o=e[1],s=e[2];return t[0]=r[0]*n+r[3]*o+r[6]*s,t[1]=r[1]*n+r[4]*o+r[7]*s,t[2]=r[2]*n+r[5]*o+r[8]*s,t[3]=e[3],t}var Xt=class extends Bt{constructor(e=0,r=0){super(2),Le(e)&&arguments.length===1?this.copy(e):(Q.debug&&(H(e),H(r)),this[0]=e,this[1]=r)}set(e,r){return this[0]=e,this[1]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return Q.debug&&(H(e.x),H(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return rs(this,this,e),this.check()}transformAsVector(e){return ns(this,this,e),this.check()}transformByMatrix3(e){return ts(this,this,e),this.check()}transformByMatrix2x3(e){return qu(this,this,e),this.check()}transformByMatrix2(e){return ku(this,this,e),this.check()}};var Qt={};xe(Qt,{add:()=>ry,angle:()=>xa,bezier:()=>my,ceil:()=>ny,clone:()=>$b,copy:()=>ey,create:()=>is,cross:()=>Yt,dist:()=>My,distance:()=>Qu,div:()=>_y,divide:()=>Ku,dot:()=>En,equals:()=>yy,exactEquals:()=>by,floor:()=>oy,forEach:()=>By,fromValues:()=>as,hermite:()=>dy,inverse:()=>uy,len:()=>ba,length:()=>Wu,lerp:()=>hy,max:()=>iy,min:()=>sy,mul:()=>Ey,multiply:()=>Yu,negate:()=>fy,normalize:()=>da,random:()=>gy,rotateX:()=>ma,rotateY:()=>ga,rotateZ:()=>Aa,round:()=>ay,scale:()=>cy,scaleAndAdd:()=>ly,set:()=>ty,slerp:()=>py,sqrDist:()=>Sy,sqrLen:()=>Cy,squaredDistance:()=>Zu,squaredLength:()=>$u,str:()=>xy,sub:()=>Ty,subtract:()=>Xu,transformMat3:()=>_n,transformMat4:()=>Kt,transformQuat:()=>Mn,zero:()=>Ay});function is(){let t=new te(3);return te!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function $b(t){let e=new te(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Wu(t){let e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function as(t,e,r){let n=new te(3);return n[0]=t,n[1]=e,n[2]=r,n}function ey(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function ty(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function ry(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Xu(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Yu(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Ku(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function ny(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function oy(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function sy(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function iy(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function ay(t,e){return t[0]=Lr(e[0]),t[1]=Lr(e[1]),t[2]=Lr(e[2]),t}function cy(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function ly(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function Qu(t,e){let r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(r*r+n*n+o*o)}function Zu(t,e){let r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return r*r+n*n+o*o}function $u(t){let e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function fy(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function uy(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function da(t,e){let r=e[0],n=e[1],o=e[2],s=r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function En(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Yt(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2];return t[0]=o*c-s*a,t[1]=s*i-n*c,t[2]=n*a-o*i,t}function hy(t,e,r,n){let o=e[0],s=e[1],i=e[2];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t}function py(t,e,r,n){let o=Math.acos(Math.min(Math.max(En(e,r),-1),1)),s=Math.sin(o),i=Math.sin((1-n)*o)/s,a=Math.sin(n*o)/s;return t[0]=i*e[0]+a*r[0],t[1]=i*e[1]+a*r[1],t[2]=i*e[2]+a*r[2],t}function dy(t,e,r,n,o,s){let i=s*s,a=i*(2*s-3)+1,c=i*(s-2)+s,l=i*(s-1),f=i*(3-2*s);return t[0]=e[0]*a+r[0]*c+n[0]*l+o[0]*f,t[1]=e[1]*a+r[1]*c+n[1]*l+o[1]*f,t[2]=e[2]*a+r[2]*c+n[2]*l+o[2]*f,t}function my(t,e,r,n,o,s){let i=1-s,a=i*i,c=s*s,l=a*i,f=3*s*a,u=3*c*i,h=c*s;return t[0]=e[0]*l+r[0]*f+n[0]*u+o[0]*h,t[1]=e[1]*l+r[1]*f+n[1]*u+o[1]*h,t[2]=e[2]*l+r[2]*f+n[2]*u+o[2]*h,t}function gy(t,e){e=e===void 0?1:e;let r=Tn()*2*Math.PI,n=Tn()*2-1,o=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=n*e,t}function Kt(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s+r[15];return i=i||1,t[0]=(r[0]*n+r[4]*o+r[8]*s+r[12])/i,t[1]=(r[1]*n+r[5]*o+r[9]*s+r[13])/i,t[2]=(r[2]*n+r[6]*o+r[10]*s+r[14])/i,t}function _n(t,e,r){let n=e[0],o=e[1],s=e[2];return t[0]=n*r[0]+o*r[3]+s*r[6],t[1]=n*r[1]+o*r[4]+s*r[7],t[2]=n*r[2]+o*r[5]+s*r[8],t}function Mn(t,e,r){let n=r[0],o=r[1],s=r[2],i=r[3],a=e[0],c=e[1],l=e[2],f=o*l-s*c,u=s*a-n*l,h=n*c-o*a,p=o*h-s*u,d=s*f-n*h,A=n*u-o*f,m=i*2;return f*=m,u*=m,h*=m,p*=2,d*=2,A*=2,t[0]=a+f+p,t[1]=c+u+d,t[2]=l+h+A,t}function ma(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),s[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function ga(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),s[1]=o[1],s[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function Aa(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),s[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function xa(t,e){let r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2],c=Math.sqrt((r*r+n*n+o*o)*(s*s+i*i+a*a)),l=c&&En(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function Ay(t){return t[0]=0,t[1]=0,t[2]=0,t}function xy(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function by(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function yy(t,e){let r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))}var Ty=Xu,Ey=Yu,_y=Ku,My=Qu,Sy=Zu,ba=Wu,Cy=$u,By=function(){let t=is();return function(e,r,n,o,s,i){let a,c;for(r||(r=3),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var ya=[0,0,0],cs,x=class extends Bt{static get ZERO(){return cs||(cs=new x(0,0,0),Object.freeze(cs)),cs}constructor(e=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&Le(e)?this.copy(e):(Q.debug&&(H(e),H(r),H(n)),this[0]=e,this[1]=r,this[2]=n)}set(e,r,n){return this[0]=e,this[1]=r,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Q.debug&&(H(e.x),H(e.y),H(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=H(e)}angle(e){return xa(this,e)}cross(e){return Yt(this,this,e),this.check()}rotateX({radians:e,origin:r=ya}){return ma(this,this,r,e),this.check()}rotateY({radians:e,origin:r=ya}){return ga(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=ya}){return Aa(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Kt(this,this,e),this.check()}transformAsVector(e){return os(this,this,e),this.check()}transformByMatrix3(e){return _n(this,this,e),this.check()}transformByMatrix2(e){return ju(this,this,e),this.check()}transformByQuaternion(e){return Mn(this,this,e),this.check()}};var ls,Pr=class extends Bt{static get ZERO(){return ls||(ls=new Pr(0,0,0,0),Object.freeze(ls)),ls}constructor(e=0,r=0,n=0,o=0){super(-0,-0,-0,-0),Le(e)&&arguments.length===1?this.copy(e):(Q.debug&&(H(e),H(r),H(n),H(o)),this[0]=e,this[1]=r,this[2]=n,this[3]=o)}set(e,r,n,o){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return Q.debug&&(H(e.x),H(e.y),H(e.z),H(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=H(e)}get w(){return this[3]}set w(e){this[3]=H(e)}transform(e){return Kt(this,this,e),this.check()}transformByMatrix3(e){return ss(this,this,e),this.check()}transformByMatrix2(e){return Ju(this,this,e),this.check()}transformByQuaternion(e){return Mn(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}};var Nr=class extends St{toString(){let e="[";if(Q.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=H(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[n+o];return r}setColumn(e,r){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=r[o];return this}};function eh(){let t=new te(9);return te!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function th(t,e){if(t===e){let r=e[1],n=e[2],o=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=o}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function rh(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=f*i-a*l,h=-f*s+a*c,p=l*s-i*c,d=r*u+n*h+o*p;return d?(d=1/d,t[0]=u*d,t[1]=(-f*n+o*l)*d,t[2]=(a*n-o*i)*d,t[3]=h*d,t[4]=(f*r-o*c)*d,t[5]=(-a*r+o*s)*d,t[6]=p*d,t[7]=(-l*r+n*c)*d,t[8]=(i*r-n*s)*d,t):null}function nh(t){let e=t[0],r=t[1],n=t[2],o=t[3],s=t[4],i=t[5],a=t[6],c=t[7],l=t[8];return e*(l*s-i*c)+r*(-l*o+i*a)+n*(c*o-s*a)}function Ta(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=r[0],p=r[1],d=r[2],A=r[3],m=r[4],b=r[5],T=r[6],E=r[7],_=r[8];return t[0]=h*n+p*i+d*l,t[1]=h*o+p*a+d*f,t[2]=h*s+p*c+d*u,t[3]=A*n+m*i+b*l,t[4]=A*o+m*a+b*f,t[5]=A*s+m*c+b*u,t[6]=T*n+E*i+_*l,t[7]=T*o+E*a+_*f,t[8]=T*s+E*c+_*u,t}function oh(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=r[0],p=r[1];return t[0]=n,t[1]=o,t[2]=s,t[3]=i,t[4]=a,t[5]=c,t[6]=h*n+p*i+l,t[7]=h*o+p*a+f,t[8]=h*s+p*c+u,t}function sh(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=Math.sin(r),p=Math.cos(r);return t[0]=p*n+h*i,t[1]=p*o+h*a,t[2]=p*s+h*c,t[3]=p*i-h*n,t[4]=p*a-h*o,t[5]=p*c-h*s,t[6]=l,t[7]=f,t[8]=u,t}function Ea(t,e,r){let n=r[0],o=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=o*e[3],t[4]=o*e[4],t[5]=o*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function ih(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r+r,a=n+n,c=o+o,l=r*i,f=n*i,u=n*a,h=o*i,p=o*a,d=o*c,A=s*i,m=s*a,b=s*c;return t[0]=1-u-d,t[3]=f-b,t[6]=h+m,t[1]=f+b,t[4]=1-l-d,t[7]=p-A,t[2]=h-m,t[5]=p+A,t[8]=1-l-u,t}var _a;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(_a||(_a={}));var Ry=Object.freeze([1,0,0,0,1,0,0,0,1]),j=class extends Nr{static get IDENTITY(){return wy()}static get ZERO(){return vy()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return _a}constructor(e,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):r.length>0?this.copy([e,...r]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(Ry)}fromObject(e){return this.check()}fromQuaternion(e){return ih(this,e),this.check()}set(e,r,n,o,s,i,a,c,l){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=s,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,n,o,s,i,a,c,l){return this[0]=e,this[1]=o,this[2]=a,this[3]=r,this[4]=s,this[5]=c,this[6]=n,this[7]=i,this[8]=l,this.check()}determinant(){return nh(this)}transpose(){return th(this,this),this.check()}invert(){return rh(this,this),this.check()}multiplyLeft(e){return Ta(this,e,this),this.check()}multiplyRight(e){return Ta(this,this,e),this.check()}rotate(e){return sh(this,this,e),this.check()}scale(e){return Array.isArray(e)?Ea(this,this,e):Ea(this,this,[e,e]),this.check()}translate(e){return oh(this,this,e),this.check()}transform(e,r){let n;switch(e.length){case 2:n=ts(r||[-0,-0],e,this);break;case 3:n=_n(r||[-0,-0,-0],e,this);break;case 4:n=ss(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ct(n,e.length),n}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}},fs,us=null;function vy(){return fs||(fs=new j([0,0,0,0,0,0,0,0,0]),Object.freeze(fs)),fs}function wy(){return us||(us=new j,Object.freeze(us)),us}var Cn={};xe(Cn,{add:()=>rT,adjoint:()=>Dy,clone:()=>Fy,copy:()=>Py,create:()=>Ly,decompose:()=>Wy,determinant:()=>Ca,equals:()=>iT,exactEquals:()=>sT,frob:()=>tT,fromQuat:()=>Fa,fromQuat2:()=>qy,fromRotation:()=>Hy,fromRotationTranslation:()=>ch,fromRotationTranslationScale:()=>Xy,fromRotationTranslationScaleOrigin:()=>Yy,fromScaling:()=>Gy,fromTranslation:()=>Uy,fromValues:()=>Ny,fromXRotation:()=>Vy,fromYRotation:()=>zy,fromZRotation:()=>ky,frustum:()=>Pa,getRotation:()=>Jy,getScaling:()=>lh,getTranslation:()=>jy,identity:()=>ah,invert:()=>Sa,lookAt:()=>Da,mul:()=>aT,multiply:()=>Sn,multiplyScalar:()=>nT,multiplyScalarAndAdd:()=>oT,ortho:()=>Oa,orthoNO:()=>uh,orthoZO:()=>Zy,perspective:()=>Na,perspectiveFromFieldOfView:()=>Qy,perspectiveNO:()=>fh,perspectiveZO:()=>Ky,rotate:()=>Ra,rotateX:()=>va,rotateY:()=>wa,rotateZ:()=>La,scale:()=>Ia,set:()=>Oy,str:()=>eT,sub:()=>cT,subtract:()=>hh,targetTo:()=>$y,translate:()=>Ba,transpose:()=>Ma});function Ly(){let t=new te(16);return te!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function Fy(t){let e=new te(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Py(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ny(t,e,r,n,o,s,i,a,c,l,f,u,h,p,d,A){let m=new te(16);return m[0]=t,m[1]=e,m[2]=r,m[3]=n,m[4]=o,m[5]=s,m[6]=i,m[7]=a,m[8]=c,m[9]=l,m[10]=f,m[11]=u,m[12]=h,m[13]=p,m[14]=d,m[15]=A,m}function Oy(t,e,r,n,o,s,i,a,c,l,f,u,h,p,d,A,m){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t[4]=s,t[5]=i,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=u,t[11]=h,t[12]=p,t[13]=d,t[14]=A,t[15]=m,t}function ah(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ma(t,e){if(t===e){let r=e[1],n=e[2],o=e[3],s=e[6],i=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=s,t[11]=e[14],t[12]=o,t[13]=i,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Sa(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],p=e[11],d=e[12],A=e[13],m=e[14],b=e[15],T=r*a-n*i,E=r*c-o*i,_=r*l-s*i,S=n*c-o*a,C=n*l-s*a,v=o*l-s*c,M=f*A-u*d,y=f*m-h*d,g=f*b-p*d,B=u*m-h*A,L=u*b-p*A,F=h*b-p*m,w=T*F-E*L+_*B+S*g-C*y+v*M;return w?(w=1/w,t[0]=(a*F-c*L+l*B)*w,t[1]=(o*L-n*F-s*B)*w,t[2]=(A*v-m*C+b*S)*w,t[3]=(h*C-u*v-p*S)*w,t[4]=(c*g-i*F-l*y)*w,t[5]=(r*F-o*g+s*y)*w,t[6]=(m*_-d*v-b*E)*w,t[7]=(f*v-h*_+p*E)*w,t[8]=(i*L-a*g+l*M)*w,t[9]=(n*g-r*L-s*M)*w,t[10]=(d*C-A*_+b*T)*w,t[11]=(u*_-f*C-p*T)*w,t[12]=(a*y-i*B-c*M)*w,t[13]=(r*B-n*y+o*M)*w,t[14]=(A*E-d*S-m*T)*w,t[15]=(f*S-u*E+h*T)*w,t):null}function Dy(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],p=e[11],d=e[12],A=e[13],m=e[14],b=e[15],T=r*a-n*i,E=r*c-o*i,_=r*l-s*i,S=n*c-o*a,C=n*l-s*a,v=o*l-s*c,M=f*A-u*d,y=f*m-h*d,g=f*b-p*d,B=u*m-h*A,L=u*b-p*A,F=h*b-p*m;return t[0]=a*F-c*L+l*B,t[1]=o*L-n*F-s*B,t[2]=A*v-m*C+b*S,t[3]=h*C-u*v-p*S,t[4]=c*g-i*F-l*y,t[5]=r*F-o*g+s*y,t[6]=m*_-d*v-b*E,t[7]=f*v-h*_+p*E,t[8]=i*L-a*g+l*M,t[9]=n*g-r*L-s*M,t[10]=d*C-A*_+b*T,t[11]=u*_-f*C-p*T,t[12]=a*y-i*B-c*M,t[13]=r*B-n*y+o*M,t[14]=A*E-d*S-m*T,t[15]=f*S-u*E+h*T,t}function Ca(t){let e=t[0],r=t[1],n=t[2],o=t[3],s=t[4],i=t[5],a=t[6],c=t[7],l=t[8],f=t[9],u=t[10],h=t[11],p=t[12],d=t[13],A=t[14],m=t[15],b=e*i-r*s,T=e*a-n*s,E=r*a-n*i,_=l*d-f*p,S=l*A-u*p,C=f*A-u*d,v=e*C-r*S+n*_,M=s*C-i*S+a*_,y=l*E-f*T+u*b,g=p*E-d*T+A*b;return c*v-o*M+m*y-h*g}function Sn(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=e[9],p=e[10],d=e[11],A=e[12],m=e[13],b=e[14],T=e[15],E=r[0],_=r[1],S=r[2],C=r[3];return t[0]=E*n+_*a+S*u+C*A,t[1]=E*o+_*c+S*h+C*m,t[2]=E*s+_*l+S*p+C*b,t[3]=E*i+_*f+S*d+C*T,E=r[4],_=r[5],S=r[6],C=r[7],t[4]=E*n+_*a+S*u+C*A,t[5]=E*o+_*c+S*h+C*m,t[6]=E*s+_*l+S*p+C*b,t[7]=E*i+_*f+S*d+C*T,E=r[8],_=r[9],S=r[10],C=r[11],t[8]=E*n+_*a+S*u+C*A,t[9]=E*o+_*c+S*h+C*m,t[10]=E*s+_*l+S*p+C*b,t[11]=E*i+_*f+S*d+C*T,E=r[12],_=r[13],S=r[14],C=r[15],t[12]=E*n+_*a+S*u+C*A,t[13]=E*o+_*c+S*h+C*m,t[14]=E*s+_*l+S*p+C*b,t[15]=E*i+_*f+S*d+C*T,t}function Ba(t,e,r){let n=r[0],o=r[1],s=r[2],i,a,c,l,f,u,h,p,d,A,m,b;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*s+e[12],t[13]=e[1]*n+e[5]*o+e[9]*s+e[13],t[14]=e[2]*n+e[6]*o+e[10]*s+e[14],t[15]=e[3]*n+e[7]*o+e[11]*s+e[15]):(i=e[0],a=e[1],c=e[2],l=e[3],f=e[4],u=e[5],h=e[6],p=e[7],d=e[8],A=e[9],m=e[10],b=e[11],t[0]=i,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=u,t[6]=h,t[7]=p,t[8]=d,t[9]=A,t[10]=m,t[11]=b,t[12]=i*n+f*o+d*s+e[12],t[13]=a*n+u*o+A*s+e[13],t[14]=c*n+h*o+m*s+e[14],t[15]=l*n+p*o+b*s+e[15]),t}function Ia(t,e,r){let n=r[0],o=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ra(t,e,r,n){let o=n[0],s=n[1],i=n[2],a=Math.sqrt(o*o+s*s+i*i),c,l,f,u,h,p,d,A,m,b,T,E,_,S,C,v,M,y,g,B,L,F,w,U;return a<1e-6?null:(a=1/a,o*=a,s*=a,i*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,u=e[0],h=e[1],p=e[2],d=e[3],A=e[4],m=e[5],b=e[6],T=e[7],E=e[8],_=e[9],S=e[10],C=e[11],v=o*o*f+c,M=s*o*f+i*l,y=i*o*f-s*l,g=o*s*f-i*l,B=s*s*f+c,L=i*s*f+o*l,F=o*i*f+s*l,w=s*i*f-o*l,U=i*i*f+c,t[0]=u*v+A*M+E*y,t[1]=h*v+m*M+_*y,t[2]=p*v+b*M+S*y,t[3]=d*v+T*M+C*y,t[4]=u*g+A*B+E*L,t[5]=h*g+m*B+_*L,t[6]=p*g+b*B+S*L,t[7]=d*g+T*B+C*L,t[8]=u*F+A*w+E*U,t[9]=h*F+m*w+_*U,t[10]=p*F+b*w+S*U,t[11]=d*F+T*w+C*U,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function va(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[4],i=e[5],a=e[6],c=e[7],l=e[8],f=e[9],u=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*o+l*n,t[5]=i*o+f*n,t[6]=a*o+u*n,t[7]=c*o+h*n,t[8]=l*o-s*n,t[9]=f*o-i*n,t[10]=u*o-a*n,t[11]=h*o-c*n,t}function wa(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[0],i=e[1],a=e[2],c=e[3],l=e[8],f=e[9],u=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o-l*n,t[1]=i*o-f*n,t[2]=a*o-u*n,t[3]=c*o-h*n,t[8]=s*n+l*o,t[9]=i*n+f*o,t[10]=a*n+u*o,t[11]=c*n+h*o,t}function La(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[0],i=e[1],a=e[2],c=e[3],l=e[4],f=e[5],u=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o+l*n,t[1]=i*o+f*n,t[2]=a*o+u*n,t[3]=c*o+h*n,t[4]=l*o-s*n,t[5]=f*o-i*n,t[6]=u*o-a*n,t[7]=h*o-c*n,t}function Uy(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function Gy(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Hy(t,e,r){let n=r[0],o=r[1],s=r[2],i=Math.sqrt(n*n+o*o+s*s),a,c,l;return i<1e-6?null:(i=1/i,n*=i,o*=i,s*=i,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=n*n*l+a,t[1]=o*n*l+s*c,t[2]=s*n*l-o*c,t[3]=0,t[4]=n*o*l-s*c,t[5]=o*o*l+a,t[6]=s*o*l+n*c,t[7]=0,t[8]=n*s*l+o*c,t[9]=o*s*l-n*c,t[10]=s*s*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function Vy(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function zy(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ky(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ch(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=n+n,c=o+o,l=s+s,f=n*a,u=n*c,h=n*l,p=o*c,d=o*l,A=s*l,m=i*a,b=i*c,T=i*l;return t[0]=1-(p+A),t[1]=u+T,t[2]=h-b,t[3]=0,t[4]=u-T,t[5]=1-(f+A),t[6]=d+m,t[7]=0,t[8]=h+b,t[9]=d-m,t[10]=1-(f+p),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function qy(t,e){let r=new te(3),n=-e[0],o=-e[1],s=-e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=n*n+o*o+s*s+i*i;return u>0?(r[0]=(a*i+f*n+c*s-l*o)*2/u,r[1]=(c*i+f*o+l*n-a*s)*2/u,r[2]=(l*i+f*s+a*o-c*n)*2/u):(r[0]=(a*i+f*n+c*s-l*o)*2,r[1]=(c*i+f*o+l*n-a*s)*2,r[2]=(l*i+f*s+a*o-c*n)*2),ch(t,e,r),t}function jy(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function lh(t,e){let r=e[0],n=e[1],o=e[2],s=e[4],i=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+n*n+o*o),t[1]=Math.sqrt(s*s+i*i+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function Jy(t,e){let r=new te(3);lh(r,e);let n=1/r[0],o=1/r[1],s=1/r[2],i=e[0]*n,a=e[1]*o,c=e[2]*s,l=e[4]*n,f=e[5]*o,u=e[6]*s,h=e[8]*n,p=e[9]*o,d=e[10]*s,A=i+f+d,m=0;return A>0?(m=Math.sqrt(A+1)*2,t[3]=.25*m,t[0]=(u-p)/m,t[1]=(h-c)/m,t[2]=(a-l)/m):i>f&&i>d?(m=Math.sqrt(1+i-f-d)*2,t[3]=(u-p)/m,t[0]=.25*m,t[1]=(a+l)/m,t[2]=(h+c)/m):f>d?(m=Math.sqrt(1+f-i-d)*2,t[3]=(h-c)/m,t[0]=(a+l)/m,t[1]=.25*m,t[2]=(u+p)/m):(m=Math.sqrt(1+d-i-f)*2,t[3]=(a-l)/m,t[0]=(h+c)/m,t[1]=(u+p)/m,t[2]=.25*m),t}function Wy(t,e,r,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];let o=n[0],s=n[1],i=n[2],a=n[4],c=n[5],l=n[6],f=n[8],u=n[9],h=n[10];r[0]=Math.sqrt(o*o+s*s+i*i),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+u*u+h*h);let p=1/r[0],d=1/r[1],A=1/r[2],m=o*p,b=s*d,T=i*A,E=a*p,_=c*d,S=l*A,C=f*p,v=u*d,M=h*A,y=m+_+M,g=0;return y>0?(g=Math.sqrt(y+1)*2,t[3]=.25*g,t[0]=(S-v)/g,t[1]=(C-T)/g,t[2]=(b-E)/g):m>_&&m>M?(g=Math.sqrt(1+m-_-M)*2,t[3]=(S-v)/g,t[0]=.25*g,t[1]=(b+E)/g,t[2]=(C+T)/g):_>M?(g=Math.sqrt(1+_-m-M)*2,t[3]=(C-T)/g,t[0]=(b+E)/g,t[1]=.25*g,t[2]=(S+v)/g):(g=Math.sqrt(1+M-m-_)*2,t[3]=(b-E)/g,t[0]=(C+T)/g,t[1]=(S+v)/g,t[2]=.25*g),t}function Xy(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3],c=o+o,l=s+s,f=i+i,u=o*c,h=o*l,p=o*f,d=s*l,A=s*f,m=i*f,b=a*c,T=a*l,E=a*f,_=n[0],S=n[1],C=n[2];return t[0]=(1-(d+m))*_,t[1]=(h+E)*_,t[2]=(p-T)*_,t[3]=0,t[4]=(h-E)*S,t[5]=(1-(u+m))*S,t[6]=(A+b)*S,t[7]=0,t[8]=(p+T)*C,t[9]=(A-b)*C,t[10]=(1-(u+d))*C,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function Yy(t,e,r,n,o){let s=e[0],i=e[1],a=e[2],c=e[3],l=s+s,f=i+i,u=a+a,h=s*l,p=s*f,d=s*u,A=i*f,m=i*u,b=a*u,T=c*l,E=c*f,_=c*u,S=n[0],C=n[1],v=n[2],M=o[0],y=o[1],g=o[2],B=(1-(A+b))*S,L=(p+_)*S,F=(d-E)*S,w=(p-_)*C,U=(1-(h+b))*C,W=(m+T)*C,z=(d+E)*v,re=(m-T)*v,K=(1-(h+A))*v;return t[0]=B,t[1]=L,t[2]=F,t[3]=0,t[4]=w,t[5]=U,t[6]=W,t[7]=0,t[8]=z,t[9]=re,t[10]=K,t[11]=0,t[12]=r[0]+M-(B*M+w*y+z*g),t[13]=r[1]+y-(L*M+U*y+re*g),t[14]=r[2]+g-(F*M+W*y+K*g),t[15]=1,t}function Fa(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r+r,a=n+n,c=o+o,l=r*i,f=n*i,u=n*a,h=o*i,p=o*a,d=o*c,A=s*i,m=s*a,b=s*c;return t[0]=1-u-d,t[1]=f+b,t[2]=h-m,t[3]=0,t[4]=f-b,t[5]=1-l-d,t[6]=p+A,t[7]=0,t[8]=h+m,t[9]=p-A,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Pa(t,e,r,n,o,s,i){let a=1/(r-e),c=1/(o-n),l=1/(s-i);return t[0]=s*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+n)*c,t[10]=(i+s)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=i*s*2*l,t[15]=0,t}function fh(t,e,r,n,o){let s=1/Math.tan(e/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let i=1/(n-o);t[10]=(o+n)*i,t[14]=2*o*n*i}else t[10]=-1,t[14]=-2*n;return t}var Na=fh;function Ky(t,e,r,n,o){let s=1/Math.tan(e/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let i=1/(n-o);t[10]=o*i,t[14]=o*n*i}else t[10]=-1,t[14]=-n;return t}function Qy(t,e,r,n){let o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),i=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(i+a),l=2/(o+s);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((i-a)*c*.5),t[9]=(o-s)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function uh(t,e,r,n,o,s,i){let a=1/(e-r),c=1/(n-o),l=1/(s-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=(i+s)*l,t[15]=1,t}var Oa=uh;function Zy(t,e,r,n,o,s,i){let a=1/(e-r),c=1/(n-o),l=1/(s-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=s*l,t[15]=1,t}function Da(t,e,r,n){let o,s,i,a,c,l,f,u,h,p,d=e[0],A=e[1],m=e[2],b=n[0],T=n[1],E=n[2],_=r[0],S=r[1],C=r[2];return Math.abs(d-_)<1e-6&&Math.abs(A-S)<1e-6&&Math.abs(m-C)<1e-6?ah(t):(u=d-_,h=A-S,p=m-C,o=1/Math.sqrt(u*u+h*h+p*p),u*=o,h*=o,p*=o,s=T*p-E*h,i=E*u-b*p,a=b*h-T*u,o=Math.sqrt(s*s+i*i+a*a),o?(o=1/o,s*=o,i*=o,a*=o):(s=0,i=0,a=0),c=h*a-p*i,l=p*s-u*a,f=u*i-h*s,o=Math.sqrt(c*c+l*l+f*f),o?(o=1/o,c*=o,l*=o,f*=o):(c=0,l=0,f=0),t[0]=s,t[1]=c,t[2]=u,t[3]=0,t[4]=i,t[5]=l,t[6]=h,t[7]=0,t[8]=a,t[9]=f,t[10]=p,t[11]=0,t[12]=-(s*d+i*A+a*m),t[13]=-(c*d+l*A+f*m),t[14]=-(u*d+h*A+p*m),t[15]=1,t)}function $y(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=n[0],c=n[1],l=n[2],f=o-r[0],u=s-r[1],h=i-r[2],p=f*f+u*u+h*h;p>0&&(p=1/Math.sqrt(p),f*=p,u*=p,h*=p);let d=c*h-l*u,A=l*f-a*h,m=a*u-c*f;return p=d*d+A*A+m*m,p>0&&(p=1/Math.sqrt(p),d*=p,A*=p,m*=p),t[0]=d,t[1]=A,t[2]=m,t[3]=0,t[4]=u*m-h*A,t[5]=h*d-f*m,t[6]=f*A-u*d,t[7]=0,t[8]=f,t[9]=u,t[10]=h,t[11]=0,t[12]=o,t[13]=s,t[14]=i,t[15]=1,t}function eT(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function tT(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function rT(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function hh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function nT(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function oT(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function sT(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function iT(t,e){let r=t[0],n=t[1],o=t[2],s=t[3],i=t[4],a=t[5],c=t[6],l=t[7],f=t[8],u=t[9],h=t[10],p=t[11],d=t[12],A=t[13],m=t[14],b=t[15],T=e[0],E=e[1],_=e[2],S=e[3],C=e[4],v=e[5],M=e[6],y=e[7],g=e[8],B=e[9],L=e[10],F=e[11],w=e[12],U=e[13],W=e[14],z=e[15];return Math.abs(r-T)<=1e-6*Math.max(1,Math.abs(r),Math.abs(T))&&Math.abs(n-E)<=1e-6*Math.max(1,Math.abs(n),Math.abs(E))&&Math.abs(o-_)<=1e-6*Math.max(1,Math.abs(o),Math.abs(_))&&Math.abs(s-S)<=1e-6*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(i-C)<=1e-6*Math.max(1,Math.abs(i),Math.abs(C))&&Math.abs(a-v)<=1e-6*Math.max(1,Math.abs(a),Math.abs(v))&&Math.abs(c-M)<=1e-6*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(l-y)<=1e-6*Math.max(1,Math.abs(l),Math.abs(y))&&Math.abs(f-g)<=1e-6*Math.max(1,Math.abs(f),Math.abs(g))&&Math.abs(u-B)<=1e-6*Math.max(1,Math.abs(u),Math.abs(B))&&Math.abs(h-L)<=1e-6*Math.max(1,Math.abs(h),Math.abs(L))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(d-w)<=1e-6*Math.max(1,Math.abs(d),Math.abs(w))&&Math.abs(A-U)<=1e-6*Math.max(1,Math.abs(A),Math.abs(U))&&Math.abs(m-W)<=1e-6*Math.max(1,Math.abs(m),Math.abs(W))&&Math.abs(b-z)<=1e-6*Math.max(1,Math.abs(b),Math.abs(z))}var aT=Sn,cT=hh;function lT(){let t=new te(4);return te!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function ph(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function dh(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function mh(t){let e=t[0],r=t[1],n=t[2],o=t[3];return Math.sqrt(e*e+r*r+n*n+o*o)}function gh(t){let e=t[0],r=t[1],n=t[2],o=t[3];return e*e+r*r+n*n+o*o}function Ah(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=r*i,t[1]=n*i,t[2]=o*i,t[3]=s*i,t}function xh(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function bh(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t[3]=a+n*(r[3]-a),t}function yh(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3];return t[0]=r[0]*n+r[4]*o+r[8]*s+r[12]*i,t[1]=r[1]*n+r[5]*o+r[9]*s+r[13]*i,t[2]=r[2]*n+r[6]*o+r[10]*s+r[14]*i,t[3]=r[3]*n+r[7]*o+r[11]*s+r[15]*i,t}function Th(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2],l=r[3],f=l*n+a*s-c*o,u=l*o+c*n-i*s,h=l*s+i*o-a*n,p=-i*n-a*o-c*s;return t[0]=f*l+p*-i+u*-c-h*-a,t[1]=u*l+p*-a+h*-i-f*-c,t[2]=h*l+p*-c+f*-a-u*-i,t[3]=e[3],t}var sL=function(){let t=lT();return function(e,r,n,o,s,i){let a,c;for(r||(r=4),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var Ha;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Ha||(Ha={}));var uT=45*Math.PI/180,hT=1,Ua=.1,Ga=500,pT=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),N=class extends Nr{static get IDENTITY(){return mT()}static get ZERO(){return dT()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ha}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,o,s,i,a,c,l,f,u,h,p,d,A,m){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=s,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=u,this[11]=h,this[12]=p,this[13]=d,this[14]=A,this[15]=m,this.check()}setRowMajor(e,r,n,o,s,i,a,c,l,f,u,h,p,d,A,m){return this[0]=e,this[1]=s,this[2]=l,this[3]=p,this[4]=r,this[5]=i,this[6]=f,this[7]=d,this[8]=n,this[9]=a,this[10]=u,this[11]=A,this[12]=o,this[13]=c,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(pT)}fromObject(e){return this.check()}fromQuaternion(e){return Fa(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:o,top:s,near:i=Ua,far:a=Ga}=e;return a===1/0?gT(this,r,n,o,s,i):Pa(this,r,n,o,s,i,a),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:o=[0,1,0]}=e;return Da(this,r,n,o),this.check()}ortho(e){let{left:r,right:n,bottom:o,top:s,near:i=Ua,far:a=Ga}=e;return Oa(this,r,n,o,s,i,a),this.check()}orthographic(e){let{fovy:r=uT,aspect:n=hT,focalDistance:o=1,near:s=Ua,far:i=Ga}=e;Eh(r);let a=r/2,c=o*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:i})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:o=.1,far:s=500}=e;return Eh(r),Na(this,r,n,o,s),this.check()}determinant(){return Ca(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],s=1/n[1],i=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*s,e[2]=this[2]*i,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*s,e[6]=this[6]*i,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*s,e[10]=this[10]*i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],s=1/n[1],i=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*s,e[2]=this[2]*i,e[3]=this[4]*o,e[4]=this[5]*s,e[5]=this[6]*i,e[6]=this[8]*o,e[7]=this[9]*s,e[8]=this[10]*i,e}transpose(){return Ma(this,this),this.check()}invert(){return Sa(this,this),this.check()}multiplyLeft(e){return Sn(this,e,this),this.check()}multiplyRight(e){return Sn(this,this,e),this.check()}rotateX(e){return va(this,this,e),this.check()}rotateY(e){return wa(this,this,e),this.check()}rotateZ(e){return La(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return Ra(this,this,e,r),this.check()}scale(e){return Ia(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Ba(this,this,e),this.check()}transform(e,r){return e.length===4?(r=yh(r||[-0,-0,-0,-0],e,this),Ct(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,o;switch(n){case 2:o=rs(r||[-0,-0],e,this);break;case 3:o=Kt(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ct(o,e.length),o}transformAsVector(e,r){let n;switch(e.length){case 2:n=ns(r||[-0,-0],e,this);break;case 3:n=os(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ct(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},hs,ps;function dT(){return hs||(hs=new N([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(hs)),hs}function mT(){return ps||(ps=new N,Object.freeze(ps)),ps}function Eh(t){if(t>Math.PI*2)throw Error("expected radians")}function gT(t,e,r,n,o,s){let i=2*s/(r-e),a=2*s/(o-n),c=(r+e)/(r-e),l=(o+n)/(o-n),f=-1,u=-1,h=-2*s;return t[0]=i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=u,t[12]=0,t[13]=0,t[14]=h,t[15]=0,t}function _h(){let t=new te(4);return te!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Mh(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Va(t,e,r){r=r*.5;let n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function za(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+i*a+o*l-s*c,t[1]=o*f+i*c+s*a-n*l,t[2]=s*f+i*l+n*c-o*a,t[3]=i*f-n*a-o*c-s*l,t}function Sh(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=o*c+s*a,t[2]=s*c-o*a,t[3]=i*c-n*a,t}function Ch(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-s*a,t[1]=o*c+i*a,t[2]=s*c+n*a,t[3]=i*c-o*a,t}function Bh(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*a,t[1]=o*c-n*a,t[2]=s*c+i*a,t[3]=i*c-s*a,t}function Ih(t,e){let r=e[0],n=e[1],o=e[2];return t[0]=r,t[1]=n,t[2]=o,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-o*o)),t}function Bn(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],h,p,d,A,m;return h=o*c+s*l+i*f+a*u,h<0&&(h=-h,c=-c,l=-l,f=-f,u=-u),1-h>1e-6?(p=Math.acos(h),m=Math.sin(p),d=Math.sin((1-n)*p)/m,A=Math.sin(n*p)/m):(d=1-n,A=n),t[0]=d*o+A*c,t[1]=d*s+A*l,t[2]=d*i+A*f,t[3]=d*a+A*u,t}function Rh(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s,a=i?1/i:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-o*a,t[3]=s*a,t}function vh(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function ka(t,e){let r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{let o=0;e[4]>e[0]&&(o=1),e[8]>e[o*3+o]&&(o=2);let s=(o+1)%3,i=(o+2)%3;n=Math.sqrt(e[o*3+o]-e[s*3+s]-e[i*3+i]+1),t[o]=.5*n,n=.5/n,t[3]=(e[s*3+i]-e[i*3+s])*n,t[s]=(e[s*3+o]+e[o*3+s])*n,t[i]=(e[i*3+o]+e[o*3+i])*n}return t}var wh=ph;var Lh=dh,Fh=xh,Ph=bh,Nh=mh;var Oh=gh;var Dh=Ah;var Uh=function(){let t=is(),e=as(1,0,0),r=as(0,1,0);return function(n,o,s){let i=En(o,s);return i<-.999999?(Yt(t,e,o),ba(t)<1e-6&&Yt(t,r,o),da(t,t),Va(n,t,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Yt(t,o,s),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+i,Dh(n,n))}}(),bL=function(){let t=_h(),e=_h();return function(r,n,o,s,i,a){return Bn(t,n,i,a),Bn(e,o,s,a),Bn(r,t,e,2*a*(1-a)),r}}(),yL=function(){let t=eh();return function(e,r,n,o){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=o[0],t[4]=o[1],t[7]=o[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],Dh(e,ka(e,t))}}();var AT=[0,0,0,1],ot=class extends St{constructor(e=0,r=0,n=0,o=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,n,o)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,n,o){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return ka(this,e),this.check()}fromAxisRotation(e,r){return Va(this,e,r),this.check()}identity(){return Mh(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=H(e)}get y(){return this[1]}set y(e){this[1]=H(e)}get z(){return this[2]}set z(e){this[2]=H(e)}get w(){return this[3]}set w(e){this[3]=H(e)}len(){return Nh(this)}lengthSquared(){return Oh(this)}dot(e){return Fh(this,e)}rotationTo(e,r){return Uh(this,e,r),this.check()}add(e){return wh(this,this,e),this.check()}calculateW(){return Ih(this,this),this.check()}conjugate(){return vh(this,this),this.check()}invert(){return Rh(this,this),this.check()}lerp(e,r,n){return n===void 0?this.lerp(this,e,r):(Ph(this,e,r,n),this.check())}multiplyRight(e){return za(this,this,e),this.check()}multiplyLeft(e){return za(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return Sh(this,this,e),this.check()}rotateY(e){return Ch(this,this,e),this.check()}rotateZ(e){return Bh(this,this,e),this.check()}scale(e){return Lh(this,this,e),this.check()}slerp(e,r,n){let o,s,i;switch(arguments.length){case 1:({start:o=AT,target:s,ratio:i}=e);break;case 2:o=this,s=e,i=r;break;default:o=e,s=r,i=n}return Bn(this,o,s,i),this.check()}transformVector4(e,r=new Pr){return Th(r,e,this),Ct(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var Ue={};xe(Ue,{EPSILON1:()=>xT,EPSILON10:()=>BT,EPSILON11:()=>IT,EPSILON12:()=>RT,EPSILON13:()=>vT,EPSILON14:()=>wT,EPSILON15:()=>LT,EPSILON16:()=>FT,EPSILON17:()=>PT,EPSILON18:()=>NT,EPSILON19:()=>OT,EPSILON2:()=>bT,EPSILON20:()=>DT,EPSILON3:()=>yT,EPSILON4:()=>TT,EPSILON5:()=>ET,EPSILON6:()=>_T,EPSILON7:()=>MT,EPSILON8:()=>ST,EPSILON9:()=>CT,PI_OVER_FOUR:()=>GT,PI_OVER_SIX:()=>HT,PI_OVER_TWO:()=>UT,TWO_PI:()=>VT});var xT=.1,bT=.01,yT=.001,TT=1e-4,ET=1e-5,_T=1e-6,MT=1e-7,ST=1e-8,CT=1e-9,BT=1e-10,IT=1e-11,RT=1e-12,vT=1e-13,wT=1e-14,LT=1e-15,FT=1e-16,PT=1e-17,NT=1e-18,OT=1e-19,DT=1e-20,UT=Math.PI/2,GT=Math.PI/4,HT=Math.PI/6,VT=Math.PI*2;function ds(t,e){e=e===void 0?t[0][0]:e;for(let r of t){let n=r[0]-e;n>180?r[0]-=360:n<-180&&(r[0]+=360)}}function zT(t,e,r){let[n,o]=(0,In.cellToLatLng)(t),s=e.length;ds(e,o);let i=e[0]===e[s-1]?s-1:s;for(let a=0;a<i;a++)e[a][0]=Mt(o,e[a][0],r),e[a][1]=Mt(n,e[a][1],r)}function Gh(t,e,r){let n=t(e,r),[o,s]=(0,In.cellToLatLng)(n);return[s,o]}function qa(t,e=1){let r=(0,In.cellToBoundary)(t,!0);return e!==1?zT(t,r,e):ds(r),r}function ms(t){let e=new Float64Array(t.length*2),r=0;for(let n of t)e[r++]=n[0],e[r++]=n[1];return e}var kT={getPentagon:{type:"accessor",value:t=>t.pentagon}},Rn=class extends De{indexToBounds(){let{data:e,getPentagon:r}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(n,o)=>{let s=r(n,o),i=Gu(typeof s=="string"?Hu(s):s,{closedRing:!0,segments:"auto"});return ms(i)}}}};Rn.layerName="A5Layer";Rn.defaultProps=kT;var Hh=Rn;var cr=D(Xe(),1),Gp=D(We(),1),Hp=D(Zt(),1);function qT(t){return typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t}function gs(t){if(Array.isArray(t))return t.map(e=>gs(e));if(t&&typeof t=="object"){let e={};for(let[r,n]of Object.entries(t))e[qT(r)]=gs(n);return e}return t}var zh=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",jT=zh+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",JT="["+zh+"]["+jT+"]*",WT=new RegExp("^"+JT+"$");function As(t,e){let r=[],n=e.exec(t);for(;n;){let o=[];o.startIndex=e.lastIndex-n[0].length;let s=n.length;for(let i=0;i<s;i++)o.push(n[i]);r.push(o),n=e.exec(t)}return r}var Or=function(t){let e=WT.exec(t);return!(e===null||typeof e>"u")};function kh(t){return typeof t<"u"}var XT={allowBooleanAttributes:!1,unpairedTags:[]};function Xh(t,e){e=Object.assign({},XT,e);let r=[],n=!1,o=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=jh(t,s),s.err)return s}else if(t[s]==="<"){let i=s;if(s++,t[s]==="!"){s=Jh(t,s);continue}else{let a=!1;t[s]==="/"&&(a=!0,s++);let c="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
8
+ `&&t[s]!=="\r";s++)c+=t[s];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),s--),!rE(c)){let u;return c.trim().length===0?u="Invalid space after '<'.":u="Tag '"+c+"' is an invalid name.",se("InvalidTag",u,Se(t,s))}let l=QT(t,s);if(l===!1)return se("InvalidAttr","Attributes for '"+c+"' have open quote.",Se(t,s));let f=l.value;if(s=l.index,f[f.length-1]==="/"){let u=s-f.length;f=f.substring(0,f.length-1);let h=Wh(f,e);if(h===!0)n=!0;else return se(h.err.code,h.err.msg,Se(t,u+h.err.line))}else if(a)if(l.tagClosed){if(f.trim().length>0)return se("InvalidTag","Closing tag '"+c+"' can't have attributes or invalid starting.",Se(t,i));if(r.length===0)return se("InvalidTag","Closing tag '"+c+"' has not been opened.",Se(t,i));{let u=r.pop();if(c!==u.tagName){let h=Se(t,u.tagStartPos);return se("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+c+"'.",Se(t,i))}r.length==0&&(o=!0)}}else return se("InvalidTag","Closing tag '"+c+"' doesn't have proper closing.",Se(t,s));else{let u=Wh(f,e);if(u!==!0)return se(u.err.code,u.err.msg,Se(t,s-f.length+u.err.line));if(o===!0)return se("InvalidXml","Multiple possible root nodes found.",Se(t,s));e.unpairedTags.indexOf(c)!==-1||r.push({tagName:c,tagStartPos:i}),n=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=Jh(t,s);continue}else if(t[s+1]==="?"){if(s=jh(t,++s),s.err)return s}else break;else if(t[s]==="&"){let u=eE(t,s);if(u==-1)return se("InvalidChar","char '&' is not expected.",Se(t,s));s=u}else if(o===!0&&!qh(t[s]))return se("InvalidXml","Extra text at the end",Se(t,s));t[s]==="<"&&s--}}else{if(qh(t[s]))continue;return se("InvalidChar","char '"+t[s]+"' is not expected.",Se(t,s))}if(n){if(r.length==1)return se("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",Se(t,r[0].tagStartPos));if(r.length>0)return se("InvalidXml","Invalid '"+JSON.stringify(r.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return se("InvalidXml","Start tag expected.",1);return!0}function qh(t){return t===" "||t===" "||t===`
9
+ `||t==="\r"}function jh(t,e){let r=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){let n=t.substr(r,e-r);if(e>5&&n==="xml")return se("InvalidXml","XML declaration allowed only at the start of the document.",Se(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Jh(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let r=1;for(e+=8;e<t.length;e++)if(t[e]==="<")r++;else if(t[e]===">"&&(r--,r===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}var YT='"',KT="'";function QT(t,e){let r="",n="",o=!1;for(;e<t.length;e++){if(t[e]===YT||t[e]===KT)n===""?n=t[e]:n!==t[e]||(n="");else if(t[e]===">"&&n===""){o=!0;break}r+=t[e]}return n!==""?!1:{value:r,index:e,tagClosed:o}}var ZT=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Wh(t,e){let r=As(t,ZT),n={};for(let o=0;o<r.length;o++){if(r[o][1].length===0)return se("InvalidAttr","Attribute '"+r[o][2]+"' has no space in starting.",vn(r[o]));if(r[o][3]!==void 0&&r[o][4]===void 0)return se("InvalidAttr","Attribute '"+r[o][2]+"' is without value.",vn(r[o]));if(r[o][3]===void 0&&!e.allowBooleanAttributes)return se("InvalidAttr","boolean attribute '"+r[o][2]+"' is not allowed.",vn(r[o]));let s=r[o][2];if(!tE(s))return se("InvalidAttr","Attribute '"+s+"' is an invalid name.",vn(r[o]));if(!n.hasOwnProperty(s))n[s]=1;else return se("InvalidAttr","Attribute '"+s+"' is repeated.",vn(r[o]))}return!0}function $T(t,e){let r=/\d/;for(t[e]==="x"&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(r))break}return-1}function eE(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,$T(t,e);let r=0;for(;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(t[e]===";")break;return-1}return e}function se(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function tE(t){return Or(t)}function rE(t){return Or(t)}function Se(t,e){let r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function vn(t){return t.startIndex+t[1].length}var nE={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t},captureMetaData:!1};function Yh(t){return typeof t=="boolean"?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:typeof t=="object"&&t!==null?{enabled:t.enabled!==!1,maxEntitySize:t.maxEntitySize??1e4,maxExpansionDepth:t.maxExpansionDepth??10,maxTotalExpansions:t.maxTotalExpansions??1e3,maxExpandedLength:t.maxExpandedLength??1e5,allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null}:Yh(!0)}var Kh=function(t){let e=Object.assign({},nE,t);return e.processEntities=Yh(e.processEntities),e};var xs;typeof Symbol!="function"?xs="@@xmlMetadata":xs=Symbol("XML Node Metadata");var Pe=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,r){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:r})}addChild(e,r){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,[":@"]:e[":@"]}):this.child.push({[e.tagname]:e.child}),r!==void 0&&(this.child[this.child.length-1][xs]={startIndex:r})}static getMetaDataSymbol(){return xs}};var Ln=class{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,r){let n={};if(e[r+3]==="O"&&e[r+4]==="C"&&e[r+5]==="T"&&e[r+6]==="Y"&&e[r+7]==="P"&&e[r+8]==="E"){r=r+9;let o=1,s=!1,i=!1,a="";for(;r<e.length;r++)if(e[r]==="<"&&!i){if(s&&$t(e,"!ENTITY",r)){r+=7;let c,l;if([c,l,r]=this.readEntityExp(e,r+1,this.suppressValidationErr),l.indexOf("&")===-1){let f=c.replace(/[.\-+*:]/g,"\\.");n[c]={regx:RegExp(`&${f};`,"g"),val:l}}}else if(s&&$t(e,"!ELEMENT",r)){r+=8;let{index:c}=this.readElementExp(e,r+1);r=c}else if(s&&$t(e,"!ATTLIST",r))r+=8;else if(s&&$t(e,"!NOTATION",r)){r+=9;let{index:c}=this.readNotationExp(e,r+1,this.suppressValidationErr);r=c}else if($t(e,"!--",r))i=!0;else throw new Error("Invalid DOCTYPE");o++,a=""}else if(e[r]===">"){if(i?e[r-1]==="-"&&e[r-2]==="-"&&(i=!1,o--):o--,o===0)break}else e[r]==="["?s=!0:a+=e[r];if(o!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:r}}readEntityExp(e,r){r=Ie(e,r);let n="";for(;r<e.length&&!/\s/.test(e[r])&&e[r]!=='"'&&e[r]!=="'";)n+=e[r],r++;if(wn(n),r=Ie(e,r),!this.suppressValidationErr){if(e.substring(r,r+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[r]==="%")throw new Error("Parameter entities are not supported")}let o="";if([r,o]=this.readIdentifierVal(e,r,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize&&o.length>this.options.maxEntitySize)throw new Error(`Entity "${n}" size (${o.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return r--,[n,o,r]}readNotationExp(e,r){r=Ie(e,r);let n="";for(;r<e.length&&!/\s/.test(e[r]);)n+=e[r],r++;!this.suppressValidationErr&&wn(n),r=Ie(e,r);let o=e.substring(r,r+6).toUpperCase();if(!this.suppressValidationErr&&o!=="SYSTEM"&&o!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${o}"`);r+=o.length,r=Ie(e,r);let s=null,i=null;if(o==="PUBLIC")[r,s]=this.readIdentifierVal(e,r,"publicIdentifier"),r=Ie(e,r),(e[r]==='"'||e[r]==="'")&&([r,i]=this.readIdentifierVal(e,r,"systemIdentifier"));else if(o==="SYSTEM"&&([r,i]=this.readIdentifierVal(e,r,"systemIdentifier"),!this.suppressValidationErr&&!i))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:s,systemIdentifier:i,index:--r}}readIdentifierVal(e,r,n){let o="",s=e[r];if(s!=='"'&&s!=="'")throw new Error(`Expected quoted string, found "${s}"`);for(r++;r<e.length&&e[r]!==s;)o+=e[r],r++;if(e[r]!==s)throw new Error(`Unterminated ${n} value`);return r++,[r,o]}readElementExp(e,r){r=Ie(e,r);let n="";for(;r<e.length&&!/\s/.test(e[r]);)n+=e[r],r++;if(!this.suppressValidationErr&&!Or(n))throw new Error(`Invalid element name: "${n}"`);r=Ie(e,r);let o="";if(e[r]==="E"&&$t(e,"MPTY",r))r+=4;else if(e[r]==="A"&&$t(e,"NY",r))r+=2;else if(e[r]==="("){for(r++;r<e.length&&e[r]!==")";)o+=e[r],r++;if(e[r]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[r]}"`);return{elementName:n,contentModel:o.trim(),index:r}}readAttlistExp(e,r){r=Ie(e,r);let n="";for(;r<e.length&&!/\s/.test(e[r]);)n+=e[r],r++;wn(n),r=Ie(e,r);let o="";for(;r<e.length&&!/\s/.test(e[r]);)o+=e[r],r++;if(!wn(o))throw new Error(`Invalid attribute name: "${o}"`);r=Ie(e,r);let s="";if(e.substring(r,r+8).toUpperCase()==="NOTATION"){if(s="NOTATION",r+=8,r=Ie(e,r),e[r]!=="(")throw new Error(`Expected '(', found "${e[r]}"`);r++;let a=[];for(;r<e.length&&e[r]!==")";){let c="";for(;r<e.length&&e[r]!=="|"&&e[r]!==")";)c+=e[r],r++;if(c=c.trim(),!wn(c))throw new Error(`Invalid notation name: "${c}"`);a.push(c),e[r]==="|"&&(r++,r=Ie(e,r))}if(e[r]!==")")throw new Error("Unterminated list of notations");r++,s+=" ("+a.join("|")+")"}else{for(;r<e.length&&!/\s/.test(e[r]);)s+=e[r],r++;let a=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!a.includes(s.toUpperCase()))throw new Error(`Invalid attribute type: "${s}"`)}r=Ie(e,r);let i="";return e.substring(r,r+8).toUpperCase()==="#REQUIRED"?(i="#REQUIRED",r+=8):e.substring(r,r+7).toUpperCase()==="#IMPLIED"?(i="#IMPLIED",r+=7):[r,i]=this.readIdentifierVal(e,r,"ATTLIST"),{elementName:n,attributeName:o,attributeType:s,defaultValue:i,index:r}}},Ie=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function $t(t,e,r){for(let n=0;n<e.length;n++)if(e[n]!==t[r+n+1])return!1;return!0}function wn(t){if(Or(t))return t;throw new Error(`Invalid entity name ${t}`)}var oE=/^[-+]?0x[a-fA-F0-9]+$/,sE=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,iE={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function ja(t,e={}){if(e=Object.assign({},iE,e),!t||typeof t!="string")return t;let r=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(r))return t;if(t==="0")return 0;if(e.hex&&oE.test(r))return fE(r,16);if(r.includes("e")||r.includes("E"))return cE(t,r,e);{let n=sE.exec(r);if(n){let o=n[1]||"",s=n[2],i=lE(n[3]),a=o?t[s.length+1]===".":t[s.length]===".";if(!e.leadingZeros&&(s.length>1||s.length===1&&!a))return t;{let c=Number(r),l=String(c);if(c===0)return c;if(l.search(/[eE]/)!==-1)return e.eNotation?c:t;if(r.indexOf(".")!==-1)return l==="0"||l===i||l===`${o}${i}`?c:t;let f=s?i:r;return s?f===l||o+f===l?c:t:f===l||f===o+l?c:t}}else return t}}var aE=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function cE(t,e,r){if(!r.eNotation)return t;let n=e.match(aE);if(n){let o=n[1]||"",s=n[3].indexOf("e")===-1?"E":"e",i=n[2],a=o?t[i.length+1]===s:t[i.length]===s;return i.length>1&&a?t:i.length===1&&(n[3].startsWith(`.${s}`)||n[3][0]===s)?Number(e):r.leadingZeros&&!a?(e=(n[1]||"")+n[3],Number(e)):t}else return t}function lE(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substring(0,t.length-1))),t}function fE(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function Ja(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(let r of t)if(typeof r=="string"&&e===r||r instanceof RegExp&&r.test(e))return!0}:()=>!1}var Fn=class{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(r,n)=>Qh(n,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(r,n)=>Qh(n,16,"&#x")}},this.addExternalEntities=uE,this.parseXml=gE,this.parseTextData=hE,this.resolveNameSpace=pE,this.buildAttributesMap=mE,this.isItStopNode=yE,this.replaceEntitiesValue=xE,this.readStopNodeData=EE,this.saveTextToParentTag=bE,this.addChild=AE,this.ignoreAttributesFn=Ja(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let r=0;r<this.options.stopNodes.length;r++){let n=this.options.stopNodes[r];typeof n=="string"&&(n.startsWith("*.")?this.stopNodesWildcard.add(n.substring(2)):this.stopNodesExact.add(n))}}}};function uE(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let n=e[r],o=n.replace(/[.\-+*:]/g,"\\.");this.lastEntities[n]={regex:new RegExp("&"+o+";","g"),val:t[n]}}}function hE(t,e,r,n,o,s,i){if(t!==void 0&&(this.options.trimValues&&!n&&(t=t.trim()),t.length>0)){i||(t=this.replaceEntitiesValue(t,e,r));let a=this.options.tagValueProcessor(e,t,r,o,s);return a==null?t:typeof a!=typeof t||a!==t?a:this.options.trimValues?Xa(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?Xa(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function pE(t){if(this.options.removeNSPrefix){let e=t.split(":"),r=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=r+e[1])}return t}var dE=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function mE(t,e,r){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){let n=As(t,dE),o=n.length,s={};for(let i=0;i<o;i++){let a=this.resolveNameSpace(n[i][1]);if(this.ignoreAttributesFn(a,e))continue;let c=n[i][4],l=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(l=this.options.transformAttributeName(l)),l==="__proto__"&&(l="#__proto__"),c!==void 0){this.options.trimValues&&(c=c.trim()),c=this.replaceEntitiesValue(c,r,e);let f=this.options.attributeValueProcessor(a,c,e);f==null?s[l]=c:typeof f!=typeof c||f!==c?s[l]=f:s[l]=Xa(c,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[l]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){let i={};return i[this.options.attributesGroupName]=s,i}return s}}var gE=function(t){t=t.replace(/\r\n?/g,`
10
+ `);let e=new Pe("!xml"),r=e,n="",o="";this.entityExpansionCount=0,this.currentExpandedLength=0;let s=new Ln(this.options.processEntities);for(let i=0;i<t.length;i++)if(t[i]==="<")if(t[i+1]==="/"){let c=er(t,">",i,"Closing Tag is not closed."),l=t.substring(i+2,c).trim();if(this.options.removeNSPrefix){let h=l.indexOf(":");h!==-1&&(l=l.substr(h+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),r&&(n=this.saveTextToParentTag(n,r,o));let f=o.substring(o.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);let u=0;f&&this.options.unpairedTags.indexOf(f)!==-1?(u=o.lastIndexOf(".",o.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=o.lastIndexOf("."),o=o.substring(0,u),r=this.tagsNodeStack.pop(),n="",i=c}else if(t[i+1]==="?"){let c=Wa(t,i,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,r,o),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){let l=new Pe(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,o,c.tagName)),this.addChild(r,l,o,i)}i=c.closeIndex+1}else if(t.substr(i+1,3)==="!--"){let c=er(t,"-->",i+4,"Comment is not closed.");if(this.options.commentPropName){let l=t.substring(i+4,c-2);n=this.saveTextToParentTag(n,r,o),r.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}i=c}else if(t.substr(i+1,2)==="!D"){let c=s.readDocType(t,i);this.docTypeEntities=c.entities,i=c.i}else if(t.substr(i+1,2)==="!["){let c=er(t,"]]>",i,"CDATA is not closed.")-2,l=t.substring(i+9,c);n=this.saveTextToParentTag(n,r,o);let f=this.parseTextData(l,r.tagname,o,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):r.add(this.options.textNodeName,f),i=c+2}else{let c=Wa(t,i,this.options.removeNSPrefix),l=c.tagName,f=c.rawTagName,u=c.tagExp,h=c.attrExpPresent,p=c.closeIndex;if(this.options.transformTagName){let m=this.options.transformTagName(l);u===l&&(u=m),l=m}r&&n&&r.tagname!=="!xml"&&(n=this.saveTextToParentTag(n,r,o,!1));let d=r;d&&this.options.unpairedTags.indexOf(d.tagname)!==-1&&(r=this.tagsNodeStack.pop(),o=o.substring(0,o.lastIndexOf("."))),l!==e.tagname&&(o+=o?"."+l:l);let A=i;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,o,l)){let m="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),o=o.substr(0,o.length-1),u=l):u=u.substr(0,u.length-1),i=c.closeIndex;else if(this.options.unpairedTags.indexOf(l)!==-1)i=c.closeIndex;else{let T=this.readStopNodeData(t,f,p+1);if(!T)throw new Error(`Unexpected end of ${f}`);i=T.i,m=T.tagContent}let b=new Pe(l);l!==u&&h&&(b[":@"]=this.buildAttributesMap(u,o,l)),m&&(m=this.parseTextData(m,l,o,!0,h,!0,!0)),o=o.substr(0,o.lastIndexOf(".")),b.add(this.options.textNodeName,m),this.addChild(r,b,o,A)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){if(l[l.length-1]==="/"?(l=l.substr(0,l.length-1),o=o.substr(0,o.length-1),u=l):u=u.substr(0,u.length-1),this.options.transformTagName){let b=this.options.transformTagName(l);u===l&&(u=b),l=b}let m=new Pe(l);l!==u&&h&&(m[":@"]=this.buildAttributesMap(u,o,l)),this.addChild(r,m,o,A),o=o.substr(0,o.lastIndexOf("."))}else{let m=new Pe(l);this.tagsNodeStack.push(r),l!==u&&h&&(m[":@"]=this.buildAttributesMap(u,o,l)),this.addChild(r,m,o,A),r=m}n="",i=p}}else n+=t[i];return e.child};function AE(t,e,r,n){this.options.captureMetaData||(n=void 0);let o=this.options.updateTag(e.tagname,r,e[":@"]);o===!1||(typeof o=="string"&&(e.tagname=o),t.addChild(e,n))}var xE=function(t,e,r){if(t.indexOf("&")===-1)return t;let n=this.options.processEntities;if(!n.enabled||n.allowedTags&&!n.allowedTags.includes(e)||n.tagFilter&&!n.tagFilter(e,r))return t;for(let o in this.docTypeEntities){let s=this.docTypeEntities[o],i=t.match(s.regx);if(i){if(this.entityExpansionCount+=i.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n.maxTotalExpansions}`);let a=t.length;if(t=t.replace(s.regx,s.val),n.maxExpandedLength&&(this.currentExpandedLength+=t.length-a,this.currentExpandedLength>n.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n.maxExpandedLength}`)}}if(t.indexOf("&")===-1)return t;for(let o in this.lastEntities){let s=this.lastEntities[o];t=t.replace(s.regex,s.val)}if(t.indexOf("&")===-1)return t;if(this.options.htmlEntities)for(let o in this.htmlEntities){let s=this.htmlEntities[o];t=t.replace(s.regex,s.val)}return t=t.replace(this.ampEntity.regex,this.ampEntity.val),t};function bE(t,e,r,n){return t&&(n===void 0&&(n=e.child.length===0),t=this.parseTextData(t,e.tagname,r,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,n),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function yE(t,e,r,n){return!!(e&&e.has(n)||t&&t.has(r))}function TE(t,e,r=">"){let n,o="";for(let s=e;s<t.length;s++){let i=t[s];if(n)i===n&&(n="");else if(i==='"'||i==="'")n=i;else if(i===r[0])if(r[1]){if(t[s+1]===r[1])return{data:o,index:s}}else return{data:o,index:s};else i===" "&&(i=" ");o+=i}}function er(t,e,r,n){let o=t.indexOf(e,r);if(o===-1)throw new Error(n);return o+e.length-1}function Wa(t,e,r,n=">"){let o=TE(t,e+1,n);if(!o)return;let s=o.data,i=o.index,a=s.search(/\s/),c=s,l=!0;a!==-1&&(c=s.substring(0,a),s=s.substring(a+1).trimStart());let f=c;if(r){let u=c.indexOf(":");u!==-1&&(c=c.substr(u+1),l=c!==o.data.substr(u+1))}return{tagName:c,tagExp:s,closeIndex:i,attrExpPresent:l,rawTagName:f}}function EE(t,e,r){let n=r,o=1;for(;r<t.length;r++)if(t[r]==="<")if(t[r+1]==="/"){let s=er(t,">",r,`${e} is not closed`);if(t.substring(r+2,s).trim()===e&&(o--,o===0))return{tagContent:t.substring(n,r),i:s};r=s}else if(t[r+1]==="?")r=er(t,"?>",r+1,"StopNode is not closed.");else if(t.substr(r+1,3)==="!--")r=er(t,"-->",r+3,"StopNode is not closed.");else if(t.substr(r+1,2)==="![")r=er(t,"]]>",r,"StopNode is not closed.")-2;else{let s=Wa(t,r,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&o++,r=s.closeIndex)}}function Xa(t,e,r){if(e&&typeof t=="string"){let n=t.trim();return n==="true"?!0:n==="false"?!1:ja(t,r)}else return kh(t)?t:""}function Qh(t,e,r){let n=Number.parseInt(t,e);return n>=0&&n<=1114111?String.fromCodePoint(n):r+t+";"}var Ya=Pe.getMetaDataSymbol();function Ka(t,e){return Zh(t,e)}function Zh(t,e,r){let n,o={};for(let s=0;s<t.length;s++){let i=t[s],a=_E(i),c="";if(r===void 0?c=a:c=r+"."+a,a===e.textNodeName)n===void 0?n=i[a]:n+=""+i[a];else{if(a===void 0)continue;if(i[a]){let l=Zh(i[a],e,c),f=SE(l,e);i[Ya]!==void 0&&(l[Ya]=i[Ya]),i[":@"]?ME(l,i[":@"],c,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),o[a]!==void 0&&o.hasOwnProperty(a)?(Array.isArray(o[a])||(o[a]=[o[a]]),o[a].push(l)):e.isArray(a,c,f)?o[a]=[l]:o[a]=l}}}return typeof n=="string"?n.length>0&&(o[e.textNodeName]=n):n!==void 0&&(o[e.textNodeName]=n),o}function _E(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let n=e[r];if(n!==":@")return n}}function ME(t,e,r,n){if(e){let o=Object.keys(e),s=o.length;for(let i=0;i<s;i++){let a=o[i];n.isArray(a,r+"."+a,!0,!0)?t[a]=[e[a]]:t[a]=e[a]}}}function SE(t,e){let{textNodeName:r}=e,n=Object.keys(t).length;return!!(n===0||n===1&&(t[r]||typeof t[r]=="boolean"||t[r]===0))}var Dr=class{constructor(e){this.externalEntities={},this.options=Kh(e)}parse(e,r){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let s=Xh(e,r);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}let n=new Fn(this.options);n.addExternalEntities(this.externalEntities);let o=n.parseXml(e);return this.options.preserveOrder||o===void 0?o:Ka(o,this.options)}addEntity(e,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=r}static getMetaDataSymbol(){return Pe.getMetaDataSymbol()}};function Qa(t,e){if(e?._parser&&e._parser!=="fast-xml-parser")throw new Error(e?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:e?.removeNSPrefix,textNodeName:e?.textNodeName,isArray:(o,s,i,a)=>Boolean(e?.arrayPaths?.some(l=>s===l)),...e?._fastXML},n=CE(t,r);return e?.uncapitalizeKeys?gs(n):n}function CE(t,e){return new Dr({ignoreAttributes:!1,attributeNamePrefix:"",...e}).parse(t)}var BE="4.4.0-alpha.18",Ke={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:BE,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:IE,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(t,e)=>Qa(new TextDecoder().decode(t),{...Ke.options.xml,...e?.xml}),parseTextSync:(t,e)=>Qa(t,{...Ke.options.xml,...e?.xml})};function IE(t){return t.startsWith("<?xml")}async function Ne(t,e,r,n){return n._parse(t,e,r,n)}function V(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var st={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},RE=st.self||st.window||st.global||{},vE=st.window||st.self||st.global||{},wE=st.global||st.self||st.window||{},LE=st.document||{};var Pn=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var $h=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),FE=$h&&parseFloat($h[1])||0;var bs=globalThis,PE=globalThis.document||{},ys=globalThis.process||{},NE=globalThis.console,P3=globalThis.navigator||{};function ep(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}function tr(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||ep()}var Za="4.1.1";function Ur(t,e){if(!t)throw new Error(e||"Assertion failed")}function $a(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return Ur(Number.isFinite(e)&&e>=0),e}function tp(t){let{logLevel:e,message:r}=t;t.logLevel=$a(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let o=typeof t.message;return Ur(o==="string"||o==="object"),Object.assign(t,{args:n},t.opts)}var rr=()=>{},Ts=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...n){return this._log("log",e,r,n)}info(e,r,...n){return this._log("info",e,r,n)}once(e,r,...n){return this._log("once",e,r,n,{once:!0})}_log(e,r,n,o,s={}){let i=tp({logLevel:r,message:n,args:this._buildArgs(r,n,o),opts:s});return this._createLogFunction(e,i,s)}_buildArgs(e,r,n){return[e,r,...n]}_createLogFunction(e,r,n){if(!this._shouldLog(r.logLevel))return rr;let o=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&o!==void 0){if(this._onceCache.has(o))return rr;this._onceCache.add(o)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=$a(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function DE(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Es=class{constructor(e,r,n="sessionStorage"){this.storage=DE(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function rp(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function np(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var _s;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(_s||(_s={}));var UE=10;function op(t){return typeof t!="string"?t:(t=t.toUpperCase(),_s[t]||_s.WHITE)}function sp(t,e,r){return!tr&&typeof t=="string"&&(e&&(t=`\x1B[${op(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${op(r)+UE}m${t}\x1B[49m`)),t}function ip(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),o=t;for(let s of n){let i=o[s];typeof i=="function"&&(e.find(a=>s===a)||(o[s]=i.bind(t)))}}function Gr(){let t;if(tr()&&bs.performance)t=bs?.performance?.now?.();else if("hrtime"in ys){let e=ys?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Hr={debug:tr()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},ec={enabled:!0,level:0},ht=class extends Ts{constructor({id:e}={id:""}){super({level:0}),this.VERSION=Za,this._startTs=Gr(),this._deltaTs=Gr(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Es(`__probe-${this.id}__`,{[this.id]:ec}),this.timeStamp(`${this.id} started`),ip(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Gr()-this._startTs).toPrecision(10))}getDelta(){return Number((Gr()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:Hr.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:Hr.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...n){return this._log("log",e,r,n,{method:Hr.log,time:!0,once:!0})}log(e,r,...n){return this._log("log",e,r,n,{method:Hr.debug})}info(e,r,...n){return this._log("info",e,r,n,{method:console.info})}once(e,r,...n){return this._log("once",e,r,n,{method:Hr.debug||Hr.info,once:!0})}table(e,r,n){return r?this._log("table",e,r,n&&[n]||[],{method:console.table||rr,tag:HE(r)}):rr}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||rr})}group(e,r,n={collapsed:!1}){let o=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:o})}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||rr})}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let n=r.method;Ur(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Gr();let o=GE(this.id,r.message,r);return n.bind(console,o,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(ec),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...ec};this._storage.setConfiguration({[this.id]:{...r,...e}})}};ht.VERSION=Za;function GE(t,e,r){if(typeof e=="string"){let n=r.time?np(rp(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=sp(e,r.color,r.background)}return e}function HE(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var tc=new ht({id:"@probe.gl/log"});var rc="4.4.0-alpha.18",VE=rc[0]>="0"&&rc[0]<="9"?`v${rc}`:"";function zE(){let t=new ht({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=VE,globalThis.probe||={},globalThis.probe.loaders=t,t}var nc=zE();var ap=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer;function Nn(t,e){return cp(t||{},e)}function cp(t,e,r=0){if(r>3)return e;let n={...t};for(let[o,s]of Object.entries(e))s&&typeof s=="object"&&!Array.isArray(s)?n[o]=cp(n[o]||{},e[o],r+1):n[o]=e[o];return n}function oc(t){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t)}function sc(t){return globalThis.loaders?.modules?.[t]||null}function kE(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.0-alpha.18"),globalThis._loadersgl_.version}var lp=kE();function fp(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var it={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},yF=it.self||it.window||it.global||{},TF=it.window||it.self||it.global||{},EF=it.global||it.self||it.window||{},_F=it.document||{};var pt=typeof process!="object"||String(process)!=="[object process]"||process.browser,On=typeof importScripts=="function",MF=typeof window<"u"&&typeof window.orientation<"u",up=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),SF=up&&parseFloat(up[1])||0;var ic={};function Dn(t={}){let e=t.useLocalLibraries??t.core?.useLocalLibraries,r=t.CDN??t.core?.CDN,n=t.modules;return{...e!==void 0?{useLocalLibraries:e}:{},...r!==void 0?{CDN:r}:{},...n!==void 0?{modules:n}:{}}}async function Ge(t,e=null,r={},n=null){return e&&(t=hp(t,e,r,n)),ic[t]=ic[t]||qE(t),await ic[t]}function hp(t,e,r={},n=null){if(r?.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!r.useLocalLibraries&&t.startsWith("http"))return t;n=n||t;let o=r.modules||{};return o[n]?o[n]:pt?r.CDN?(fp(r.CDN.startsWith("http")),`${r.CDN}/${e}@${lp}/dist/libs/${n}`):On?`../src/libs/${n}`:`modules/${e}/src/libs/${n}`:`modules/${e}/dist/libs/${n}`}async function qE(t){if(t.endsWith("wasm"))return await JE(t);if(!pt){let{requireFromFile:r}=globalThis.loaders||{};try{let n=await r?.(t);return n||!t.includes("/dist/libs/")?n:await r?.(t.replace("/dist/libs/","/src/libs/"))}catch(n){if(t.includes("/dist/libs/"))try{return await r?.(t.replace("/dist/libs/","/src/libs/"))}catch{}return console.error(n),null}}if(On)return importScripts(t);let e=await WE(t);return jE(e,t)}function jE(t,e){if(!pt){let{requireFromString:n}=globalThis.loaders||{};return n?.(t,e)}if(On)return eval.call(globalThis,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function JE(t){let{readFileAsArrayBuffer:e}=globalThis.loaders||{};if(pt||!e||t.startsWith("http"))return await(await fetch(t)).arrayBuffer();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${t}`)}}async function WE(t){let{readFileAsText:e}=globalThis.loaders||{};if(pt||!e||t.startsWith("http"))return await(await fetch(t)).text();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${t}`)}}function dp(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?pp(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?pp(t,0,e):""}function pp(t,e,r){if(t.byteLength<=e+r)return"";let n=new DataView(t),o="";for(let s=0;s<r;s++)o+=String.fromCharCode(n.getUint8(e+s));return o}function ac(t){try{return JSON.parse(t)}catch{throw new Error(`Failed to parse JSON from data starting with "${dp(t)}"`)}}function Un(...t){let e=t,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let n=e.reduce((i,a)=>i+a.length,0),o=new r(n),s=0;for(let i of e)o.set(i,s),s+=i.length;return o}function nr(t,e,r){let n=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(n).buffer}function It(t,e){return V(t>=0),V(e>0),t+(e-1)&~(e-1)}function cc(t,e,r){let n;if(t instanceof ArrayBuffer)n=new Uint8Array(t);else{let o=t.byteOffset,s=t.byteLength;n=new Uint8Array(t.buffer||t.arrayBuffer,o,s)}return e.set(n,r),r+It(n.byteLength,4)}function Gn(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var or=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Gn(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Gn()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var Rt=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,o=this.stats[r];return o||(e instanceof or?o=e:o=new or(r,n),this.stats[r]=o),o}};var XE="Queued Requests",YE="Active Requests",KE="Cancelled Requests",QE="Queued Requests Ever",ZE="Active Requests Ever",$E={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},vt=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...$E,...e},this.stats=new Rt({id:this.props.id}),this.stats.get(XE),this.stats.get(YE),this.stats.get(KE),this.stats.get(QE),this.stats.get(ZE)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},o=new Promise(s=>(n.resolve=s,n));return this.requestQueue.push(n),this.requestMap.set(e,o),this._issueNewRequests(),o}_issueRequest(e){let{handle:r,resolve:n}=e,o=!1,s=()=>{o||(o=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({done:s}):Promise.resolve({done:s})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var e_="",mp={};function gp(t){for(let e in mp)if(t.startsWith(e)){let r=mp[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${e_}${t}`),t}function wt(t){if(t instanceof ArrayBuffer)return t;if(ap(t))return Hn(t);let{buffer:e,byteOffset:r,byteLength:n}=t;return e instanceof ArrayBuffer&&r===0&&n===e.byteLength?e:Hn(e,r,n)}function Hn(t,e=0,r=t.byteLength-e){let n=new Uint8Array(t,e,r),o=new Uint8Array(n.length);return o.set(n),o.buffer}var Lt={};xe(Lt,{dirname:()=>r_,filename:()=>t_,join:()=>n_,resolve:()=>o_});function Ap(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function t_(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function r_(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function n_(...t){let e="/";return t=t.map((r,n)=>(n&&(r=r.replace(new RegExp(`^${e}`),"")),n!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function o_(...t){let e=[];for(let s=0;s<t.length;s++)e[s]=t[s];let r="",n=!1,o;for(let s=e.length-1;s>=-1&&!n;s--){let i;s>=0?i=e[s]:(o===void 0&&(o=Ap()),i=o),i.length!==0&&(r=`${i}/${r}`,n=i.charCodeAt(0)===Vn)}return r=s_(r,!n),n?`/${r}`:r.length>0?r:"."}var Vn=47,lc=46;function s_(t,e){let r="",n=-1,o=0,s,i=!1;for(let a=0;a<=t.length;++a){if(a<t.length)s=t.charCodeAt(a);else{if(s===Vn)break;s=Vn}if(s===Vn){if(!(n===a-1||o===1))if(n!==a-1&&o===2){if(r.length<2||!i||r.charCodeAt(r.length-1)!==lc||r.charCodeAt(r.length-2)!==lc){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Vn;--l);if(l!==c){r=l===-1?"":r.slice(0,l),n=a,o=0,i=!1;continue}}else if(r.length===2||r.length===1){r="",n=a,o=0,i=!1;continue}}e&&(r.length>0?r+="/..":r="..",i=!0)}else{let c=t.slice(n+1,a);r.length>0?r+=`/${c}`:r=c,i=!1}n=a,o=0}else s===lc&&o!==-1?++o:o=-1}return r}var fc=class{optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(e,r,n){n?this.options=Nn({...n,core:fc.defaultOptions},r):this.options={...r},this.data=e,this.url=typeof e=="string"?gp(e):"",this.loadOptions={...this.options.core?.loadOptions},this.fetch=i_(this.loadOptions)}setProps(e){this.options=Object.assign(this.options,e),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}},Vr=fc;qt(Vr,"defaultOptions",{core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}});function i_(t){let e=t?.core?.fetch;if(e&&typeof e=="function")return(n,o)=>e(n,o);let r=t?.fetch;return r&&typeof r!="function"?n=>fetch(n,r):n=>fetch(n)}var Ft=class{};qt(Ft,"type","template"),qt(Ft,"testURL",e=>!1);function xp(t,e){let r=Ke.parseTextSync?.(t,e),n=r?.ServiceExceptionReport?.ServiceException||r?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return typeof n=="string"?n:n.value||n.code||"Unknown error"}var a_="4.4.0-alpha.18",zn={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:a_,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:c_,options:{wms:{throwOnError:!1}},parse:async(t,e)=>uc(new TextDecoder().decode(t),e),parseSync:(t,e)=>uc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>uc(t,e)};function c_(t){return t.startsWith("<?xml")}function uc(t,e){let r={...zn.options.wms,...e?.wms},n=xp(t,r),o=r.minimalErrors?n:`WMS Service error: ${n}`;if(r.throwOnError)throw new Error(o);return o}function sr(t){return Array.isArray(t)?t:t?[t]:[]}function kn(t){let e=sr(t);return e.length>0&&e.every(r=>typeof r=="string")?e:[]}function qn(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseFloat(t);default:return}}function Ms(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseInt(t,10);default:return}}function ir(t){switch(t){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function hc(t,e){let r=Ke.parseTextSync?.(t,e),n=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,o=l_(n);if(e?.inheritedLayerProps)for(let s of o.layers)yp(s,null);return e?.includeRawJSON&&(o.json=n),e?.includeXMLText&&(o.xml=t),o}function l_(t){let e={version:String(t.version||""),name:String(t.Service?.Name||"unnamed"),title:t.Service?.Title?String(t.Service?.Title):void 0,abstract:t.Service?.Abstract?String(t.Service?.Abstract):void 0,keywords:kn(t.Service?.KeywordList?.Keyword),fees:t.Service?.Fees?JSON.stringify(t.Service?.Fees):void 0,accessConstraints:t.Service?.AccessConstraints?JSON.stringify(t.Service?.AccessConstraints):void 0,layerLimit:Ms(t.Service?.LayerLimit),maxWidth:Ms(t.Service?.maxWidth),maxHeight:Ms(t.Service?.maxHeight),layers:[],requests:f_(t.Capability?.Request),exceptions:u_(t.Exception)},r=sr(t.Capability?.Layer);for(let n of r)e.layers.push(bp(n));for(let[n,o]of Object.entries(e))o===void 0&&delete e[n];return e}function f_(t){let e={};for(let[r,n]of Object.entries(t||{})){let o=kn(n?.Format);e[r]={mimeTypes:o}}return e}function u_(t){if(sr(t?.Format).length>0)return{mimeTypes:kn(t)}}function bp(t){let e={title:String(t?.Title||""),name:t?.Name&&String(t?.Name),abstract:t?.Name&&String(t?.Abstract),keywords:kn(t.KeywordList?.Keyword)},r=t?.CRS||t?.SRS;r&&Array.isArray(r)&&r.every(l=>typeof l=="string")&&(e.crs=r);let n=t?.EX_GeographicBoundingBox&&h_(t?.EX_GeographicBoundingBox);n&&(e.geographicBoundingBox=n),n=t?.LatLonBoundingBox&&p_(t?.LatLonBoundingBox),n&&(e.geographicBoundingBox=n);let o=t?.BoundingBox&&d_(t?.BoundingBox);o&&o.length>0&&(e.boundingBoxes=o);let i=sr(t?.Dimension).map(l=>g_(l));i.length&&(e.dimensions=i),t?.opaque&&(e.opaque=ir(t?.opaque)),t?.cascaded&&(e.cascaded=ir(t?.cascaded)),t?.queryable&&(e.queryable=ir(t?.queryable));let a=sr(t?.Layer),c=[];for(let l of a)c.push(bp(l));c.length>0&&(e.layers=c);for(let[l,f]of Object.entries(e))f===void 0&&delete e[l];return e}function h_(t){let{westBoundLongitude:e,northBoundLatitude:r,eastBoundLongitude:n,southBoundLatitude:o}=t;return[[e,o],[n,r]]}function p_(t){let{minx:e,miny:r,maxx:n,maxy:o}=t;return[[e,r],[n,o]]}function d_(t){return sr(t).map(r=>m_(r))}function m_(t){let{CRS:e,SRS:r,minx:n,miny:o,maxx:s,maxy:i,resx:a,resy:c}=t,l={crs:e||r,boundingBox:[[qn(n),qn(o)],[qn(s),qn(i)]]};return a&&(l.xResolution=a),c&&(l.yResolution=c),l}function g_(t){let{name:e,units:r,value:n}=t,o={name:e,units:r,extent:n};return t.unitSymbol&&(o.unitSymbol=t.unitSymbol),t.default&&(o.defaultValue=t.default),t.multipleValues&&(o.multipleValues=ir(t.multipleValues)),t.nearestValue&&(o.nearestValue=ir(t.nearestValue)),t.current&&(o.current=ir(t.current)),o}function yp(t,e){e?.geographicBoundingBox&&!t.geographicBoundingBox&&(t.geographicBoundingBox=[...e.geographicBoundingBox]),e?.crs&&!t.crs&&(t.crs=[...e.crs]),e?.boundingBoxes&&!t.boundingBoxes&&(t.boundingBoxes=[...e.boundingBoxes]),e?.dimensions&&!t.dimensions&&(t.dimensions=[...e.dimensions]);for(let r of t.layers||[])yp(r,t)}var A_="4.4.0-alpha.18",zr={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:A_,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:x_,options:{wms:{}},parse:async(t,e)=>hc(new TextDecoder().decode(t),e?.wms),parseTextSync:(t,e)=>hc(t,e?.wms)};function x_(t){return t.startsWith("<?xml")}function pc(t,e){let n=(Ke.parseTextSync?.(t,e)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(n)?n:[n]).map(s=>b_(s))}}function b_(t){return{attributes:t||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var Tp={...zr,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(t,e)=>pc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>pc(t,e)};function dc(t,e){return Ke.parseTextSync?.(t,e)}var Ep={...zr,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(t,e)=>dc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>dc(t,e)};var _p="4.4.0-alpha.18";var y_=globalThis.loaders?.parseImageNode,mc=typeof Image<"u",gc=typeof ImageBitmap<"u",T_=Boolean(y_),Ac=Pn?!0:T_;function Mp(t){switch(t){case"auto":return gc||mc||Ac;case"imagebitmap":return gc;case"image":return mc;case"data":return Ac;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function Sp(){if(gc)return"imagebitmap";if(mc)return"image";if(Ac)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Cp(t){let e=E_(t);if(!e)throw new Error("Not an image");return e}function jn(t){switch(Cp(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function E_(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var __=/^data:image\/svg\+xml/,M_=/\.svg((\?|#).*)?$/;function Ss(t){return t&&(__.test(t)||M_.test(t))}function Bp(t,e){if(Ss(e)){let n=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(s){throw new Error(s.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return xc(t,e)}function xc(t,e){if(Ss(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function Cs(t,e,r){let n=Bp(t,r),o=self.URL||self.webkitURL,s=typeof n!="string"&&o.createObjectURL(n);try{return await S_(s||n,e)}finally{s&&o.revokeObjectURL(s)}}async function S_(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((n,o)=>{try{r.onload=()=>n(r),r.onerror=s=>{let i=s instanceof Error?s.message:"error";o(new Error(i))}}catch(s){o(s)}})}var Ip=!0;async function Rp(t,e,r){let n;Ss(r)?n=await Cs(t,e,r):n=xc(t,r);let o=e&&e.imagebitmap;return await C_(n,o)}async function C_(t,e=null){if((B_(e)||!Ip)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),Ip=!1}return await createImageBitmap(t)}function B_(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function vp(t){return!w_(t,"ftyp",4)||!(t[8]&96)?null:I_(t)}function I_(t){switch(R_(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function R_(t,e,r){return String.fromCharCode(...t.slice(e,r))}function v_(t){return[...t].map(e=>e.charCodeAt(0))}function w_(t,e,r=0){let n=v_(e);for(let o=0;o<n.length;++o)if(n[o]!==t[o+r])return!1;return!0}var at=!1,Jn=!0;function ar(t){let e=Wn(t);return F_(e)||O_(e)||P_(e)||N_(e)||L_(e)}function L_(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=vp(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function F_(t){let e=Wn(t);return e.byteLength>=24&&e.getUint32(0,at)===2303741511?{mimeType:"image/png",width:e.getUint32(16,at),height:e.getUint32(20,at)}:null}function P_(t){let e=Wn(t);return e.byteLength>=10&&e.getUint32(0,at)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Jn),height:e.getUint16(8,Jn)}:null}function N_(t){let e=Wn(t);return e.byteLength>=14&&e.getUint16(0,at)===16973&&e.getUint32(2,Jn)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Jn),height:e.getUint32(22,Jn)}:null}function O_(t){let e=Wn(t);if(!(e.byteLength>=3&&e.getUint16(0,at)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:o}=D_(),s=2;for(;s+9<e.byteLength;){let i=e.getUint16(s,at);if(o.has(i))return{mimeType:"image/jpeg",height:e.getUint16(s+5,at),width:e.getUint16(s+7,at)};if(!n.has(i))return null;s+=2,s+=e.getUint16(s,at)}return null}function D_(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Wn(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function wp(t,e){let{mimeType:r}=ar(t)||{},n=globalThis.loaders?.parseImageNode;return V(n),await n(t,r)}async function Lp(t,e,r){e=e||{};let o=(e.image||{}).type||"auto",{url:s}=r||{},i=U_(o),a;switch(i){case"imagebitmap":a=await Rp(t,e,s);break;case"image":a=await Cs(t,e,s);break;case"data":a=await wp(t,e);break;default:V(!1)}return o==="data"&&(a=jn(a)),a}function U_(t){switch(t){case"auto":case"data":return Sp();default:return Mp(t),t}}var G_=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],H_=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],V_={image:{type:"auto",decode:!0}},kr={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:_p,mimeTypes:H_,extensions:G_,parse:Lp,tests:[t=>Boolean(ar(new DataView(t)))],options:V_};var bc={};function yc(t){if(bc[t]===void 0){let e=Pn?k_(t):z_(t);bc[t]=e}return bc[t]}function z_(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&r.includes(t)}function k_(t){switch(t){case"image/avif":case"image/webp":return q_(t);default:return!0}}function q_(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}var Is={name:"Web Map Service (OGC WMS)",id:"wms",module:"wms",version:"0.0.0",extensions:[],mimeTypes:[],type:"wms",fromUrl:!0,fromBlob:!1,defaultOptions:{wms:{}},testURL:t=>t.toLowerCase().includes("wms"),createDataSource:(t,e)=>new Bs(t,e)},Bs=class extends Vr{substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e,r){super(e,r,Is.defaultOptions),this.substituteCRS84=r.wms?.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...r.wmsParameters,...r.wms?.wmsParameters},this.vendorParameters=r.wms?.vendorParameters||r.vendorParameters||{}}async getMetadata(){let e=await this.getCapabilities();return this.normalizeMetadata(e)}async getImage(e){let{boundingBox:r,bbox:n,...o}=e,s={bbox:r?[...r[0],...r[1]]:n,...o};return await this.getMap(s)}normalizeMetadata(e){return e}async getCapabilities(e,r){let n=this.getCapabilitiesURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();this._checkResponse(o,s);let i=await zr.parse(s,this.loadOptions);return this.capabilities=i,i}async getMap(e,r){let n=this.getMapURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();this._checkResponse(o,s);try{return await kr.parse(s,this.loadOptions)}catch{throw this._parseError(s)}}async getFeatureInfo(e,r){let n=this.getFeatureInfoURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();return this._checkResponse(o,s),await Tp.parse(s,this.loadOptions)}async getFeatureInfoText(e,r){let n=this.getFeatureInfoURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();return this._checkResponse(o,s),new TextDecoder().decode(s)}async describeLayer(e,r){let n=this.describeLayerURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();return this._checkResponse(o,s),await Ep.parse(s,this.loadOptions)}async getLegendGraphic(e,r){let n=this.getLegendGraphicURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();this._checkResponse(o,s);try{return await kr.parse(s,this.loadOptions)}catch{throw this._parseError(s)}}getCapabilitiesURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetCapabilities",n,r)}getMapURL(e,r){e=this._getWMS130Parameters(e);let n={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetMap",n,r)}getFeatureInfoURL(e,r){e=this._getWMS130Parameters(e);let{boundingBox:n,bbox:o}=e;e.bbox=n?[...n[0],...n[1]]:o;let s={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",s,r)}describeLayerURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("DescribeLayer",n,r)}getLegendGraphicURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetLegendGraphic",n,r)}_parseWMSUrl(e){let[r,n]=e.split("?"),o=n.split("&"),s={};for(let i of o){let[a,c]=i.split("=");s[a]=c}return{url:r,parameters:s}}_getWMSUrl(e,r,n){let o=this.url,s=!0,i={service:"WMS",version:r.version,request:e,...r,...this.vendorParameters,...n},a=["transparent","time","elevation"];for(let[c,l]of Object.entries(i))(!a.includes(c)||l)&&(o+=s?"?":"&",s=!1,o+=this._getURLParameter(c,l,r));return encodeURI(o)}_getWMS130Parameters(e){let r={...e};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(e,r,n){switch(e){case"crs":n.version!=="1.3.0"?e="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":n.version==="1.3.0"&&(e="crs");break;case"bbox":let o=this._flipBoundingBox(r,n);o&&(r=o);break;case"x":n.version==="1.3.0"&&(e="i");break;case"y":n.version==="1.3.0"&&(e="j");break;default:}return e=e.toUpperCase(),Array.isArray(r)?`${e}=${r.join(",")}`:`${e}=${r?String(r):""}`}_flipBoundingBox(e,r){if(!Array.isArray(e)||e.length!==4)return null;let n=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),o=e;return n?[o[1],o[0],o[3],o[2]]:o}async _fetchArrayBuffer(e){let r=await this.fetch(e),n=await r.arrayBuffer();return this._checkResponse(r,n),n}_checkResponse(e,r){let n=e.headers["content-type"];if(!e.ok||zn.mimeTypes.includes(n)){let o=Nn(this.loadOptions,{wms:{throwOnError:!0}}),s=zn.parseSync?.(r,o);throw new Error(s)}}_parseError(e){let r=zn.parseSync?.(e,this.options.core?.loadOptions);return new Error(r)}};function Rs(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var Qe=Math.PI,Op=Qe/4,Fp=Qe/180,Pp=180/Qe,vs=512;function dt(t){let[e,r]=t;Rs(Number.isFinite(e)),Rs(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let n=e*Fp,o=r*Fp,s=vs*(n+Qe)/(2*Qe),i=vs*(Qe+Math.log(Math.tan(Op+o*.5)))/(2*Qe);return[s,i]}function mt(t){let[e,r]=t,n=e/vs*(2*Qe)-Qe,o=2*(Math.atan(Math.exp(r/vs*(2*Qe)-Qe))-Op);return[n*Pp,o*Pp]}var cO=Math.PI/180;var Up=6378137*Math.PI;function Tc(t){let e=dt(t);return e[0]=(e[0]/256-1)*Up,e[1]=(e[1]/256-1)*Up,e}var iM={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(t,e)=>console.error(e,t)}},qr=class extends cr.CompositeLayer{get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:e,props:r,oldProps:n}){let{viewport:o}=this.context;e.dataChanged||r.serviceType!==n.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(o,"image source changed"),0)):(0,cr._deepEqual)(r.layers,n.layers,1)?e.viewportChanged&&this.debounce(()=>this.loadImage(o,"viewport changed")):this.debounce(()=>this.loadImage(o,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:e,image:r,lastRequestParameters:n}=this.state;return r&&new Gp.BitmapLayer({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:n.srs==="EPSG:4326"?cr.COORDINATE_SYSTEM.LNGLAT:cr.COORDINATE_SYSTEM.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,r){let{lastRequestParameters:n}=this.state;return n?await this.state.imageSource.getFeatureInfoText?.({...n,query_layers:n.layers,x:e,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(e){if(e.data instanceof Ft)return e.data;if(typeof e.data=="string")return(0,Hp.createDataSource)(e.data,[Is],{core:{type:e.serviceType,loadOptions:e.loadOptions}});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:e}=this.state;try{this.state.loadCounter++;let r=await e.getMetadata();this.state.imageSource===e&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(e,r){let{layers:n,serviceType:o}=this.props;if(o==="wms"&&n.length===0)return;let s=e.getBounds(),{width:i,height:a}=e,c=this.getRequestId(),{srs:l}=this.props;l==="auto"&&(l=e.resolution?"EPSG:4326":"EPSG:3857");let f={width:i,height:a,boundingBox:[[s[0],s[1]],[s[2],s[3]]],layers:n,crs:l};if(l==="EPSG:3857"){let u=Tc([s[0],s[1]]),h=Tc([s[2],s[3]]);f.boundingBox=[u,h]}try{this.state.loadCounter++,this.props.onImageLoadStart(c);let u=await this.state.imageSource.getImage(f);this.state.lastRequestId<c&&(this.getCurrentLayer()?.props.onImageLoad(c),this.setState({image:u,bounds:s,lastRequestParameters:f,lastRequestId:c}))}catch(u){this.raiseError(u,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(c,u)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(e,r=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>e(),r)}};qr.layerName="WMSLayer";qr.defaultProps=iM;var Vp=D(We(),1),aM={getHeight:{type:"accessor",value:0},greatCircle:!0},Xn=class extends Vp.ArcLayer{};Xn.layerName="GreatCircleLayer";Xn.defaultProps=aM;var zp=Xn;var ws=D(Ec(),1),cM=3,lM=30,fM=2*lM+1,qp=180/Math.PI;function Jp(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function jp(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function Wp(t){return[jp(t[0]),jp(t[1])]}function Xp(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function Yp([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*qp,n*qp]}function Kp(t){let e=ws.default.fromString(t,!0,10).toString(2);for(;e.length<cM+fM;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),o=e.substring(3,r),s=o.length/2,i=ws.default.fromString(n,!0,2).toString(10),a=ws.default.fromString(o,!0,2).toString(4);for(;a.length<s;)a="0"+a;return`${i}/${a}`}function uM(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let o=e[0];e[0]=e[1],e[1]=o}}function Qp(t){let e=t.split("/"),r=parseInt(e[0],10),n=e[1],o=n.length,s=[0,0],i;for(let a=o-1;a>=0;a--){i=o-a;let c=n[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,i-1);uM(u,s,l,f),s[0]+=u*l,s[1]+=u*f}if(r%2===1){let a=s[0];s[0]=s[1],s[1]=a}return{face:r,ij:s,level:i}}var Zp=D(Ec(),1);function hM(t){let e=t.padEnd(16,"0");return Zp.default.fromString(e,16)}var pM=100;function dM({face:t,ij:e,level:r}){let n=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(pM*Math.pow(2,-r))),s=new Float64Array(4*o*2+2),i=0,a=0;for(let c=0;c<4;c++){let l=n[c].slice(0),f=n[c+1],u=(f[0]-l[0])/o,h=(f[1]-l[1])/o;for(let p=0;p<o;p++){l[0]+=u,l[1]+=h;let d=Jp(e,r,l),A=Wp(d),m=Xp(t,A),b=Yp(m);Math.abs(b[1])>89.999&&(b[0]=a);let T=b[0]-a;b[0]+=T>180?-360:T<-180?360:0,s[i++]=b[0],s[i++]=b[1],a=b[0]}}return s[i++]=s[0],s[i++]=s[1],s}function mM(t){if(typeof t=="string"){if(t.indexOf("/")>0)return t;t=hM(t)}return Kp(t.toString())}function $p(t){let e=mM(t),r=Qp(e);return dM(r)}var gM={getS2Token:{type:"accessor",value:t=>t.token}},Kn=class extends De{indexToBounds(){let{data:e,getS2Token:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(n,o)=>$p(r(n,o))}}};Kn.layerName="S2Layer";Kn.defaultProps=gM;var ed=Kn;var _c=512;function AM(t,e){let r=0,n=0,o=1<<t.length,s=o/_c;for(let i=0;i<t.length;i++){o>>=1;let a=parseInt(t[i]);a%2&&(r|=o),a>1&&(n|=o)}return[[r/s,_c-n/s],[(r+e)/s,_c-(n+e)/s]]}function td(t,e=1){let[r,n]=AM(t,e),[o,s]=mt(r),[i,a]=mt(n);return[i,s,i,a,o,a,o,s,i,s]}var xM={getQuadkey:{type:"accessor",value:t=>t.quadkey}},Qn=class extends De{indexToBounds(){let{data:e,extruded:r,getQuadkey:n}=this.props,o=r?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(s,i)=>td(n(s,i),o),updateTriggers:{getPolygon:o}}}};Qn.layerName="QuadkeyLayer";Qn.defaultProps=xM;var rd=Qn;var Gs=D(Xe(),1),bd=D(We(),1);var lr=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,requestScheduler:r,onLoad:n,onError:o}){let{index:s,id:i,bbox:a,userData:c,zoom:l}=this,f=this._loaderId;this._abortController=new AbortController;let{signal:u}=this._abortController,h=await r.scheduleRequest(this,A=>A.isSelected?1:-1);if(!h){this._isCancelled=!0;return}if(this._isCancelled){h.done();return}let p=null,d;try{p=await e({index:s,id:i,bbox:a,userData:c,zoom:l,signal:u})}catch(A){d=A||!0}finally{h.done()}if(f===this._loaderId){if(this._loader=void 0,this.content=p,this._isCancelled&&!p){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,d?o(d,this):n(this)}}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};var eo=D(Xe(),1);var ie={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var nd=new x,bM=new x,Pt=class{constructor(e=[0,0,0],r=[0,0,0],n){n=n||nd.copy(e).add(r).scale(.5),this.center=new x(n),this.halfDiagonal=new x(r).subtract(this.center),this.minimum=new x(e),this.maximum=new x(r)}clone(){return new Pt(this.minimum,this.maximum,this.center)}equals(e){return this===e||Boolean(e)&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){let{halfDiagonal:r}=this,n=bM.from(e.normal),o=r.x*Math.abs(n.x)+r.y*Math.abs(n.y)+r.z*Math.abs(n.z),s=this.center.dot(n)+e.distance;return s-o>0?ie.INSIDE:s+o<0?ie.OUTSIDE:ie.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=nd.from(e).subtract(this.center),{halfDiagonal:n}=this,o=0,s;return s=Math.abs(r.x)-n.x,s>0&&(o+=s*s),s=Math.abs(r.y)-n.y,s>0&&(o+=s*s),s=Math.abs(r.z)-n.z,s>0&&(o+=s*s),o}};var Zn=new x,od=new x,He=class{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new x,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=Zn.from(r),this.center=new x().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new He(this.center,this.radius)}union(e){let r=this.center,n=this.radius,o=e.center,s=e.radius,i=Zn.copy(o).subtract(r),a=i.magnitude();if(n>=a+s)return this.clone();if(s>=a+n)return e.clone();let c=(n+a+s)*.5;return od.copy(i).scale((-n+c)/a).add(r),this.center.copy(od),this.radius=c,this}expand(e){let n=Zn.from(e).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(e){this.center.transform(e);let r=Cn.getScaling(Zn,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let n=Zn.from(e).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(e){let r=this.center,n=this.radius,s=e.normal.dot(r)+e.distance;return s<-n?ie.OUTSIDE:s<n?ie.INTERSECTING:ie.INSIDE}};var yM=new x,TM=new x,Ls=new x,Fs=new x,Ps=new x,EM=new x,_M=new x,gt={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},Ze=class{constructor(e=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new x().from(e),this.halfAxes=new j(r)}get halfSize(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new x(e).len(),new x(r).len(),new x(n).len()]}get quaternion(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),o=new x(e).normalize(),s=new x(r).normalize(),i=new x(n).normalize();return new ot().fromMatrix3(new j([...o,...s,...i]))}fromCenterHalfSizeQuaternion(e,r,n){let o=new ot(n),s=new j().fromQuaternion(o);return s[0]=s[0]*r[0],s[1]=s[1]*r[0],s[2]=s[2]*r[0],s[3]=s[3]*r[1],s[4]=s[4]*r[1],s[5]=s[5]*r[1],s[6]=s[6]*r[2],s[7]=s[7]*r[2],s[8]=s[8]*r[2],this.center=new x().from(e),this.halfAxes=s,this}clone(){return new Ze(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new He){let r=this.halfAxes,n=r.getColumn(0,Ls),o=r.getColumn(1,Fs),s=r.getColumn(2,Ps),i=yM.copy(n).add(o).add(s);return e.center.copy(this.center),e.radius=i.magnitude(),e}intersectPlane(e){let r=this.center,n=e.normal,o=this.halfAxes,s=n.x,i=n.y,a=n.z,c=Math.abs(s*o[gt.COLUMN0ROW0]+i*o[gt.COLUMN0ROW1]+a*o[gt.COLUMN0ROW2])+Math.abs(s*o[gt.COLUMN1ROW0]+i*o[gt.COLUMN1ROW1]+a*o[gt.COLUMN1ROW2])+Math.abs(s*o[gt.COLUMN2ROW0]+i*o[gt.COLUMN2ROW1]+a*o[gt.COLUMN2ROW2]),l=n.dot(r)+e.distance;return l<=-c?ie.OUTSIDE:l>=c?ie.INSIDE:ie.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=TM.from(e).subtract(this.center),n=this.halfAxes,o=n.getColumn(0,Ls),s=n.getColumn(1,Fs),i=n.getColumn(2,Ps),a=o.magnitude(),c=s.magnitude(),l=i.magnitude();o.normalize(),s.normalize(),i.normalize();let f=0,u;return u=Math.abs(r.dot(o))-a,u>0&&(f+=u*u),u=Math.abs(r.dot(s))-c,u>0&&(f+=u*u),u=Math.abs(r.dot(i))-l,u>0&&(f+=u*u),f}computePlaneDistances(e,r,n=[-0,-0]){let o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,i=this.center,a=this.halfAxes,c=a.getColumn(0,Ls),l=a.getColumn(1,Fs),f=a.getColumn(2,Ps),u=EM.copy(c).add(l).add(f).add(i),h=_M.copy(u).subtract(e),p=r.dot(h);return o=Math.min(p,o),s=Math.max(p,s),u.copy(i).add(c).add(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),u.copy(i).add(c).subtract(l).add(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),u.copy(i).add(c).subtract(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).add(l).add(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).add(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).subtract(l).add(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).subtract(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),n[0]=o,n[1]=s,n}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,Ls);r.transformAsPoint(e);let n=this.halfAxes.getColumn(1,Fs);n.transformAsPoint(e);let o=this.halfAxes.getColumn(2,Ps);return o.transformAsPoint(e),this.halfAxes=new j([...r,...n,...o]),this}getTransform(){throw new Error("not implemented")}};var sd=new x,id=new x,he=class{constructor(e=[0,0,1],r=0){this.normal=new x,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return ue(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=sd.from(e),this.normal.from(r).normalize();let n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,r,n,o){return this.normal.set(e,r,n),ue(Me(this.normal.len(),1)),this.distance=o,this}clone(){return new he(this.normal,this.distance)}equals(e){return Me(this.distance,e.distance)&&Me(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=id.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,r)}projectPointOntoPlane(e,r=[0,0,0]){let n=sd.from(e),o=this.getPointDistance(n),s=id.copy(this.normal).scale(o);return n.subtract(s).to(r)}};var ad=[new x([1,0,0]),new x([0,1,0]),new x([0,0,1])],cd=new x,MM=new x,ce=class{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*ad.length;let r=e.center,n=e.radius,o=0;for(let s of ad){let i=this.planes[o],a=this.planes[o+1];i||(i=this.planes[o]=new he),a||(a=this.planes[o+1]=new he);let c=cd.copy(s).scale(-n).add(r);i.fromPointNormal(c,s);let l=cd.copy(s).scale(n).add(r),f=MM.copy(s).negate();a.fromPointNormal(l,f),o+=2}return this}computeVisibility(e){let r=ie.INSIDE;for(let n of this.planes)switch(e.intersectPlane(n)){case ie.OUTSIDE:return ie.OUTSIDE;case ie.INTERSECTING:r=ie.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(ue(Number.isFinite(r),"parentPlaneMask is required."),r===ce.MASK_OUTSIDE||r===ce.MASK_INSIDE)return r;let n=ce.MASK_INSIDE,o=this.planes;for(let s=0;s<this.planes.length;++s){let i=s<31?1<<s:0;if(s<31&&!(r&i))continue;let a=o[s],c=e.intersectPlane(a);if(c===ie.OUTSIDE)return ce.MASK_OUTSIDE;c===ie.INTERSECTING&&(n|=i)}return n}};ce.MASK_OUTSIDE=4294967295;ce.MASK_INSIDE=0;ce.MASK_INDETERMINATE=2147483647;var MD=new x,SD=new x,CD=new x,BD=new x,ID=new x;var PD=new x,ND=new x,OD=new x,DD=new x,UD=new x,GD=new x,HD=new x,VD=new x,zD=new x,kD=new x,qD=new x,jD=new x;var ct=new j,CM=new j,BM=new j,Ns=new j,ld=new j;function Cc(t,e={}){let r=Ue.EPSILON20,n=10,o=0,s=0,i=CM,a=BM;i.identity(),a.copy(t);let c=r*IM(a);for(;s<n&&RM(a)>c;)vM(a,Ns),ld.copy(Ns).transpose(),a.multiplyRight(Ns),a.multiplyLeft(ld),i.multiplyRight(Ns),++o>2&&(++s,o=0);return e.unitary=i.toTarget(e.unitary),e.diagonal=a.toTarget(e.diagonal),e}function IM(t){let e=0;for(let r=0;r<9;++r){let n=t[r];e+=n*n}return Math.sqrt(e)}var Mc=[1,0,0],Sc=[2,2,1];function RM(t){let e=0;for(let r=0;r<3;++r){let n=t[ct.getElementIndex(Sc[r],Mc[r])];e+=2*n*n}return Math.sqrt(e)}function vM(t,e){let r=Ue.EPSILON15,n=0,o=1;for(let l=0;l<3;++l){let f=Math.abs(t[ct.getElementIndex(Sc[l],Mc[l])]);f>n&&(o=l,n=f)}let s=Mc[o],i=Sc[o],a=1,c=0;if(Math.abs(t[ct.getElementIndex(i,s)])>r){let l=t[ct.getElementIndex(i,i)],f=t[ct.getElementIndex(s,s)],u=t[ct.getElementIndex(i,s)],h=(l-f)/2/u,p;h<0?p=-1/(-h+Math.sqrt(1+h*h)):p=1/(h+Math.sqrt(1+h*h)),a=1/Math.sqrt(1+p*p),c=p*a}return j.IDENTITY.to(e),e[ct.getElementIndex(s,s)]=e[ct.getElementIndex(i,i)]=a,e[ct.getElementIndex(i,s)]=c,e[ct.getElementIndex(s,i)]=-c,e}var Nt=new x,wM=new x,LM=new x,FM=new x,PM=new x,NM=new j,OM={diagonal:new j,unitary:new j};function $n(t,e=new Ze){if(!t||t.length===0)return e.halfAxes=new j([0,0,0,0,0,0,0,0,0]),e.center=new x,e;let r=t.length,n=new x(0,0,0);for(let y of t)n.add(y);let o=1/r;n.multiplyByScalar(o);let s=0,i=0,a=0,c=0,l=0,f=0;for(let y of t){let g=Nt.copy(y).subtract(n);s+=g.x*g.x,i+=g.x*g.y,a+=g.x*g.z,c+=g.y*g.y,l+=g.y*g.z,f+=g.z*g.z}s*=o,i*=o,a*=o,c*=o,l*=o,f*=o;let u=NM;u[0]=s,u[1]=i,u[2]=a,u[3]=i,u[4]=c,u[5]=l,u[6]=a,u[7]=l,u[8]=f;let{unitary:h}=Cc(u,OM),p=e.halfAxes.copy(h),d=p.getColumn(0,LM),A=p.getColumn(1,FM),m=p.getColumn(2,PM),b=-Number.MAX_VALUE,T=-Number.MAX_VALUE,E=-Number.MAX_VALUE,_=Number.MAX_VALUE,S=Number.MAX_VALUE,C=Number.MAX_VALUE;for(let y of t)Nt.copy(y),b=Math.max(Nt.dot(d),b),T=Math.max(Nt.dot(A),T),E=Math.max(Nt.dot(m),E),_=Math.min(Nt.dot(d),_),S=Math.min(Nt.dot(A),S),C=Math.min(Nt.dot(m),C);d=d.multiplyByScalar(.5*(_+b)),A=A.multiplyByScalar(.5*(S+T)),m=m.multiplyByScalar(.5*(C+E)),e.center.copy(d).add(A).add(m);let v=wM.set(b-_,T-S,E-C).multiplyByScalar(.5),M=new j([v[0],0,0,0,v[1],0,0,0,v[2]]);return e.halfAxes.multiplyRight(M),e}var jr=512,fd=3,ud=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],hd=ud.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),DM=hd.concat([[.25,.5],[.75,.5]]),Ot=class{constructor(e,r,n){this.x=e,this.y=r,this.z=n}get children(){if(!this._children){let e=this.x*2,r=this.y*2,n=this.z+1;this._children=[new Ot(e,r,n),new Ot(e,r+1,n),new Ot(e+1,r,n),new Ot(e+1,r+1,n)]}return this._children}update(e){let{viewport:r,cullingVolume:n,elevationBounds:o,minZ:s,maxZ:i,bounds:a,offset:c,project:l}=e,f=this.getBoundingVolume(o,c,l);if(a&&!this.insideBounds(a)||n.computeVisibility(f)<0)return!1;if(!this.childVisible){let{z:h}=this;if(h<i&&h>=s){let p=f.distanceTo(r.cameraPosition)*r.scale/r.height;h+=Math.floor(Math.log2(p))}if(h>=i)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let h of this.children)h.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(let r of this._children)r.getSelected(e);return e}insideBounds([e,r,n,o]){let s=Math.pow(2,this.z),i=jr/s;return this.x*i<n&&this.y*i<o&&(this.x+1)*i>e&&(this.y+1)*i>r}getBoundingVolume(e,r,n){if(n){let c=this.z<1?DM:this.z<2?hd:ud,l=[];for(let f of c){let u=Os(this.x+f[0],this.y+f[1],this.z);u[2]=e[0],l.push(n(u)),e[0]!==e[1]&&(u[2]=e[1],l.push(n(u)))}return $n(l)}let o=Math.pow(2,this.z),s=jr/o,i=this.x*s+r*jr,a=jr-(this.y+1)*s;return new Pt([i,a,e[0]],[i+s,a+s,e[1]])}};function pd(t,e,r,n){let o=t instanceof eo._GlobeViewport&&t.resolution?t.projectPosition:null,s=Object.values(t.getFrustumPlanes()).map(({normal:p,distance:d})=>new he(p.clone().negate(),d)),i=new ce(s),a=t.distanceScales.unitsPerMeter[2],c=r&&r[0]*a||0,l=r&&r[1]*a||0,f=t instanceof eo.WebMercatorViewport&&t.pitch<=60?e:0;if(n){let[p,d,A,m]=n,b=dt([p,m]),T=dt([A,d]);n=[b[0],jr-b[1],T[0],jr-T[1]]}let u=new Ot(0,0,0),h={viewport:t,project:o,cullingVolume:i,elevationBounds:[c,l],minZ:f,maxZ:e,bounds:n,offset:0};if(u.update(h),t instanceof eo.WebMercatorViewport&&t.subViewports&&t.subViewports.length>1){for(h.offset=-1;u.update(h)&&!(--h.offset<-fd););for(h.offset=1;u.update(h)&&!(++h.offset>fd););}return u.getSelected()}var At=512,UM=[-1/0,-1/0,1/0,1/0],Dt={type:"object",value:null,validate:(t,e)=>e.optional&&t===null||typeof t=="string"||Array.isArray(t)&&t.every(r=>typeof r=="string"),equal:(t,e)=>{if(t===e)return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;let r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}};function Ds(t,e){let r=[e.transformAsPoint([t[0],t[1]]),e.transformAsPoint([t[2],t[1]]),e.transformAsPoint([t[0],t[3]]),e.transformAsPoint([t[2],t[3]])];return[Math.min(...r.map(o=>o[0])),Math.min(...r.map(o=>o[1])),Math.max(...r.map(o=>o[0])),Math.max(...r.map(o=>o[1]))]}function GM(t){return Math.abs(t.split("").reduce((e,r)=>(e<<5)-e+r.charCodeAt(0)|0,0))}function lt(t,e){if(!t||!t.length)return null;let{index:r,id:n}=e;if(Array.isArray(t)){let s=GM(n)%t.length;t=t[s]}let o=t;for(let s of Object.keys(r)){let i=new RegExp(`{${s}}`,"g");o=o.replace(i,String(r[s]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(o=o.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),o}function HM(t,e,r){let n;if(e&&e.length===2){let[o,s]=e,i=t.getBounds({z:o}),a=t.getBounds({z:s});n=[Math.min(i[0],a[0]),Math.min(i[1],a[1]),Math.max(i[2],a[2]),Math.max(i[3],a[3])]}else n=t.getBounds();return t.isGeospatial?[Math.max(n[0],r[0]),Math.max(n[1],r[1]),Math.min(n[2],r[2]),Math.min(n[3],r[3])]:[Math.max(Math.min(n[0],r[2]),r[0]),Math.max(Math.min(n[1],r[3]),r[1]),Math.min(Math.max(n[2],r[0]),r[2]),Math.min(Math.max(n[3],r[1]),r[3])]}function md({viewport:t,z:e,cullRect:r}){return(t.subViewports||[t]).map(o=>Bc(o,e||0,r))}function Bc(t,e,r){if(!Array.isArray(e)){let s=r.x-t.x,i=r.y-t.y,{width:a,height:c}=r,l={targetZ:e},f=t.unproject([s,i],l),u=t.unproject([s+a,i],l),h=t.unproject([s,i+c],l),p=t.unproject([s+a,i+c],l);return[Math.min(f[0],u[0],h[0],p[0]),Math.min(f[1],u[1],h[1],p[1]),Math.max(f[0],u[0],h[0],p[0]),Math.max(f[1],u[1],h[1],p[1])]}let n=Bc(t,e[0],r),o=Bc(t,e[1],r);return[Math.min(n[0],o[0]),Math.min(n[1],o[1]),Math.max(n[2],o[2]),Math.max(n[3],o[3])]}function VM(t,e,r){return r?Ds(t,r).map(o=>o*e/At):t.map(n=>n*e/At)}function Ic(t,e){return Math.pow(2,t)*At/e}function Os(t,e,r){let n=Ic(r,At),o=t/n*360-180,s=Math.PI-2*Math.PI*e/n,i=180/Math.PI*Math.atan(.5*(Math.exp(s)-Math.exp(-s)));return[o,i]}function dd(t,e,r,n){let o=Ic(r,n);return[t/o*At,e/o*At]}function Rc(t,e,r,n,o=At){if(t.isGeospatial){let[l,f]=Os(e,r,n),[u,h]=Os(e+1,r+1,n);return{west:l,north:f,east:u,south:h}}let[s,i]=dd(e,r,n,o),[a,c]=dd(e+1,r+1,n,o);return{left:s,top:i,right:a,bottom:c}}function zM(t,e,r,n,o){let s=HM(t,null,n),i=Ic(e,r),[a,c,l,f]=VM(s,i,o),u=[];for(let h=Math.floor(a);h<l;h++)for(let p=Math.floor(c);p<f;p++)u.push({x:h,y:p,z:e});return u}function vc({viewport:t,maxZoom:e,minZoom:r,zRange:n,extent:o,tileSize:s=At,modelMatrix:i,modelMatrixInverse:a,zoomOffset:c=0}){let l=t.isGeospatial?Math.round(t.zoom+Math.log2(At/s))+c:Math.ceil(t.zoom)+c;if(typeof r=="number"&&Number.isFinite(r)&&l<r){if(!o)return[];l=r}typeof e=="number"&&Number.isFinite(e)&&l>e&&(l=e);let f=o;return i&&a&&o&&!t.isGeospatial&&(f=Ds(o,i)),t.isGeospatial?pd(t,l,n,o):zM(t,l,s,f||UM,a)}function wc(t){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(t)}function Lc(t){return Number.isFinite(t.west)&&Number.isFinite(t.north)&&Number.isFinite(t.east)&&Number.isFinite(t.south)}function gd(t){let e={},r;return n=>{for(let o in n)if(!kM(n[o],e[o])){r=t(n),e=n;break}return r}}function kM(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}return!1}var Ad=1,Us=2,qM="never",jM="no-overlap",to="best-available",JM=5,WM={[to]:YM,[jM]:KM,[qM]:()=>{}},XM={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}},fr=class{constructor(e){this._getCullBounds=gd(md),this.opts={...XM,...e},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize!==null&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new vt({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new N,this._modelMatrixInverse=new N}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return this._selectedTiles!==null&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom))}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let e of this._cache.keys()){let r=this._cache.get(e);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(e):r.setNeedsReload()}}update(e,{zRange:r,modelMatrix:n}={zRange:null,modelMatrix:null}){let o=n?new N(n):new N,s=!o.equals(this._modelMatrix);if(!this._viewport||!e.equals(this._viewport)||!Me(this._zRange,r)||s){s&&(this._modelMatrixInverse=o.clone().invert(),this._modelMatrix=o),this._viewport=e,this._zRange=r;let a=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:r,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=a.map(c=>this._getTile(c,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(a=>this._getTile(a.index,!0)));let i=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),i&&this._frameNumber++,this._frameNumber}isTileVisible(e,r,n){if(!e.isVisible)return!1;if(r&&this._viewport){let o=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:s}=e;for(let[i,a,c,l]of o){let f;if("west"in s)f=s.west<c&&s.east>i&&s.south<l&&s.north>a;else{if(n&&!N.IDENTITY.equals(n)){let[p,d,A,m]=Ds([s.left,s.top,s.right,s.bottom],n);s={left:p,top:d,right:A,bottom:m}}let u=Math.min(s.top,s.bottom),h=Math.max(s.top,s.bottom);f=s.left<c&&s.right>i&&u<l&&h>a}if(f)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:r,minZoom:n,zRange:o,modelMatrix:s,modelMatrixInverse:i}){let{tileSize:a,extent:c,zoomOffset:l}=this.opts;return vc({viewport:e,maxZoom:r,minZoom:n,zRange:o,tileSize:a,extent:c,modelMatrix:s,modelMatrixInverse:i,zoomOffset:l})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){let{tileSize:r}=this.opts;return{bbox:Rc(this._viewport,e.x,e.y,e.z,r)}}getParentIndex(e){let r=Math.floor(e.x/2),n=Math.floor(e.y/2),o=e.z-1;return{x:r,y:n,z:o}}updateTileStates(){let e=this.opts.refinementStrategy||to,r=new Array(this._cache.size),n=0;for(let o of this._cache.values())r[n++]=o.isVisible,o.isSelected=!1,o.isVisible=!1;for(let o of this._selectedTiles)o.isSelected=!0,o.isVisible=!0;(typeof e=="function"?e:WM[e])(Array.from(this._cache.values())),n=0;for(let o of this._cache.values())if(r[n++]!==o.isVisible)return!0;return!1}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=[],n=0;for(let o of this._cache.values())o.isLoading&&(n++,!o.isSelected&&!o.isVisible&&r.push(o));for(;e>0&&n>e&&r.length>0;)r.shift().abort(),n--}_rebuildTree(){let{_cache:e}=this;for(let r of e.values())r.parent=null,r.children&&(r.children.length=0);for(let r of e.values()){let n=this._getNearestAncestor(r);r.parent=n,n?.children&&n.children.push(r)}}_resizeCache(){let{_cache:e,opts:r}=this,n=r.maxCacheSize??(r.maxCacheByteSize!==null?1/0:JM*this.selectedTiles.length),o=r.maxCacheByteSize??1/0;if(e.size>n||this._cacheByteSize>o){for(let[i,a]of e)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize!==null?a.byteLength:0,e.delete(i),this.opts.onTileUnload?.(a)),e.size<=n&&this._cacheByteSize<=o)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((i,a)=>i.zoom-a.zoom),this._dirty=!1)}_getTile(e,r){let n=this.getTileId(e),o=this._cache.get(n),s=!1;return!o&&r?(o=new lr(e),Object.assign(o,this.getTileMetadata(o.index)),Object.assign(o,{id:n,zoom:this.getTileZoom(o.index)}),s=!0,this._cache.set(n,o),this._dirty=!0):o&&o.needsReload&&(s=!0),o&&s&&o.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),o}_getNearestAncestor(e){let{_minZoom:r=0}=this,n=e.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let o=this._getTile(n);if(o)return o}return null}};function YM(t){for(let e of t)e.state=0;for(let e of t)e.isSelected&&!xd(e)&&Fc(e);for(let e of t)e.isVisible=Boolean(e.state&Us)}function KM(t){for(let r of t)r.state=0;for(let r of t)r.isSelected&&xd(r);let e=Array.from(t).sort((r,n)=>r.zoom-n.zoom);for(let r of e)if(r.isVisible=Boolean(r.state&Us),r.children&&(r.isVisible||r.state&Ad))for(let n of r.children)n.state=Ad;else r.isSelected&&Fc(r)}function xd(t){let e=t;for(;e;){if(e.isLoaded||e.content)return e.state|=Us,!0;e=e.parent}return!1}function Fc(t){for(let e of t.children)e.isLoaded||e.content?e.state|=Us:Fc(e)}var QM={TilesetClass:fr,data:{type:"data",value:[]},dataComparator:Dt.equal,renderSubLayers:{type:"function",value:t=>new bd.GeoJsonLayer(t)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:t=>console.error(t)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:to,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0},ro=class extends Gs.CompositeLayer{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&(!e.content||!e.layers||e.layers.every(r=>r.isLoaded))))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:r}=this.state,n=e.propsOrDataChanged||e.updateTriggersChanged,o=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);r?n&&(r.setOptions(this._getTilesetOptions()),o?r.reloadAll():r.tiles.forEach(s=>{s.layers=null})):(r=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:r})),this._updateTileset()}_getTilesetOptions(){let{tileSize:e,maxCacheSize:r,maxCacheByteSize:n,refinementStrategy:o,extent:s,maxZoom:i,minZoom:a,maxRequests:c,debounceTime:l,zoomOffset:f}=this.props;return{maxCacheSize:r,maxCacheByteSize:n,maxZoom:i,minZoom:a,tileSize:e,refinementStrategy:o,extent:s,maxRequests:c,debounceTime:l,zoomOffset:f,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let e=this.state.tileset,{zRange:r,modelMatrix:n}=this.props,o=e.update(this.context.viewport,{zRange:r,modelMatrix:n}),{isLoaded:s}=e,i=this.state.isLoaded!==s,a=this.state.frameNumber!==o;s&&(i||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:o}),this.state.isLoaded=s}_onViewportLoad(){let{tileset:e}=this.state,{onViewportLoad:r}=this.props;r&&r(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,r){this.props.onTileError(e),r.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){let{data:r,getTileData:n,fetch:o}=this.props,{signal:s}=e;return e.url=typeof r=="string"||Array.isArray(r)?lt(r,e):null,n?n(e):o&&e.url?o(e.url,{propName:"data",layer:this,signal:s}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){let r=e.sourceLayer,n=r.props.tile,o=e.info;return o.picked&&(o.tile=n),o.sourceTile=n,o.sourceTileSubLayer=r,o}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){return this.state.tileset.tiles.map(e=>{let r=this.getSubLayerPropsByTile(e);if(!(!e.isLoaded&&!e.content))if(e.layers)r&&e.layers[0]&&Object.keys(r).some(n=>e.layers[0].props[n]!==r[n])&&(e.layers=e.layers.map(n=>n.clone(r)));else{let n=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:e.id,updateTriggers:this.props.updateTriggers}),data:e.content,_offset:0,tile:e});e.layers=(0,Gs._flatten)(n,Boolean).map(o=>o.clone({tile:e,...r}))}return e.layers})}filterSubLayer({layer:e,cullRect:r}){let{tile:n}=e.props,{modelMatrix:o}=this.props;return this.state.tileset.isTileVisible(n,r,o?new N(o):null)}};ro.defaultProps=QM;ro.layerName="TileLayer";var ur=ro;var Ed=D(We(),1);var yd=`layout(std140) uniform tripsUniforms {
11
11
  bool fadeTrail;
12
12
  float trailLength;
13
13
  float currentTime;
14
14
  } trips;
15
- `,bp={name:"trips",vs:Tp,fs:Tp,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};var X_={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:t=>t.timestamps}},es=class extends Ep.PathLayer{getShaders(){let e=super.getShaders();return e.inject={"vs:#decl":`in float instanceTimestamps;
15
+ `,Td={name:"trips",vs:yd,fs:yd,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};var ZM={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:t=>t.timestamps}},no=class extends Ed.PathLayer{getShaders(){let e=super.getShaders();return e.inject={"vs:#decl":`in float instanceTimestamps;
16
16
  in float instanceNextTimestamps;
17
17
  out float vTime;
18
18
  `,"vs:#main-end":`vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength;
@@ -23,7 +23,7 @@ out float vTime;
23
23
  `,"fs:DECKGL_FILTER_COLOR":`if(trips.fadeTrail) {
24
24
  color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;
25
25
  }
26
- `},e.modules=[...e.modules,bp],e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(e){let{fadeTrail:r,trailLength:n,currentTime:s}=this.props,o={fadeTrail:r,trailLength:n,currentTime:s};this.state.model.shaderInputs.setProps({trips:o}),super.draw(e)}};es.layerName="TripsLayer";es.defaultProps=X_;var Mp=es;var _p=D(Zs(),1),Bp=D(Je(),1);var Ue=D(Zs(),1),Vo=D(Je(),1),ts=D(je(),1);var Y_=10;function K_(t,e){let r;return t==null?r=e:typeof t=="object"?r={...t,coverage:e}:r={getHexagon:t,coverage:e},r}var Q_={...ts.PolygonLayer.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:t=>t.hexagon},extruded:!0},Nt=class extends Vo.CompositeLayer{initializeState(){Nt._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:r}){if(e.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let n=this._calculateH3DataProps();this.setState(n)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,r=!1,n=!1,{iterable:s,objectInfo:o}=(0,Vo.createIterable)(this.props.data);for(let i of s){o.index++;let a=this.props.getHexagon(i,o),c=(0,Ue.getResolution)(a);if(e<0){if(e=c,!this.props.highPrecision)break}else if(e!==c){n=!0;break}if((0,Ue.isPentagon)(a)){r=!0;break}}return{resolution:e,edgeLengthKM:e>=0?(0,Ue.getHexagonEdgeLengthAvg)(e,"km"):0,hasMultipleRes:n,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:e,hasPentagon:r,hasMultipleRes:n}=this.state,{viewport:s}=this.context;return Boolean(s?.resolution)||n||r||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:n,centerHex:s}=this.state;if(r<0)return;let o=this.props.centerHexagon||(0,Ue.latLngToCell)(e.latitude,e.longitude,r);if(s===o)return;if(s)try{if((0,Ue.gridDistance)(s,o)*n<Y_)return}catch{}let{unitsPerMeter:i}=e.distanceScales,a=ka(o),[c,l]=(0,Ue.cellToLatLng)(o),[f,u]=e.projectFlat([l,c]);a=a.map(h=>{let d=e.projectFlat(h);return[(d[0]-f)/i[0],(d[1]-u)/i[1]]}),this.setState({centerHex:o,vertices:a})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:e,material:r,coverage:n,extruded:s,wireframe:o,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,getFillColor:h,getElevation:d,getLineColor:p,getLineWidth:A,transitions:m,updateTriggers:y}=this.props;return{elevationScale:e,extruded:s,coverage:n,wireframe:o,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,material:r,getElevation:d,getFillColor:h,getLineColor:p,getLineWidth:A,transitions:m,updateTriggers:{getFillColor:y.getFillColor,getElevation:y.getElevation,getLineColor:y.getLineColor,getLineWidth:y.getLineWidth}}}_renderPolygonLayer(){let{data:e,getHexagon:r,updateTriggers:n,coverage:s}=this.props,o=this.getSubLayerClass("hexagon-cell-hifi",ts.PolygonLayer),i=this._getForwardProps();return i.updateTriggers.getPolygon=K_(n.getHexagon,s),new o(i,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:i.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,c)=>{let l=r(a,c);return mo(ka(l,s))}})}_renderColumnLayer(){let{data:e,getHexagon:r,updateTriggers:n}=this.props,s=this.getSubLayerClass("hexagon-cell",ts.ColumnLayer),o=this._getForwardProps();return o.updateTriggers.getPosition=n.getHexagon,new s(o,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:o.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:Uh.bind(null,r)})}};Nt.defaultProps=Q_;Nt.layerName="H3HexagonLayer";Nt._checkH3Lib=()=>{};var Ho=Nt;var Z_={getHexagons:{type:"accessor",value:t=>t.hexagons}},rs=class extends Oe{initializeState(){Ho._checkH3Lib()}updateState({props:e,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:n,getHexagons:s}=e,o=[],{iterable:i,objectInfo:a}=(0,Bp.createIterable)(n);for(let c of i){a.index++;let l=s(c,a),f=(0,_p.cellsToMultiPolygon)(l,!0);for(let u of f){for(let h of u)po(h);o.push(this.getSubLayerRow({polygon:u},c,a.index))}}this.setState({polygons:o})}}indexToBounds(){let{getElevation:e,getFillColor:r,getLineColor:n,getLineWidth:s}=this.props;return{data:this.state.polygons,getPolygon:o=>o.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(n),getLineWidth:this.getSubLayerAccessor(s)}}};rs.layerName="H3ClusterLayer";rs.defaultProps=Z_;var Cp=rs;var c0=D(Rc(),1),Ht=D(Je(),1),l0=D(je(),1),f0=D(zo(),1);var wp="4.4.0-alpha.18";var ko={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},vp;async function Oc(t){nc(t.modules);let e=sc("basis");return e||(vp||=$_(t),await vp)}async function $_(t){let e=null,r=null;return[e,r]=await Promise.all([await De(ko.TRANSCODER,"textures",t),await De(ko.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await eB(e,r)}function eB(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t(r).then(s=>{let{BasisFile:o,initializeBasis:i}=s;i(),n({BasisFile:o})})})}var Pc;async function Nc(t){let e=t.modules||{};return e.basisEncoder?e.basisEncoder:(Pc=Pc||tB(t),await Pc)}async function tB(t){let e=null,r=null;return[e,r]=await Promise.all([await De(ko.ENCODER,"textures",t),await De(ko.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await rB(e,r)}function rB(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t(r).then(s=>{let{BasisFile:o,KTX2File:i,initializeBasis:a,BasisEncoder:c}=s;a(),n({BasisFile:o,KTX2File:i,BasisEncoder:c})})})}var nB=["","WEBKIT_","MOZ_"],Lp={WEBGL_compressed_texture_s3tc:["bc1-rgb-unorm-webgl","bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"],WEBGL_compressed_texture_s3tc_srgb:["bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"],EXT_texture_compression_rgtc:["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"],EXT_texture_compression_bptc:["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"],WEBGL_compressed_texture_etc1:["etc1-rbg-unorm-webgl"],WEBGL_compressed_texture_etc:["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"],WEBGL_compressed_texture_pvrtc:["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rbg2unorm-webgl","pvrtc-rgba2unorm-webgl"],WEBGL_compressed_texture_atc:["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"],WEBGL_compressed_texture_astc:["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]};var qo=null;function Fp(t){if(!qo){t=t||sB()||void 0,qo=new Set;for(let e of nB)for(let r in Lp)if(t&&t.getExtension(`${e}${r}`))for(let n of Lp[r])qo.add(n)}return qo}function sB(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var Re=[171,75,84,88,32,50,48,187,13,10,26,10];function Rp(t){let e=new Uint8Array(t);return!(e.byteLength<Re.length||e[0]!==Re[0]||e[1]!==Re[1]||e[2]!==Re[2]||e[3]!==Re[3]||e[4]!==Re[4]||e[5]!==Re[5]||e[6]!==Re[6]||e[7]!==Re[7]||e[8]!==Re[8]||e[9]!==Re[9]||e[10]!==Re[10]||e[11]!==Re[11])}var Np={etc1:{basisFormat:0,compressed:!0,format:36196,textureFormat:"etc1-rbg-unorm-webgl"},etc2:{basisFormat:1,compressed:!0,format:37493,textureFormat:"etc2-rgba8unorm"},bc1:{basisFormat:2,compressed:!0,format:33776,textureFormat:"bc1-rgb-unorm-webgl"},bc3:{basisFormat:3,compressed:!0,format:33779,textureFormat:"bc3-rgba-unorm"},bc4:{basisFormat:4,compressed:!0,format:36283,textureFormat:"bc4-r-unorm"},bc5:{basisFormat:5,compressed:!0,format:36285,textureFormat:"bc5-rg-unorm"},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"bc7-m5":{basisFormat:7,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840,textureFormat:"pvrtc-rgb4unorm-webgl"},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842,textureFormat:"pvrtc-rgba4unorm-webgl"},"astc-4x4":{basisFormat:10,compressed:!0,format:37808,textureFormat:"astc-4x4-unorm"},"atc-rgb":{basisFormat:11,compressed:!0,format:35986,textureFormat:"atc-rgb-unorm-webgl"},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0,format:34798,textureFormat:"atc-rgbai-unorm-webgl"},rgba32:{basisFormat:13,compressed:!1,format:32856,textureFormat:"rgba8unorm"},rgb565:{basisFormat:14,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},bgr565:{basisFormat:15,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},rgba4444:{basisFormat:16,compressed:!1,format:32854,textureFormat:"rgba4unorm-webgl"}},JG=Object.freeze(Object.keys(Np));async function Dp(t,e={}){let r=Pn(e);if(!e.basis?.containerFormat||e.basis.containerFormat==="auto"){if(Rp(t)){let s=await Nc(r);return Pp(s.KTX2File,t,e)}let{BasisFile:n}=await Oc(r);return Dc(n,t,e)}switch(e.basis.module){case"encoder":let n=await Nc(r);switch(e.basis.containerFormat){case"ktx2":return Pp(n.KTX2File,t,e);case"basis":default:return Dc(n.BasisFile,t,e)}case"transcoder":default:let{BasisFile:s}=await Oc(r);return Dc(s,t,e)}}function Dc(t,e,r){let n=new t(new Uint8Array(e));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");let s=n.getNumImages(),o=[];for(let i=0;i<s;i++){let a=n.getNumLevels(i),c=[];for(let l=0;l<a;l++)c.push(aB(n,i,l,r));o.push(c)}return o}finally{n.close(),n.delete()}}function aB(t,e,r,n){let s=t.getImageWidth(e,r),o=t.getImageHeight(e,r),i=t.getHasAlpha(),{compressed:a,format:c,basisFormat:l,textureFormat:f}=Gp(n,i),u=t.getImageTranscodedSizeInBytes(e,r,l),h=new Uint8Array(u);if(!t.transcodeImage(h,e,r,l,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:s,height:o,data:h,compressed:a,...c!==void 0?{format:c}:{},...f!==void 0?{textureFormat:f}:{},hasAlpha:i}}function Pp(t,e,r){let n=new t(new Uint8Array(e));try{if(!n.startTranscoding())throw new Error("failed to start KTX2 transcoding");let s=n.getLevels(),o=[];for(let i=0;i<s;i++)o.push(cB(n,i,r));return[o]}finally{n.close(),n.delete()}}function cB(t,e,r){let{alphaFlag:n,height:s,width:o}=t.getImageLevelInfo(e,0,0),{compressed:i,format:a,basisFormat:c,textureFormat:l}=Gp(r,n),f=t.getImageTranscodedSizeInBytes(e,0,0,c),u=new Uint8Array(f);if(!t.transcodeImage(u,e,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:o,height:s,data:u,compressed:i,...a!==void 0?{format:a}:{},...l!==void 0?{textureFormat:l}:{},levelSize:f,hasAlpha:n}}function Gp(t,e){let r=t.basis?.format||"auto";r==="auto"&&(r=t.basis?.supportedTextureFormats?Op(t.basis.supportedTextureFormats):Op()),typeof r=="object"&&(r=e?r.alpha:r.noAlpha);let n=r.toLowerCase(),s=Np[n];if(!s)throw new Error(`Unknown Basis format ${r}`);return s}function Op(t=Fp()){let e=new Set(t);return kr(e,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":kr(e,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:kr(e,["bc1-rgb-unorm-webgl","bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb"])?{alpha:"bc3",noAlpha:"bc1"}:kr(e,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rbg2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:kr(e,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":e.has("etc1-rbg-unorm-webgl")?"etc1":kr(e,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function kr(t,e){return e.some(r=>t.has(r))}var Up={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:wp,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}}},Gc={...Up,parse:Dp};var Pe=D(Uc(),1);function zp(t){return{addressModeU:Hp(t.wrapS),addressModeV:Hp(t.wrapT),magFilter:lB(t.magFilter),...fB(t.minFilter)}}function Hp(t){switch(t){case 33071:return"clamp-to-edge";case 10497:return"repeat";case 33648:return"mirror-repeat";default:return}}function lB(t){switch(t){case 9728:return"nearest";case 9729:return"linear";default:return}}function fB(t){switch(t){case 9728:return{minFilter:"nearest"};case 9729:return{minFilter:"linear"};case 9984:return{minFilter:"nearest",mipmapFilter:"nearest"};case 9985:return{minFilter:"linear",mipmapFilter:"nearest"};case 9986:return{minFilter:"nearest",mipmapFilter:"linear"};case 9987:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}function Hc(t,e,r,n){let s={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=!0;let{imageBasedLightingEnvironment:o}=n;return o&&(s.bindings.pbr_diffuseEnvSampler=o.diffuseEnvSampler.texture,s.bindings.pbr_specularEnvSampler=o.specularEnvSampler.texture,s.bindings.pbr_BrdfLUT=o.brdfLutTexture.texture,s.uniforms.scaleIBLAmbient=[1,1]),n?.pbrDebug&&(s.defines.PBR_DEBUG=!0,s.uniforms.scaleDiffBaseMR=[0,0,0,0],s.uniforms.scaleFGDSpec=[0,0,0,0]),r.NORMAL&&(s.defines.HAS_NORMALS=!0),r.TANGENT&&n?.useTangents&&(s.defines.HAS_TANGENTS=!0),r.TEXCOORD_0&&(s.defines.HAS_UV=!0),r.JOINTS_0&&r.WEIGHTS_0&&(s.defines.HAS_SKIN=!0),r.COLOR_0&&(s.defines.HAS_COLORS=!0),n?.imageBasedLightingEnvironment&&(s.defines.USE_IBL=!0),n?.lights&&(s.defines.USE_LIGHTS=!0),e&&uB(t,e,s),s}function uB(t,e,r){if(r.uniforms.unlit=Boolean(e.unlit),e.pbrMetallicRoughness&&hB(t,e.pbrMetallicRoughness,r),e.normalTexture){ns(t,e.normalTexture,"pbr_normalSampler","HAS_NORMALMAP",r);let{scale:n=1}=e.normalTexture;r.uniforms.normalScale=n}if(e.occlusionTexture){ns(t,e.occlusionTexture,"pbr_occlusionSampler","HAS_OCCLUSIONMAP",r);let{strength:n=1}=e.occlusionTexture;r.uniforms.occlusionStrength=n}switch(e.emissiveTexture&&(ns(t,e.emissiveTexture,"pbr_emissiveSampler","HAS_EMISSIVEMAP",r),r.uniforms.emissiveFactor=e.emissiveFactor||[0,0,0]),e.alphaMode||"MASK"){case"MASK":let{alphaCutoff:n=.5}=e;r.defines.ALPHA_CUTOFF=!0,r.uniforms.alphaCutoff=n;break;case"BLEND":Pe.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),r.parameters.blend=!0,r.parameters.blendColorOperation="add",r.parameters.blendColorSrcFactor="src-alpha",r.parameters.blendColorDstFactor="one-minus-src-alpha",r.parameters.blendAlphaOperation="add",r.parameters.blendAlphaSrcFactor="one",r.parameters.blendAlphaDstFactor="one-minus-src-alpha",r.glParameters.blend=!0,r.glParameters.blendEquation=32774,r.glParameters.blendFunc=[770,771,1,771];break}}function hB(t,e,r){e.baseColorTexture&&ns(t,e.baseColorTexture,"pbr_baseColorSampler","HAS_BASECOLORMAP",r),r.uniforms.baseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&ns(t,e.metallicRoughnessTexture,"pbr_metallicRoughnessSampler","HAS_METALROUGHNESSMAP",r);let{metallicFactor:n=1,roughnessFactor:s=1}=e;r.uniforms.metallicRoughnessValues=[n,s]}function ns(t,e,r,n,s){let o=e.texture.source.image,i={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...e?.texture?.sampler},a={id:e.uniformName||e.id,sampler:zp(i)},c;if(o.compressed)c=pB(t,o,a);else{let{width:l,height:f}=t.getExternalImageSize(o);c=t.createTexture({...a,width:l,height:f,data:o})}s.bindings[r]=c,n&&(s.defines[n]=!0),s.generatedTextures.push(c)}function Vc(t,e){return t.createTexture({...e,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function kp(t){return t.textureFormat}function dB(t,e,r){let{blockWidth:n=1,blockHeight:s=1}=Pe.textureFormatDecoder.getInfo(r),o=1;for(let i=1;;i++){let a=Math.max(1,t>>i),c=Math.max(1,e>>i);if(a<n||c<s)break;o++}return o}function pB(t,e,r){let n;if(Array.isArray(e.data)&&e.data[0]?.data?n=e.data:"mipmaps"in e&&Array.isArray(e.mipmaps)?n=e.mipmaps:n=[],n.length===0||!n[0]?.data)return Pe.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),Vc(t,r);let s=n[0],o=s.width??e.width??0,i=s.height??e.height??0;if(o<=0||i<=0)return Pe.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),Vc(t,r);let a=kp(s);if(!a)return Pe.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),Vc(t,r);let c=dB(o,i,a),l=Math.min(n.length,c),f=1;for(let h=1;h<l;h++){let d=n[h];if(!d.data||d.width<=0||d.height<=0){Pe.log.warn(`createCompressedTexture: mip level ${h} has invalid data/dimensions, truncating`)();break}let p=kp(d);if(p&&p!==a){Pe.log.warn(`createCompressedTexture: mip level ${h} format '${p}' differs from base '${a}', truncating`)();break}let A=Math.max(1,o>>h),m=Math.max(1,i>>h);if(d.width!==A||d.height!==m){Pe.log.warn(`createCompressedTexture: mip level ${h} dimensions ${d.width}x${d.height} don't match expected ${A}x${m}, truncating`)();break}f++}let u=t.createTexture({...r,format:a,usage:Pe.Texture.TEXTURE|Pe.Texture.COPY_DST,width:o,height:i,mipLevels:f,data:s.data});for(let h=1;h<f;h++)u.writeData(n[h].data,{width:n[h].width,height:n[h].height,mipLevel:h});return u}var jp=D(Uc(),1);var zc=`precision highp int;
26
+ `},e.modules=[...e.modules,Td],e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(e){let{fadeTrail:r,trailLength:n,currentTime:o}=this.props,s={fadeTrail:r,trailLength:n,currentTime:o};this.state.model.shaderInputs.setProps({trips:s}),super.draw(e)}};no.layerName="TripsLayer";no.defaultProps=ZM;var _d=no;var Md=D($o(),1),Sd=D(Xe(),1);var Ve=D($o(),1),Hs=D(Xe(),1),oo=D(We(),1);var $M=10;function eS(t,e){let r;return t==null?r=e:typeof t=="object"?r={...t,coverage:e}:r={getHexagon:t,coverage:e},r}var tS={...oo.PolygonLayer.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:t=>t.hexagon},extruded:!0},Ut=class extends Hs.CompositeLayer{initializeState(){Ut._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:r}){if(e.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let n=this._calculateH3DataProps();this.setState(n)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,r=!1,n=!1,{iterable:o,objectInfo:s}=(0,Hs.createIterable)(this.props.data);for(let i of o){s.index++;let a=this.props.getHexagon(i,s),c=(0,Ve.getResolution)(a);if(e<0){if(e=c,!this.props.highPrecision)break}else if(e!==c){n=!0;break}if((0,Ve.isPentagon)(a)){r=!0;break}}return{resolution:e,edgeLengthKM:e>=0?(0,Ve.getHexagonEdgeLengthAvg)(e,"km"):0,hasMultipleRes:n,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:e,hasPentagon:r,hasMultipleRes:n}=this.state,{viewport:o}=this.context;return Boolean(o?.resolution)||n||r||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:n,centerHex:o}=this.state;if(r<0)return;let s=this.props.centerHexagon||(0,Ve.latLngToCell)(e.latitude,e.longitude,r);if(o===s)return;if(o)try{if((0,Ve.gridDistance)(o,s)*n<$M)return}catch{}let{unitsPerMeter:i}=e.distanceScales,a=qa(s),[c,l]=(0,Ve.cellToLatLng)(s),[f,u]=e.projectFlat([l,c]);a=a.map(h=>{let p=e.projectFlat(h);return[(p[0]-f)/i[0],(p[1]-u)/i[1]]}),this.setState({centerHex:s,vertices:a})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:e,material:r,coverage:n,extruded:o,wireframe:s,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,getFillColor:h,getElevation:p,getLineColor:d,getLineWidth:A,transitions:m,updateTriggers:b}=this.props;return{elevationScale:e,extruded:o,coverage:n,wireframe:s,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,material:r,getElevation:p,getFillColor:h,getLineColor:d,getLineWidth:A,transitions:m,updateTriggers:{getFillColor:b.getFillColor,getElevation:b.getElevation,getLineColor:b.getLineColor,getLineWidth:b.getLineWidth}}}_renderPolygonLayer(){let{data:e,getHexagon:r,updateTriggers:n,coverage:o}=this.props,s=this.getSubLayerClass("hexagon-cell-hifi",oo.PolygonLayer),i=this._getForwardProps();return i.updateTriggers.getPolygon=eS(n.getHexagon,o),new s(i,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:i.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,c)=>{let l=r(a,c);return ms(qa(l,o))}})}_renderColumnLayer(){let{data:e,getHexagon:r,updateTriggers:n}=this.props,o=this.getSubLayerClass("hexagon-cell",oo.ColumnLayer),s=this._getForwardProps();return s.updateTriggers.getPosition=n.getHexagon,new o(s,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:s.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:Gh.bind(null,r)})}};Ut.defaultProps=tS;Ut.layerName="H3HexagonLayer";Ut._checkH3Lib=()=>{};var Vs=Ut;var rS={getHexagons:{type:"accessor",value:t=>t.hexagons}},so=class extends De{initializeState(){Vs._checkH3Lib()}updateState({props:e,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:n,getHexagons:o}=e,s=[],{iterable:i,objectInfo:a}=(0,Sd.createIterable)(n);for(let c of i){a.index++;let l=o(c,a),f=(0,Md.cellsToMultiPolygon)(l,!0);for(let u of f){for(let h of u)ds(h);s.push(this.getSubLayerRow({polygon:u},c,a.index))}}this.setState({polygons:s})}}indexToBounds(){let{getElevation:e,getFillColor:r,getLineColor:n,getLineWidth:o}=this.props;return{data:this.state.polygons,getPolygon:s=>s.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(n),getLineWidth:this.getSubLayerAccessor(o)}}};so.layerName="H3ClusterLayer";so.defaultProps=rS;var Cd=so;var h0=D(Pc(),1),kt=D(Xe(),1),p0=D(We(),1),d0=D(zs(),1);var Rd="4.4.0-alpha.18";var ks={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},vd;async function Oc(t){oc(t.modules);let e=sc("basis");return e||(vd||=nS(t),await vd)}async function nS(t){let e=null,r=null;return[e,r]=await Promise.all([await Ge(ks.TRANSCODER,"textures",t),await Ge(ks.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await oS(e,r)}function oS(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t(r).then(o=>{let{BasisFile:s,initializeBasis:i}=o;i(),n({BasisFile:s})})})}var Nc;async function Dc(t){let e=t.modules||{};return e.basisEncoder?e.basisEncoder:(Nc=Nc||sS(t),await Nc)}async function sS(t){let e=null,r=null;return[e,r]=await Promise.all([await Ge(ks.ENCODER,"textures",t),await Ge(ks.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await iS(e,r)}function iS(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t(r).then(o=>{let{BasisFile:s,KTX2File:i,initializeBasis:a,BasisEncoder:c}=o;a(),n({BasisFile:s,KTX2File:i,BasisEncoder:c})})})}var aS=["","WEBKIT_","MOZ_"],wd={WEBGL_compressed_texture_s3tc:["bc1-rgb-unorm-webgl","bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"],WEBGL_compressed_texture_s3tc_srgb:["bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"],EXT_texture_compression_rgtc:["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"],EXT_texture_compression_bptc:["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"],WEBGL_compressed_texture_etc1:["etc1-rbg-unorm-webgl"],WEBGL_compressed_texture_etc:["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"],WEBGL_compressed_texture_pvrtc:["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rbg2unorm-webgl","pvrtc-rgba2unorm-webgl"],WEBGL_compressed_texture_atc:["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"],WEBGL_compressed_texture_astc:["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]};var qs=null;function Ld(t){if(!qs){t=t||cS()||void 0,qs=new Set;for(let e of aS)for(let r in wd)if(t&&t.getExtension(`${e}${r}`))for(let n of wd[r])qs.add(n)}return qs}function cS(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var Oe=[171,75,84,88,32,50,48,187,13,10,26,10];function Fd(t){let e=new Uint8Array(t);return!(e.byteLength<Oe.length||e[0]!==Oe[0]||e[1]!==Oe[1]||e[2]!==Oe[2]||e[3]!==Oe[3]||e[4]!==Oe[4]||e[5]!==Oe[5]||e[6]!==Oe[6]||e[7]!==Oe[7]||e[8]!==Oe[8]||e[9]!==Oe[9]||e[10]!==Oe[10]||e[11]!==Oe[11])}var Od={etc1:{basisFormat:0,compressed:!0,format:36196,textureFormat:"etc1-rbg-unorm-webgl"},etc2:{basisFormat:1,compressed:!0,format:37493,textureFormat:"etc2-rgba8unorm"},bc1:{basisFormat:2,compressed:!0,format:33776,textureFormat:"bc1-rgb-unorm-webgl"},bc3:{basisFormat:3,compressed:!0,format:33779,textureFormat:"bc3-rgba-unorm"},bc4:{basisFormat:4,compressed:!0,format:36283,textureFormat:"bc4-r-unorm"},bc5:{basisFormat:5,compressed:!0,format:36285,textureFormat:"bc5-rg-unorm"},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"bc7-m5":{basisFormat:7,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840,textureFormat:"pvrtc-rgb4unorm-webgl"},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842,textureFormat:"pvrtc-rgba4unorm-webgl"},"astc-4x4":{basisFormat:10,compressed:!0,format:37808,textureFormat:"astc-4x4-unorm"},"atc-rgb":{basisFormat:11,compressed:!0,format:35986,textureFormat:"atc-rgb-unorm-webgl"},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0,format:34798,textureFormat:"atc-rgbai-unorm-webgl"},rgba32:{basisFormat:13,compressed:!1,format:32856,textureFormat:"rgba8unorm"},rgb565:{basisFormat:14,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},bgr565:{basisFormat:15,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},rgba4444:{basisFormat:16,compressed:!1,format:32854,textureFormat:"rgba4unorm-webgl"}},gG=Object.freeze(Object.keys(Od));async function Dd(t,e={}){let r=Dn(e);if(!e.basis?.containerFormat||e.basis.containerFormat==="auto"){if(Fd(t)){let o=await Dc(r);return Pd(o.KTX2File,t,e)}let{BasisFile:n}=await Oc(r);return Uc(n,t,e)}switch(e.basis.module){case"encoder":let n=await Dc(r);switch(e.basis.containerFormat){case"ktx2":return Pd(n.KTX2File,t,e);case"basis":default:return Uc(n.BasisFile,t,e)}case"transcoder":default:let{BasisFile:o}=await Oc(r);return Uc(o,t,e)}}function Uc(t,e,r){let n=new t(new Uint8Array(e));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");let o=n.getNumImages(),s=[];for(let i=0;i<o;i++){let a=n.getNumLevels(i),c=[];for(let l=0;l<a;l++)c.push(uS(n,i,l,r));s.push(c)}return s}finally{n.close(),n.delete()}}function uS(t,e,r,n){let o=t.getImageWidth(e,r),s=t.getImageHeight(e,r),i=t.getHasAlpha(),{compressed:a,format:c,basisFormat:l,textureFormat:f}=Ud(n,i),u=t.getImageTranscodedSizeInBytes(e,r,l),h=new Uint8Array(u);if(!t.transcodeImage(h,e,r,l,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:o,height:s,data:h,compressed:a,...c!==void 0?{format:c}:{},...f!==void 0?{textureFormat:f}:{},hasAlpha:i}}function Pd(t,e,r){let n=new t(new Uint8Array(e));try{if(!n.startTranscoding())throw new Error("failed to start KTX2 transcoding");let o=n.getLevels(),s=[];for(let i=0;i<o;i++)s.push(hS(n,i,r));return[s]}finally{n.close(),n.delete()}}function hS(t,e,r){let{alphaFlag:n,height:o,width:s}=t.getImageLevelInfo(e,0,0),{compressed:i,format:a,basisFormat:c,textureFormat:l}=Ud(r,n),f=t.getImageTranscodedSizeInBytes(e,0,0,c),u=new Uint8Array(f);if(!t.transcodeImage(u,e,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:s,height:o,data:u,compressed:i,...a!==void 0?{format:a}:{},...l!==void 0?{textureFormat:l}:{},levelSize:f,hasAlpha:n}}function Ud(t,e){let r=t.basis?.format||"auto";r==="auto"&&(r=t.basis?.supportedTextureFormats?Nd(t.basis.supportedTextureFormats):Nd()),typeof r=="object"&&(r=e?r.alpha:r.noAlpha);let n=r.toLowerCase(),o=Od[n];if(!o)throw new Error(`Unknown Basis format ${r}`);return o}function Nd(t=Ld()){let e=new Set(t);return Jr(e,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":Jr(e,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:Jr(e,["bc1-rgb-unorm-webgl","bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb"])?{alpha:"bc3",noAlpha:"bc1"}:Jr(e,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rbg2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:Jr(e,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":e.has("etc1-rbg-unorm-webgl")?"etc1":Jr(e,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function Jr(t,e){return e.some(r=>t.has(r))}var Gd={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:Rd,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}}},Gc={...Gd,parse:Dd};var ge=D(Hc(),1);var $;(function(t){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.ONE=1]="ONE",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST=9728]="NEAREST",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_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.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})($||($={}));function zd(t){return{addressModeU:Vd(t.wrapS),addressModeV:Vd(t.wrapT),magFilter:pS(t.magFilter),...dS(t.minFilter)}}function Vd(t){switch(t){case $.CLAMP_TO_EDGE:return"clamp-to-edge";case $.REPEAT:return"repeat";case $.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function pS(t){switch(t){case $.NEAREST:return"nearest";case $.LINEAR:return"linear";default:return}}function dS(t){switch(t){case $.NEAREST:return{minFilter:"nearest"};case $.LINEAR:return{minFilter:"linear"};case $.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case $.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case $.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case $.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}function zc(t,e,r,n){let o={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};o.defines.USE_TEX_LOD=!0;let{imageBasedLightingEnvironment:s}=n;return s&&(o.bindings.pbr_diffuseEnvSampler=s.diffuseEnvSampler.texture,o.bindings.pbr_specularEnvSampler=s.specularEnvSampler.texture,o.bindings.pbr_brdfLUT=s.brdfLutTexture.texture,o.uniforms.IBLenabled=!0,o.uniforms.scaleIBLAmbient=[1,1]),n?.pbrDebug&&(o.defines.PBR_DEBUG=!0,o.uniforms.scaleDiffBaseMR=[0,0,0,0],o.uniforms.scaleFGDSpec=[0,0,0,0]),r.NORMAL&&(o.defines.HAS_NORMALS=!0),r.TANGENT&&n?.useTangents&&(o.defines.HAS_TANGENTS=!0),r.TEXCOORD_0&&(o.defines.HAS_UV=!0),r.JOINTS_0&&r.WEIGHTS_0&&(o.defines.HAS_SKIN=!0),r.COLOR_0&&(o.defines.HAS_COLORS=!0),n?.imageBasedLightingEnvironment&&(o.defines.USE_IBL=!0),n?.lights&&(o.defines.USE_LIGHTS=!0),e&&(n.validateAttributes!==!1&&mS(e,r),AS(t,e,o,n.gltf)),o}function mS(t,e){let r=gS(t);if(r.length>0&&!e.TEXCOORD_0&&ge.log.warn(`glTF material uses ${r.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)(),Boolean(t.unlit||t.extensions?.KHR_materials_unlit)||e.NORMAL)return;let o=t.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";ge.log.warn(`glTF primitive is missing NORMAL while using ${o}; shading will fall back to geometric normals`)()}function gS(t){let e=[];return t.pbrMetallicRoughness?.baseColorTexture&&e.push("baseColorTexture"),t.pbrMetallicRoughness?.metallicRoughnessTexture&&e.push("metallicRoughnessTexture"),t.normalTexture&&e.push("normalTexture"),t.occlusionTexture&&e.push("occlusionTexture"),t.emissiveTexture&&e.push("emissiveTexture"),t.extensions?.KHR_materials_specular?.specularTexture&&e.push("KHR_materials_specular.specularTexture"),t.extensions?.KHR_materials_specular?.specularColorTexture&&e.push("KHR_materials_specular.specularColorTexture"),t.extensions?.KHR_materials_transmission?.transmissionTexture&&e.push("KHR_materials_transmission.transmissionTexture"),t.extensions?.KHR_materials_clearcoat?.clearcoatTexture&&e.push("KHR_materials_clearcoat.clearcoatTexture"),t.extensions?.KHR_materials_clearcoat?.clearcoatRoughnessTexture&&e.push("KHR_materials_clearcoat.clearcoatRoughnessTexture"),t.extensions?.KHR_materials_sheen?.sheenColorTexture&&e.push("KHR_materials_sheen.sheenColorTexture"),t.extensions?.KHR_materials_sheen?.sheenRoughnessTexture&&e.push("KHR_materials_sheen.sheenRoughnessTexture"),t.extensions?.KHR_materials_iridescence?.iridescenceTexture&&e.push("KHR_materials_iridescence.iridescenceTexture"),t.extensions?.KHR_materials_anisotropy?.anisotropyTexture&&e.push("KHR_materials_anisotropy.anisotropyTexture"),e}function AS(t,e,r,n){if(r.uniforms.unlit=Boolean(e.unlit||e.extensions?.KHR_materials_unlit),e.pbrMetallicRoughness&&yS(t,e.pbrMetallicRoughness,r,n),e.normalTexture){Ae(t,e.normalTexture,"pbr_normalSampler",r,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:n});let{scale:o=1}=e.normalTexture;r.uniforms.normalScale=o}if(e.occlusionTexture){Ae(t,e.occlusionTexture,"pbr_occlusionSampler",r,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:n});let{strength:o=1}=e.occlusionTexture;r.uniforms.occlusionStrength=o}switch(r.uniforms.emissiveFactor=e.emissiveFactor||[0,0,0],e.emissiveTexture&&Ae(t,e.emissiveTexture,"pbr_emissiveSampler",r,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:n}),TS(t,e.extensions,r,n),e.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{let{alphaCutoff:o=.5}=e;r.defines.ALPHA_CUTOFF=!0,r.uniforms.alphaCutoffEnabled=!0,r.uniforms.alphaCutoff=o;break}case"BLEND":ge.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),xS(r);break}}function xS(t){t.parameters.blend=!0,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="src-alpha",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.blendEquation=$.FUNC_ADD,t.glParameters.blendFunc=[$.SRC_ALPHA,$.ONE_MINUS_SRC_ALPHA,$.ONE,$.ONE_MINUS_SRC_ALPHA]}function bS(t){t.parameters.blend=!0,t.parameters.depthWriteEnabled=!1,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="one",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.depthMask=!1,t.glParameters.blendEquation=$.FUNC_ADD,t.glParameters.blendFunc=[$.ONE,$.ONE_MINUS_SRC_ALPHA,$.ONE,$.ONE_MINUS_SRC_ALPHA]}function yS(t,e,r,n){e.baseColorTexture&&Ae(t,e.baseColorTexture,"pbr_baseColorSampler",r,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:n}),r.uniforms.baseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&Ae(t,e.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",r,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:n});let{metallicFactor:o=1,roughnessFactor:s=1}=e;r.uniforms.metallicRoughnessValues=[o,s]}function TS(t,e,r,n){e&&(ES(e)&&(r.defines.USE_MATERIAL_EXTENSIONS=!0),_S(t,e.KHR_materials_specular,r,n),MS(e.KHR_materials_ior,r),SS(t,e.KHR_materials_transmission,r,n),CS(t,e.KHR_materials_volume,r,n),BS(t,e.KHR_materials_clearcoat,r,n),IS(t,e.KHR_materials_sheen,r,n),RS(t,e.KHR_materials_iridescence,r,n),vS(t,e.KHR_materials_anisotropy,r,n),wS(e.KHR_materials_emissive_strength,r))}function ES(t){return Boolean(t.KHR_materials_specular||t.KHR_materials_ior||t.KHR_materials_transmission||t.KHR_materials_volume||t.KHR_materials_clearcoat||t.KHR_materials_sheen||t.KHR_materials_iridescence||t.KHR_materials_anisotropy)}function _S(t,e,r,n){e&&(e.specularColorFactor&&(r.uniforms.specularColorFactor=e.specularColorFactor),e.specularFactor!==void 0&&(r.uniforms.specularIntensityFactor=e.specularFactor),e.specularColorTexture&&Ae(t,e.specularColorTexture,"pbr_specularColorSampler",r,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:n}),e.specularTexture&&Ae(t,e.specularTexture,"pbr_specularIntensitySampler",r,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:n}))}function MS(t,e){t?.ior!==void 0&&(e.uniforms.ior=t.ior)}function SS(t,e,r,n){e&&(e.transmissionFactor!==void 0&&(r.uniforms.transmissionFactor=e.transmissionFactor),e.transmissionTexture&&Ae(t,e.transmissionTexture,"pbr_transmissionSampler",r,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:n}),((e.transmissionFactor??0)>0||e.transmissionTexture)&&(ge.log.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),bS(r)))}function CS(t,e,r,n){e&&(e.thicknessFactor!==void 0&&(r.uniforms.thicknessFactor=e.thicknessFactor),e.thicknessTexture&&Ae(t,e.thicknessTexture,"pbr_thicknessSampler",r,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:n}),e.attenuationDistance!==void 0&&(r.uniforms.attenuationDistance=e.attenuationDistance),e.attenuationColor&&(r.uniforms.attenuationColor=e.attenuationColor))}function BS(t,e,r,n){e&&(e.clearcoatFactor!==void 0&&(r.uniforms.clearcoatFactor=e.clearcoatFactor),e.clearcoatRoughnessFactor!==void 0&&(r.uniforms.clearcoatRoughnessFactor=e.clearcoatRoughnessFactor),e.clearcoatTexture&&Ae(t,e.clearcoatTexture,"pbr_clearcoatSampler",r,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:n}),e.clearcoatRoughnessTexture&&Ae(t,e.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",r,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:n}),e.clearcoatNormalTexture&&Ae(t,e.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",r,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:n}))}function IS(t,e,r,n){e&&(e.sheenColorFactor&&(r.uniforms.sheenColorFactor=e.sheenColorFactor),e.sheenRoughnessFactor!==void 0&&(r.uniforms.sheenRoughnessFactor=e.sheenRoughnessFactor),e.sheenColorTexture&&Ae(t,e.sheenColorTexture,"pbr_sheenColorSampler",r,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:n}),e.sheenRoughnessTexture&&Ae(t,e.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",r,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:n}))}function RS(t,e,r,n){e&&(e.iridescenceFactor!==void 0&&(r.uniforms.iridescenceFactor=e.iridescenceFactor),e.iridescenceIor!==void 0&&(r.uniforms.iridescenceIor=e.iridescenceIor),(e.iridescenceThicknessMinimum!==void 0||e.iridescenceThicknessMaximum!==void 0)&&(r.uniforms.iridescenceThicknessRange=[e.iridescenceThicknessMinimum??100,e.iridescenceThicknessMaximum??400]),e.iridescenceTexture&&Ae(t,e.iridescenceTexture,"pbr_iridescenceSampler",r,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:n}),e.iridescenceThicknessTexture&&Ae(t,e.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",r,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:n}))}function vS(t,e,r,n){e&&(e.anisotropyStrength!==void 0&&(r.uniforms.anisotropyStrength=e.anisotropyStrength),e.anisotropyRotation!==void 0&&(r.uniforms.anisotropyRotation=e.anisotropyRotation),e.anisotropyTexture&&Ae(t,e.anisotropyTexture,"pbr_anisotropySampler",r,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:n}))}function wS(t,e){t?.emissiveStrength!==void 0&&(e.uniforms.emissiveStrength=t.emissiveStrength)}function Ae(t,e,r,n,o={}){let{featureOptions:s={},gltf:i}=o,{define:a,enabledUniformName:c}=s,l=LS(e,i),f=l.texture?.source?.image;if(!f){ge.log.warn(`Skipping unresolved glTF texture for ${String(r)}`)();return}let u={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...l?.texture?.sampler},h={id:l.uniformName||l.id,sampler:zd(u)},p;if(f.compressed)p=PS(t,f,h);else{let{width:d,height:A}=t.getExternalImageSize(f);p=t.createTexture({...h,width:d,height:A,data:f})}n.bindings[r]=p,a&&(n.defines[a]=!0),c&&(n.uniforms[c]=!0),n.generatedTextures.push(p)}function LS(t,e){if(t.texture||t.index===void 0||!e?.textures)return t;let r=e.textures[t.index];return r?"texture"in r&&r.texture?{...r,...t,texture:r.texture}:"source"in r?{...t,texture:r}:t:t}function Vc(t,e){return t.createTexture({...e,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function kd(t){return t.textureFormat}function FS(t,e,r){let{blockWidth:n=1,blockHeight:o=1}=ge.textureFormatDecoder.getInfo(r),s=1;for(let i=1;;i++){let a=Math.max(1,t>>i),c=Math.max(1,e>>i);if(a<n||c<o)break;s++}return s}function PS(t,e,r){let n;if(Array.isArray(e.data)&&e.data[0]?.data?n=e.data:"mipmaps"in e&&Array.isArray(e.mipmaps)?n=e.mipmaps:n=[],n.length===0||!n[0]?.data)return ge.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),Vc(t,r);let o=n[0],s=o.width??e.width??0,i=o.height??e.height??0;if(s<=0||i<=0)return ge.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),Vc(t,r);let a=kd(o);if(!a)return ge.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),Vc(t,r);let c=FS(s,i,a),l=Math.min(n.length,c),f=1;for(let h=1;h<l;h++){let p=n[h];if(!p.data||p.width<=0||p.height<=0){ge.log.warn(`createCompressedTexture: mip level ${h} has invalid data/dimensions, truncating`)();break}let d=kd(p);if(d&&d!==a){ge.log.warn(`createCompressedTexture: mip level ${h} format '${d}' differs from base '${a}', truncating`)();break}let A=Math.max(1,s>>h),m=Math.max(1,i>>h);if(p.width!==A||p.height!==m){ge.log.warn(`createCompressedTexture: mip level ${h} dimensions ${p.width}x${p.height} don't match expected ${A}x${m}, truncating`)();break}f++}let u=t.createTexture({...r,format:a,usage:ge.Texture.TEXTURE|ge.Texture.COPY_DST,width:s,height:i,mipLevels:f,data:o.data});for(let h=1;h<f;h++)u.writeData(n[h].data,{width:n[h].width,height:n[h].height,mipLevel:h});return u}var jd=D(Hc(),1);var kc=`precision highp int;
27
27
 
28
28
  // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
29
29
  struct AmbientLight {
@@ -36,77 +36,51 @@ struct PointLight {
36
36
  vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential
37
37
  };
38
38
 
39
+ struct SpotLight {
40
+ vec3 color;
41
+ vec3 position;
42
+ vec3 direction;
43
+ vec3 attenuation;
44
+ vec2 coneCos;
45
+ };
46
+
39
47
  struct DirectionalLight {
40
48
  vec3 color;
41
49
  vec3 direction;
42
50
  };
43
51
 
44
- uniform lightingUniforms {
45
- int enabled;
46
- int lightType;
52
+ struct UniformLight {
53
+ vec3 color;
54
+ vec3 position;
55
+ vec3 direction;
56
+ vec3 attenuation;
57
+ vec2 coneCos;
58
+ };
47
59
 
60
+ layout(std140) uniform lightingUniforms {
61
+ int enabled;
48
62
  int directionalLightCount;
49
63
  int pointLightCount;
50
-
64
+ int spotLightCount;
51
65
  vec3 ambientColor;
52
-
53
- vec3 lightColor0;
54
- vec3 lightPosition0;
55
- vec3 lightDirection0;
56
- vec3 lightAttenuation0;
57
-
58
- vec3 lightColor1;
59
- vec3 lightPosition1;
60
- vec3 lightDirection1;
61
- vec3 lightAttenuation1;
62
-
63
- vec3 lightColor2;
64
- vec3 lightPosition2;
65
- vec3 lightDirection2;
66
- vec3 lightAttenuation2;
67
-
68
- vec3 lightColor3;
69
- vec3 lightPosition3;
70
- vec3 lightDirection3;
71
- vec3 lightAttenuation3;
72
-
73
- vec3 lightColor4;
74
- vec3 lightPosition4;
75
- vec3 lightDirection4;
76
- vec3 lightAttenuation4;
66
+ UniformLight lights[5];
77
67
  } lighting;
78
68
 
79
69
  PointLight lighting_getPointLight(int index) {
80
- switch (index) {
81
- case 0:
82
- return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
83
- case 1:
84
- return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
85
- case 2:
86
- return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
87
- case 3:
88
- return PointLight(lighting.lightColor3, lighting.lightPosition3, lighting.lightAttenuation3);
89
- case 4:
90
- default:
91
- return PointLight(lighting.lightColor4, lighting.lightPosition4, lighting.lightAttenuation4);
92
- }
70
+ UniformLight light = lighting.lights[index];
71
+ return PointLight(light.color, light.position, light.attenuation);
72
+ }
73
+
74
+ SpotLight lighting_getSpotLight(int index) {
75
+ UniformLight light = lighting.lights[lighting.pointLightCount + index];
76
+ return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
93
77
  }
94
78
 
95
79
  DirectionalLight lighting_getDirectionalLight(int index) {
96
- switch (index) {
97
- case 0:
98
- return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
99
- case 1:
100
- return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
101
- case 2:
102
- return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
103
- case 3:
104
- return DirectionalLight(lighting.lightColor3, lighting.lightDirection3);
105
- case 4:
106
- default:
107
- return DirectionalLight(lighting.lightColor4, lighting.lightDirection4);
108
- }
109
- }
80
+ UniformLight light =
81
+ lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
82
+ return DirectionalLight(light.color, light.direction);
83
+ }
110
84
 
111
85
  float getPointLightAttenuation(PointLight pointLight, float distance) {
112
86
  return pointLight.attenuation.x
@@ -114,8 +88,22 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
114
88
  + pointLight.attenuation.z * distance * distance;
115
89
  }
116
90
 
91
+ float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
92
+ vec3 light_direction = normalize(positionWorldspace - spotLight.position);
93
+ float coneFactor = smoothstep(
94
+ spotLight.coneCos.y,
95
+ spotLight.coneCos.x,
96
+ dot(normalize(spotLight.direction), light_direction)
97
+ );
98
+ float distanceAttenuation = getPointLightAttenuation(
99
+ PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
100
+ distance(spotLight.position, positionWorldspace)
101
+ );
102
+ return distanceAttenuation / max(coneFactor, 0.0001);
103
+ }
104
+
117
105
  // #endif
118
- `;var qp=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
106
+ `;var qd=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
119
107
  const MAX_LIGHTS: i32 = 5;
120
108
 
121
109
  struct AmbientLight {
@@ -128,95 +116,86 @@ struct PointLight {
128
116
  attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
129
117
  };
130
118
 
119
+ struct SpotLight {
120
+ color: vec3<f32>,
121
+ position: vec3<f32>,
122
+ direction: vec3<f32>,
123
+ attenuation: vec3<f32>,
124
+ coneCos: vec2<f32>,
125
+ };
126
+
131
127
  struct DirectionalLight {
132
128
  color: vec3<f32>,
133
129
  direction: vec3<f32>,
134
130
  };
135
131
 
132
+ struct UniformLight {
133
+ color: vec3<f32>,
134
+ position: vec3<f32>,
135
+ direction: vec3<f32>,
136
+ attenuation: vec3<f32>,
137
+ coneCos: vec2<f32>,
138
+ };
139
+
136
140
  struct lightingUniforms {
137
141
  enabled: i32,
138
- lightType: i32,
139
-
140
142
  directionalLightCount: i32,
141
143
  pointLightCount: i32,
142
-
144
+ spotLightCount: i32,
143
145
  ambientColor: vec3<f32>,
144
-
145
- lightColor0: vec3<f32>,
146
- lightPosition0: vec3<f32>,
147
- lightDirection0: vec3<f32>,
148
- lightAttenuation0: vec3<f32>,
149
-
150
- lightColor1: vec3<f32>,
151
- lightPosition1: vec3<f32>,
152
- lightDirection1: vec3<f32>,
153
- lightAttenuation1: vec3<f32>,
154
-
155
- lightColor2: vec3<f32>,
156
- lightPosition2: vec3<f32>,
157
- lightDirection2: vec3<f32>,
158
- lightAttenuation2: vec3<f32>,
159
-
160
- lightColor3: vec3<f32>,
161
- lightPosition3: vec3<f32>,
162
- lightDirection3: vec3<f32>,
163
- lightAttenuation3: vec3<f32>,
164
-
165
- lightColor4: vec3<f32>,
166
- lightPosition4: vec3<f32>,
167
- lightDirection4: vec3<f32>,
168
- lightAttenuation4: vec3<f32>,
146
+ lights: array<UniformLight, 5>,
169
147
  };
170
148
 
171
- // Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)
172
- @binding(1) @group(0) var<uniform> lighting : lightingUniforms;
149
+ @group(2) @binding(auto) var<uniform> lighting : lightingUniforms;
173
150
 
174
151
  fn lighting_getPointLight(index: i32) -> PointLight {
175
- switch (index) {
176
- case 0: {
177
- return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
178
- }
179
- case 1: {
180
- return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
181
- }
182
- case 2: {
183
- return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
184
- }
185
- case 3: {
186
- return PointLight(lighting.lightColor3, lighting.lightPosition3, lighting.lightAttenuation3);
187
- }
188
- case 4, default: {
189
- return PointLight(lighting.lightColor4, lighting.lightPosition4, lighting.lightAttenuation4);
190
- }
191
- }
152
+ let light = lighting.lights[index];
153
+ return PointLight(light.color, light.position, light.attenuation);
154
+ }
155
+
156
+ fn lighting_getSpotLight(index: i32) -> SpotLight {
157
+ let light = lighting.lights[lighting.pointLightCount + index];
158
+ return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
192
159
  }
193
160
 
194
161
  fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
195
- switch (index) {
196
- case 0: {
197
- return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
198
- }
199
- case 1: {
200
- return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
201
- }
202
- case 2: {
203
- return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
204
- }
205
- case 3: {
206
- return DirectionalLight(lighting.lightColor3, lighting.lightDirection3);
207
- }
208
- case 4, default: {
209
- return DirectionalLight(lighting.lightColor4, lighting.lightDirection4);
210
- }
211
- }
212
- }
162
+ let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
163
+ return DirectionalLight(light.color, light.direction);
164
+ }
213
165
 
214
166
  fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
215
167
  return pointLight.attenuation.x
216
168
  + pointLight.attenuation.y * distance
217
169
  + pointLight.attenuation.z * distance * distance;
218
170
  }
219
- `;var jo=5,mB=255,os;(function(t){t[t.POINT=0]="POINT",t[t.DIRECTIONAL=1]="DIRECTIONAL"})(os||(os={}));var ss={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>",lightColor3:"vec3<f32>",lightPosition3:"vec3<f32>",lightDirection3:"vec3<f32>",lightAttenuation3:"vec3<f32>",lightColor4:"vec3<f32>",lightPosition4:"vec3<f32>",lightDirection4:"vec3<f32>",lightAttenuation4:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:os.POINT,directionalLightCount:0,pointLightCount:0,ambientColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0],lightColor3:[1,1,1],lightPosition3:[1,1,2],lightDirection3:[1,1,1],lightAttenuation3:[1,0,0],lightColor4:[1,1,1],lightPosition4:[1,1,2],lightDirection4:[1,1,1],lightAttenuation4:[1,0,0]},source:qp,vs:zc,fs:zc,getUniforms:gB};function gB(t,e={}){if(t=t&&{...t},!t)return{...ss.defaultUniforms};t.lights&&(t={...t,...xB(t.lights),lights:void 0});let{ambientLight:r,pointLights:n,directionalLights:s}=t||{};if(!(r||n&&n.length>0||s&&s.length>0))return{...ss.defaultUniforms,enabled:0};let i={...ss.defaultUniforms,...e,...AB({ambientLight:r,pointLights:n,directionalLights:s})};return t.enabled!==void 0&&(i.enabled=t.enabled?1:0),i}function AB({ambientLight:t,pointLights:e=[],directionalLights:r=[]}){let n={};n.ambientColor=kc(t);let s=0,o=0,i=0;for(let a of e){if(s>=jo)break;n.lightType=os.POINT;let c=s;n[`lightColor${c}`]=kc(a),n[`lightPosition${c}`]=a.position,n[`lightAttenuation${c}`]=a.attenuation||[1,0,0],s++,o++}for(let a of r){if(s>=jo)break;n.lightType=os.DIRECTIONAL;let c=s;n[`lightColor${c}`]=kc(a),n[`lightDirection${c}`]=a.direction,s++,i++}return e.length+r.length>jo&&jp.log.warn(`MAX_LIGHTS exceeded, truncating to ${jo}`)(),n.directionalLightCount=i,n.pointLightCount=o,n}function xB(t){let e={pointLights:[],directionalLights:[]};for(let r of t||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;default:}return e}function kc(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(n=>n*r/mB)}var Jp=`out vec3 pbr_vPosition;
171
+
172
+ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {
173
+ let lightDirection = normalize(positionWorldspace - spotLight.position);
174
+ let coneFactor = smoothstep(
175
+ spotLight.coneCos.y,
176
+ spotLight.coneCos.x,
177
+ dot(normalize(spotLight.direction), lightDirection)
178
+ );
179
+ let distanceAttenuation = getPointLightAttenuation(
180
+ PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
181
+ distance(spotLight.position, positionWorldspace)
182
+ );
183
+ return distanceAttenuation / max(coneFactor, 0.0001);
184
+ }
185
+ `;var hr=5,NS=255,OS={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},Jd={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[OS,hr]},defaultUniforms:Js(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:qd,vs:kc,fs:kc,getUniforms:DS};function DS(t,e={}){if(t=t&&{...t},!t)return Js();t.lights&&(t={...t,...GS(t.lights),lights:void 0});let{ambientLight:r,pointLights:n,spotLights:o,directionalLights:s}=t||{};if(!(r||n&&n.length>0||o&&o.length>0||s&&s.length>0))return{...Js(),enabled:0};let a={...Js(),...US({ambientLight:r,pointLights:n,spotLights:o,directionalLights:s})};return t.enabled!==void 0&&(a.enabled=t.enabled?1:0),a}function US({ambientLight:t,pointLights:e=[],spotLights:r=[],directionalLights:n=[]}){let o=Wd(),s=0,i=0,a=0,c=0;for(let l of e){if(s>=hr)break;o[s]={...o[s],color:js(l),position:l.position,attenuation:l.attenuation||[1,0,0]},s++,i++}for(let l of r){if(s>=hr)break;o[s]={...o[s],color:js(l),position:l.position,direction:l.direction,attenuation:l.attenuation||[1,0,0],coneCos:VS(l)},s++,a++}for(let l of n){if(s>=hr)break;o[s]={...o[s],color:js(l),direction:l.direction},s++,c++}return e.length+r.length+n.length>hr&&jd.log.warn(`MAX_LIGHTS exceeded, truncating to ${hr}`)(),{ambientColor:js(t),directionalLightCount:c,pointLightCount:i,spotLightCount:a,lights:o}}function GS(t){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let r of t||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;case"spot":e.spotLights?.push(r);break;default:}return e}function js(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(n=>n*r/NS)}function Js(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:Wd()}}function Wd(){return Array.from({length:hr},()=>HS())}function HS(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function VS(t){let e=t.innerConeAngle??0,r=t.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(r)]}var zS=`#ifdef USE_IBL
186
+ @group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>;
187
+ @group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler;
188
+ @group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>;
189
+ @group(2) @binding(auto) var pbr_specularEnvSamplerSampler: sampler;
190
+ @group(2) @binding(auto) var pbr_brdfLUT: texture_2d<f32>;
191
+ @group(2) @binding(auto) var pbr_brdfLUTSampler: sampler;
192
+ #endif
193
+ `,Xd=`#ifdef USE_IBL
194
+ uniform samplerCube pbr_diffuseEnvSampler;
195
+ uniform samplerCube pbr_specularEnvSampler;
196
+ uniform sampler2D pbr_brdfLUT;
197
+ #endif
198
+ `,Yd={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:zS,vs:Xd,fs:Xd};var Kd=`out vec3 pbr_vPosition;
220
199
  out vec2 pbr_vUV;
221
200
 
222
201
  #ifdef HAS_NORMALS
@@ -249,9 +228,9 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
249
228
  pbr_vUV = vec2(0.,0.);
250
229
  #endif
251
230
  }
252
- `,Wp=`precision highp float;
231
+ `,Qd=`precision highp float;
253
232
 
254
- uniform pbrMaterialUniforms {
233
+ layout(std140) uniform pbrMaterialUniforms {
255
234
  // Material is unlit
256
235
  bool unlit;
257
236
 
@@ -291,10 +270,12 @@ uniform pbrMaterialUniforms {
291
270
  float clearcoatFactor;
292
271
  float clearcoatRoughnessFactor;
293
272
  bool clearcoatMapEnabled;
273
+ bool clearcoatRoughnessMapEnabled;
294
274
 
295
275
  vec3 sheenColorFactor;
296
276
  float sheenRoughnessFactor;
297
277
  bool sheenColorMapEnabled;
278
+ bool sheenRoughnessMapEnabled;
298
279
 
299
280
  float iridescenceFactor;
300
281
  float iridescenceIor;
@@ -344,26 +325,33 @@ uniform sampler2D pbr_specularIntensitySampler;
344
325
  #ifdef HAS_TRANSMISSIONMAP
345
326
  uniform sampler2D pbr_transmissionSampler;
346
327
  #endif
328
+ #ifdef HAS_THICKNESSMAP
329
+ uniform sampler2D pbr_thicknessSampler;
330
+ #endif
347
331
  #ifdef HAS_CLEARCOATMAP
348
332
  uniform sampler2D pbr_clearcoatSampler;
333
+ #endif
334
+ #ifdef HAS_CLEARCOATROUGHNESSMAP
349
335
  uniform sampler2D pbr_clearcoatRoughnessSampler;
350
336
  #endif
337
+ #ifdef HAS_CLEARCOATNORMALMAP
338
+ uniform sampler2D pbr_clearcoatNormalSampler;
339
+ #endif
351
340
  #ifdef HAS_SHEENCOLORMAP
352
341
  uniform sampler2D pbr_sheenColorSampler;
342
+ #endif
343
+ #ifdef HAS_SHEENROUGHNESSMAP
353
344
  uniform sampler2D pbr_sheenRoughnessSampler;
354
345
  #endif
355
346
  #ifdef HAS_IRIDESCENCEMAP
356
347
  uniform sampler2D pbr_iridescenceSampler;
357
348
  #endif
349
+ #ifdef HAS_IRIDESCENCETHICKNESSMAP
350
+ uniform sampler2D pbr_iridescenceThicknessSampler;
351
+ #endif
358
352
  #ifdef HAS_ANISOTROPYMAP
359
353
  uniform sampler2D pbr_anisotropySampler;
360
354
  #endif
361
- #ifdef USE_IBL
362
- uniform samplerCube pbr_diffuseEnvSampler;
363
- uniform samplerCube pbr_specularEnvSampler;
364
- uniform sampler2D pbr_brdfLUT;
365
- #endif
366
-
367
355
  // Inputs from vertex shader
368
356
 
369
357
  in vec3 pbr_vPosition;
@@ -400,6 +388,8 @@ struct PBRInfo {
400
388
  const float M_PI = 3.141592653589793;
401
389
  const float c_MinRoughness = 0.04;
402
390
 
391
+ vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor);
392
+
403
393
  vec4 SRGBtoLINEAR(vec4 srgbIn)
404
394
  {
405
395
  #ifdef MANUAL_SRGB
@@ -415,11 +405,9 @@ vec4 SRGBtoLINEAR(vec4 srgbIn)
415
405
  #endif //MANUAL_SRGB
416
406
  }
417
407
 
418
- // Find the normal for this fragment, pulling either from a predefined normal map
419
- // or from the interpolated mesh normal and tangent attributes.
420
- vec3 getNormal()
408
+ // Build the tangent basis from interpolated attributes or screen-space derivatives.
409
+ mat3 getTBN()
421
410
  {
422
- // Retrieve the tangent space matrix
423
411
  #ifndef HAS_TANGENTS
424
412
  vec3 pos_dx = dFdx(pbr_vPosition);
425
413
  vec3 pos_dy = dFdy(pbr_vPosition);
@@ -440,9 +428,21 @@ vec3 getNormal()
440
428
  mat3 tbn = pbr_vTBN;
441
429
  #endif
442
430
 
431
+ return tbn;
432
+ }
433
+
434
+ // Find the normal for this fragment, pulling either from a predefined normal map
435
+ // or from the interpolated mesh normal and tangent attributes.
436
+ vec3 getMappedNormal(sampler2D normalSampler, mat3 tbn, float normalScale)
437
+ {
438
+ vec3 n = texture(normalSampler, pbr_vUV).rgb;
439
+ return normalize(tbn * ((2.0 * n - 1.0) * vec3(normalScale, normalScale, 1.0)));
440
+ }
441
+
442
+ vec3 getNormal(mat3 tbn)
443
+ {
443
444
  #ifdef HAS_NORMALMAP
444
- vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
445
- n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
445
+ vec3 n = getMappedNormal(pbr_normalSampler, tbn, pbrMaterial.normalScale);
446
446
  #else
447
447
  // The tbn matrix is linearly interpolated, so we need to re-normalize
448
448
  vec3 n = normalize(tbn[2].xyz);
@@ -451,6 +451,15 @@ vec3 getNormal()
451
451
  return n;
452
452
  }
453
453
 
454
+ vec3 getClearcoatNormal(mat3 tbn, vec3 baseNormal)
455
+ {
456
+ #ifdef HAS_CLEARCOATNORMALMAP
457
+ return getMappedNormal(pbr_clearcoatNormalSampler, tbn, 1.0);
458
+ #else
459
+ return baseNormal;
460
+ #endif
461
+ }
462
+
454
463
  // Calculation of the lighting contribution from an optional Image Based Light source.
455
464
  // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
456
465
  // See our README.md on Environment Maps [3] for additional discussion.
@@ -526,6 +535,169 @@ float microfacetDistribution(PBRInfo pbrInfo)
526
535
  return roughnessSq / (M_PI * f * f);
527
536
  }
528
537
 
538
+ float maxComponent(vec3 value)
539
+ {
540
+ return max(max(value.r, value.g), value.b);
541
+ }
542
+
543
+ float getDielectricF0(float ior)
544
+ {
545
+ float clampedIor = max(ior, 1.0);
546
+ float ratio = (clampedIor - 1.0) / (clampedIor + 1.0);
547
+ return ratio * ratio;
548
+ }
549
+
550
+ vec2 normalizeDirection(vec2 direction)
551
+ {
552
+ float directionLength = length(direction);
553
+ return directionLength > 0.0001 ? direction / directionLength : vec2(1.0, 0.0);
554
+ }
555
+
556
+ vec2 rotateDirection(vec2 direction, float rotation)
557
+ {
558
+ float s = sin(rotation);
559
+ float c = cos(rotation);
560
+ return vec2(direction.x * c - direction.y * s, direction.x * s + direction.y * c);
561
+ }
562
+
563
+ vec3 getIridescenceTint(float iridescence, float thickness, float NdotV)
564
+ {
565
+ if (iridescence <= 0.0) {
566
+ return vec3(1.0);
567
+ }
568
+
569
+ float phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0;
570
+ vec3 thinFilmTint =
571
+ 0.5 + 0.5 * cos(vec3(phase, phase + 2.0943951, phase + 4.1887902));
572
+ return mix(vec3(1.0), thinFilmTint, iridescence);
573
+ }
574
+
575
+ vec3 getVolumeAttenuation(float thickness)
576
+ {
577
+ if (thickness <= 0.0) {
578
+ return vec3(1.0);
579
+ }
580
+
581
+ vec3 attenuationCoefficient =
582
+ -log(max(pbrMaterial.attenuationColor, vec3(0.0001))) /
583
+ max(pbrMaterial.attenuationDistance, 0.0001);
584
+ return exp(-attenuationCoefficient * thickness);
585
+ }
586
+
587
+ PBRInfo createClearcoatPBRInfo(PBRInfo basePBRInfo, vec3 clearcoatNormal, float clearcoatRoughness)
588
+ {
589
+ float perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
590
+ float alphaRoughness = perceptualRoughness * perceptualRoughness;
591
+ float NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0);
592
+
593
+ return PBRInfo(
594
+ basePBRInfo.NdotL,
595
+ NdotV,
596
+ basePBRInfo.NdotH,
597
+ basePBRInfo.LdotH,
598
+ basePBRInfo.VdotH,
599
+ perceptualRoughness,
600
+ 0.0,
601
+ vec3(0.04),
602
+ vec3(1.0),
603
+ alphaRoughness,
604
+ vec3(0.0),
605
+ vec3(0.04),
606
+ clearcoatNormal,
607
+ basePBRInfo.v
608
+ );
609
+ }
610
+
611
+ vec3 calculateClearcoatContribution(
612
+ PBRInfo pbrInfo,
613
+ vec3 lightColor,
614
+ vec3 clearcoatNormal,
615
+ float clearcoatFactor,
616
+ float clearcoatRoughness
617
+ ) {
618
+ if (clearcoatFactor <= 0.0) {
619
+ return vec3(0.0);
620
+ }
621
+
622
+ PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);
623
+ return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor;
624
+ }
625
+
626
+ #ifdef USE_IBL
627
+ vec3 calculateClearcoatIBLContribution(
628
+ PBRInfo pbrInfo,
629
+ vec3 clearcoatNormal,
630
+ vec3 reflection,
631
+ float clearcoatFactor,
632
+ float clearcoatRoughness
633
+ ) {
634
+ if (clearcoatFactor <= 0.0) {
635
+ return vec3(0.0);
636
+ }
637
+
638
+ PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);
639
+ return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor;
640
+ }
641
+ #endif
642
+
643
+ vec3 calculateSheenContribution(
644
+ PBRInfo pbrInfo,
645
+ vec3 lightColor,
646
+ vec3 sheenColor,
647
+ float sheenRoughness
648
+ ) {
649
+ if (maxComponent(sheenColor) <= 0.0) {
650
+ return vec3(0.0);
651
+ }
652
+
653
+ float sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
654
+ float sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness);
655
+ return pbrInfo.NdotL *
656
+ lightColor *
657
+ sheenColor *
658
+ (0.25 + 0.75 * sheenFresnel) *
659
+ sheenVisibility *
660
+ (1.0 - pbrInfo.metalness);
661
+ }
662
+
663
+ float calculateAnisotropyBoost(
664
+ PBRInfo pbrInfo,
665
+ vec3 anisotropyTangent,
666
+ float anisotropyStrength
667
+ ) {
668
+ if (anisotropyStrength <= 0.0) {
669
+ return 1.0;
670
+ }
671
+
672
+ vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));
673
+ float bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent));
674
+ return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength);
675
+ }
676
+
677
+ vec3 calculateMaterialLightColor(
678
+ PBRInfo pbrInfo,
679
+ vec3 lightColor,
680
+ vec3 clearcoatNormal,
681
+ float clearcoatFactor,
682
+ float clearcoatRoughness,
683
+ vec3 sheenColor,
684
+ float sheenRoughness,
685
+ vec3 anisotropyTangent,
686
+ float anisotropyStrength
687
+ ) {
688
+ float anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);
689
+ vec3 color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost;
690
+ color += calculateClearcoatContribution(
691
+ pbrInfo,
692
+ lightColor,
693
+ clearcoatNormal,
694
+ clearcoatFactor,
695
+ clearcoatRoughness
696
+ );
697
+ color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness);
698
+ return color;
699
+ }
700
+
529
701
  void PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) {
530
702
  pbrInfo.NdotL = 1.0;
531
703
  pbrInfo.NdotH = 0.0;
@@ -550,6 +722,11 @@ void PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) {
550
722
  PBRInfo_setDirectionalLight(pbrInfo, light_direction);
551
723
  }
552
724
 
725
+ void PBRInfo_setSpotLight(inout PBRInfo pbrInfo, SpotLight spotLight) {
726
+ vec3 light_direction = normalize(spotLight.position - pbr_vPosition);
727
+ PBRInfo_setDirectionalLight(pbrInfo, light_direction);
728
+ }
729
+
553
730
  vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {
554
731
  // Calculate the shading terms for the microfacet specular shading model
555
732
  vec3 F = specularReflection(pbrInfo);
@@ -580,6 +757,8 @@ vec4 pbr_filterColor(vec4 colorUnused)
580
757
 
581
758
  vec3 color = vec3(0, 0, 0);
582
759
 
760
+ float transmission = 0.0;
761
+
583
762
  if(pbrMaterial.unlit){
584
763
  color.rgb = baseColor.rgb;
585
764
  }
@@ -598,14 +777,252 @@ vec4 pbr_filterColor(vec4 colorUnused)
598
777
  #endif
599
778
  perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
600
779
  metallic = clamp(metallic, 0.0, 1.0);
780
+ mat3 tbn = getTBN();
781
+ vec3 n = getNormal(tbn); // normal at surface point
782
+ vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
783
+ float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
784
+ #ifdef USE_MATERIAL_EXTENSIONS
785
+ bool useExtendedPBR =
786
+ pbrMaterial.specularColorMapEnabled ||
787
+ pbrMaterial.specularIntensityMapEnabled ||
788
+ abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||
789
+ maxComponent(abs(pbrMaterial.specularColorFactor - vec3(1.0))) > 0.0001 ||
790
+ abs(pbrMaterial.ior - 1.5) > 0.0001 ||
791
+ pbrMaterial.transmissionMapEnabled ||
792
+ pbrMaterial.transmissionFactor > 0.0001 ||
793
+ pbrMaterial.clearcoatMapEnabled ||
794
+ pbrMaterial.clearcoatRoughnessMapEnabled ||
795
+ pbrMaterial.clearcoatFactor > 0.0001 ||
796
+ pbrMaterial.clearcoatRoughnessFactor > 0.0001 ||
797
+ pbrMaterial.sheenColorMapEnabled ||
798
+ pbrMaterial.sheenRoughnessMapEnabled ||
799
+ maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 ||
800
+ pbrMaterial.sheenRoughnessFactor > 0.0001 ||
801
+ pbrMaterial.iridescenceMapEnabled ||
802
+ pbrMaterial.iridescenceFactor > 0.0001 ||
803
+ abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 ||
804
+ abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 ||
805
+ abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 ||
806
+ pbrMaterial.anisotropyMapEnabled ||
807
+ pbrMaterial.anisotropyStrength > 0.0001 ||
808
+ abs(pbrMaterial.anisotropyRotation) > 0.0001 ||
809
+ length(pbrMaterial.anisotropyDirection - vec2(1.0, 0.0)) > 0.0001;
810
+ #else
811
+ bool useExtendedPBR = false;
812
+ #endif
813
+
814
+ if (!useExtendedPBR) {
815
+ // Keep the baseline metallic-roughness implementation byte-for-byte equivalent in behavior.
816
+ float alphaRoughness = perceptualRoughness * perceptualRoughness;
817
+
818
+ vec3 f0 = vec3(0.04);
819
+ vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
820
+ diffuseColor *= 1.0 - metallic;
821
+ vec3 specularColor = mix(f0, baseColor.rgb, metallic);
822
+
823
+ float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
824
+ float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
825
+ vec3 specularEnvironmentR0 = specularColor.rgb;
826
+ vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
827
+ vec3 reflection = -normalize(reflect(v, n));
828
+
829
+ PBRInfo pbrInfo = PBRInfo(
830
+ 0.0, // NdotL
831
+ NdotV,
832
+ 0.0, // NdotH
833
+ 0.0, // LdotH
834
+ 0.0, // VdotH
835
+ perceptualRoughness,
836
+ metallic,
837
+ specularEnvironmentR0,
838
+ specularEnvironmentR90,
839
+ alphaRoughness,
840
+ diffuseColor,
841
+ specularColor,
842
+ n,
843
+ v
844
+ );
845
+
846
+ #ifdef USE_LIGHTS
847
+ PBRInfo_setAmbientLight(pbrInfo);
848
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
849
+
850
+ for(int i = 0; i < lighting.directionalLightCount; i++) {
851
+ if (i < lighting.directionalLightCount) {
852
+ PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
853
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
854
+ }
855
+ }
856
+
857
+ for(int i = 0; i < lighting.pointLightCount; i++) {
858
+ if (i < lighting.pointLightCount) {
859
+ PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
860
+ float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
861
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
862
+ }
863
+ }
864
+
865
+ for(int i = 0; i < lighting.spotLightCount; i++) {
866
+ if (i < lighting.spotLightCount) {
867
+ PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));
868
+ float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);
869
+ color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation);
870
+ }
871
+ }
872
+ #endif
873
+
874
+ #ifdef USE_IBL
875
+ if (pbrMaterial.IBLenabled) {
876
+ color += getIBLContribution(pbrInfo, n, reflection);
877
+ }
878
+ #endif
879
+
880
+ #ifdef HAS_OCCLUSIONMAP
881
+ if (pbrMaterial.occlusionMapEnabled) {
882
+ float ao = texture(pbr_occlusionSampler, pbr_vUV).r;
883
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
884
+ }
885
+ #endif
886
+
887
+ vec3 emissive = pbrMaterial.emissiveFactor;
888
+ #ifdef HAS_EMISSIVEMAP
889
+ if (pbrMaterial.emissiveMapEnabled) {
890
+ emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb;
891
+ }
892
+ #endif
893
+ color += emissive * pbrMaterial.emissiveStrength;
894
+
895
+ #ifdef PBR_DEBUG
896
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
897
+ color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
898
+ color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
899
+ #endif
900
+
901
+ return vec4(pow(color, vec3(1.0 / 2.2)), baseColor.a);
902
+ }
903
+
904
+ float specularIntensity = pbrMaterial.specularIntensityFactor;
905
+ #ifdef HAS_SPECULARINTENSITYMAP
906
+ if (pbrMaterial.specularIntensityMapEnabled) {
907
+ specularIntensity *= texture(pbr_specularIntensitySampler, pbr_vUV).a;
908
+ }
909
+ #endif
910
+
911
+ vec3 specularFactor = pbrMaterial.specularColorFactor;
912
+ #ifdef HAS_SPECULARCOLORMAP
913
+ if (pbrMaterial.specularColorMapEnabled) {
914
+ specularFactor *= SRGBtoLINEAR(texture(pbr_specularColorSampler, pbr_vUV)).rgb;
915
+ }
916
+ #endif
917
+
918
+ transmission = pbrMaterial.transmissionFactor;
919
+ #ifdef HAS_TRANSMISSIONMAP
920
+ if (pbrMaterial.transmissionMapEnabled) {
921
+ transmission *= texture(pbr_transmissionSampler, pbr_vUV).r;
922
+ }
923
+ #endif
924
+ transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0);
925
+ float thickness = max(pbrMaterial.thicknessFactor, 0.0);
926
+ #ifdef HAS_THICKNESSMAP
927
+ thickness *= texture(pbr_thicknessSampler, pbr_vUV).g;
928
+ #endif
929
+
930
+ float clearcoatFactor = pbrMaterial.clearcoatFactor;
931
+ float clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;
932
+ #ifdef HAS_CLEARCOATMAP
933
+ if (pbrMaterial.clearcoatMapEnabled) {
934
+ clearcoatFactor *= texture(pbr_clearcoatSampler, pbr_vUV).r;
935
+ }
936
+ #endif
937
+ #ifdef HAS_CLEARCOATROUGHNESSMAP
938
+ if (pbrMaterial.clearcoatRoughnessMapEnabled) {
939
+ clearcoatRoughness *= texture(pbr_clearcoatRoughnessSampler, pbr_vUV).g;
940
+ }
941
+ #endif
942
+ clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);
943
+ clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
944
+ vec3 clearcoatNormal = getClearcoatNormal(tbn, n);
945
+
946
+ vec3 sheenColor = pbrMaterial.sheenColorFactor;
947
+ float sheenRoughness = pbrMaterial.sheenRoughnessFactor;
948
+ #ifdef HAS_SHEENCOLORMAP
949
+ if (pbrMaterial.sheenColorMapEnabled) {
950
+ sheenColor *= SRGBtoLINEAR(texture(pbr_sheenColorSampler, pbr_vUV)).rgb;
951
+ }
952
+ #endif
953
+ #ifdef HAS_SHEENROUGHNESSMAP
954
+ if (pbrMaterial.sheenRoughnessMapEnabled) {
955
+ sheenRoughness *= texture(pbr_sheenRoughnessSampler, pbr_vUV).a;
956
+ }
957
+ #endif
958
+ sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0);
959
+
960
+ float iridescence = pbrMaterial.iridescenceFactor;
961
+ #ifdef HAS_IRIDESCENCEMAP
962
+ if (pbrMaterial.iridescenceMapEnabled) {
963
+ iridescence *= texture(pbr_iridescenceSampler, pbr_vUV).r;
964
+ }
965
+ #endif
966
+ iridescence = clamp(iridescence, 0.0, 1.0);
967
+ float iridescenceThickness = mix(
968
+ pbrMaterial.iridescenceThicknessRange.x,
969
+ pbrMaterial.iridescenceThicknessRange.y,
970
+ 0.5
971
+ );
972
+ #ifdef HAS_IRIDESCENCETHICKNESSMAP
973
+ iridescenceThickness = mix(
974
+ pbrMaterial.iridescenceThicknessRange.x,
975
+ pbrMaterial.iridescenceThicknessRange.y,
976
+ texture(pbr_iridescenceThicknessSampler, pbr_vUV).g
977
+ );
978
+ #endif
979
+
980
+ float anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0);
981
+ vec2 anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection);
982
+ #ifdef HAS_ANISOTROPYMAP
983
+ if (pbrMaterial.anisotropyMapEnabled) {
984
+ vec3 anisotropySample = texture(pbr_anisotropySampler, pbr_vUV).rgb;
985
+ anisotropyStrength *= anisotropySample.b;
986
+ vec2 mappedDirection = anisotropySample.rg * 2.0 - 1.0;
987
+ if (length(mappedDirection) > 0.0001) {
988
+ anisotropyDirection = normalize(mappedDirection);
989
+ }
990
+ }
991
+ #endif
992
+ anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation);
993
+ vec3 anisotropyTangent = normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y);
994
+ if (length(anisotropyTangent) < 0.0001) {
995
+ anisotropyTangent = normalize(tbn[0]);
996
+ }
997
+ float anisotropyViewAlignment = abs(dot(v, anisotropyTangent));
998
+ perceptualRoughness = mix(
999
+ perceptualRoughness,
1000
+ clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),
1001
+ anisotropyStrength
1002
+ );
1003
+
601
1004
  // Roughness is authored as perceptual roughness; as is convention,
602
1005
  // convert to material roughness by squaring the perceptual roughness [2].
603
1006
  float alphaRoughness = perceptualRoughness * perceptualRoughness;
604
1007
 
605
- vec3 f0 = vec3(0.04);
606
- vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
607
- diffuseColor *= 1.0 - metallic;
608
- vec3 specularColor = mix(f0, baseColor.rgb, metallic);
1008
+ float dielectricF0 = getDielectricF0(pbrMaterial.ior);
1009
+ vec3 dielectricSpecularF0 = min(
1010
+ vec3(dielectricF0) * specularFactor * specularIntensity,
1011
+ vec3(1.0)
1012
+ );
1013
+ vec3 iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV);
1014
+ dielectricSpecularF0 = mix(
1015
+ dielectricSpecularF0,
1016
+ dielectricSpecularF0 * iridescenceTint,
1017
+ iridescence
1018
+ );
1019
+ vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - dielectricSpecularF0);
1020
+ diffuseColor *= (1.0 - metallic) * (1.0 - transmission);
1021
+ vec3 specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);
1022
+
1023
+ float baseLayerEnergy = 1.0 - clearcoatFactor * 0.25;
1024
+ diffuseColor *= baseLayerEnergy;
1025
+ specularColor *= baseLayerEnergy;
609
1026
 
610
1027
  // Compute reflectance.
611
1028
  float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
@@ -617,11 +1034,6 @@ vec4 pbr_filterColor(vec4 colorUnused)
617
1034
  float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
618
1035
  vec3 specularEnvironmentR0 = specularColor.rgb;
619
1036
  vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
620
-
621
- vec3 n = getNormal(); // normal at surface point
622
- vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
623
-
624
- float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
625
1037
  vec3 reflection = -normalize(reflect(v, n));
626
1038
 
627
1039
  PBRInfo pbrInfo = PBRInfo(
@@ -645,13 +1057,33 @@ vec4 pbr_filterColor(vec4 colorUnused)
645
1057
  #ifdef USE_LIGHTS
646
1058
  // Apply ambient light
647
1059
  PBRInfo_setAmbientLight(pbrInfo);
648
- color += calculateFinalColor(pbrInfo, lighting.ambientColor);
1060
+ color += calculateMaterialLightColor(
1061
+ pbrInfo,
1062
+ lighting.ambientColor,
1063
+ clearcoatNormal,
1064
+ clearcoatFactor,
1065
+ clearcoatRoughness,
1066
+ sheenColor,
1067
+ sheenRoughness,
1068
+ anisotropyTangent,
1069
+ anisotropyStrength
1070
+ );
649
1071
 
650
1072
  // Apply directional light
651
1073
  for(int i = 0; i < lighting.directionalLightCount; i++) {
652
1074
  if (i < lighting.directionalLightCount) {
653
1075
  PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
654
- color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
1076
+ color += calculateMaterialLightColor(
1077
+ pbrInfo,
1078
+ lighting_getDirectionalLight(i).color,
1079
+ clearcoatNormal,
1080
+ clearcoatFactor,
1081
+ clearcoatRoughness,
1082
+ sheenColor,
1083
+ sheenRoughness,
1084
+ anisotropyTangent,
1085
+ anisotropyStrength
1086
+ );
655
1087
  }
656
1088
  }
657
1089
 
@@ -660,7 +1092,35 @@ vec4 pbr_filterColor(vec4 colorUnused)
660
1092
  if (i < lighting.pointLightCount) {
661
1093
  PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
662
1094
  float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
663
- color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
1095
+ color += calculateMaterialLightColor(
1096
+ pbrInfo,
1097
+ lighting_getPointLight(i).color / attenuation,
1098
+ clearcoatNormal,
1099
+ clearcoatFactor,
1100
+ clearcoatRoughness,
1101
+ sheenColor,
1102
+ sheenRoughness,
1103
+ anisotropyTangent,
1104
+ anisotropyStrength
1105
+ );
1106
+ }
1107
+ }
1108
+
1109
+ for(int i = 0; i < lighting.spotLightCount; i++) {
1110
+ if (i < lighting.spotLightCount) {
1111
+ PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));
1112
+ float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);
1113
+ color += calculateMaterialLightColor(
1114
+ pbrInfo,
1115
+ lighting_getSpotLight(i).color / attenuation,
1116
+ clearcoatNormal,
1117
+ clearcoatFactor,
1118
+ clearcoatRoughness,
1119
+ sheenColor,
1120
+ sheenRoughness,
1121
+ anisotropyTangent,
1122
+ anisotropyStrength
1123
+ );
664
1124
  }
665
1125
  }
666
1126
  #endif
@@ -668,7 +1128,16 @@ vec4 pbr_filterColor(vec4 colorUnused)
668
1128
  // Calculate lighting contribution from image based lighting source (IBL)
669
1129
  #ifdef USE_IBL
670
1130
  if (pbrMaterial.IBLenabled) {
671
- color += getIBLContribution(pbrInfo, n, reflection);
1131
+ color += getIBLContribution(pbrInfo, n, reflection) *
1132
+ calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);
1133
+ color += calculateClearcoatIBLContribution(
1134
+ pbrInfo,
1135
+ clearcoatNormal,
1136
+ -normalize(reflect(v, clearcoatNormal)),
1137
+ clearcoatFactor,
1138
+ clearcoatRoughness
1139
+ );
1140
+ color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;
672
1141
  }
673
1142
  #endif
674
1143
 
@@ -680,12 +1149,17 @@ vec4 pbr_filterColor(vec4 colorUnused)
680
1149
  }
681
1150
  #endif
682
1151
 
1152
+ vec3 emissive = pbrMaterial.emissiveFactor;
683
1153
  #ifdef HAS_EMISSIVEMAP
684
1154
  if (pbrMaterial.emissiveMapEnabled) {
685
- vec3 emissive = SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
686
- color += emissive;
1155
+ emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb;
687
1156
  }
688
1157
  #endif
1158
+ color += emissive * pbrMaterial.emissiveStrength;
1159
+
1160
+ if (transmission > 0.0) {
1161
+ color = mix(color, color * getVolumeAttenuation(thickness), transmission);
1162
+ }
689
1163
 
690
1164
  // This section uses mix to override final color for reference app visualization
691
1165
  // of various parameters in the lighting equation.
@@ -705,9 +1179,10 @@ vec4 pbr_filterColor(vec4 colorUnused)
705
1179
 
706
1180
  }
707
1181
 
708
- return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
1182
+ float alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);
1183
+ return vec4(pow(color,vec3(1.0/2.2)), alpha);
709
1184
  }
710
- `;var Xp=`struct PBRFragmentInputs {
1185
+ `;var Zd=`struct PBRFragmentInputs {
711
1186
  pbr_vPosition: vec3f,
712
1187
  pbr_vUV: vec2f,
713
1188
  pbr_vTBN: mat3x3f,
@@ -765,6 +1240,42 @@ struct pbrMaterialUniforms {
765
1240
 
766
1241
  alphaCutoffEnabled: i32,
767
1242
  alphaCutoff: f32, // #ifdef ALPHA_CUTOFF
1243
+
1244
+ specularColorFactor: vec3f,
1245
+ specularIntensityFactor: f32,
1246
+ specularColorMapEnabled: i32,
1247
+ specularIntensityMapEnabled: i32,
1248
+
1249
+ ior: f32,
1250
+
1251
+ transmissionFactor: f32,
1252
+ transmissionMapEnabled: i32,
1253
+
1254
+ thicknessFactor: f32,
1255
+ attenuationDistance: f32,
1256
+ attenuationColor: vec3f,
1257
+
1258
+ clearcoatFactor: f32,
1259
+ clearcoatRoughnessFactor: f32,
1260
+ clearcoatMapEnabled: i32,
1261
+ clearcoatRoughnessMapEnabled: i32,
1262
+
1263
+ sheenColorFactor: vec3f,
1264
+ sheenRoughnessFactor: f32,
1265
+ sheenColorMapEnabled: i32,
1266
+ sheenRoughnessMapEnabled: i32,
1267
+
1268
+ iridescenceFactor: f32,
1269
+ iridescenceIor: f32,
1270
+ iridescenceThicknessRange: vec2f,
1271
+ iridescenceMapEnabled: i32,
1272
+
1273
+ anisotropyStrength: f32,
1274
+ anisotropyRotation: f32,
1275
+ anisotropyDirection: vec2f,
1276
+ anisotropyMapEnabled: i32,
1277
+
1278
+ emissiveStrength: f32,
768
1279
 
769
1280
  // IBL
770
1281
  IBLenabled: i32,
@@ -777,38 +1288,77 @@ struct pbrMaterialUniforms {
777
1288
  // #endif
778
1289
  }
779
1290
 
780
- @binding(2) @group(0) var<uniform> pbrMaterial : pbrMaterialUniforms;
1291
+ @group(3) @binding(auto) var<uniform> pbrMaterial : pbrMaterialUniforms;
781
1292
 
782
1293
  // Samplers
783
1294
  #ifdef HAS_BASECOLORMAP
784
- @binding(3) @group(0) var pbr_baseColorSampler: texture_2d<f32>;
785
- @binding(4) @group(0) var pbr_baseColorSamplerSampler: sampler;
1295
+ @group(3) @binding(auto) var pbr_baseColorSampler: texture_2d<f32>;
1296
+ @group(3) @binding(auto) var pbr_baseColorSamplerSampler: sampler;
786
1297
  #endif
787
1298
  #ifdef HAS_NORMALMAP
788
- @binding(5) @group(0) var pbr_normalSampler: texture_2d<f32>;
789
- @binding(6) @group(0) var pbr_normalSamplerSampler: sampler;
1299
+ @group(3) @binding(auto) var pbr_normalSampler: texture_2d<f32>;
1300
+ @group(3) @binding(auto) var pbr_normalSamplerSampler: sampler;
790
1301
  #endif
791
1302
  #ifdef HAS_EMISSIVEMAP
792
- @binding(7) @group(0) var pbr_emissiveSampler: texture_2d<f32>;
793
- @binding(8) @group(0) var pbr_emissiveSamplerSampler: sampler;
1303
+ @group(3) @binding(auto) var pbr_emissiveSampler: texture_2d<f32>;
1304
+ @group(3) @binding(auto) var pbr_emissiveSamplerSampler: sampler;
794
1305
  #endif
795
1306
  #ifdef HAS_METALROUGHNESSMAP
796
- @binding(9) @group(0) var pbr_metallicRoughnessSampler: texture_2d<f32>;
797
- @binding(10) @group(0) var pbr_metallicRoughnessSamplerSampler: sampler;
1307
+ @group(3) @binding(auto) var pbr_metallicRoughnessSampler: texture_2d<f32>;
1308
+ @group(3) @binding(auto) var pbr_metallicRoughnessSamplerSampler: sampler;
798
1309
  #endif
799
1310
  #ifdef HAS_OCCLUSIONMAP
800
- @binding(11) @group(0) var pbr_occlusionSampler: texture_2d<f32>;
801
- @binding(12) @group(0) var pbr_occlusionSamplerSampler: sampler;
1311
+ @group(3) @binding(auto) var pbr_occlusionSampler: texture_2d<f32>;
1312
+ @group(3) @binding(auto) var pbr_occlusionSamplerSampler: sampler;
802
1313
  #endif
803
- #ifdef USE_IBL
804
- @binding(13) @group(0) var pbr_diffuseEnvSampler: texture_cube<f32>;
805
- @binding(14) @group(0) var pbr_diffuseEnvSamplerSampler: sampler;
806
- @binding(15) @group(0) var pbr_specularEnvSampler: texture_cube<f32>;
807
- @binding(16) @group(0) var pbr_specularEnvSamplerSampler: sampler;
808
- @binding(17) @group(0) var pbr_BrdfLUT: texture_2d<f32>;
809
- @binding(18) @group(0) var pbr_BrdfLUTSampler: sampler;
1314
+ #ifdef HAS_SPECULARCOLORMAP
1315
+ @group(3) @binding(auto) var pbr_specularColorSampler: texture_2d<f32>;
1316
+ @group(3) @binding(auto) var pbr_specularColorSamplerSampler: sampler;
1317
+ #endif
1318
+ #ifdef HAS_SPECULARINTENSITYMAP
1319
+ @group(3) @binding(auto) var pbr_specularIntensitySampler: texture_2d<f32>;
1320
+ @group(3) @binding(auto) var pbr_specularIntensitySamplerSampler: sampler;
1321
+ #endif
1322
+ #ifdef HAS_TRANSMISSIONMAP
1323
+ @group(3) @binding(auto) var pbr_transmissionSampler: texture_2d<f32>;
1324
+ @group(3) @binding(auto) var pbr_transmissionSamplerSampler: sampler;
1325
+ #endif
1326
+ #ifdef HAS_THICKNESSMAP
1327
+ @group(3) @binding(auto) var pbr_thicknessSampler: texture_2d<f32>;
1328
+ @group(3) @binding(auto) var pbr_thicknessSamplerSampler: sampler;
1329
+ #endif
1330
+ #ifdef HAS_CLEARCOATMAP
1331
+ @group(3) @binding(auto) var pbr_clearcoatSampler: texture_2d<f32>;
1332
+ @group(3) @binding(auto) var pbr_clearcoatSamplerSampler: sampler;
1333
+ #endif
1334
+ #ifdef HAS_CLEARCOATROUGHNESSMAP
1335
+ @group(3) @binding(auto) var pbr_clearcoatRoughnessSampler: texture_2d<f32>;
1336
+ @group(3) @binding(auto) var pbr_clearcoatRoughnessSamplerSampler: sampler;
1337
+ #endif
1338
+ #ifdef HAS_CLEARCOATNORMALMAP
1339
+ @group(3) @binding(auto) var pbr_clearcoatNormalSampler: texture_2d<f32>;
1340
+ @group(3) @binding(auto) var pbr_clearcoatNormalSamplerSampler: sampler;
1341
+ #endif
1342
+ #ifdef HAS_SHEENCOLORMAP
1343
+ @group(3) @binding(auto) var pbr_sheenColorSampler: texture_2d<f32>;
1344
+ @group(3) @binding(auto) var pbr_sheenColorSamplerSampler: sampler;
1345
+ #endif
1346
+ #ifdef HAS_SHEENROUGHNESSMAP
1347
+ @group(3) @binding(auto) var pbr_sheenRoughnessSampler: texture_2d<f32>;
1348
+ @group(3) @binding(auto) var pbr_sheenRoughnessSamplerSampler: sampler;
1349
+ #endif
1350
+ #ifdef HAS_IRIDESCENCEMAP
1351
+ @group(3) @binding(auto) var pbr_iridescenceSampler: texture_2d<f32>;
1352
+ @group(3) @binding(auto) var pbr_iridescenceSamplerSampler: sampler;
1353
+ #endif
1354
+ #ifdef HAS_IRIDESCENCETHICKNESSMAP
1355
+ @group(3) @binding(auto) var pbr_iridescenceThicknessSampler: texture_2d<f32>;
1356
+ @group(3) @binding(auto) var pbr_iridescenceThicknessSamplerSampler: sampler;
1357
+ #endif
1358
+ #ifdef HAS_ANISOTROPYMAP
1359
+ @group(3) @binding(auto) var pbr_anisotropySampler: texture_2d<f32>;
1360
+ @group(3) @binding(auto) var pbr_anisotropySamplerSampler: sampler;
810
1361
  #endif
811
-
812
1362
  // Encapsulate the various inputs used by the various functions in the shading equation
813
1363
  // We store values in this struct to simplify the integration of alternative implementations
814
1364
  // of the shading terms, outlined in the Readme.MD Appendix.
@@ -849,11 +1399,9 @@ fn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f
849
1399
  return vec4f(linOut, srgbIn.w);
850
1400
  }
851
1401
 
852
- // Find the normal for this fragment, pulling either from a predefined normal map
853
- // or from the interpolated mesh normal and tangent attributes.
854
- fn getNormal() -> vec3f
1402
+ // Build the tangent basis from interpolated attributes or screen-space derivatives.
1403
+ fn getTBN() -> mat3x3f
855
1404
  {
856
- // Retrieve the tangent space matrix
857
1405
  let pos_dx: vec3f = dpdx(fragmentInputs.pbr_vPosition);
858
1406
  let pos_dy: vec3f = dpdy(fragmentInputs.pbr_vPosition);
859
1407
  let tex_dx: vec3f = dpdx(vec3f(fragmentInputs.pbr_vUV, 0.0));
@@ -871,16 +1419,52 @@ fn getNormal() -> vec3f
871
1419
  tbn = fragmentInputs.pbr_vTBN;
872
1420
  #endif
873
1421
 
1422
+ return tbn;
1423
+ }
1424
+
1425
+ // Find the normal for this fragment, pulling either from a predefined normal map
1426
+ // or from the interpolated mesh normal and tangent attributes.
1427
+ fn getMappedNormal(
1428
+ normalSampler: texture_2d<f32>,
1429
+ normalSamplerBinding: sampler,
1430
+ tbn: mat3x3f,
1431
+ normalScale: f32
1432
+ ) -> vec3f
1433
+ {
1434
+ let n = textureSample(normalSampler, normalSamplerBinding, fragmentInputs.pbr_vUV).rgb;
1435
+ return normalize(tbn * ((2.0 * n - 1.0) * vec3f(normalScale, normalScale, 1.0)));
1436
+ }
1437
+
1438
+ fn getNormal(tbn: mat3x3f) -> vec3f
1439
+ {
874
1440
  // The tbn matrix is linearly interpolated, so we need to re-normalize
875
1441
  var n: vec3f = normalize(tbn[2].xyz);
876
1442
  #ifdef HAS_NORMALMAP
877
- n = textureSample(pbr_normalSampler, pbr_normalSamplerSampler, fragmentInputs.pbr_vUV).rgb;
878
- n = normalize(tbn * ((2.0 * n - 1.0) * vec3f(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
1443
+ n = getMappedNormal(
1444
+ pbr_normalSampler,
1445
+ pbr_normalSamplerSampler,
1446
+ tbn,
1447
+ pbrMaterial.normalScale
1448
+ );
879
1449
  #endif
880
1450
 
881
1451
  return n;
882
1452
  }
883
1453
 
1454
+ fn getClearcoatNormal(tbn: mat3x3f, baseNormal: vec3f) -> vec3f
1455
+ {
1456
+ #ifdef HAS_CLEARCOATNORMALMAP
1457
+ return getMappedNormal(
1458
+ pbr_clearcoatNormalSampler,
1459
+ pbr_clearcoatNormalSamplerSampler,
1460
+ tbn,
1461
+ 1.0
1462
+ );
1463
+ #else
1464
+ return baseNormal;
1465
+ #endif
1466
+ }
1467
+
884
1468
  // Calculation of the lighting contribution from an optional Image Based Light source.
885
1469
  // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
886
1470
  // See our README.md on Environment Maps [3] for additional discussion.
@@ -891,17 +1475,25 @@ fn getIBLContribution(pbrInfo: PBRInfo, n: vec3f, reflection: vec3f) -> vec3f
891
1475
  let lod: f32 = pbrInfo.perceptualRoughness * mipCount;
892
1476
  // retrieve a scale and bias to F0. See [1], Figure 3
893
1477
  let brdf = SRGBtoLINEAR(
894
- textureSample(
895
- pbr_BrdfLUT,
896
- pbr_BrdfLUTSampler,
897
- vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness)
1478
+ textureSampleLevel(
1479
+ pbr_brdfLUT,
1480
+ pbr_brdfLUTSampler,
1481
+ vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness),
1482
+ 0.0
898
1483
  )
899
1484
  ).rgb;
900
1485
  let diffuseLight =
901
- SRGBtoLINEAR(textureSample(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, n)).rgb;
902
- let specularLightDefault =
903
- SRGBtoLINEAR(textureSample(pbr_specularEnvSampler, pbr_specularEnvSamplerSampler, reflection)).rgb;
904
- var specularLight = specularLightDefault;
1486
+ SRGBtoLINEAR(
1487
+ textureSampleLevel(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, n, 0.0)
1488
+ ).rgb;
1489
+ var specularLight = SRGBtoLINEAR(
1490
+ textureSampleLevel(
1491
+ pbr_specularEnvSampler,
1492
+ pbr_specularEnvSamplerSampler,
1493
+ reflection,
1494
+ 0.0
1495
+ )
1496
+ ).rgb;
905
1497
  #ifdef USE_TEX_LOD
906
1498
  specularLight = SRGBtoLINEAR(
907
1499
  textureSampleLevel(
@@ -962,6 +1554,172 @@ fn microfacetDistribution(pbrInfo: PBRInfo) -> f32 {
962
1554
  return roughnessSq / (M_PI * f * f);
963
1555
  }
964
1556
 
1557
+ fn maxComponent(value: vec3f) -> f32 {
1558
+ return max(max(value.r, value.g), value.b);
1559
+ }
1560
+
1561
+ fn getDielectricF0(ior: f32) -> f32 {
1562
+ let clampedIor = max(ior, 1.0);
1563
+ let ratio = (clampedIor - 1.0) / (clampedIor + 1.0);
1564
+ return ratio * ratio;
1565
+ }
1566
+
1567
+ fn normalizeDirection(direction: vec2f) -> vec2f {
1568
+ let directionLength = length(direction);
1569
+ if (directionLength > 0.0001) {
1570
+ return direction / directionLength;
1571
+ }
1572
+
1573
+ return vec2f(1.0, 0.0);
1574
+ }
1575
+
1576
+ fn rotateDirection(direction: vec2f, rotation: f32) -> vec2f {
1577
+ let s = sin(rotation);
1578
+ let c = cos(rotation);
1579
+ return vec2f(direction.x * c - direction.y * s, direction.x * s + direction.y * c);
1580
+ }
1581
+
1582
+ fn getIridescenceTint(iridescence: f32, thickness: f32, NdotV: f32) -> vec3f {
1583
+ if (iridescence <= 0.0) {
1584
+ return vec3f(1.0);
1585
+ }
1586
+
1587
+ let phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0;
1588
+ let thinFilmTint =
1589
+ 0.5 +
1590
+ 0.5 *
1591
+ cos(vec3f(phase, phase + 2.0943951, phase + 4.1887902));
1592
+ return mix(vec3f(1.0), thinFilmTint, iridescence);
1593
+ }
1594
+
1595
+ fn getVolumeAttenuation(thickness: f32) -> vec3f {
1596
+ if (thickness <= 0.0) {
1597
+ return vec3f(1.0);
1598
+ }
1599
+
1600
+ let attenuationCoefficient =
1601
+ -log(max(pbrMaterial.attenuationColor, vec3f(0.0001))) /
1602
+ max(pbrMaterial.attenuationDistance, 0.0001);
1603
+ return exp(-attenuationCoefficient * thickness);
1604
+ }
1605
+
1606
+ fn createClearcoatPBRInfo(
1607
+ basePBRInfo: PBRInfo,
1608
+ clearcoatNormal: vec3f,
1609
+ clearcoatRoughness: f32
1610
+ ) -> PBRInfo {
1611
+ let perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
1612
+ let alphaRoughness = perceptualRoughness * perceptualRoughness;
1613
+ let NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0);
1614
+
1615
+ return PBRInfo(
1616
+ basePBRInfo.NdotL,
1617
+ NdotV,
1618
+ basePBRInfo.NdotH,
1619
+ basePBRInfo.LdotH,
1620
+ basePBRInfo.VdotH,
1621
+ perceptualRoughness,
1622
+ 0.0,
1623
+ vec3f(0.04),
1624
+ vec3f(1.0),
1625
+ alphaRoughness,
1626
+ vec3f(0.0),
1627
+ vec3f(0.04),
1628
+ clearcoatNormal,
1629
+ basePBRInfo.v
1630
+ );
1631
+ }
1632
+
1633
+ fn calculateClearcoatContribution(
1634
+ pbrInfo: PBRInfo,
1635
+ lightColor: vec3f,
1636
+ clearcoatNormal: vec3f,
1637
+ clearcoatFactor: f32,
1638
+ clearcoatRoughness: f32
1639
+ ) -> vec3f {
1640
+ if (clearcoatFactor <= 0.0) {
1641
+ return vec3f(0.0);
1642
+ }
1643
+
1644
+ let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);
1645
+ return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor;
1646
+ }
1647
+
1648
+ #ifdef USE_IBL
1649
+ fn calculateClearcoatIBLContribution(
1650
+ pbrInfo: PBRInfo,
1651
+ clearcoatNormal: vec3f,
1652
+ reflection: vec3f,
1653
+ clearcoatFactor: f32,
1654
+ clearcoatRoughness: f32
1655
+ ) -> vec3f {
1656
+ if (clearcoatFactor <= 0.0) {
1657
+ return vec3f(0.0);
1658
+ }
1659
+
1660
+ let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);
1661
+ return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor;
1662
+ }
1663
+ #endif
1664
+
1665
+ fn calculateSheenContribution(
1666
+ pbrInfo: PBRInfo,
1667
+ lightColor: vec3f,
1668
+ sheenColor: vec3f,
1669
+ sheenRoughness: f32
1670
+ ) -> vec3f {
1671
+ if (maxComponent(sheenColor) <= 0.0) {
1672
+ return vec3f(0.0);
1673
+ }
1674
+
1675
+ let sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
1676
+ let sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness);
1677
+ return pbrInfo.NdotL *
1678
+ lightColor *
1679
+ sheenColor *
1680
+ (0.25 + 0.75 * sheenFresnel) *
1681
+ sheenVisibility *
1682
+ (1.0 - pbrInfo.metalness);
1683
+ }
1684
+
1685
+ fn calculateAnisotropyBoost(
1686
+ pbrInfo: PBRInfo,
1687
+ anisotropyTangent: vec3f,
1688
+ anisotropyStrength: f32
1689
+ ) -> f32 {
1690
+ if (anisotropyStrength <= 0.0) {
1691
+ return 1.0;
1692
+ }
1693
+
1694
+ let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));
1695
+ let bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent));
1696
+ return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength);
1697
+ }
1698
+
1699
+ fn calculateMaterialLightColor(
1700
+ pbrInfo: PBRInfo,
1701
+ lightColor: vec3f,
1702
+ clearcoatNormal: vec3f,
1703
+ clearcoatFactor: f32,
1704
+ clearcoatRoughness: f32,
1705
+ sheenColor: vec3f,
1706
+ sheenRoughness: f32,
1707
+ anisotropyTangent: vec3f,
1708
+ anisotropyStrength: f32
1709
+ ) -> vec3f {
1710
+ let anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);
1711
+ var color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost;
1712
+ color += calculateClearcoatContribution(
1713
+ pbrInfo,
1714
+ lightColor,
1715
+ clearcoatNormal,
1716
+ clearcoatFactor,
1717
+ clearcoatRoughness
1718
+ );
1719
+ color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness);
1720
+ return color;
1721
+ }
1722
+
965
1723
  fn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) {
966
1724
  (*pbrInfo).NdotL = 1.0;
967
1725
  (*pbrInfo).NdotH = 0.0;
@@ -986,6 +1744,11 @@ fn PBRInfo_setPointLight(pbrInfo: ptr<function, PBRInfo>, pointLight: PointLight
986
1744
  PBRInfo_setDirectionalLight(pbrInfo, light_direction);
987
1745
  }
988
1746
 
1747
+ fn PBRInfo_setSpotLight(pbrInfo: ptr<function, PBRInfo>, spotLight: SpotLight) {
1748
+ let light_direction = normalize(spotLight.position - fragmentInputs.pbr_vPosition);
1749
+ PBRInfo_setDirectionalLight(pbrInfo, light_direction);
1750
+ }
1751
+
989
1752
  fn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> {
990
1753
  // Calculate the shading terms for the microfacet specular shading model
991
1754
  let F = specularReflection(pbrInfo);
@@ -1015,6 +1778,7 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
1015
1778
  #endif
1016
1779
 
1017
1780
  var color = vec3<f32>(0.0, 0.0, 0.0);
1781
+ var transmission = 0.0;
1018
1782
 
1019
1783
  if (pbrMaterial.unlit != 0u) {
1020
1784
  color = baseColor.rgb;
@@ -1037,14 +1801,308 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
1037
1801
  #endif
1038
1802
  perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
1039
1803
  metallic = clamp(metallic, 0.0, 1.0);
1804
+ let tbn = getTBN();
1805
+ let n = getNormal(tbn); // normal at surface point
1806
+ let v = normalize(pbrProjection.camera - fragmentInputs.pbr_vPosition); // Vector from surface point to camera
1807
+ let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
1808
+ var useExtendedPBR = false;
1809
+ #ifdef USE_MATERIAL_EXTENSIONS
1810
+ useExtendedPBR =
1811
+ pbrMaterial.specularColorMapEnabled != 0 ||
1812
+ pbrMaterial.specularIntensityMapEnabled != 0 ||
1813
+ abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||
1814
+ maxComponent(abs(pbrMaterial.specularColorFactor - vec3f(1.0))) > 0.0001 ||
1815
+ abs(pbrMaterial.ior - 1.5) > 0.0001 ||
1816
+ pbrMaterial.transmissionMapEnabled != 0 ||
1817
+ pbrMaterial.transmissionFactor > 0.0001 ||
1818
+ pbrMaterial.clearcoatMapEnabled != 0 ||
1819
+ pbrMaterial.clearcoatRoughnessMapEnabled != 0 ||
1820
+ pbrMaterial.clearcoatFactor > 0.0001 ||
1821
+ pbrMaterial.clearcoatRoughnessFactor > 0.0001 ||
1822
+ pbrMaterial.sheenColorMapEnabled != 0 ||
1823
+ pbrMaterial.sheenRoughnessMapEnabled != 0 ||
1824
+ maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 ||
1825
+ pbrMaterial.sheenRoughnessFactor > 0.0001 ||
1826
+ pbrMaterial.iridescenceMapEnabled != 0 ||
1827
+ pbrMaterial.iridescenceFactor > 0.0001 ||
1828
+ abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 ||
1829
+ abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 ||
1830
+ abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 ||
1831
+ pbrMaterial.anisotropyMapEnabled != 0 ||
1832
+ pbrMaterial.anisotropyStrength > 0.0001 ||
1833
+ abs(pbrMaterial.anisotropyRotation) > 0.0001 ||
1834
+ length(pbrMaterial.anisotropyDirection - vec2f(1.0, 0.0)) > 0.0001;
1835
+ #endif
1836
+
1837
+ if (!useExtendedPBR) {
1838
+ let alphaRoughness = perceptualRoughness * perceptualRoughness;
1839
+
1840
+ let f0 = vec3<f32>(0.04);
1841
+ var diffuseColor = baseColor.rgb * (vec3<f32>(1.0) - f0);
1842
+ diffuseColor *= 1.0 - metallic;
1843
+ let specularColor = mix(f0, baseColor.rgb, metallic);
1844
+
1845
+ let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
1846
+ let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
1847
+ let specularEnvironmentR0 = specularColor;
1848
+ let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;
1849
+ let reflection = -normalize(reflect(v, n));
1850
+
1851
+ var pbrInfo = PBRInfo(
1852
+ 0.0, // NdotL
1853
+ NdotV,
1854
+ 0.0, // NdotH
1855
+ 0.0, // LdotH
1856
+ 0.0, // VdotH
1857
+ perceptualRoughness,
1858
+ metallic,
1859
+ specularEnvironmentR0,
1860
+ specularEnvironmentR90,
1861
+ alphaRoughness,
1862
+ diffuseColor,
1863
+ specularColor,
1864
+ n,
1865
+ v
1866
+ );
1867
+
1868
+ #ifdef USE_LIGHTS
1869
+ PBRInfo_setAmbientLight(&pbrInfo);
1870
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
1871
+
1872
+ for (var i = 0; i < lighting.directionalLightCount; i++) {
1873
+ if (i < lighting.directionalLightCount) {
1874
+ PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);
1875
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
1876
+ }
1877
+ }
1878
+
1879
+ for (var i = 0; i < lighting.pointLightCount; i++) {
1880
+ if (i < lighting.pointLightCount) {
1881
+ PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));
1882
+ let attenuation = getPointLightAttenuation(
1883
+ lighting_getPointLight(i),
1884
+ distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition)
1885
+ );
1886
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
1887
+ }
1888
+ }
1889
+
1890
+ for (var i = 0; i < lighting.spotLightCount; i++) {
1891
+ if (i < lighting.spotLightCount) {
1892
+ PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i));
1893
+ let attenuation = getSpotLightAttenuation(
1894
+ lighting_getSpotLight(i),
1895
+ fragmentInputs.pbr_vPosition
1896
+ );
1897
+ color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation);
1898
+ }
1899
+ }
1900
+ #endif
1901
+
1902
+ #ifdef USE_IBL
1903
+ if (pbrMaterial.IBLenabled != 0) {
1904
+ color += getIBLContribution(pbrInfo, n, reflection);
1905
+ }
1906
+ #endif
1907
+
1908
+ #ifdef HAS_OCCLUSIONMAP
1909
+ if (pbrMaterial.occlusionMapEnabled != 0) {
1910
+ let ao =
1911
+ textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, fragmentInputs.pbr_vUV).r;
1912
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
1913
+ }
1914
+ #endif
1915
+
1916
+ var emissive = pbrMaterial.emissiveFactor;
1917
+ #ifdef HAS_EMISSIVEMAP
1918
+ if (pbrMaterial.emissiveMapEnabled != 0u) {
1919
+ emissive *= SRGBtoLINEAR(
1920
+ textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, fragmentInputs.pbr_vUV)
1921
+ ).rgb;
1922
+ }
1923
+ #endif
1924
+ color += emissive * pbrMaterial.emissiveStrength;
1925
+
1926
+ #ifdef PBR_DEBUG
1927
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
1928
+ color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);
1929
+ color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
1930
+ #endif
1931
+
1932
+ return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), baseColor.a);
1933
+ }
1934
+
1935
+ var specularIntensity = pbrMaterial.specularIntensityFactor;
1936
+ #ifdef HAS_SPECULARINTENSITYMAP
1937
+ if (pbrMaterial.specularIntensityMapEnabled != 0) {
1938
+ specularIntensity *= textureSample(
1939
+ pbr_specularIntensitySampler,
1940
+ pbr_specularIntensitySamplerSampler,
1941
+ fragmentInputs.pbr_vUV
1942
+ ).a;
1943
+ }
1944
+ #endif
1945
+
1946
+ var specularFactor = pbrMaterial.specularColorFactor;
1947
+ #ifdef HAS_SPECULARCOLORMAP
1948
+ if (pbrMaterial.specularColorMapEnabled != 0) {
1949
+ specularFactor *= SRGBtoLINEAR(
1950
+ textureSample(
1951
+ pbr_specularColorSampler,
1952
+ pbr_specularColorSamplerSampler,
1953
+ fragmentInputs.pbr_vUV
1954
+ )
1955
+ ).rgb;
1956
+ }
1957
+ #endif
1958
+
1959
+ transmission = pbrMaterial.transmissionFactor;
1960
+ #ifdef HAS_TRANSMISSIONMAP
1961
+ if (pbrMaterial.transmissionMapEnabled != 0) {
1962
+ transmission *= textureSample(
1963
+ pbr_transmissionSampler,
1964
+ pbr_transmissionSamplerSampler,
1965
+ fragmentInputs.pbr_vUV
1966
+ ).r;
1967
+ }
1968
+ #endif
1969
+ transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0);
1970
+ var thickness = max(pbrMaterial.thicknessFactor, 0.0);
1971
+ #ifdef HAS_THICKNESSMAP
1972
+ thickness *= textureSample(
1973
+ pbr_thicknessSampler,
1974
+ pbr_thicknessSamplerSampler,
1975
+ fragmentInputs.pbr_vUV
1976
+ ).g;
1977
+ #endif
1978
+
1979
+ var clearcoatFactor = pbrMaterial.clearcoatFactor;
1980
+ var clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;
1981
+ #ifdef HAS_CLEARCOATMAP
1982
+ if (pbrMaterial.clearcoatMapEnabled != 0) {
1983
+ clearcoatFactor *= textureSample(
1984
+ pbr_clearcoatSampler,
1985
+ pbr_clearcoatSamplerSampler,
1986
+ fragmentInputs.pbr_vUV
1987
+ ).r;
1988
+ }
1989
+ #endif
1990
+ #ifdef HAS_CLEARCOATROUGHNESSMAP
1991
+ if (pbrMaterial.clearcoatRoughnessMapEnabled != 0) {
1992
+ clearcoatRoughness *= textureSample(
1993
+ pbr_clearcoatRoughnessSampler,
1994
+ pbr_clearcoatRoughnessSamplerSampler,
1995
+ fragmentInputs.pbr_vUV
1996
+ ).g;
1997
+ }
1998
+ #endif
1999
+ clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);
2000
+ clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
2001
+ let clearcoatNormal = getClearcoatNormal(tbn, n);
2002
+
2003
+ var sheenColor = pbrMaterial.sheenColorFactor;
2004
+ var sheenRoughness = pbrMaterial.sheenRoughnessFactor;
2005
+ #ifdef HAS_SHEENCOLORMAP
2006
+ if (pbrMaterial.sheenColorMapEnabled != 0) {
2007
+ sheenColor *= SRGBtoLINEAR(
2008
+ textureSample(
2009
+ pbr_sheenColorSampler,
2010
+ pbr_sheenColorSamplerSampler,
2011
+ fragmentInputs.pbr_vUV
2012
+ )
2013
+ ).rgb;
2014
+ }
2015
+ #endif
2016
+ #ifdef HAS_SHEENROUGHNESSMAP
2017
+ if (pbrMaterial.sheenRoughnessMapEnabled != 0) {
2018
+ sheenRoughness *= textureSample(
2019
+ pbr_sheenRoughnessSampler,
2020
+ pbr_sheenRoughnessSamplerSampler,
2021
+ fragmentInputs.pbr_vUV
2022
+ ).a;
2023
+ }
2024
+ #endif
2025
+ sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0);
2026
+
2027
+ var iridescence = pbrMaterial.iridescenceFactor;
2028
+ #ifdef HAS_IRIDESCENCEMAP
2029
+ if (pbrMaterial.iridescenceMapEnabled != 0) {
2030
+ iridescence *= textureSample(
2031
+ pbr_iridescenceSampler,
2032
+ pbr_iridescenceSamplerSampler,
2033
+ fragmentInputs.pbr_vUV
2034
+ ).r;
2035
+ }
2036
+ #endif
2037
+ iridescence = clamp(iridescence, 0.0, 1.0);
2038
+ var iridescenceThickness = mix(
2039
+ pbrMaterial.iridescenceThicknessRange.x,
2040
+ pbrMaterial.iridescenceThicknessRange.y,
2041
+ 0.5
2042
+ );
2043
+ #ifdef HAS_IRIDESCENCETHICKNESSMAP
2044
+ iridescenceThickness = mix(
2045
+ pbrMaterial.iridescenceThicknessRange.x,
2046
+ pbrMaterial.iridescenceThicknessRange.y,
2047
+ textureSample(
2048
+ pbr_iridescenceThicknessSampler,
2049
+ pbr_iridescenceThicknessSamplerSampler,
2050
+ fragmentInputs.pbr_vUV
2051
+ ).g
2052
+ );
2053
+ #endif
2054
+
2055
+ var anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0);
2056
+ var anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection);
2057
+ #ifdef HAS_ANISOTROPYMAP
2058
+ if (pbrMaterial.anisotropyMapEnabled != 0) {
2059
+ let anisotropySample = textureSample(
2060
+ pbr_anisotropySampler,
2061
+ pbr_anisotropySamplerSampler,
2062
+ fragmentInputs.pbr_vUV
2063
+ ).rgb;
2064
+ anisotropyStrength *= anisotropySample.b;
2065
+ let mappedDirection = anisotropySample.rg * 2.0 - 1.0;
2066
+ if (length(mappedDirection) > 0.0001) {
2067
+ anisotropyDirection = normalize(mappedDirection);
2068
+ }
2069
+ }
2070
+ #endif
2071
+ anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation);
2072
+ var anisotropyTangent =
2073
+ normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y);
2074
+ if (length(anisotropyTangent) < 0.0001) {
2075
+ anisotropyTangent = normalize(tbn[0]);
2076
+ }
2077
+ let anisotropyViewAlignment = abs(dot(v, anisotropyTangent));
2078
+ perceptualRoughness = mix(
2079
+ perceptualRoughness,
2080
+ clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),
2081
+ anisotropyStrength
2082
+ );
2083
+
1040
2084
  // Roughness is authored as perceptual roughness; as is convention,
1041
2085
  // convert to material roughness by squaring the perceptual roughness [2].
1042
2086
  let alphaRoughness = perceptualRoughness * perceptualRoughness;
1043
2087
 
1044
- let f0 = vec3<f32>(0.04);
1045
- var diffuseColor = baseColor.rgb * (vec3<f32>(1.0) - f0);
1046
- diffuseColor *= 1.0 - metallic;
1047
- let specularColor = mix(f0, baseColor.rgb, metallic);
2088
+ let dielectricF0 = getDielectricF0(pbrMaterial.ior);
2089
+ var dielectricSpecularF0 = min(
2090
+ vec3f(dielectricF0) * specularFactor * specularIntensity,
2091
+ vec3f(1.0)
2092
+ );
2093
+ let iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV);
2094
+ dielectricSpecularF0 = mix(
2095
+ dielectricSpecularF0,
2096
+ dielectricSpecularF0 * iridescenceTint,
2097
+ iridescence
2098
+ );
2099
+ var diffuseColor = baseColor.rgb * (vec3f(1.0) - dielectricSpecularF0);
2100
+ diffuseColor *= (1.0 - metallic) * (1.0 - transmission);
2101
+ var specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);
2102
+
2103
+ let baseLayerEnergy = 1.0 - clearcoatFactor * 0.25;
2104
+ diffuseColor *= baseLayerEnergy;
2105
+ specularColor *= baseLayerEnergy;
1048
2106
 
1049
2107
  // Compute reflectance.
1050
2108
  let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
@@ -1056,11 +2114,6 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
1056
2114
  let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
1057
2115
  let specularEnvironmentR0 = specularColor;
1058
2116
  let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;
1059
-
1060
- let n = getNormal(); // normal at surface point
1061
- let v = normalize(pbrProjection.camera - fragmentInputs.pbr_vPosition); // Vector from surface point to camera
1062
-
1063
- let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
1064
2117
  let reflection = -normalize(reflect(v, n));
1065
2118
 
1066
2119
  var pbrInfo = PBRInfo(
@@ -1083,13 +2136,33 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
1083
2136
  #ifdef USE_LIGHTS
1084
2137
  // Apply ambient light
1085
2138
  PBRInfo_setAmbientLight(&pbrInfo);
1086
- color += calculateFinalColor(pbrInfo, lighting.ambientColor);
2139
+ color += calculateMaterialLightColor(
2140
+ pbrInfo,
2141
+ lighting.ambientColor,
2142
+ clearcoatNormal,
2143
+ clearcoatFactor,
2144
+ clearcoatRoughness,
2145
+ sheenColor,
2146
+ sheenRoughness,
2147
+ anisotropyTangent,
2148
+ anisotropyStrength
2149
+ );
1087
2150
 
1088
2151
  // Apply directional light
1089
2152
  for (var i = 0; i < lighting.directionalLightCount; i++) {
1090
2153
  if (i < lighting.directionalLightCount) {
1091
2154
  PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);
1092
- color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
2155
+ color += calculateMaterialLightColor(
2156
+ pbrInfo,
2157
+ lighting_getDirectionalLight(i).color,
2158
+ clearcoatNormal,
2159
+ clearcoatFactor,
2160
+ clearcoatRoughness,
2161
+ sheenColor,
2162
+ sheenRoughness,
2163
+ anisotropyTangent,
2164
+ anisotropyStrength
2165
+ );
1093
2166
  }
1094
2167
  }
1095
2168
 
@@ -1101,7 +2174,35 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
1101
2174
  lighting_getPointLight(i),
1102
2175
  distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition)
1103
2176
  );
1104
- color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
2177
+ color += calculateMaterialLightColor(
2178
+ pbrInfo,
2179
+ lighting_getPointLight(i).color / attenuation,
2180
+ clearcoatNormal,
2181
+ clearcoatFactor,
2182
+ clearcoatRoughness,
2183
+ sheenColor,
2184
+ sheenRoughness,
2185
+ anisotropyTangent,
2186
+ anisotropyStrength
2187
+ );
2188
+ }
2189
+ }
2190
+
2191
+ for (var i = 0; i < lighting.spotLightCount; i++) {
2192
+ if (i < lighting.spotLightCount) {
2193
+ PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i));
2194
+ let attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), fragmentInputs.pbr_vPosition);
2195
+ color += calculateMaterialLightColor(
2196
+ pbrInfo,
2197
+ lighting_getSpotLight(i).color / attenuation,
2198
+ clearcoatNormal,
2199
+ clearcoatFactor,
2200
+ clearcoatRoughness,
2201
+ sheenColor,
2202
+ sheenRoughness,
2203
+ anisotropyTangent,
2204
+ anisotropyStrength
2205
+ );
1105
2206
  }
1106
2207
  }
1107
2208
  #endif
@@ -1109,7 +2210,16 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
1109
2210
  // Calculate lighting contribution from image based lighting source (IBL)
1110
2211
  #ifdef USE_IBL
1111
2212
  if (pbrMaterial.IBLenabled != 0) {
1112
- color += getIBLContribution(pbrInfo, n, reflection);
2213
+ color += getIBLContribution(pbrInfo, n, reflection) *
2214
+ calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);
2215
+ color += calculateClearcoatIBLContribution(
2216
+ pbrInfo,
2217
+ clearcoatNormal,
2218
+ -normalize(reflect(v, clearcoatNormal)),
2219
+ clearcoatFactor,
2220
+ clearcoatRoughness
2221
+ );
2222
+ color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;
1113
2223
  }
1114
2224
  #endif
1115
2225
 
@@ -1122,14 +2232,19 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
1122
2232
  }
1123
2233
  #endif
1124
2234
 
2235
+ var emissive = pbrMaterial.emissiveFactor;
1125
2236
  #ifdef HAS_EMISSIVEMAP
1126
2237
  if (pbrMaterial.emissiveMapEnabled != 0u) {
1127
- let emissive = SRGBtoLINEAR(
2238
+ emissive *= SRGBtoLINEAR(
1128
2239
  textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, fragmentInputs.pbr_vUV)
1129
- ).rgb * pbrMaterial.emissiveFactor;
1130
- color += emissive;
2240
+ ).rgb;
1131
2241
  }
1132
2242
  #endif
2243
+ color += emissive * pbrMaterial.emissiveStrength;
2244
+
2245
+ if (transmission > 0.0) {
2246
+ color = mix(color, color * getVolumeAttenuation(thickness), transmission);
2247
+ }
1133
2248
 
1134
2249
  // This section uses mix to override final color for reference app visualization
1135
2250
  // of various parameters in the lighting equation.
@@ -1148,26 +2263,27 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
1148
2263
  #endif
1149
2264
  }
1150
2265
 
1151
- return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), baseColor.a);
2266
+ let alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);
2267
+ return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), alpha);
1152
2268
  }
1153
- `;var Yp=`uniform pbrProjectionUniforms {
2269
+ `;var $d=`layout(std140) uniform pbrProjectionUniforms {
1154
2270
  mat4 modelViewProjectionMatrix;
1155
2271
  mat4 modelMatrix;
1156
2272
  mat4 normalMatrix;
1157
2273
  vec3 camera;
1158
2274
  } pbrProjection;
1159
- `,yB=`struct pbrProjectionUniforms {
2275
+ `,kS=`struct pbrProjectionUniforms {
1160
2276
  modelViewProjectionMatrix: mat4x4<f32>,
1161
2277
  modelMatrix: mat4x4<f32>,
1162
2278
  normalMatrix: mat4x4<f32>,
1163
2279
  camera: vec3<f32>
1164
2280
  };
1165
2281
 
1166
- @binding(0) @group(0) var<uniform> pbrProjection: pbrProjectionUniforms;
1167
- `,Kp={name:"pbrProjection",source:yB,vs:Yp,fs:Yp,getUniforms:t=>t,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var qc={props:{},uniforms:{},name:"pbrMaterial",dependencies:[ss,Kp],source:Xp,vs:Jp,fs:Wp,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,HAS_SPECULARCOLORMAP:!1,HAS_SPECULARINTENSITYMAP:!1,HAS_TRANSMISSIONMAP:!1,HAS_CLEARCOATMAP:!1,HAS_SHEENCOLORMAP:!1,HAS_IRIDESCENCEMAP:!1,HAS_ANISOTROPYMAP:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:t=>t,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>",specularColorFactor:"vec3<f32>",specularIntensityFactor:"f32",specularColorMapEnabled:"i32",specularIntensityMapEnabled:"i32",ior:"f32",transmissionFactor:"f32",transmissionMapEnabled:"i32",thicknessFactor:"f32",attenuationDistance:"f32",attenuationColor:"vec3<f32>",clearcoatFactor:"f32",clearcoatRoughnessFactor:"f32",clearcoatMapEnabled:"i32",sheenColorFactor:"vec3<f32>",sheenRoughnessFactor:"f32",sheenColorMapEnabled:"i32",iridescenceFactor:"f32",iridescenceIor:"f32",iridescenceThicknessRange:"vec2<f32>",iridescenceMapEnabled:"i32",anisotropyStrength:"f32",anisotropyRotation:"f32",anisotropyDirection:"vec2<f32>",anisotropyMapEnabled:"i32",emissiveStrength:"f32"}};var tm=D(Rc(),1),rm=D(zo(),1);var Qp=`uniform meshUniforms {
2282
+ @group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;
2283
+ `,em={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:kS,vs:$d,fs:$d,getUniforms:t=>t,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var qc={props:{},uniforms:{},defaultUniforms:{unlit:!1,baseColorMapEnabled:!1,baseColorFactor:[1,1,1,1],normalMapEnabled:!1,normalScale:1,emissiveMapEnabled:!1,emissiveFactor:[0,0,0],metallicRoughnessValues:[1,1],metallicRoughnessMapEnabled:!1,occlusionMapEnabled:!1,occlusionStrength:1,alphaCutoffEnabled:!1,alphaCutoff:.5,IBLenabled:!1,scaleIBLAmbient:[1,1],scaleDiffBaseMR:[0,0,0,0],scaleFGDSpec:[0,0,0,0],specularColorFactor:[1,1,1],specularIntensityFactor:1,specularColorMapEnabled:!1,specularIntensityMapEnabled:!1,ior:1.5,transmissionFactor:0,transmissionMapEnabled:!1,thicknessFactor:0,attenuationDistance:1e9,attenuationColor:[1,1,1],clearcoatFactor:0,clearcoatRoughnessFactor:0,clearcoatMapEnabled:!1,clearcoatRoughnessMapEnabled:!1,sheenColorFactor:[0,0,0],sheenRoughnessFactor:0,sheenColorMapEnabled:!1,sheenRoughnessMapEnabled:!1,iridescenceFactor:0,iridescenceIor:1.3,iridescenceThicknessRange:[100,400],iridescenceMapEnabled:!1,anisotropyStrength:0,anisotropyRotation:0,anisotropyDirection:[1,0],anisotropyMapEnabled:!1,emissiveStrength:1},name:"pbrMaterial",firstBindingSlot:0,bindingLayout:[{name:"pbrMaterial",group:3},{name:"pbr_baseColorSampler",group:3},{name:"pbr_normalSampler",group:3},{name:"pbr_emissiveSampler",group:3},{name:"pbr_metallicRoughnessSampler",group:3},{name:"pbr_occlusionSampler",group:3},{name:"pbr_specularColorSampler",group:3},{name:"pbr_specularIntensitySampler",group:3},{name:"pbr_transmissionSampler",group:3},{name:"pbr_thicknessSampler",group:3},{name:"pbr_clearcoatSampler",group:3},{name:"pbr_clearcoatRoughnessSampler",group:3},{name:"pbr_clearcoatNormalSampler",group:3},{name:"pbr_sheenColorSampler",group:3},{name:"pbr_sheenRoughnessSampler",group:3},{name:"pbr_iridescenceSampler",group:3},{name:"pbr_iridescenceThicknessSampler",group:3},{name:"pbr_anisotropySampler",group:3}],dependencies:[Jd,Yd,em],source:Zd,vs:Kd,fs:Qd,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,HAS_SPECULARCOLORMAP:!1,HAS_SPECULARINTENSITYMAP:!1,HAS_TRANSMISSIONMAP:!1,HAS_THICKNESSMAP:!1,HAS_CLEARCOATMAP:!1,HAS_CLEARCOATROUGHNESSMAP:!1,HAS_CLEARCOATNORMALMAP:!1,HAS_SHEENCOLORMAP:!1,HAS_SHEENROUGHNESSMAP:!1,HAS_IRIDESCENCEMAP:!1,HAS_IRIDESCENCETHICKNESSMAP:!1,HAS_ANISOTROPYMAP:!1,USE_MATERIAL_EXTENSIONS:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:t=>t,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",specularColorFactor:"vec3<f32>",specularIntensityFactor:"f32",specularColorMapEnabled:"i32",specularIntensityMapEnabled:"i32",ior:"f32",transmissionFactor:"f32",transmissionMapEnabled:"i32",thicknessFactor:"f32",attenuationDistance:"f32",attenuationColor:"vec3<f32>",clearcoatFactor:"f32",clearcoatRoughnessFactor:"f32",clearcoatMapEnabled:"i32",clearcoatRoughnessMapEnabled:"i32",sheenColorFactor:"vec3<f32>",sheenRoughnessFactor:"f32",sheenColorMapEnabled:"i32",sheenRoughnessMapEnabled:"i32",iridescenceFactor:"f32",iridescenceIor:"f32",iridescenceThicknessRange:"vec2<f32>",iridescenceMapEnabled:"i32",anisotropyStrength:"f32",anisotropyRotation:"f32",anisotropyDirection:"vec2<f32>",anisotropyMapEnabled:"i32",emissiveStrength:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>"}};var sm=D(Pc(),1),im=D(zs(),1);var tm=`layout(std140) uniform meshUniforms {
1168
2284
  bool pickFeatureIds;
1169
2285
  } mesh;
1170
- `,Zp={name:"mesh",vs:Qp,fs:Qp,uniformTypes:{pickFeatureIds:"f32"}};var $p=`#version 300 es
2286
+ `,rm={name:"mesh",vs:tm,fs:tm,uniformTypes:{pickFeatureIds:"f32"}};var nm=`#version 300 es
1171
2287
  #define SHADER_NAME simple-mesh-layer-vs
1172
2288
  in vec3 positions;
1173
2289
  in vec3 normals;
@@ -1226,7 +2342,7 @@ geometry.uv = pbr_vUV;
1226
2342
  #endif
1227
2343
  DECKGL_FILTER_COLOR(vColor, geometry);
1228
2344
  }
1229
- `;var em=`#version 300 es
2345
+ `;var om=`#version 300 es
1230
2346
  #define SHADER_NAME simple-mesh-layer-fs
1231
2347
  precision highp float;
1232
2348
  uniform sampler2D sampler;
@@ -1255,7 +2371,7 @@ fragColor = vec4(lightColor, color.a * layer.opacity);
1255
2371
  #endif
1256
2372
  DECKGL_FILTER_COLOR(fragColor, geometry);
1257
2373
  }
1258
- `;function TB(t){let e=t.positions||t.POSITION,r=e.value.length/e.size;t.COLOR_0||t.colors||(t.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var bB={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},is=class extends rm.SimpleMeshLayer{getShaders(){let e=super.getShaders();return e.modules.push(qc,Zp),{...e,vs:$p,fs:em}}initializeState(){let{featureIds:e}=this.props;super.initializeState();let r=this.getAttributeManager();e&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);let{props:r,oldProps:n}=e;r.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(e){let{featureIds:r}=this.props,{model:n}=this.state;if(!n)return;let s={pickFeatureIds:Boolean(r)},o={camera:this.context.viewport.cameraPosition};n.shaderInputs.setProps({pbrProjection:o,mesh:s}),super.draw(e)}getModel(e){let{id:r}=this.props,n=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:n});let s=this.getShaders();return TB(e.attributes),new tm.Model(this.context.device,{...this.getShaders(),id:r,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...s.defines,...n?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:n?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){let{model:r}=this.state;if(r){let{mesh:n}=this.props,s=this.parseMaterial(e,n);this.setState({parsedPBRMaterial:s});let{pbr_baseColorSampler:o}=s.bindings,{emptyTexture:i}=this.state,a={sampler:o||i,hasTexture:Boolean(o)},{camera:c,...l}={...s.bindings,...s.uniforms};r.shaderInputs.setProps({simpleMesh:a,pbrMaterial:l})}}parseMaterial(e,r){let n=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return Hc(this.context.device,{unlit:n,...e},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){let r=this.props.featureIds,n=new Uint8ClampedArray(r.length*e.size),s=[];for(let o=0;o<r.length;o++)this.encodePickingColor(r[o],s),n[o*3]=s[0],n[o*3+1]=s[1],n[o*3+2]=s[2];e.value=n}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}};is.layerName="MeshLayer";is.defaultProps=bB;var nm=is;var u0=D(Kt(),1);var gt=6356752314245179e-9,EB={radii:[6378137,6378137,gt],radiiSquared:[6378137*6378137,6378137*6378137,gt*gt],oneOverRadii:[1/6378137,1/6378137,1/gt],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(gt*gt)],maximumRadius:Math.max(6378137,6378137,gt),centerToleranceSquared:.1};function Jo(t){return t}var RU=new x;function MB(t,e=[],r=Jo){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function sm(t,e=[]){return MB(t,e,Q._cartographicRadians?Jo:fa)}function _B(t,e,r=Jo){return"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):"x"in e?(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function om(t,e){return _B(t,e,Q._cartographicRadians?Jo:ua)}var im=1e-14,BB=new x,am={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},jc={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},as={east:new x,north:new x,up:new x,west:new x,south:new x,down:new x},CB=new x,SB=new x,IB=new x;function Jc(t,e,r,n,s,o){let i=am[e]&&am[e][r];fe(i&&(!n||n===i));let a,c,l,f=BB.copy(s);if(be(f.x,0,im)&&be(f.y,0,im)){let h=Math.sign(f.z);a=CB.fromArray(jc[e]),e!=="east"&&e!=="west"&&a.scale(h),c=SB.fromArray(jc[r]),r!=="east"&&r!=="west"&&c.scale(h),l=IB.fromArray(jc[n]),n!=="east"&&n!=="west"&&l.scale(h)}else{let{up:h,east:d,north:p}=as;d.set(-f.y,f.x,0).normalize(),t.geodeticSurfaceNormal(f,h),p.copy(h).cross(d);let{down:A,west:m,south:y}=as;A.copy(h).scale(-1),m.copy(d).scale(-1),y.copy(p).scale(-1),a=as[e],c=as[r],l=as[n]}return o[0]=a.x,o[1]=a.y,o[2]=a.z,o[3]=0,o[4]=c.x,o[5]=c.y,o[6]=c.z,o[7]=0,o[8]=l.x,o[9]=l.y,o[10]=l.z,o[11]=0,o[12]=f.x,o[13]=f.y,o[14]=f.z,o[15]=1,o}var qr=new x,wB=new x,vB=new x;function cm(t,e,r=[]){let{oneOverRadii:n,oneOverRadiiSquared:s,centerToleranceSquared:o}=e;qr.from(t);let i=qr.x,a=qr.y,c=qr.z,l=n.x,f=n.y,u=n.z,h=i*i*l*l,d=a*a*f*f,p=c*c*u*u,A=h+d+p,m=Math.sqrt(1/A);if(!Number.isFinite(m))return;let y=wB;if(y.copy(t).scale(m),A<o)return y.to(r);let b=s.x,E=s.y,M=s.z,B=vB;B.set(y.x*b*2,y.y*E*2,y.z*M*2);let C=(1-m)*qr.len()/(.5*B.len()),v=0,_,T,g,S;do{C-=v,_=1/(1+C*b),T=1/(1+C*E),g=1/(1+C*M);let F=_*_,R=T*T,L=g*g,G=F*_,W=R*T,z=L*g;S=h*F+d*R+p*L-1;let K=-2*(h*G*b+d*W*E+p*z*M);v=S/K}while(Math.abs(S)>Ne.EPSILON12);return qr.scale([_,T,g]).to(r)}var Wo=new x,lm=new x,RB=new x,Qe=new x,PB=new x,Xo=new x,U=class{constructor(e=0,r=0,n=0){this.centerToleranceSquared=Ne.EPSILON1,fe(e>=0),fe(r>=0),fe(n>=0),this.radii=new x(e,r,n),this.radiiSquared=new x(e*e,r*r,n*n),this.radiiToTheFourth=new x(e*e*e*e,r*r*r*r,n*n*n*n),this.oneOverRadii=new x(e===0?0:1/e,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new x(e===0?0:1/(e*e),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(e,r,n),this.maximumRadius=Math.max(e,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){let n=lm,s=RB,[,,o]=e;this.geodeticSurfaceNormalCartographic(e,n),s.copy(this.radiiSquared).scale(n);let i=Math.sqrt(n.dot(s));return s.scale(1/i),n.scale(o),s.add(n),s.to(r)}cartesianToCartographic(e,r=[0,0,0]){Xo.from(e);let n=this.scaleToGeodeticSurface(Xo,Qe);if(!n)return;let s=this.geodeticSurfaceNormal(n,lm),o=PB;o.copy(Xo).subtract(n);let i=Math.atan2(s.y,s.x),a=Math.asin(s.z),c=Math.sign(Yt.dot(o,Xo))*Yt.length(o);return om([i,a,c],r)}eastNorthUpToFixedFrame(e,r=new O){return Jc(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,n,s,o=new O){return Jc(this,e,r,n,s,o)}geocentricSurfaceNormal(e,r=[0,0,0]){return Wo.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let n=sm(e),s=n[0],o=n[1],i=Math.cos(o);return Wo.set(i*Math.cos(s),i*Math.sin(s),Math.sin(o)).normalize(),Wo.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return Wo.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return cm(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){Qe.from(e);let n=Qe.x,s=Qe.y,o=Qe.z,i=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*i.x+s*s*i.y+o*o*i.z);return Qe.multiplyScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return Qe.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return Qe.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,n=[0,0,0]){fe(be(this.radii.x,this.radii.y,Ne.EPSILON15)),fe(this.radii.z>0),Qe.from(e);let s=Qe.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-r))return Qe.set(0,0,s).to(n)}};U.WGS84=new U(6378137,6378137,gt);var Yo=class{item;previous;next;constructor(e,r,n){this.item=e,this.previous=r,this.next=n}};var Ko=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new Yo(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let n=e.next;e.next=r,this.tail===e?this.tail=r:n.previous=r,r.next=n,r.previous=e,++this._length}};var Qo=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Ko,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(e,r))}unloadTile(e,r,n){let s=r._cacheNode;s&&(this._list.remove(s),r._cacheNode=null,n&&n(e,r))}unloadTiles(e,r){let n=this._trimTiles;this._trimTiles=!1;let s=this._list,o=e.maximumMemoryUsage*1024*1024,i=this._sentinel,a=s.head;for(;a!==i&&(e.gpuMemoryUsageInBytes>o||n);){let c=a.item;a=a.next,this.unloadTile(e,c,r)}}trim(){this._trimTiles=!0}};function fm(t,e){H(t),H(e);let{rtcCenter:r,gltfUpAxis:n}=e,{computedTransform:s,boundingVolume:{center:o}}=t,i=new O(s);switch(r&&i.translate(r),n){case"Z":break;case"Y":let h=new O().rotateX(Math.PI/2);i=i.multiplyRight(h);break;case"X":let d=new O().rotateY(-Math.PI/2);i=i.multiplyRight(d);break;default:break}e.isQuantized&&i.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new x(o);e.cartesianModelMatrix=i,e.cartesianOrigin=a;let c=U.WGS84.cartesianToCartographic(a,new x),f=U.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=f.multiplyRight(i),e.cartographicOrigin=c;let u=NB(e);u&&(e.cartesianModelMatrix=new O(i).multiplyRight(u.matrix),e.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=O.IDENTITY),e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var OB=1e6**2;function NB(t){let e=t.gltf;if(!e)return null;let r=typeof e.scene=="number"?e.scene:0,s=e.scenes?.[r]?.nodes?.[0];if(!s?.matrix)return null;let o=s.matrix;return o[12]*o[12]+o[13]*o[13]+o[14]*o[14]<=OB?null:s}var um=new x,Wc=new x,Xc=new ae([new ue,new ue,new ue,new ue,new ue,new ue]);function dm(t,e){let{cameraDirection:r,cameraUp:n,height:s}=t,{metersPerUnit:o}=t.distanceScales,i=Zo(t,t.center),a=U.WGS84.eastNorthUpToFixedFrame(i),c=t.unprojectPosition(t.cameraPosition),l=U.WGS84.cartographicToCartesian(c,new x),f=new x(a.transformAsVector(new x(r).scale(o))).normalize(),u=new x(a.transformAsVector(new x(n).scale(o))).normalize();DB(t);let h=t.constructor,{longitude:d,latitude:p,width:A,bearing:m,zoom:y}=t,b=new h({longitude:d,latitude:p,height:s,width:A,bearing:m,zoom:y,pitch:0});return{camera:{position:l,direction:f,up:u},viewport:t,topDownViewport:b,height:s,cullingVolume:Xc,frameNumber:e,sseDenominator:1.15}}function pm(t,e,r){if(r===0||t.length<=r)return[t,[]];let n=[],{longitude:s,latitude:o}=e.viewport;for(let[l,f]of t.entries()){let[u,h]=f.header.mbs,d=Math.abs(s-u),p=Math.abs(o-h),A=Math.sqrt(p*p+d*d);n.push([l,A])}let i=n.sort((l,f)=>l[1]-f[1]),a=[];for(let l=0;l<r;l++)a.push(t[i[l][0]]);let c=[];for(let l=r;l<i.length;l++)c.push(t[i[l][0]]);return[a,c]}function DB(t){let e=t.getFrustumPlanes(),r=hm(e.near,t.cameraPosition),n=Zo(t,r),s=Zo(t,t.cameraPosition,Wc),o=0;Xc.planes[o++].fromPointNormal(n,um.copy(n).subtract(s));for(let i in e){if(i==="near")continue;let a=e[i],c=hm(a,r,Wc),l=Zo(t,c,Wc);Xc.planes[o++].fromPointNormal(l,um.copy(n).subtract(l))}}function hm(t,e,r=new x){let n=t.normal.dot(e);return r.copy(t.normal).scale(t.distance-n).add(e),r}function Zo(t,e,r=new x){let n=t.unprojectPosition(e);return U.WGS84.cartographicToCartesian(n,r)}var GB=6378137,UB=6378137,Yc=6356752314245179e-9,jr=new x;function mm(t,e){if(t instanceof Ke){let{halfAxes:r}=t,n=VB(r);return Math.log2(Yc/(n+e[2]))}else if(t instanceof Ge){let{radius:r}=t;return Math.log2(Yc/(r+e[2]))}else if(t.width&&t.height){let{width:r,height:n}=t,s=Math.log2(GB/r),o=Math.log2(UB/n);return(s+o)/2}return 1}function Kc(t,e,r){U.WGS84.cartographicToCartesian([t.xmax,t.ymax,t.zmax],jr);let n=Math.sqrt(Math.pow(jr[0]-r[0],2)+Math.pow(jr[1]-r[1],2)+Math.pow(jr[2]-r[2],2));return Math.log2(Yc/(n+e[2]))}function gm(t,e,r){let[n,s,o,i]=t;return Kc({xmin:n,xmax:o,ymin:s,ymax:i,zmin:0,zmax:0},e,r)}function VB(t){t.getColumn(0,jr);let e=t.getColumn(1),r=t.getColumn(2);return jr.add(e).add(r).len()}var Rm=D(Kt(),1);var Me={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},ge;(function(t){t[t.ADD=1]="ADD",t[t.REPLACE=2]="REPLACE"})(ge||(ge={}));var Ve;(function(t){t.EMPTY="empty",t.SCENEGRAPH="scenegraph",t.POINTCLOUD="pointcloud",t.MESH="mesh"})(Ve||(Ve={}));var he;(function(t){t.I3S="I3S",t.TILES3D="TILES3D"})(he||(he={}));var At;(function(t){t.GEOMETRIC_ERROR="geometricError",t.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(At||(At={}));var Am={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function bm(t){return t!=null}var Ae=new x,$o=new x,HB=new x,zB=new x,fr=new x,xm=new x,ym=new x,Tm=new x;function ei(t,e,r){if(H(t,"3D Tile: boundingVolume must be defined"),t.box)return Mm(t.box,e,r);if(t.region)return qB(t.region);if(t.sphere)return kB(t.sphere,e,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Em(t,e){if(t.box)return jB(e);if(t.region){let[r,n,s,o,i,a]=t.region;return[[ve(r),ve(n),i],[ve(s),ve(o),a]]}if(t.sphere)return JB(e);throw new Error("Unkown boundingVolume type")}function Mm(t,e,r){let n=new x(t[0],t[1],t[2]);e.transform(n,n);let s=[];if(t.length===10){let l=t.slice(3,6),f=new rt;f.fromArray(t,6);let u=new x([1,0,0]),h=new x([0,1,0]),d=new x([0,0,1]);u.transformByQuaternion(f),u.scale(l[0]),h.transformByQuaternion(f),h.scale(l[1]),d.transformByQuaternion(f),d.scale(l[2]),s=[...u.toArray(),...h.toArray(),...d.toArray()]}else s=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];let o=e.transformAsVector(s.slice(0,3)),i=e.transformAsVector(s.slice(3,6)),a=e.transformAsVector(s.slice(6,9)),c=new j([o[0],o[1],o[2],i[0],i[1],i[2],a[0],a[1],a[2]]);return bm(r)?(r.center=n,r.halfAxes=c,r):new Ke(n,c)}function kB(t,e,r){let n=new x(t[0],t[1],t[2]);e.transform(n,n);let s=e.getScale($o),o=Math.max(Math.max(s[0],s[1]),s[2]),i=t[3]*o;return bm(r)?(r.center=n,r.radius=i,r):new Ge(n,i)}function qB(t){let[e,r,n,s,o,i]=t,a=U.WGS84.cartographicToCartesian([ve(e),ve(s),o],HB),c=U.WGS84.cartographicToCartesian([ve(n),ve(r),i],zB),l=new x().addVectors(a,c).multiplyByScalar(.5);return U.WGS84.cartesianToCartographic(l,fr),U.WGS84.cartographicToCartesian([ve(n),fr[1],fr[2]],xm),U.WGS84.cartographicToCartesian([fr[0],ve(s),fr[2]],ym),U.WGS84.cartographicToCartesian([fr[0],fr[1],i],Tm),Mm([...l,...xm.subtract(l),...ym.subtract(l),...Tm.subtract(l)],new O)}function jB(t){let e=_m(),{halfAxes:r}=t,n=new x(r.getColumn(0)),s=new x(r.getColumn(1)),o=new x(r.getColumn(2));for(let i=0;i<2;i++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)Ae.copy(t.center),Ae.add(n),Ae.add(s),Ae.add(o),Bm(e,Ae),o.negate();s.negate()}n.negate()}return e}function JB(t){let e=_m(),{center:r,radius:n}=t,s=U.WGS84.scaleToGeodeticSurface(r,Ae),o;s?o=U.WGS84.geodeticSurfaceNormal(s):o=new x(0,0,1);let i=new x(o[2],-o[1],0);i.len()>0?i.normalize():i=new x(0,1,0);let a=i.clone().cross(o);for(let c of[i,a,o]){$o.copy(c).scale(n);for(let l=0;l<2;l++)Ae.copy(r),Ae.add($o),Bm(e,Ae),$o.negate()}return e}function _m(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Bm(t,e){U.WGS84.cartesianToCartographic(e,Ae),t[0][0]=Math.min(t[0][0],Ae[0]),t[0][1]=Math.min(t[0][1],Ae[1]),t[0][2]=Math.min(t[0][2],Ae[2]),t[1][0]=Math.max(t[1][0],Ae[0]),t[1][1]=Math.max(t[1][1],Ae[1]),t[1][2]=Math.max(t[1][2],Ae[2])}var y4=new x,T4=new x,b4=new O,E4=new x,M4=new x,_4=new x;function WB(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function XB(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){let r=t.dynamicScreenSpaceErrorComputedDensity,n=t.dynamicScreenSpaceErrorFactor;return WB(e,r)*n}return 0}function Cm(t,e,r){let n=t.tileset,s=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,o=r?s:t.lodMetricValue;if(o===0)return 0;let i=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:c}=e,{viewDistanceScale:l}=n.options,f=o*a*(l||1)/(i*c);return f-=XB(n,i),f}var Qc=new x,Sm=new x,Dt=new x,Im=new x,YB=new x,Zc=new O,wm=new O;function vm(t,e){if(t.lodMetricValue===0||isNaN(t.lodMetricValue))return"DIG";let r=2*$c(t,e);return r<2?"OUT":!t.header.children||r<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function $c(t,e){let{topDownViewport:r}=e,n=t.header.mbs[1],s=t.header.mbs[0],o=t.header.mbs[2],i=t.header.mbs[3],a=[...t.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);U.WGS84.cartographicToCartesian(c,Qc),Sm.copy(Qc).subtract(a).normalize(),U.WGS84.eastNorthUpToFixedFrame(a,Zc),wm.copy(Zc).invert(),Dt.copy(Qc).transform(wm);let l=Math.sqrt(Dt[0]*Dt[0]+Dt[1]*Dt[1]),f=l*l/Dt[2];Im.copy([Dt[0],Dt[1],f]);let h=Im.transform(Zc).subtract(a).normalize(),p=Sm.cross(h).normalize().scale(i).add(a),A=U.WGS84.cartesianToCartographic(p),m=r.project([s,n,o]),y=r.project(A);return YB.copy(m).subtract(y).magnitude()}function Lm(t){return{assetGltfUpAxis:t.asset&&t.asset.gltfUpAxis||"Y"}}var cs=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return H(e<this._array.length),this._array[e]}set(e,r){H(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){H(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){H(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var KB={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},ct=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new cs;_emptyTraversalStack=new cs;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...KB,...e}}traverse(e,r,n){this.root=e,this.options={...this.options,...n},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let n=this._traversalStack;for(e._selectionDepth=1,n.push(e);n.length>0;){let o=n.pop(),i=!1;this.canTraverse(o,r)&&(this.updateChildTiles(o,r),i=this.updateAndPushChildren(o,r,n,o.hasRenderContent?o._selectionDepth+1:o._selectionDepth));let a=o.parent,c=Boolean(!a||a._shouldRefine),l=!i;o.hasRenderContent?o.refine===ge.ADD?(this.loadTile(o,r),this.selectTile(o,r)):o.refine===ge.REPLACE&&(this.loadTile(o,r),l&&this.selectTile(o,r)):(this.emptyTiles[o.id]=o,this.loadTile(o,r),l&&this.selectTile(o,r)),this.touchTile(o,r),o._shouldRefine=i&&c}let s=new Date().getTime();(this.traversalFinished(r)||s-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=s,this.options.onTraversalEnd(r))}updateChildTiles(e,r){let n=e.children;for(let s of n)this.updateTile(s,r)}updateAndPushChildren(e,r,n,s){let{loadSiblings:o,skipLevelOfDetail:i}=this.options,a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let c=e.refine===ge.REPLACE&&e.hasRenderContent&&!i,l=!1,f=!0;for(let u of a)if(u._selectionDepth=s,u.isVisibleAndInRequestVolume?(n.find(u)&&n.delete(u),n.push(u),l=!0):(c||o)&&(this.loadTile(u,r),this.touchTile(u,r)),c){let h;if(u._inRequestVolume?u.hasRenderContent?h=u.contentAvailable:h=this.executeEmptyTraversal(u,r):h=!1,f=f&&h,!f)return!1}return l||(f=!1),f}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){this.shouldLoadTile(e)&&(e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,r):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,r,n=!1){let s=e._screenSpaceError;return n&&(s=e.getScreenSpaceError(r,!0)),s>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let n=[];if(this.options.viewportTraversersMap)for(let s in this.options.viewportTraversersMap)this.options.viewportTraversersMap[s]===r.viewport.id&&n.push(s);else n.push(r.viewport.id);e.updateVisibility(r,n)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let n=!1;for(let s of e.children)s.updateVisibility(r),n=n||s.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,r){let n=!0,s=this._emptyTraversalStack;for(s.push(e);s.length>0;){let o=s.pop(),i=!o.hasRenderContent&&this.canTraverse(o,r),a=!o.hasRenderContent&&o.children.length===0;if(!i&&!o.contentAvailable&&!a&&(n=!1),this.updateTile(o,r),o.isVisibleAndInRequestVolume||(this.loadTile(o,r),this.touchTile(o,r)),i){let c=o.children;for(let l of c)s.push(l)}}return e.hasEmptyContent||n}};var Fm=new x;function QB(t){return t!=null}var ur=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Me.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new O;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new ct({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new O;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(e,r,n,s=""){this.header=r,this.tileset=e,this.id=s||r.id,this.url=r.url,this.parent=n,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this._initializeLodMetric(r),this._initializeTransforms(r),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Me.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Me.UNLOADED}get contentExpired(){return this.contentState===Me.EXPIRED}get contentFailed(){return this.contentState===Me.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Em(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,r){switch(this.tileset.type){case he.I3S:return $c(this,e);case he.TILES3D:return Cm(this,e,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let e=this.tileset._traverser,{skipLevelOfDetail:r}=e.options,n=this.refine===ge.ADD||r;if(n&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Me.UNLOADED)return-1;let s=this.parent,i=s&&(!n||this._screenSpaceError===0||s.hasTilesetContent)?s._screenSpaceError:this._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-i,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Me.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Me.UNLOADED,!1;try{let n=this.tileset.getTileUrl(this.contentUrl),s=this.tileset.loader,o=this.tileset.loadOptions[s.id]||{},i={...this.tileset.loadOptions,[s.id]:{...o,isTileset:this.type==="json",...this._getLoaderSpecificOptions(s.id)}};return this.content=await(0,Rm.load)(n,s,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Me.READY,this._onContentLoaded(),!0}catch(n){throw this.contentState=Me.FAILED,n}finally{r.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Me.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let n=this.parent,s=n?n._visibilityPlaneMask:ae.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let o=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(o)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,s),this._visible=this._visibilityPlaneMask!==ae.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}visibility(e,r){let{cullingVolume:n}=e,{boundingVolume:s}=this;return n.computeVisibilityWithPlaneMask(s,r)}contentVisibility(){return!0}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return Fm.subVectors(r.center,e.position),e.direction.dot(Fm)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(QB(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=Me.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new O(e.transform):new O;let r=this.parent,n=this.tileset,s=r&&r.computedTransform?r.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new O(s).multiplyRight(this.transform);let o=r&&r._initialTransform?r._initialTransform.clone():new O;this._initialTransform=new O(o).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Me.UNLOADED,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=ae.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||ge.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=ei(e.boundingVolume,this.computedTransform,this.boundingVolume);let r=e.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=ei(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=ei(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new O){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return Lm(this.tileset.tileset)}}};var ti=class extends ct{compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let n=e.children.length>0;if(e.hasTilesetContent&&n){let i=e.children[0];this.updateTileVisibility(i,r),e._visible=i._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let s=e.refine===ge.REPLACE,o=e._optimChildrenWithinParent===Am.USE_OPTIMIZATION;if(s&&o&&n&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:n}=e;return!n||n.hasTilesetContent||n.refine!==ge.ADD?!1:!this.shouldRefine(e,r,!0)}};var Pm=D(Kt(),1);var ri=class{frameNumberMap=new Map;register(e,r){let n=this.frameNumberMap.get(e)||new Map,s=n.get(r)||0;n.set(r,s+1),this.frameNumberMap.set(e,n)}deregister(e,r){let n=this.frameNumberMap.get(e);if(!n)return;let s=n.get(r)||1;n.set(r,s-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var el={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},ni=class{_statusMap;pendingTilesRegister=new ri;constructor(){this._statusMap={}}add(e,r,n,s){if(!this._statusMap[r]){let{frameNumber:o,viewport:{id:i}}=s;this._statusMap[r]={request:e,callback:n,key:r,frameState:s,status:el.REQUESTED},this.pendingTilesRegister.register(i,o),e().then(a=>{this._statusMap[r].status=el.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,s)}).catch(a=>{this._statusMap[r].status=el.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),n(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:n,viewport:{id:s}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(s,n);let{frameNumber:o,viewport:{id:i}}=r;this.pendingTilesRegister.register(i,o),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var si=class extends ct{_tileManager;constructor(e){super(e),this._tileManager=new ni}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=vm(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let n=e.header.children||[],s=e.children,o=e.tileset;for(let i of n){let a=`${i.id}-${r.viewport.id}`,c=s&&s.find(l=>l.id===a);if(c)c&&this.updateTile(c,r);else{let l=()=>this._loadTile(i.id,o);this._tileManager.find(a)?this._tileManager.update(a,r):(o.tileset.nodePages&&(l=()=>o.tileset.nodePagesTile.formTileFromNodePages(i.id)),this._tileManager.add(l,a,u=>this._onTileLoad(u,e,a),r))}}return!1}async _loadTile(e,r){let{loader:n}=r,s=r.getTileUrl(`${r.url}/nodes/${e}`),o={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await(0,Pm.load)(s,n,o)}_onTileLoad(e,r,n){let s=new ur(r.tileset,e,r,n);r.children.push(s);let o=this._tileManager.find(s.id).frameState;this.updateTile(s,o),this._frameNumber===o.frameNumber&&(this.traversalFinished(o)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(s,o)}};var ZB={description:"",ellipsoid:U.WGS84,modelMatrix:new O,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},oi="Tiles In Tileset(s)",tl="Tiles In Memory",Om="Tiles In View",Nm="Tiles To Render",Dm="Tiles Loaded",rl="Tiles Loading",Gm="Tiles Unloaded",Um="Failed Tile Loads",Vm="Points/Vertices",nl="Tile Memory Use",Hm="Maximum Screen Space Error",ls=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new Qo;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,r){this.options={...ZB,...r},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||vt.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new It({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new St({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let n=e;return this.queryParams.length&&(n=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),n}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let n=[];for(let s of r){let o=s.id;this._needTraverse(o)?n.push(o):this.traverseCounter--}for(let s of r){let o=s.id;if(this.roots[o]||(this.roots[o]=this._initializeTileHeaders(this.tileset,null)),!n.includes(o))continue;let i=dm(s,this._frameNumber);this._traverser.traverse(this.roots[o],i,this.options)}}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],s=Object.values(this._traverser.selectedTiles),[o,i]=pm(s,e,this.options.maximumTilesSelected);n.selectedTiles=o;for(let a of i)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let o in this.frameStateData){let i=this.frameStateData[o];this.selectedTiles=this.selectedTiles.concat(i.selectedTiles),this._requestedTiles=this._requestedTiles.concat(i._requestedTiles),this._emptyTiles=this._emptyTiles.concat(i._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles.map(o=>o.id)),n=this.selectedTiles.some(o=>!o.tileDrawn),s=0;if(n){for(let o of r)this._heldTiles.add(o);for(let o of this._heldTiles){if(r.has(o))continue;let i=this._tiles[o];i&&i.contentAvailable?(i._selectedFrame=this._frameNumber,this.selectedTiles.push(i),s++):this._heldTiles.delete(o)}}else this._heldTiles=r;s>0&&setTimeout(()=>{this.selectTiles()},0);for(let o of this.selectedTiles)this._tiles[o.id]=o;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(e,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(e,r){if(e.length!==r.length)return!0;let n=new Set(e.map(i=>i.id)),s=new Set(r.map(i=>i.id)),o=e.filter(i=>!s.has(i.id)).length>0;return o=o||r.filter(i=>!n.has(i.id)).length>0,o}_loadTiles(){this._requestedTiles.sort((e,r)=>e._priority-r._priority);for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r))}_updateStats(){let e=0,r=0;for(let n of this.selectedTiles)n.contentAvailable&&n.content&&(e++,n.content.pointCount?r+=n.content.pointCount:r+=n.content.vertexCount);this.stats.get(Om).count=this.selectedTiles.length,this.stats.get(Nm).count=e,this.stats.get(Vm).count=r,this.stats.get(Hm).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===he.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===he.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===he.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let e=this.tileset.fullExtent;if(e){let{xmin:n,xmax:s,ymin:o,ymax:i,zmin:a,zmax:c}=e;this.cartographicCenter=new x(n+(s-n)/2,o+(i-o)/2,a+(c-a)/2),this.cartesianCenter=new x,U.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=Kc(e,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[n,s,o,i]=r;this.cartographicCenter=new x(n+(o-n)/2,s+(i-s)/2,0),this.cartesianCenter=new x,U.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=gm(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new x,this.zoom=1}calculateViewPropsTiles3D(){let e=this.root,{center:r}=e.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new x,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new x,U.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new x(0,0,-U.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=mm(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(oi),this.stats.get(rl),this.stats.get(tl),this.stats.get(Om),this.stats.get(Nm),this.stats.get(Dm),this.stats.get(Gm),this.stats.get(Um),this.stats.get(Vm),this.stats.get(nl,"memory"),this.stats.get(Hm)}_initializeTileHeaders(e,r){let n=new ur(this,e.root,r);if(r&&(r.children.push(n),n.depth=r.depth+1),this.type===he.TILES3D){let s=[];for(s.push(n);s.length>0;){let o=s.pop();this.stats.get(oi).incrementCount();let i=o.header.children||[];for(let a of i){let c=new ur(this,a,o);if(c.contentUrl?.includes("?session=")){let f=new URL(c.contentUrl).searchParams.get("session");f&&(this._queryParams.session=f)}o.children.push(c),c.depth=o.depth+1,s.push(c)}}}return n}_initializeTraverser(){let e;switch(this.type){case he.TILES3D:e=ti;break;case he.I3S:e=si;break;default:e=ct}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r;try{this._onStartTileLoading(),r=await e.loadContent()}catch(n){this._onTileLoadError(e,n instanceof Error?n:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}_onTileLoadError(e,r){this.stats.get(Um).incrementCount();let n=r.message||r.toString(),s=e.url;console.error(`A 3D tile failed to load: ${e.url} ${n}`),this.options.onTileError(e,n,s)}_onTileLoad(e,r){if(r){if(this.type===he.I3S){let n=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(oi).reset(),this.stats.get(oi).addCount(n)}e&&e.content&&fm(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===he.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===he.TILES3D){let{extensionsRemoved:r=[]}=e.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(rl).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(rl).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(Dm).incrementCount(),this.stats.get(tl).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(nl).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(tl).decrementCount(),this.stats.get(Gm).incrementCount(),this.stats.get(nl).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let n of r.children)e.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,n=[];for(n.push(r);n.length>0;){e=n.pop();for(let s of e.children)n.push(s);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){let r=new URLSearchParams(e.queryString),n=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){let e=this.loadOptions.i3s;e&&typeof e=="object"&&"token"in e&&(this._queryParams.token=e.token)}};var ii="4.4.0-alpha.18";var hr={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},y8=Object.keys(hr);function sl(t,e,r){H(t instanceof ArrayBuffer);let n=new TextDecoder("utf8"),s=new Uint8Array(t,e,r);return n.decode(s)}function zm(t,e=0){let r=new DataView(t);return`${String.fromCharCode(r.getUint8(e+0))}${String.fromCharCode(r.getUint8(e+1))}${String.fromCharCode(r.getUint8(e+2))}${String.fromCharCode(r.getUint8(e+3))}`}var $B="1.5.6",eC="1.4.1",ol=`https://www.gstatic.com/draco/versioned/decoders/${$B}`,de={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},fs={[de.DECODER]:`${ol}/${de.DECODER}`,[de.DECODER_WASM]:`${ol}/${de.DECODER_WASM}`,[de.FALLBACK_DECODER]:`${ol}/${de.FALLBACK_DECODER}`,[de.ENCODER]:`https://raw.githubusercontent.com/google/draco/${eC}/javascript/${de.ENCODER}`},il;async function qm(t={},e){let r=t.modules||{};return r.draco3d?il||=r.draco3d.createDecoderModule({}).then(n=>({draco:n})):il||=tC(t,e),await il}function km(t,e){if(t&&typeof t=="object"){if(t.default)return t.default;if(t[e])return t[e]}return t}async function tC(t,e){let r,n;switch(e){case"js":r=await De(fs[de.FALLBACK_DECODER],"draco",t,de.FALLBACK_DECODER);break;case"wasm":default:try{[r,n]=await Promise.all([await De(fs[de.DECODER],"draco",t,de.DECODER),await De(fs[de.DECODER_WASM],"draco",t,de.DECODER_WASM)])}catch{r=null,n=null}}return r=km(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule,!r&&!ut&&([r,n]=await Promise.all([await De(fs[de.DECODER],"draco",{...t,useLocalLibraries:!0},de.DECODER),await De(fs[de.DECODER_WASM],"draco",{...t,useLocalLibraries:!0},de.DECODER_WASM)]),r=km(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule),await rC(r,n)}function rC(t,e){if(typeof t!="function")throw new Error("DracoDecoderModule could not be loaded");let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t({...r,onModuleLoaded:s=>n({draco:s})})})}var jm="4.4.0-alpha.18";function Jm(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function dr(t){let e=1/0,r=1/0,n=1/0,s=-1/0,o=-1/0,i=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let f=a[l],u=a[l+1],h=a[l+2];e=f<e?f:e,r=u<r?u:r,n=h<n?h:n,s=f>s?f:s,o=u>o?u:o,i=h>i?h:i}return[[e,r,n],[s,o,i]]}function al(t,e,r){let n=Jm(e.value),s=r||Wm(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:n}]},nullable:!1,metadata:s}}function Wm(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}function Ym(t,e,r){let n=Km(e.metadata),s=[],o=nC(e.attributes);for(let i in t){let a=t[i],c=Xm(i,a,o[i]);s.push(c)}if(r){let i=Xm("indices",r);s.push(i)}return{fields:s,metadata:n}}function nC(t){let e={};for(let r in t){let n=t[r];e[n.name||"undefined"]=n}return e}function Xm(t,e,r){let n=r?Km(r.metadata):void 0;return al(t,e,n)}function Km(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var Qm={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},sC={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},oC=4,us=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let s=this.decoder.GetEncodedGeometryType(n),o=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(s){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(n,o);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(n,o);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!o.ptr){let h=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(h)}let a=this._getDracoLoaderData(o,s,r),c=this._getMeshData(o,a,r),l=dr(c.attributes),f=Ym(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:o.num_points(),boundingBox:l},...c,schema:f}}finally{this.draco.destroy(n),o&&this.draco.destroy(o)}}_getDracoLoaderData(e,r,n){let s=this._getTopLevelMetadata(e),o=this._getDracoAttributes(e,n);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:s,attributes:o}}_getDracoAttributes(e,r){let n={};for(let s=0;s<e.num_attributes();s++){let o=this.decoder.GetAttribute(e,s),i=this._getAttributeMetadata(e,s);n[o.unique_id()]={unique_id:o.unique_id(),attribute_type:o.attribute_type(),data_type:o.data_type(),num_components:o.num_components(),byte_offset:o.byte_offset(),byte_stride:o.byte_stride(),normalized:o.normalized(),attribute_index:s,metadata:i};let a=this._getQuantizationTransform(o,r);a&&(n[o.unique_id()].quantization_transform=a);let c=this._getOctahedronTransform(o,r);c&&(n[o.unique_id()].octahedron_transform=c)}return n}_getMeshData(e,r,n){let s=this._getMeshAttributes(r,e,n);if(!s.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(n.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:s,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:s,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:s}}_getMeshAttributes(e,r,n){let s={};for(let o of Object.values(e.attributes)){let i=this._deduceAttributeName(o,n);o.name=i;let a=this._getAttributeValues(r,o);if(a){let{value:c,size:l}=a;s[i]={value:c,size:l,byteOffset:o.byte_offset,byteStride:o.byte_stride,normalized:o.normalized}}}return s}_getTriangleListIndices(e){let n=e.num_faces()*3,s=n*oC,o=this.draco._malloc(s);try{return this.decoder.GetTrianglesUInt32Array(e,s,o),new Uint32Array(this.draco.HEAPF32.buffer,o,n).slice()}finally{this.draco._free(o)}}_getTriangleStripIndices(e){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,r),cC(r)}finally{this.draco.destroy(r)}}_getAttributeValues(e,r){let n=sC[r.data_type];if(!n)return console.warn(`DRACO: Unsupported attribute type ${r.data_type}`),null;let s=r.num_components,i=e.num_points()*s,a=i*n.BYTES_PER_ELEMENT,c=iC(this.draco,n),l,f=this.draco._malloc(a);try{let u=this.decoder.GetAttribute(e,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,u,c,a,f),l=new n(this.draco.HEAPF32.buffer,f,i).slice()}finally{this.draco._free(f)}return{value:l,size:s}}_deduceAttributeName(e,r){let n=e.unique_id;for(let[i,a]of Object.entries(r.extraAttributes||{}))if(a===n)return i;let s=e.attribute_type;for(let i in Qm)if(this.draco[i]===s)return Qm[i];let o=r.attributeNameEntry||"name";return e.metadata[o]?e.metadata[o].string:`CUSTOM_ATTRIBUTE_${n}`}_getTopLevelMetadata(e){let r=this.decoder.GetMetadata(e);return this._getDracoMetadata(r)}_getAttributeMetadata(e,r){let n=this.decoder.GetAttributeMetadata(e,r);return this._getDracoMetadata(n)}_getDracoMetadata(e){if(!e||!e.ptr)return{};let r={},n=this.metadataQuerier.NumEntries(e);for(let s=0;s<n;s++){let o=this.metadataQuerier.GetEntryName(e,s);r[o]=this._getDracoMetadataField(e,o)}return r}_getDracoMetadataField(e,r){let n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,r,n);let s=aC(n);return{int:this.metadataQuerier.GetIntEntry(e,r),string:this.metadataQuerier.GetStringEntry(e,r),double:this.metadataQuerier.GetDoubleEntry(e,r),intArray:s}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){let{quantizedAttributes:r=[],octahedronAttributes:n=[]}=e,s=[...r,...n];for(let o of s)this.decoder.SkipAttributeTransform(this.draco[o])}_getQuantizationTransform(e,r){let{quantizedAttributes:n=[]}=r,s=e.attribute_type();if(n.map(i=>this.decoder[i]).includes(s)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(a=>i.min_value(a))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:n=[]}=r,s=e.attribute_type();if(n.map(i=>this.decoder[i]).includes(s)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function iC(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function aC(t){let e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}function cC(t){let e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}var Zm={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:jm,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",extraAttributes:{},attributeNameEntry:void 0}}},hs={...Zm,parse:lC};async function lC(t,e){let{draco:r}=await qm(Pn(e),e?.draco?.decoderType||"wasm"),n=new us(r);try{return n.parseSync(t,e?.draco)}finally{n.destroy()}}var fC={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ie={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},N={...fC,...ie};var cl={[ie.DOUBLE]:Float64Array,[ie.FLOAT]:Float32Array,[ie.UNSIGNED_SHORT]:Uint16Array,[ie.UNSIGNED_INT]:Uint32Array,[ie.UNSIGNED_BYTE]:Uint8Array,[ie.BYTE]:Int8Array,[ie.SHORT]:Int16Array,[ie.INT]:Int32Array},uC={DOUBLE:ie.DOUBLE,FLOAT:ie.FLOAT,UNSIGNED_SHORT:ie.UNSIGNED_SHORT,UNSIGNED_INT:ie.UNSIGNED_INT,UNSIGNED_BYTE:ie.UNSIGNED_BYTE,BYTE:ie.BYTE,SHORT:ie.SHORT,INT:ie.INT},ll="Failed to convert GL type",ce=class{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(let r in cl)if(cl[r]===e)return r;throw new Error(ll)}static fromName(e){let r=uC[e];if(!r)throw new Error(ll);return r}static getArrayType(e){switch(e){case ie.UNSIGNED_SHORT_5_6_5:case ie.UNSIGNED_SHORT_4_4_4_4:case ie.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=cl[e];if(!r)throw new Error(ll);return r}}static getByteSize(e){return ce.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(ce.getArrayType(e))}static createTypedArray(e,r,n=0,s){s===void 0&&(s=(r.byteLength-n)/ce.getByteSize(e));let o=ArrayBuffer.isView(r)?r.buffer:r,i=ce.getArrayType(e);return new i(o,n,s)}};function $m(t,e){if(!t)throw new Error(`math.gl assertion failed. ${e}`)}function fl(t,e=[0,0,0]){let r=t>>11&31,n=t>>5&63,s=t&31;return e[0]=r<<3,e[1]=n<<2,e[2]=s<<3,e}var e9=1/256;var t9=new Jt,r9=new x,n9=new Jt,s9=new Jt,o9=new Uint8Array(1);function eg(t,e=255){return $s(t,0,e)/e*2-1}function tg(t){return t<0?-1:1}function rg(t,e,r,n){if($m(n),t<0||t>r||e<0||e>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(n.x=eg(t,r),n.y=eg(e,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){let s=n.x;n.x=(1-Math.abs(n.y))*tg(s),n.y=(1-Math.abs(s))*tg(n.y)}return n.normalize()}function ul(t,e,r){return rg(t,e,255,r)}var xt=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,r){this.json=e,this.buffer=r}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,r=N.UNSIGNED_INT,n=1){let s=this.json[e];return s&&Number.isFinite(s.byteOffset)?this._getTypedArrayFromBinary(e,r,n,1,s.byteOffset):s}getPropertyArray(e,r,n){let s=this.json[e];return s&&Number.isFinite(s.byteOffset)?("componentType"in s&&(r=ce.fromName(s.componentType)),this._getTypedArrayFromBinary(e,r,n,this.featuresLength,s.byteOffset)):this._getTypedArrayFromArray(e,r,s)}getProperty(e,r,n,s,o){let i=this.json[e];if(!i)return i;let a=this.getPropertyArray(e,r,n);if(n===1)return a[s];for(let c=0;c<n;++c)o[c]=a[n*s+c];return o}_getTypedArrayFromBinary(e,r,n,s,o){let i=this._cachedTypedArrays,a=i[e];return a||(a=ce.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+o,s*n),i[e]=a),a}_getTypedArrayFromArray(e,r,n){let s=this._cachedTypedArrays,o=s[e];if(!o){if(ArrayBuffer.isView(n)){let i=n.byteOffset,c=n.byteLength/ce.getByteSize(r);o=ce.createTypedArray(r,n.buffer,i,c)}else if(n instanceof ArrayBuffer)o=ce.createTypedArray(r,n);else{let i=ce.getArrayType(r);o=new i(n)}s[e]=o}return o}};var hC={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},dC={SCALAR:(t,e)=>t[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},pC={SCALAR:(t,e,r)=>{e[r]=t},VEC2:(t,e,r)=>{e[2*r+0]=t[0],e[2*r+1]=t[1]},VEC3:(t,e,r)=>{e[3*r+0]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2]},VEC4:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT2:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT3:(t,e,r)=>{e[9*r+0]=t[0],e[9*r+1]=t[1],e[9*r+2]=t[2],e[9*r+3]=t[3],e[9*r+4]=t[4],e[9*r+5]=t[5],e[9*r+6]=t[6],e[9*r+7]=t[7],e[9*r+8]=t[8],e[9*r+9]=t[9]},MAT4:(t,e,r)=>{e[16*r+0]=t[0],e[16*r+1]=t[1],e[16*r+2]=t[2],e[16*r+3]=t[3],e[16*r+4]=t[4],e[16*r+5]=t[5],e[16*r+6]=t[6],e[16*r+7]=t[7],e[16*r+8]=t[8],e[16*r+9]=t[9],e[16*r+10]=t[10],e[16*r+11]=t[11],e[16*r+12]=t[12],e[16*r+13]=t[13],e[16*r+14]=t[14],e[16*r+15]=t[15]}};function ng(t,e,r,n){let{componentType:s}=t;H(t.componentType);let o=typeof s=="string"?ce.fromName(s):s,i=hC[t.type],a=dC[t.type],c=pC[t.type];return r+=t.byteOffset,{values:ce.createTypedArray(o,e,r,i*n),type:o,size:i,unpacker:a,packer:c}}var lt=t=>t!==void 0;function sg(t,e,r){if(!e)return null;let n=t.getExtension("3DTILES_batch_table_hierarchy"),s=e.HIERARCHY;return s&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=s,n=s),n?mC(n,r):null}function mC(t,e){let r,n,s,o=t.instancesLength,i=t.classes,a=t.classIds,c=t.parentCounts,l=t.parentIds,f=o;lt(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,s=getBinaryAccessor(a),a=s.createArrayBufferView(e.buffer,e.byteOffset+a.byteOffset,o));let u;if(lt(c))for(lt(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,s=getBinaryAccessor(c),c=s.createArrayBufferView(e.buffer,e.byteOffset+c.byteOffset,o)),u=new Uint16Array(o),f=0,r=0;r<o;++r)u[r]=f,f+=c[r];lt(l)&&lt(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,s=getBinaryAccessor(l),l=s.createArrayBufferView(e.buffer,e.byteOffset+l.byteOffset,f));let h=i.length;for(r=0;r<h;++r){let m=i[r].length,y=i[r].instances,b=getBinaryProperties(m,y,e);i[r].instances=combine(b,y)}let d=new Array(h).fill(0),p=new Uint16Array(o);for(r=0;r<o;++r)n=a[r],p[r]=d[n],++d[n];let A={classes:i,classIds:a,classIndexes:p,parentCounts:c,parentIndexes:u,parentIds:l};return xC(A),A}function Jr(t,e,r){if(!t)return;let n=t.parentCounts;return t.parentIds?r(t,e):n>0?gC(t,e,r):AC(t,e,r)}function gC(t,e,r){let n=t.classIds,s=t.parentCounts,o=t.parentIds,i=t.parentIndexes,a=n.length,c=scratchVisited;c.length=Math.max(c.length,a);let l=++marker,f=scratchStack;for(f.length=0,f.push(e);f.length>0;){if(e=f.pop(),c[e]===l)continue;c[e]=l;let u=r(t,e);if(lt(u))return u;let h=s[e],d=i[e];for(let p=0;p<h;++p){let A=o[d+p];A!==e&&f.push(A)}}return null}function AC(t,e,r){let n=!0;for(;n;){let s=r(t,e);if(lt(s))return s;let o=t.parentIds[e];n=o!==e,e=o}throw new Error("traverseHierarchySingleParent")}function xC(t){let e=[],n=t.classIds.length;for(let s=0;s<n;++s)og(t,s,stack)}function og(t,e,r){let n=t.parentCounts,s=t.parentIds,o=t.parentIndexes,a=t.classIds.length;if(!lt(s))return;assert(e<a,`Parent index ${e} exceeds the total number of instances: ${a}`),assert(r.indexOf(e)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(e);let c=lt(n)?n[e]:1,l=lt(n)?o[e]:e;for(let f=0;f<c;++f){let u=s[l+f];u!==e&&og(t,u,r)}r.pop(e)}function Ce(t){return t!=null}var ai=(t,e)=>t,yC={HIERARCHY:!0,extensions:!0,extras:!0},pr=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,r,n,s={}){H(n>=0),this.json=e||{},this.binary=r,this.featureCount=n,this._extensions=this.json?.extensions||{},this._properties={};for(let o in this.json)yC[o]||(this._properties[o]=this.json[o]);this._binaryProperties=this._initializeBinaryProperties(),s["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=sg(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,r){if(this._checkBatchId(e),H(typeof r=="string",r),this._hierarchy){let n=Jr(this._hierarchy,e,(s,o)=>{let i=s.classIds[o];return s.classes[i].name===r});return Ce(n)}return!1}isExactClass(e,r){return H(typeof r=="string",r),this.getExactClassName(e)===r}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){let r=this._hierarchy.classIds[e];return this._hierarchy.classes[r].name}}hasProperty(e,r){return this._checkBatchId(e),H(typeof r=="string",r),Ce(this._properties[r])||this._hasPropertyInHierarchy(e,r)}getPropertyNames(e,r){this._checkBatchId(e),r=Ce(r)?r:[],r.length=0;let n=Object.keys(this._properties);return r.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(e,r),r}getProperty(e,r){if(this._checkBatchId(e),H(typeof r=="string",r),this._binaryProperties){let s=this._binaryProperties[r];if(Ce(s))return this._getBinaryProperty(s,e)}let n=this._properties[r];if(Ce(n))return ai(n[e],!0);if(this._hierarchy){let s=this._getHierarchyProperty(e,r);if(Ce(s))return s}}setProperty(e,r,n){let s=this.featureCount;if(this._checkBatchId(e),H(typeof r=="string",r),this._binaryProperties){let i=this._binaryProperties[r];if(i){this._setBinaryProperty(i,e,n);return}}if(this._hierarchy&&this._setHierarchyProperty(this,e,r,n))return;let o=this._properties[r];Ce(o)||(this._properties[r]=new Array(s),o=this._properties[r]),o[e]=ai(n,!0)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,r){return e.unpack(e.typedArray,r)}_setBinaryProperty(e,r,n){e.pack(n,e.typedArray,r)}_initializeBinaryProperties(){let e=null;for(let r in this._properties){let n=this._properties[r],s=this._initializeBinaryProperty(r,n);s&&(e=e||{},e[r]=s)}return e}_initializeBinaryProperty(e,r){if("byteOffset"in r){let n=r;H(this.binary,`Property ${e} requires a batch table binary.`),H(n.type,`Property ${e} requires a type.`);let s=ng(n,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:s.values,componentCount:s.size,unpack:s.unpacker,pack:s.packer}}return null}_hasPropertyInHierarchy(e,r){if(!this._hierarchy)return!1;let n=Jr(this._hierarchy,e,(s,o)=>{let i=s.classIds[o],a=s.classes[i].instances;return Ce(a[r])});return Ce(n)}_getPropertyNamesInHierarchy(e,r){Jr(this._hierarchy,e,(n,s)=>{let o=n.classIds[s],i=n.classes[o].instances;for(let a in i)i.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(e,r){return Jr(this._hierarchy,e,(n,s)=>{let o=n.classIds[s],i=n.classes[o],a=n.classIndexes[s],c=i.instances[r];return Ce(c)?Ce(c.typedArray)?this._getBinaryProperty(c,a):ai(c[a],!0):null})}_setHierarchyProperty(e,r,n,s){let o=Jr(this._hierarchy,r,(i,a)=>{let c=i.classIds[a],l=i.classes[c],f=i.classIndexes[a],u=l.instances[n];return Ce(u)?(H(a===r,`Inherited property "${n}" is read-only.`),Ce(u.typedArray)?this._setBinaryProperty(u,f,s):u[f]=ai(s,!0),!0):!1});return Ce(o)}};function Gt(t,e,r=0){let n=new DataView(e);if(t.magic=n.getUint32(r,!0),r+=4,t.version=n.getUint32(r,!0),r+=4,t.byteLength=n.getUint32(r,!0),r+=4,t.version!==1)throw new Error(`3D Tile Version ${t.version} not supported`);return r}var Wr=4,ig="b3dm tile in legacy format.";function Xr(t,e,r){let n=new DataView(e),s;t.header=t.header||{};let o=n.getUint32(r,!0);r+=Wr;let i=n.getUint32(r,!0);r+=Wr;let a=n.getUint32(r,!0);r+=Wr;let c=n.getUint32(r,!0);return r+=Wr,a>=570425344?(r-=Wr*2,s=o,a=i,c=0,o=0,i=0,console.warn(ig)):c>=570425344&&(r-=Wr,s=a,a=o,c=i,o=0,i=0,console.warn(ig)),t.header.featureTableJsonByteLength=o,t.header.featureTableBinaryByteLength=i,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=c,t.header.batchLength=s,r}function Yr(t,e,r,n){return r=TC(t,e,r,n),r=bC(t,e,r,n),r}function TC(t,e,r,n){let{featureTableJsonByteLength:s,featureTableBinaryByteLength:o,batchLength:i}=t.header||{};if(t.featureTableJson={BATCH_LENGTH:i||0},s&&s>0){let a=sl(e,r,s);t.featureTableJson=JSON.parse(a)}return r+=s||0,t.featureTableBinary=new Uint8Array(e,r,o),r+=o||0,r}function bC(t,e,r,n){let{batchTableJsonByteLength:s,batchTableBinaryByteLength:o}=t.header||{};if(s&&s>0){let i=sl(e,r,s);t.batchTableJson=JSON.parse(i),r+=s,o&&o>0&&(t.batchTableBinary=new Uint8Array(e,r,o),t.batchTableBinary=new Uint8Array(t.batchTableBinary),r+=o)}return r}function hl(t,e,r){if(!e&&(!t||!t.batchIds||!r))return null;let{batchIds:n,isRGB565:s,pointCount:o=0}=t;if(n&&r){let i=new Uint8ClampedArray(o*3);for(let a=0;a<o;a++){let c=n[a],f=r.getProperty(c,"dimensions").map(u=>u*255);i[a*3]=f[0],i[a*3+1]=f[1],i[a*3+2]=f[2]}return{type:N.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}if(e&&s){let i=new Uint8ClampedArray(o*3);for(let a=0;a<o;a++){let c=fl(e[a]);i[a*3]=c[0],i[a*3+1]=c[1],i[a*3+2]=c[2]}return{type:N.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}return e&&e.length===o*3?{type:N.UNSIGNED_BYTE,value:e,size:3,normalized:!0}:{type:N.UNSIGNED_BYTE,value:e||new Uint8ClampedArray,size:4,normalized:!0}}var ag=new x;function cg(t,e){if(!e)return null;if(t.isOctEncoded16P){let r=new Float32Array((t.pointsLength||0)*3);for(let n=0;n<(t.pointsLength||0);n++)ul(e[n*2],e[n*2+1],ag),ag.toArray(r,n*3);return{type:N.FLOAT,size:2,value:r}}return{type:N.FLOAT,size:2,value:e}}function lg(t,e,r){return t.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(t.isQuantized=!1,EC(t,e)):{type:N.UNSIGNED_SHORT,value:e,size:3,normalized:!0}:e}function EC(t,e){let r=new x,n=new Float32Array(t.pointCount*3);for(let s=0;s<t.pointCount;s++)r.set(e[s*3],e[s*3+1],e[s*3+2]).scale(1/t.quantizedRange).multiply(t.quantizedVolumeScale).add(t.quantizedVolumeOffset).toArray(n,s*3);return n}async function fg(t,e,r,n,s){r=Gt(t,e,r),r=Xr(t,e,r),r=Yr(t,e,r,n),MC(t);let{featureTable:o,batchTable:i}=_C(t);return await wC(t,o,i,n,s),BC(t,o,n),CC(t,o,i),SC(t,o),r}function MC(t){t.attributes={positions:null,colors:null,normals:null,batchIds:null},t.isQuantized=!1,t.isTranslucent=!1,t.isRGB565=!1,t.isOctEncoded16P=!1}function _C(t){let e=new xt(t.featureTableJson,t.featureTableBinary),r=e.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");e.featuresLength=r,t.featuresLength=r,t.pointsLength=r,t.pointCount=r,t.rtcCenter=e.getGlobalProperty("RTC_CENTER",N.FLOAT,3);let n=IC(t,e);return{featureTable:e,batchTable:n}}function BC(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.positions){if(e.hasProperty("POSITION"))t.attributes.positions=e.getPropertyArray("POSITION",N.FLOAT,3);else if(e.hasProperty("POSITION_QUANTIZED")){let n=e.getPropertyArray("POSITION_QUANTIZED",N.UNSIGNED_SHORT,3);if(t.isQuantized=!0,t.quantizedRange=(1<<16)-1,t.quantizedVolumeScale=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",N.FLOAT,3),!t.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(t.quantizedVolumeOffset=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",N.FLOAT,3),!t.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");t.attributes.positions=lg(t,n,r)}}if(!t.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function CC(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.colors){let n=null;e.hasProperty("RGBA")?(n=e.getPropertyArray("RGBA",N.UNSIGNED_BYTE,4),t.isTranslucent=!0):e.hasProperty("RGB")?n=e.getPropertyArray("RGB",N.UNSIGNED_BYTE,3):e.hasProperty("RGB565")&&(n=e.getPropertyArray("RGB565",N.UNSIGNED_SHORT,1),t.isRGB565=!0),t.attributes.colors=hl(t,n,r)}e.hasProperty("CONSTANT_RGBA")&&(t.constantRGBA=e.getGlobalProperty("CONSTANT_RGBA",N.UNSIGNED_BYTE,4))}function SC(t,e){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.normals){let r=null;e.hasProperty("NORMAL")?r=e.getPropertyArray("NORMAL",N.FLOAT,3):e.hasProperty("NORMAL_OCT16P")&&(r=e.getPropertyArray("NORMAL_OCT16P",N.UNSIGNED_BYTE,2),t.isOctEncoded16P=!0),t.attributes.normals=cg(t,r)}}function IC(t,e){let r=null;if(!t.batchIds&&e.hasProperty("BATCH_ID")&&(t.batchIds=e.getPropertyArray("BATCH_ID",N.UNSIGNED_SHORT,1),t.batchIds)){let n=e.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");let{batchTableJson:s,batchTableBinary:o}=t;r=new pr(s,o,n)}return r}async function wC(t,e,r,n,s){let o,i,a,c=t.batchTableJson&&t.batchTableJson.extensions&&t.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);let l=e.getExtension("3DTILES_draco_point_compression");if(l){i=l.properties;let u=l.byteOffset,h=l.byteLength;if(!i||!Number.isFinite(u)||!h)throw new Error("Draco properties, byteOffset, and byteLength must be defined");o=(t.featureTableBinary||[]).slice(u,u+h),t.hasPositions=Number.isFinite(i.POSITION),t.hasColors=Number.isFinite(i.RGB)||Number.isFinite(i.RGBA),t.hasNormals=Number.isFinite(i.NORMAL),t.hasBatchIds=Number.isFinite(i.BATCH_ID),t.isTranslucent=Number.isFinite(i.RGBA)}if(!o)return!0;let f={buffer:o,properties:{...i,...a},featureTableProperties:i,batchTableProperties:a,dequantizeInShader:!1};return await vC(t,f,n,s)}async function vC(t,e,r,n){if(!n)return;let s={...r,draco:{...r?.draco,extraAttributes:e.batchTableProperties||{}}};delete s["3d-tiles"];let o=await Fe(e.buffer,hs,s,n),i=o.attributes.POSITION&&o.attributes.POSITION.value,a=o.attributes.COLOR_0&&o.attributes.COLOR_0.value,c=o.attributes.NORMAL&&o.attributes.NORMAL.value,l=o.attributes.BATCH_ID&&o.attributes.BATCH_ID.value,f=i&&o.attributes.POSITION.value.quantization,u=c&&o.attributes.NORMAL.value.quantization;if(f){let d=o.POSITION.data.quantization,p=d.range;t.quantizedVolumeScale=new x(p,p,p),t.quantizedVolumeOffset=new x(d.minValues),t.quantizedRange=(1<<d.quantizationBits)-1,t.isQuantizedDraco=!0}u&&(t.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,t.isOctEncodedDraco=!0);let h={};if(e.batchTableProperties)for(let d of Object.keys(e.batchTableProperties))o.attributes[d]&&o.attributes[d].value&&(h[d.toLowerCase()]=o.attributes[d].value);t.attributes={positions:i,colors:hl(t,a,void 0),normals:c,batchIds:l,...h}}var dl={};me(dl,{createExtMeshFeatures:()=>WC,decode:()=>zC,encode:()=>kC,name:()=>HC});function le(t,e){if(!t)throw new Error(e||"assert failed: gltf")}var ci={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},li={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var LC=1.33,ug=["SCALAR","VEC2","VEC3","VEC4"],FC=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],RC=new Map(FC),PC={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},OC={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},NC={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function fi(t){return ug[t-1]||ug[0]}function Ut(t){let e=RC.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function Kr(t,e){let r=NC[t.componentType],n=PC[t.type],s=OC[t.componentType],o=t.count*n,i=t.count*n*s;le(i>=0&&i<=e.byteLength);let a=li[t.componentType],c=ci[t.type];return{ArrayType:r,length:o,byteLength:i,componentByteSize:a,numberOfComponentsInElement:c}}function ds(t){let{images:e,bufferViews:r}=t;e=e||[],r=r||[];let n=e.map(i=>i.bufferView);r=r.filter(i=>!n.includes(i));let s=r.reduce((i,a)=>i+a.byteLength,0),o=e.reduce((i,a)=>{let{width:c,height:l}=a.image;return i+c*l},0);return s+Math.ceil(4*o*LC)}function hg(t,e,r){let n=t.bufferViews[r];le(n);let s=n.buffer,o=e[s];le(o);let i=(n.byteOffset||0)+o.byteOffset;return new Uint8Array(o.arrayBuffer,i,n.byteLength)}function dg(t,e,r){let n=typeof r=="number"?t.accessors?.[r]:r;if(!n)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let s=t.bufferViews?.[n.bufferView||0];if(!s)throw new Error(`No gltf buffer view for accessor ${s}`);let{arrayBuffer:o,byteOffset:i}=e[s.buffer],a=(i||0)+(n.byteOffset||0)+(s.byteOffset||0),{ArrayType:c,length:l,componentByteSize:f,numberOfComponentsInElement:u}=Kr(n,s),h=f*u,d=s.byteStride||h;if(typeof s.byteStride>"u"||s.byteStride===h)return new c(o,a,l);let p=new c(l);for(let A=0;A<n.count;A++){let m=new c(o,a+A*d,u);p.set(m,A*u)}return p}function DC(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}var k=class{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||DC(),buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){let r=this.getUsedExtensions().find(s=>s===e),n=this.getRequiredExtensions().find(s=>s===e);return typeof r=="string"||typeof n=="string"}getExtension(e){let r=this.getUsedExtensions().find(s=>s===e),n=this.json.extensions||{};return r?n[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(n=>n===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,r){return(e.extensions||{})[r]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,r){if(typeof r=="object")return r;let n=this.json[e]&&this.json[e][r];if(!n)throw new Error(`glTF file error: Could not find ${e}[${r}]`);return n}getTypedArrayForBufferView(e){e=this.getBufferView(e);let r=e.buffer,n=this.gltf.buffers[r];le(n);let s=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,s,e.byteLength)}getTypedArrayForAccessor(e){let r=this.getAccessor(e);return dg(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);let r=this.getBufferView(e.bufferView),s=this.getBuffer(r.buffer).data,o=r.byteOffset||0;return new Uint8Array(s,o,r.byteLength)}addApplicationData(e,r){return this.json[e]=r,this}addExtraData(e,r){return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addObjectExtension(e,r,n){return e.extensions=e.extensions||{},e.extensions[r]=n,this.registerUsedExtension(r),this}setObjectExtension(e,r,n){let s=e.extensions||{};s[r]=n}removeObjectExtension(e,r){let n=e?.extensions||{};if(n[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let s=this.json.extensionsRemoved;s.includes(r)||s.push(r)}delete n[r]}addExtension(e,r={}){return le(r),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),r}addRequiredExtension(e,r={}){return le(r),this.addExtension(e,r),this.registerRequiredExtension(e),r}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(e)||r.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){let{nodeIndices:r}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(e){let{meshIndex:r,matrix:n}=e;this.json.nodes=this.json.nodes||[];let s={mesh:r};return n&&(s.matrix=n),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(e){let{attributes:r,indices:n,material:s,mode:o=4}=e,a={primitives:[{attributes:this._addAttributes(r),mode:o}]};if(n){let c=this._addIndices(n);a.primitives[0].indices=c}return Number.isFinite(s)&&(a.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){let n={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(n),this.json.meshes.length-1}addImage(e,r){let n=or(e),s=r||n?.mimeType,i={bufferView:this.addBufferView(e),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(i),this.json.images.length-1}addBufferView(e,r=0,n=this.byteLength){let s=e.byteLength;le(Number.isFinite(s)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);let o={buffer:r,byteOffset:n,byteLength:s};return this.byteLength+=Ct(s,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(o),this.json.bufferViews.length-1}addAccessor(e,r){let n={bufferView:e,type:fi(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e,r={size:3}){let n=this.addBufferView(e),s={min:r.min,max:r.max};(!s.min||!s.max)&&(s=this._getAccessorMinMax(e,r.size));let o={size:r.size,componentType:Ut(e),count:Math.round(e.length/r.size),min:s.min,max:s.max};return this.addAccessor(n,Object.assign(o,r))}addTexture(e){let{imageIndex:r}=e,n={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){let e=this.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r),s=0;for(let o of this.sourceBuffers||[])s=ac(o,n,s);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=r,this.sourceBuffers=[r],this.gltf.buffers=[{arrayBuffer:r,byteOffset:0,byteLength:r.byteLength}]}_removeStringFromArray(e,r){let n=!0;for(;n;){let s=e.indexOf(r);s>-1?e.splice(s,1):n=!1}}_addAttributes(e={}){let r={};for(let n in e){let s=e[n],o=this._getGltfAttributeName(n),i=this.addBinaryBuffer(s.value,s);r[o]=i}return r}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,r){let n={min:null,max:null};if(e.length<r)return n;n.min=[],n.max=[];let s=e.subarray(0,r);for(let o of s)n.min.push(o),n.max.push(o);for(let o=r;o<e.length;o+=r)for(let i=0;i<r;i++)n.min[0+i]=Math.min(n.min[0+i],e[o+i]),n.max[0+i]=Math.max(n.max[0+i],e[o+i]);return n}};function pg(t){return(t%1+1)%1}var mg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},GC={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},gg={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function ps(t,e){return gg[e]*mg[t]}function Qr(t,e,r,n){if(r!=="UINT8"&&r!=="UINT16"&&r!=="UINT32"&&r!=="UINT64")return null;let s=t.getTypedArrayForBufferView(e),o=Zr(s,"SCALAR",r,n+1);return o instanceof BigInt64Array||o instanceof BigUint64Array?null:o}function Zr(t,e,r,n=1){let s=mg[e],o=GC[r],i=gg[r],a=n*s,c=a*i,l=t.buffer,f=t.byteOffset;return f%i!==0&&(l=new Uint8Array(l).slice(f,f+c).buffer,f=0),new o(wt(l),f,a)}function $r(t,e,r){let n=`TEXCOORD_${e.texCoord||0}`,s=r.attributes[n],o=t.getTypedArrayForAccessor(s),i=t.gltf.json,a=e.index,c=i.textures?.[a]?.source;if(typeof c<"u"){let l=i.images?.[c]?.mimeType,f=t.gltf.images?.[c];if(f&&typeof f.width<"u"){let u=[];for(let h=0;h<o.length;h+=2){let d=UC(f,l,o,h,e.channels);u.push(d)}return u}}return[]}function ui(t,e,r,n,s){if(!r?.length)return;let o=[];for(let f of r){let u=n.findIndex(h=>h===f);u===-1&&(u=n.push(f)-1),o.push(u)}let i=new Uint32Array(o),a=t.gltf.buffers.push({arrayBuffer:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength})-1,c=t.addBufferView(i,a,0),l=t.addAccessor(c,{size:1,componentType:Ut(i),count:i.length});s.attributes[e]=l}function UC(t,e,r,n,s=[0]){let o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},i=r[n],a=r[n+1],c=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(c=4);let l=VC(i,a,t,c),f=0;for(let u of s){let h=typeof u=="number"?Object.values(o)[u]:o[u],d=l+h.offset,p=zn(t);if(p.data.length<=d)throw new Error(`${p.data.length} <= ${d}`);let A=p.data[d];f|=A<<h.shift}return f}function VC(t,e,r,n=1){let s=r.width,o=pg(t)*(s-1),i=Math.round(o),a=r.height,c=pg(e)*(a-1),l=Math.round(c),f=r.components?r.components:n;return(l*s+i)*f}function hi(t,e,r,n,s){let o=[];for(let i=0;i<e;i++){let a=r[i],c=r[i+1]-r[i];if(c+a>n)break;let l=a/s,f=c/s;o.push(t.slice(l,l+f))}return o}function di(t,e,r){let n=[];for(let s=0;s<e;s++){let o=s*r;n.push(t.slice(o,o+r))}return n}function pi(t,e,r,n){if(r)throw new Error("Not implemented - arrayOffsets for strings is specified");if(n){let s=[],o=new TextDecoder("utf8"),i=0;for(let a=0;a<t;a++){let c=n[a+1]-n[a];if(c+i<=e.length){let l=e.subarray(i,c+i),f=o.decode(l);s.push(f),i+=c}}return s}return[]}var en="EXT_mesh_features",HC=en;async function zC(t,e){let r=new k(t);qC(r,e)}function kC(t,e){let r=new k(t);return JC(r,e),r.createBinaryChunk(),r.gltf}function qC(t,e){let r=t.gltf.json;if(r.meshes)for(let n of r.meshes)for(let s of n.primitives)jC(t,s,e)}function jC(t,e,r){if(!r?.gltf?.loadBuffers)return;let s=e.extensions?.[en]?.featureIds;if(s)for(let o of s){let i;if(typeof o.attribute<"u"){let a=`_FEATURE_ID_${o.attribute}`,c=e.attributes[a];i=t.getTypedArrayForAccessor(c)}else typeof o.texture<"u"&&r?.gltf?.loadImages?i=$r(t,o.texture,e):i=[];o.data=i}}function JC(t,e){let r=t.gltf.json.meshes;if(r)for(let n of r)for(let s of n.primitives)XC(t,s)}function WC(t,e,r,n){e.extensions||(e.extensions={});let s=e.extensions[en];s||(s={featureIds:[]},e.extensions[en]=s);let{featureIds:o}=s,i={featureCount:r.length,propertyTable:n,data:r};o.push(i),t.addObjectExtension(e,en,s)}function XC(t,e){let r=e.extensions?.[en];if(!r)return;let n=r.featureIds;n.forEach((s,o)=>{if(s.data){let{accessorKey:i,index:a}=YC(e.attributes),c=new Uint32Array(s.data);n[o]={featureCount:c.length,propertyTable:s.propertyTable,attribute:a},t.gltf.buffers.push({arrayBuffer:c.buffer,byteOffset:c.byteOffset,byteLength:c.byteLength});let l=t.addBufferView(c),f=t.addAccessor(l,{size:1,componentType:Ut(c),count:c.length});e.attributes[i]=f}})}function YC(t){let e="_FEATURE_ID_",r=Object.keys(t).filter(o=>o.indexOf(e)===0),n=-1;for(let o of r){let i=Number(o.substring(e.length));i>n&&(n=i)}return n++,{accessorKey:`${e}${n}`,index:n}}var gl={};me(gl,{createExtStructuralMetadata:()=>AS,decode:()=>QC,encode:()=>ZC,name:()=>KC});var tn="EXT_structural_metadata",KC=tn;async function QC(t,e){let r=new k(t);$C(r,e)}function ZC(t,e){let r=new k(t);return mS(r,e),r.createBinaryChunk(),r.gltf}function $C(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(tn);r&&(e.gltf?.loadImages&&eS(t,r),tS(t,r))}function eS(t,e){let r=e.propertyTextures,n=t.gltf.json;if(r&&n.meshes)for(let s of n.meshes)for(let o of s.primitives)nS(t,r,o,e)}function tS(t,e){let r=e.schema;if(!r)return;let n=r.classes,s=e.propertyTables;if(n&&s)for(let o in n){let i=rS(s,o);i&&oS(t,r,i)}}function rS(t,e){for(let r of t)if(r.class===e)return r;return null}function nS(t,e,r,n){if(!e)return;let o=r.extensions?.[tn]?.propertyTextures;if(o)for(let i of o){let a=e[i];sS(t,a,r,n)}}function sS(t,e,r,n){if(!e.properties)return;n.dataAttributeNames||(n.dataAttributeNames=[]);let s=e.class;for(let o in e.properties){let i=`${s}_${o}`,a=e.properties?.[o];if(!a)continue;a.data||(a.data=[]);let c=a.data,l=$r(t,a,r);l!==null&&(ui(t,i,l,c,r),a.data=c,n.dataAttributeNames.push(i))}}function oS(t,e,r){let n=e.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let s=r.count;for(let o in n.properties){let i=n.properties[o],a=r.properties?.[o];if(a){let c=iS(t,e,i,s,a);a.data=c}}}function iS(t,e,r,n,s){let o=[],i=s.values,a=t.getTypedArrayForBufferView(i),c=aS(t,r,s,n),l=cS(t,s,n);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{o=lS(r,n,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{o=pi(n,a,c,l);break}case"ENUM":{o=fS(e,r,n,a,c);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return o}function aS(t,e,r,n){return e.array&&typeof e.count>"u"&&typeof r.arrayOffsets<"u"?Qr(t,r.arrayOffsets,r.arrayOffsetType||"UINT32",n):null}function cS(t,e,r){return typeof e.stringOffsets<"u"?Qr(t,e.stringOffsets,e.stringOffsetType||"UINT32",r):null}function lS(t,e,r,n){let s=t.array,o=t.count,i=ps(t.type,t.componentType),a=r.byteLength/i,c;return t.componentType?c=Zr(r,t.type,t.componentType,a):c=r,s?n?hi(c,e,n,r.length,i):o?di(c,e,o):[]:c}function fS(t,e,r,n,s){let o=e.enumType;if(!o)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let i=t.enums?.[o];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${o}`);let a=i.valueType||"UINT16",c=ps(e.type,a),l=n.byteLength/c,f=Zr(n,e.type,a,l);if(f||(f=n),e.array){if(s)return uS({valuesData:f,numberOfElements:r,arrayOffsets:s,valuesDataBytesLength:n.length,elementSize:c,enumEntry:i});let u=e.count;return u?hS(f,r,u,i):[]}return ml(f,0,r,i)}function uS(t){let{valuesData:e,numberOfElements:r,arrayOffsets:n,valuesDataBytesLength:s,elementSize:o,enumEntry:i}=t,a=[];for(let c=0;c<r;c++){let l=n[c],f=n[c+1]-n[c];if(f+l>s)break;let u=l/o,h=f/o,d=ml(e,u,h,i);a.push(d)}return a}function hS(t,e,r,n){let s=[];for(let o=0;o<e;o++){let i=r*o,a=ml(t,i,r,n);s.push(a)}return s}function ml(t,e,r,n){let s=[];for(let o=0;o<r;o++)if(t instanceof BigInt64Array||t instanceof BigUint64Array)s.push("");else{let i=t[e+o],a=dS(n,i);a?s.push(a.name):s.push("")}return s}function dS(t,e){for(let r of t.values)if(r.value===e)return r;return null}var pS="schemaClassId";function mS(t,e){let r=t.getExtension(tn);if(r&&r.propertyTables)for(let n of r.propertyTables){let s=n.class,o=r.schema?.classes?.[s];n.properties&&o&&gS(n,o,t)}}function gS(t,e,r){for(let n in t.properties){let s=t.properties[n].data;if(s){let o=e.properties[n];if(o){let i=TS(s,o,r);t.properties[n]=i}}}}function AS(t,e,r=pS){let n=t.getExtension(tn);n||(n=t.addExtension(tn)),n.schema=xS(e,r,n.schema);let s=yS(e,r,n.schema);return n.propertyTables||(n.propertyTables=[]),n.propertyTables.push(s)-1}function xS(t,e,r){let n=r??{id:"schema_id"},s={properties:{}};for(let o of t){let i={type:o.elementType,componentType:o.componentType};s.properties[o.name]=i}return n.classes={},n.classes[e]=s,n}function yS(t,e,r){let n={class:e,count:0},s=0,o=r.classes?.[e];for(let i of t){if(s===0&&(s=i.values.length),s!==i.values.length&&i.values.length)throw new Error("Illegal values in attributes");o?.properties[i.name]&&(n.properties||(n.properties={}),n.properties[i.name]={values:0,data:i.values})}return n.count=s,n}function TS(t,e,r){let n={values:0};if(e.type==="STRING"){let{stringData:s,stringOffsets:o}=MS(t);n.stringOffsets=pl(o,r),n.values=pl(s,r)}else if(e.type==="SCALAR"&&e.componentType){let s=ES(t,e.componentType);n.values=pl(s,r)}return n}var bS={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function ES(t,e){let r=[];for(let s of t)r.push(Number(s));let n=bS[e];if(!n)throw new Error("Illegal component type");return new n(r)}function MS(t){let e=new TextEncoder,r=[],n=0;for(let c of t){let l=e.encode(c);n+=l.length,r.push(l)}let s=new Uint8Array(n),o=[],i=0;for(let c of r)s.set(c,i),o.push(i),i+=c.length;o.push(i);let a=new Uint32Array(o);return{stringData:s,stringOffsets:a}}function pl(t,e){return e.gltf.buffers.push({arrayBuffer:wt(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength}),e.addBufferView(t)}var Al={};me(Al,{decode:()=>BS,name:()=>_S});var Ag="EXT_feature_metadata",_S=Ag;async function BS(t,e){let r=new k(t);CS(r,e)}function CS(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(Ag);r&&(e.gltf?.loadImages&&SS(t,r),IS(t,r))}function SS(t,e){let r=e.schema;if(!r)return;let n=r.classes,{featureTextures:s}=e;if(n&&s)for(let o in n){let i=n[o],a=vS(s,o);a&&FS(t,a,i)}}function IS(t,e){let r=e.schema;if(!r)return;let n=r.classes,s=e.featureTables;if(n&&s)for(let o in n){let i=wS(s,o);i&&LS(t,r,i)}}function wS(t,e){for(let r in t){let n=t[r];if(n.class===e)return n}return null}function vS(t,e){for(let r in t){let n=t[r];if(n.class===e)return n}return null}function LS(t,e,r){if(!r.class)return;let n=e.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let s=r.count;for(let o in n.properties){let i=n.properties[o],a=r.properties?.[o];if(a){let c=RS(t,e,i,s,a);a.data=c}}}function FS(t,e,r){let n=e.class;for(let s in r.properties){let o=e?.properties?.[s];if(o){let i=GS(t,o,n);o.data=i}}}function RS(t,e,r,n,s){let o=[],i=s.bufferView,a=t.getTypedArrayForBufferView(i),c=PS(t,r,s,n),l=OS(t,r,s,n);return r.type==="STRING"||r.componentType==="STRING"?o=pi(n,a,c,l):NS(r)&&(o=DS(r,n,a,c)),o}function PS(t,e,r,n){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?Qr(t,r.arrayOffsetBufferView,r.offsetType||"UINT32",n):null}function OS(t,e,r,n){return typeof r.stringOffsetBufferView<"u"?Qr(t,r.stringOffsetBufferView,r.offsetType||"UINT32",n):null}function NS(t){let e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function DS(t,e,r,n){let s=t.type==="ARRAY",o=t.componentCount,i="SCALAR",a=t.componentType||t.type,c=ps(i,a),l=r.byteLength/c,f=Zr(r,i,a,l);return s?n?hi(f,e,n,r.length,c):o?di(f,e,o):[]:f}function GS(t,e,r){let n=t.gltf.json;if(!n.meshes)return[];let s=[];for(let o of n.meshes)for(let i of o.primitives)US(t,r,e,s,i);return s}function US(t,e,r,n,s){let o={channels:r.channels,...r.texture},i=$r(t,o,s);i&&ui(t,e,i,n,s)}var xg="4.4.0-alpha.18";var rn=!0,yg=1735152710,Tl=12,mi=8,VS=1313821514,HS=5130562,zS=0,kS=0,qS=1;function jS(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function Tg(t,e=0,r={}){let n=new DataView(t),{magic:s=yg}=r,o=n.getUint32(e,!1);return o===s||o===yg}function bg(t,e,r=0,n={}){let s=new DataView(e),o=jS(s,r+0),i=s.getUint32(r+4,rn),a=s.getUint32(r+8,rn);switch(Object.assign(t,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:o,version:i,json:{},binChunks:[]}),r+=Tl,t.version){case 1:return JS(t,s,r);case 2:return WS(t,s,r,n={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function JS(t,e,r){H(t.header.byteLength>Tl+mi);let n=e.getUint32(r+0,rn),s=e.getUint32(r+4,rn);return r+=mi,H(s===zS),xl(t,e,r,n),r+=n,r+=yl(t,e,r,t.header.byteLength),r}function WS(t,e,r,n){return H(t.header.byteLength>Tl+mi),XS(t,e,r,n),r+t.header.byteLength}function XS(t,e,r,n){for(;r+8<=t.header.byteLength;){let s=e.getUint32(r+0,rn),o=e.getUint32(r+4,rn);switch(r+=mi,o){case VS:xl(t,e,r,s);break;case HS:yl(t,e,r,s);break;case kS:n.strict||xl(t,e,r,s);break;case qS:n.strict||yl(t,e,r,s);break;default:break}r+=Ct(s,4)}return r}function xl(t,e,r,n){let s=new Uint8Array(e.buffer,r,n),i=new TextDecoder("utf8").decode(s);return t.json=JSON.parse(i),Ct(n,4)}function yl(t,e,r,n){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:n,arrayBuffer:e.buffer}),Ct(n,4)}function bl(t,e){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;let n=e?.core?.baseUri||e.baseUri||e.uri;if(!n)throw new Error(`'baseUri' must be provided to resolve relative url ${t}`);return n.substr(0,n.lastIndexOf("/")+1)+t}var Ml={};me(Ml,{decode:()=>iI,name:()=>oI});var YS="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",KS="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",QS=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),ZS=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),$S={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},eI={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function Eg(t,e,r,n,s,o="NONE"){let i=await tI();sI(i,i.exports[eI[s]],t,e,r,n,i.exports[$S[o||"NONE"]])}var El;async function tI(){return El||(El=rI()),El}async function rI(){let t=YS;WebAssembly.validate(QS)&&(t=KS,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let e=await WebAssembly.instantiate(nI(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function nI(t){let e=new Uint8Array(t.length);for(let n=0;n<t.length;++n){let s=t.charCodeAt(n);e[n]=s>96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let r=0;for(let n=0;n<t.length;++n)e[r++]=e[n]<60?ZS[e[n]]:(e[n]-60)*64+e[++n];return e.buffer.slice(0,r)}function sI(t,e,r,n,s,o,i){let a=t.exports.sbrk,c=n+3&-4,l=a(c*s),f=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,f);let h=e(l,n,s,f,o.length);if(h===0&&i&&i(l,c,s),r.set(u.subarray(l,l+n*s)),a(l-a(0)),h!==0)throw new Error(`Malformed buffer data: ${h}`)}var gi="EXT_meshopt_compression",oI=gi;async function iI(t,e){let r=new k(t);if(!e?.gltf?.decompressMeshes||!e.gltf?.loadBuffers)return;let n=[];for(let s of t.json.bufferViews||[])n.push(aI(r,s));await Promise.all(n),r.removeExtension(gi)}async function aI(t,e){let r=t.getObjectExtension(e,gi);if(r){let{byteOffset:n=0,byteLength:s=0,byteStride:o,count:i,mode:a,filter:c="NONE",buffer:l}=r,f=t.gltf.buffers[l],u=new Uint8Array(f.arrayBuffer,f.byteOffset+n,s),h=new Uint8Array(t.gltf.buffers[e.buffer].arrayBuffer,e.byteOffset,e.byteLength);await Eg(h,i,o,u,a,c),t.removeObjectExtension(e,gi)}}var _l={};me(_l,{name:()=>cI,preprocess:()=>lI});var nn="EXT_texture_webp",cI=nn;function lI(t,e){let r=new k(t);if(!yc("image/webp")){if(r.getRequiredExtensions().includes(nn))throw new Error(`gltf: Required extension ${nn} not supported by browser`);return}let{json:n}=r;for(let s of n.textures||[]){let o=r.getObjectExtension(s,nn);o&&(s.source=o.source),r.removeObjectExtension(s,nn)}r.removeExtension(nn)}var Bl={};me(Bl,{name:()=>fI,preprocess:()=>uI});var Ai="KHR_texture_basisu",fI=Ai;function uI(t,e){let r=new k(t),{json:n}=r;for(let s of n.textures||[]){let o=r.getObjectExtension(s,Ai);o&&(s.source=o.source,r.removeObjectExtension(s,Ai))}r.removeExtension(Ai)}var Sl={};me(Sl,{decode:()=>gI,encode:()=>AI,name:()=>pI,preprocess:()=>mI});function Mg(t){let e={};for(let r in t){let n=t[r];if(r!=="indices"){let s=Cl(n);e[r]=s}}return e}function Cl(t){let{buffer:e,size:r,count:n}=hI(t);return{value:e,size:r,byteOffset:0,count:n,type:fi(r),componentType:Ut(e)}}function hI(t){let e=t,r=1,n=0;return t&&t.value&&(e=t.value,r=t.size||1),e&&(ArrayBuffer.isView(e)||(e=dI(e,Float32Array)),n=e.length/r),{buffer:e,size:r,count:n}}function dI(t,e,r=!1){return t?Array.isArray(t)?new e(t):r&&!(t instanceof e)?new e(t):t:null}var Vt="KHR_draco_mesh_compression",pI=Vt;function mI(t,e,r){let n=new k(t);for(let s of _g(n))n.getObjectExtension(s,Vt)}async function gI(t,e,r){if(!e?.gltf?.decompressMeshes)return;let n=new k(t),s=[];for(let o of _g(n))n.getObjectExtension(o,Vt)&&s.push(xI(n,o,e,r));await Promise.all(s),n.removeExtension(Vt)}function AI(t,e={}){let r=new k(t);for(let n of r.json.meshes||[])yI(n,e),r.addRequiredExtension(Vt)}async function xI(t,e,r,n){let s=t.getObjectExtension(e,Vt);if(!s)return;let o=t.getTypedArrayForBufferView(s.bufferView),i=tr(o.buffer,o.byteOffset),a={...r};delete a["3d-tiles"];let c=await Fe(i,hs,a,n),l=Mg(c.attributes);for(let[f,u]of Object.entries(l))if(f in e.attributes){let h=e.attributes[f],d=t.getAccessor(h);d?.min&&d?.max&&(u.min=d.min,u.max=d.max)}e.attributes=l,c.indices&&(e.indices=Cl(c.indices)),t.removeObjectExtension(e,Vt),TI(e)}function yI(t,e,r=4,n,s){if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let o=n.DracoWriter.encodeSync({attributes:t}),i=s?.parseSync?.({attributes:t}),a=n._addFauxAttributes(i.attributes),c=n.addBufferView(o);return{primitives:[{attributes:a,mode:r,extensions:{[Vt]:{bufferView:c,attributes:a}}}]}}function TI(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*_g(t){for(let e of t.json.meshes||[])for(let r of e.primitives)yield r}var Il={};me(Il,{decode:()=>_I,name:()=>bI});var yi="KHR_texture_transform",bI=yi,xi=new x,EI=new j,MI=new j;async function _I(t,e){if(!new k(t).hasExtension(yi)||!e.gltf?.loadBuffers)return;let s=t.json.materials||[];for(let o=0;o<s.length;o++)BI(o,t)}function BI(t,e){let r=e.json.materials?.[t],n=[r?.pbrMetallicRoughness?.baseColorTexture,r?.emissiveTexture,r?.normalTexture,r?.occlusionTexture,r?.pbrMetallicRoughness?.metallicRoughnessTexture],s=[];for(let o of n)o&&o?.extensions?.[yi]&&CI(e,t,o,s)}function CI(t,e,r,n){let s=SI(r,n);if(!s)return;let o=t.json.meshes||[];for(let i of o)for(let a of i.primitives){let c=a.material;Number.isFinite(c)&&e===c&&II(t,a,s)}}function SI(t,e){let r=t.extensions?.[yi],{texCoord:n=0}=t,{texCoord:s=n}=r;if(!(e.findIndex(([i,a])=>i===n&&a===s)!==-1)){let i=LI(r);return n!==s&&(t.texCoord=s),e.push([n,s]),{originalTexCoord:n,texCoord:s,matrix:i}}return null}function II(t,e,r){let{originalTexCoord:n,texCoord:s,matrix:o}=r,i=e.attributes[`TEXCOORD_${n}`];if(Number.isFinite(i)){let a=t.json.accessors?.[i];if(a&&a.bufferView!==void 0){let c=t.json.bufferViews?.[a.bufferView];if(c){let{arrayBuffer:l,byteOffset:f}=t.buffers[c.buffer],u=(f||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:h,length:d}=Kr(a,c),p=li[a.componentType],A=ci[a.type],m=c.byteStride||p*A,y=new Float32Array(d);for(let b=0;b<a.count;b++){let E=new h(l,u+b*m,2);xi.set(E[0],E[1],1),xi.transformByMatrix3(o),y.set([xi[0],xi[1]],b*A)}n===s?wI(a,t,y,a.bufferView):vI(s,a,e,t,y)}}}}function wI(t,e,r,n){t.componentType=5126,t.byteOffset=0;let i=(e.json.accessors||[]).reduce((l,f)=>f.bufferView===n?l+1:l,0)>1;e.buffers.push({arrayBuffer:wt(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength});let a=e.buffers.length-1;if(e.json.bufferViews=e.json.bufferViews||[],i){e.json.bufferViews.push({buffer:a,byteLength:r.buffer.byteLength,byteOffset:0}),t.bufferView=e.json.bufferViews.length-1;return}let c=e.json.bufferViews[n];c&&(c.buffer=a,c.byteOffset=0,c.byteLength=r.buffer.byteLength,c.byteStride!==void 0&&delete c.byteStride)}function vI(t,e,r,n,s){n.buffers.push({arrayBuffer:wt(s.buffer),byteOffset:0,byteLength:s.buffer.byteLength}),n.json.bufferViews=n.json.bufferViews||[];let o=n.json.bufferViews;o.push({buffer:n.buffers.length-1,byteLength:s.buffer.byteLength,byteOffset:0});let i=n.json.accessors;i&&(i.push({bufferView:o?.length-1,byteOffset:0,componentType:5126,count:e.count,type:"VEC2"}),r.attributes[`TEXCOORD_${t}`]=i.length-1)}function LI(t){let{offset:e=[0,0],rotation:r=0,scale:n=[1,1]}=t,s=new j().set(1,0,0,0,1,0,e[0],e[1],1),o=EI.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),i=MI.set(n[0],0,0,0,n[1],0,0,0,1);return s.multiplyRight(o).multiplyRight(i)}var wl={};me(wl,{decode:()=>RI,encode:()=>PI,name:()=>FI});var mr="KHR_lights_punctual",FI=mr;async function RI(t){let e=new k(t),{json:r}=e,n=e.getExtension(mr);n&&(e.json.lights=n.lights,e.removeExtension(mr));for(let s of r.nodes||[]){let o=e.getObjectExtension(s,mr);o&&(s.light=o.light),e.removeObjectExtension(s,mr)}}async function PI(t){let e=new k(t),{json:r}=e;if(r.lights){let n=e.addExtension(mr);le(!n.lights),n.lights=r.lights,delete r.lights}if(e.json.lights){for(let n of e.json.lights){let s=n.node;e.addObjectExtension(s,mr,n)}delete e.json.lights}}var vl={};me(vl,{decode:()=>NI,encode:()=>DI,name:()=>OI});var ms="KHR_materials_unlit",OI=ms;async function NI(t){let e=new k(t),{json:r}=e;for(let n of r.materials||[])n.extensions&&n.extensions.KHR_materials_unlit&&(n.unlit=!0),e.removeObjectExtension(n,ms);e.removeExtension(ms)}function DI(t){let e=new k(t),{json:r}=e;if(e.materials)for(let n of r.materials||[])n.unlit&&(delete n.unlit,e.addObjectExtension(n,ms,{}),e.addExtension(ms))}var Ll={};me(Ll,{decode:()=>UI,encode:()=>VI,name:()=>GI});var gs="KHR_techniques_webgl",GI=gs;async function UI(t){let e=new k(t),{json:r}=e,n=e.getExtension(gs);if(n){let s=HI(n,e);for(let o of r.materials||[]){let i=e.getObjectExtension(o,gs);i&&(o.technique=Object.assign({},i,s[i.technique]),o.technique.values=zI(o.technique,e)),e.removeObjectExtension(o,gs)}e.removeExtension(gs)}}async function VI(t,e){}function HI(t,e){let{programs:r=[],shaders:n=[],techniques:s=[]}=t,o=new TextDecoder;return n.forEach(i=>{if(Number.isFinite(i.bufferView))i.code=o.decode(e.getTypedArrayForBufferView(i.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(i=>{i.fragmentShader=n[i.fragmentShader],i.vertexShader=n[i.vertexShader]}),s.forEach(i=>{i.program=r[i.program]}),s}function zI(t,e){let r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(n=>{t.uniforms[n].value&&!(n in r)&&(r[n]=t.uniforms[n].value)}),Object.keys(r).forEach(n=>{typeof r[n]=="object"&&r[n].index!==void 0&&(r[n].texture=e.getTexture(r[n].index))}),r}var Bg=[gl,dl,Ml,_l,Bl,Sl,wl,vl,Ll,Il,Al];function Cg(t,e={},r){let n=Bg.filter(s=>Ig(s.name,e));for(let s of n)s.preprocess?.(t,e,r)}async function Sg(t,e={},r){let n=Bg.filter(s=>Ig(s.name,e));for(let s of n)await s.decode?.(t,e,r)}function Ig(t,e){let r=e?.gltf?.excludeExtensions||{};return!(t in r&&!r[t])}var Fl="KHR_binary_glTF";function wg(t){let e=new k(t),{json:r}=e;for(let n of r.images||[]){let s=e.getObjectExtension(n,Fl);s&&Object.assign(n,s),e.removeObjectExtension(n,Fl)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(Fl)}var vg={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},qI={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},Rl=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,r){this.json=e.json;let n=e.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${n.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),wg(e),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(let r in vg)this._convertTopLevelObjectToArray(e,r)}_convertTopLevelObjectToArray(e,r){let n=e[r];if(!(!n||Array.isArray(n))){e[r]=[];for(let s in n){let o=n[s];o.id=o.id||s;let i=e[r].length;e[r].push(o),this.idToIndexMap[r][s]=i}}}_convertObjectIdsToArrayIndices(e){for(let r in vg)this._convertIdsToIndices(e,r);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(let r of e.textures)this._convertTextureIds(r);for(let r of e.meshes)this._convertMeshIds(r);for(let r of e.nodes)this._convertNodeIds(r);for(let r of e.scenes)this._convertSceneIds(r)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(let r of e.primitives){let{attributes:n,indices:s,material:o}=r;for(let i in n)n[i]=this._convertIdToIndex(n[i],"accessor");s&&(r.indices=this._convertIdToIndex(s,"accessor")),o&&(r.material=this._convertIdToIndex(o,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(r=>this._convertIdToIndex(r,"node"))),e.meshes&&(e.meshes=e.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(e,r){e[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),e[r]=[]);for(let n of e[r])for(let s in n){let o=n[s],i=this._convertIdToIndex(o,s);n[s]=i}}_convertIdToIndex(e,r){let n=qI[r];if(n in this.idToIndexMap){let s=this.idToIndexMap[n][e];if(!Number.isFinite(s))throw new Error(`gltf v1: failed to resolve ${r} with id ${e}`);return s}return e}_updateObjects(e){for(let r of this.json.buffers)delete r.type}_updateMaterial(e){for(let r of e.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let n=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,s=e.textures.findIndex(o=>o.id===n);s!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:s})}}};function Lg(t,e={}){return new Rl().normalize(t,e)}async function Fg(t,e,r=0,n,s){return jI(t,e,r,n),Lg(t,{normalize:n?.gltf?.normalize}),Cg(t,n,s),n?.gltf?.loadBuffers&&t.json.buffers&&await JI(t,n,s),n?.gltf?.loadImages&&await WI(t,n,s),await Sg(t,n,s),t}function jI(t,e,r,n){if(n.core?.baseUri&&(t.baseUri=n.core?.baseUri),e instanceof ArrayBuffer&&!Tg(e,r,n.glb)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=ic(e);else if(e instanceof ArrayBuffer){let i={};r=bg(i,e,r,n.glb),le(i.type==="glTF",`Invalid GLB magic string ${i.type}`),t._glb=i,t.json=i.json}else le(!1,"GLTF: must be ArrayBuffer or string");let s=t.json.buffers||[];if(t.buffers=new Array(s.length).fill(null),t._glb&&t._glb.header.hasBinChunk){let{binChunks:i}=t._glb;t.buffers[0]={arrayBuffer:i[0].arrayBuffer,byteOffset:i[0].byteOffset,byteLength:i[0].byteLength}}let o=t.json.images||[];t.images=new Array(o.length).fill({})}async function JI(t,e,r){let n=t.json.buffers||[];for(let s=0;s<n.length;++s){let o=n[s];if(o.uri){let{fetch:i}=r;le(i);let a=bl(o.uri,e),l=await(await r?.fetch?.(a))?.arrayBuffer?.();t.buffers[s]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete o.uri}else t.buffers[s]===null&&(t.buffers[s]={arrayBuffer:new ArrayBuffer(o.byteLength),byteOffset:0,byteLength:o.byteLength})}}async function WI(t,e,r){let n=XI(t),s=t.json.images||[],o=[];for(let i of n)o.push(YI(t,s[i],i,e,r));return await Promise.all(o)}function XI(t){let e=new Set,r=t.json.textures||[];for(let n of r)n.source!==void 0&&e.add(n.source);return Array.from(e).sort()}async function YI(t,e,r,n,s){let o;if(e.uri&&!e.hasOwnProperty("bufferView")){let l=bl(e.uri,n),{fetch:f}=s;o=await(await f(l)).arrayBuffer(),e.bufferView={data:o}}if(Number.isFinite(e.bufferView)){let l=hg(t.json,t.buffers,e.bufferView);o=tr(l.buffer,l.byteOffset,l.byteLength)}le(o,"glTF image has no data");let i=n,a={...i,core:{...i?.core,mimeType:e.mimeType}},c=await Fe(o,[Vr,Gc],a,s);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c[0]}),t.images=t.images||[],t.images[r]=c}var gr={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:xg,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:KI,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};async function KI(t,e={},r){let n={...gr.options,...e};n.gltf={...gr.options.gltf,...n.gltf};let s=e?.glb?.byteOffset||0;return await Fg({},t,s,n,r)}var QI={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ZI={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},He={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},$I={magFilter:He.TEXTURE_MAG_FILTER,minFilter:He.TEXTURE_MIN_FILTER,wrapS:He.TEXTURE_WRAP_S,wrapT:He.TEXTURE_WRAP_T},e2={[He.TEXTURE_MAG_FILTER]:He.LINEAR,[He.TEXTURE_MIN_FILTER]:He.NEAREST_MIPMAP_LINEAR,[He.TEXTURE_WRAP_S]:He.REPEAT,[He.TEXTURE_WRAP_T]:He.REPEAT};function t2(){return{id:"default-sampler",parameters:e2}}function r2(t){return ZI[t]}function n2(t){return QI[t]}var Pl=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,r={}){let{json:n,buffers:s=[],images:o=[]}=e,{baseUri:i=""}=e;return le(n),this.baseUri=i,this.buffers=s,this.images=o,this.jsonUnprocessed=n,this.json=this._resolveTree(e.json,r),this.json}_resolveTree(e,r={}){let n={...e};return this.json=n,e.bufferViews&&(n.bufferViews=e.bufferViews.map((s,o)=>this._resolveBufferView(s,o))),e.images&&(n.images=e.images.map((s,o)=>this._resolveImage(s,o))),e.samplers&&(n.samplers=e.samplers.map((s,o)=>this._resolveSampler(s,o))),e.textures&&(n.textures=e.textures.map((s,o)=>this._resolveTexture(s,o))),e.accessors&&(n.accessors=e.accessors.map((s,o)=>this._resolveAccessor(s,o))),e.materials&&(n.materials=e.materials.map((s,o)=>this._resolveMaterial(s,o))),e.meshes&&(n.meshes=e.meshes.map((s,o)=>this._resolveMesh(s,o))),e.nodes&&(n.nodes=e.nodes.map((s,o)=>this._resolveNode(s,o)),n.nodes=n.nodes.map((s,o)=>this._resolveNodeChildren(s))),e.skins&&(n.skins=e.skins.map((s,o)=>this._resolveSkin(s,o))),e.scenes&&(n.scenes=e.scenes.map((s,o)=>this._resolveScene(s,o))),typeof this.json.scene=="number"&&n.scenes&&(n.scene=n.scenes[this.json.scene]),n}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,r){if(typeof r=="object")return r;let n=e&&e[r];return n||console.warn(`glTF file error: Could not find ${e}[${r}]`),n}_resolveScene(e,r){return{...e,id:e.id||`scene-${r}`,nodes:(e.nodes||[]).map(n=>this.getNode(n))}}_resolveNode(e,r){let n={...e,id:e?.id||`node-${r}`};return e.mesh!==void 0&&(n.mesh=this.getMesh(e.mesh)),e.camera!==void 0&&(n.camera=this.getCamera(e.camera)),e.skin!==void 0&&(n.skin=this.getSkin(e.skin)),e.meshes!==void 0&&e.meshes.length&&(n.mesh=e.meshes.reduce((s,o)=>{let i=this.getMesh(o);return s.id=i.id,s.primitives=s.primitives.concat(i.primitives),s},{primitives:[]})),n}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(r=>this.getNode(r))),e}_resolveSkin(e,r){let n=typeof e.inverseBindMatrices=="number"?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${r}`,inverseBindMatrices:n}}_resolveMesh(e,r){let n={...e,id:e.id||`mesh-${r}`,primitives:[]};return e.primitives&&(n.primitives=e.primitives.map(s=>{let o={...s,attributes:{},indices:void 0,material:void 0},i=s.attributes;for(let a in i)o.attributes[a]=this.getAccessor(i[a]);return s.indices!==void 0&&(o.indices=this.getAccessor(s.indices)),s.material!==void 0&&(o.material=this.getMaterial(s.material)),o})),n}_resolveMaterial(e,r){let n={...e,id:e.id||`material-${r}`};if(n.normalTexture&&(n.normalTexture={...n.normalTexture},n.normalTexture.texture=this.getTexture(n.normalTexture.index)),n.occlusionTexture&&(n.occlusionTexture={...n.occlusionTexture},n.occlusionTexture.texture=this.getTexture(n.occlusionTexture.index)),n.emissiveTexture&&(n.emissiveTexture={...n.emissiveTexture},n.emissiveTexture.texture=this.getTexture(n.emissiveTexture.index)),n.emissiveFactor||(n.emissiveFactor=n.emissiveTexture?[1,1,1]:[0,0,0]),n.pbrMetallicRoughness){n.pbrMetallicRoughness={...n.pbrMetallicRoughness};let s=n.pbrMetallicRoughness;s.baseColorTexture&&(s.baseColorTexture={...s.baseColorTexture},s.baseColorTexture.texture=this.getTexture(s.baseColorTexture.index)),s.metallicRoughnessTexture&&(s.metallicRoughnessTexture={...s.metallicRoughnessTexture},s.metallicRoughnessTexture.texture=this.getTexture(s.metallicRoughnessTexture.index))}return n}_resolveAccessor(e,r){let n=r2(e.componentType),s=n2(e.type),o=n*s,i={...e,id:e.id||`accessor-${r}`,bytesPerComponent:n,components:s,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(e.bufferView!==void 0&&(i.bufferView=this.getBufferView(e.bufferView)),i.bufferView){let a=i.bufferView.buffer,{ArrayType:c,byteLength:l}=Kr(i,i.bufferView),f=(i.bufferView.byteOffset||0)+(i.byteOffset||0)+a.byteOffset,u=Dn(a.arrayBuffer,f,l);i.bufferView.byteStride&&(u=this._getValueFromInterleavedBuffer(a,f,i.bufferView.byteStride,i.bytesPerElement,i.count)),i.value=new c(u)}return i}_getValueFromInterleavedBuffer(e,r,n,s,o){let i=new Uint8Array(o*s);for(let a=0;a<o;a++){let c=r+a*n;i.set(new Uint8Array(e.arrayBuffer.slice(c,c+s)),a*s)}return i.buffer}_resolveTexture(e,r){return{...e,id:e.id||`texture-${r}`,sampler:typeof e.sampler=="number"?this.getSampler(e.sampler):t2(),source:typeof e.source=="number"?this.getImage(e.source):void 0}}_resolveSampler(e,r){let n={id:e.id||`sampler-${r}`,...e,parameters:{}};for(let s in n){let o=this._enumSamplerParameter(s);o!==void 0&&(n.parameters[o]=n[s])}return n}_enumSamplerParameter(e){return $I[e]}_resolveImage(e,r){let n={...e,id:e.id||`image-${r}`,image:null,bufferView:e.bufferView!==void 0?this.getBufferView(e.bufferView):void 0},s=this.images[r];return s&&(n.image=s),n}_resolveBufferView(e,r){let n=e.buffer,s=this.buffers[n].arrayBuffer,o=this.buffers[n].byteOffset||0;return e.byteOffset&&(o+=e.byteOffset),{id:`bufferView-${r}`,...e,buffer:this.buffers[n],data:new Uint8Array(s,o,e.byteLength)}}_resolveCamera(e,r){let n={...e,id:e.id||`camera-${r}`};return n.perspective,n.orthographic,n}};function As(t,e){return new Pl().postProcess(t,e)}var Ti={URI:0,EMBEDDED:1};function bi(t,e,r,n){t.rotateYtoZ=!0;let s=(t.byteOffset||0)+(t.byteLength||0)-r;if(s===0)throw new Error("glTF byte length must be greater than 0.");return t.gltfUpAxis=n?.["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",t.gltfArrayBuffer=tr(e,r,s),t.gltfByteOffset=0,t.gltfByteLength=s,r%4===0||console.warn(`${t.type}: embedded glb is not aligned to a 4-byte boundary.`),(t.byteOffset||0)+(t.byteLength||0)}async function Ei(t,e,r,n){let s=r?.["3d-tiles"]||{};if(s2(t,e,r),s.loadGLTF){if(!n)return;if(t.gltfUrl){let{fetch:o}=n,i=await o(t.gltfUrl,r?.core);t.gltfArrayBuffer=await i.arrayBuffer(),t.gltfByteOffset=0}if(t.gltfArrayBuffer){let o=await Fe(t.gltfArrayBuffer,gr,r,n);t.gltf=As(o),t.gpuMemoryUsageInBytes=ds(t.gltf),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength}}}function s2(t,e,r){switch(e){case Ti.URI:if(t.gltfArrayBuffer){let n=new Uint8Array(t.gltfArrayBuffer,t.gltfByteOffset),o=new TextDecoder().decode(n);t.gltfUrl=o.replace(/[\s\0]+$/,"")}delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength;break;case Ti.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function Rg(t,e,r,n,s){r=o2(t,e,r,n,s),await Ei(t,Ti.EMBEDDED,n,s);let o=t?.gltf?.extensions;return o&&o.CESIUM_RTC&&(t.rtcCenter=o.CESIUM_RTC.center),r}function o2(t,e,r,n,s){r=Gt(t,e,r),r=Xr(t,e,r),r=Yr(t,e,r,n),r=bi(t,e,r,n);let o=new xt(t.featureTableJson,t.featureTableBinary);return t.rtcCenter=o.getGlobalProperty("RTC_CENTER",N.FLOAT,3),r}async function Pg(t,e,r,n,s){return r=i2(t,e,r,n,s),await Ei(t,t.gltfFormat||0,n,s),r}function i2(t,e,r,n,s){if(r=Gt(t,e,r),t.version!==1)throw new Error(`Instanced 3D Model version ${t.version} is not supported`);r=Xr(t,e,r);let o=new DataView(e);if(t.gltfFormat=o.getUint32(r,!0),r+=4,r=Yr(t,e,r,n),r=bi(t,e,r,n),!t?.header?.featureTableJsonByteLength||t.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");let i=new xt(t.featureTableJson,t.featureTableBinary),a=i.getGlobalProperty("INSTANCES_LENGTH");if(i.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");t.eastNorthUp=i.getGlobalProperty("EAST_NORTH_UP"),t.rtcCenter=i.getGlobalProperty("RTC_CENTER",N.FLOAT,3);let c=new pr(t.batchTableJson,t.batchTableBinary,a);return a2(t,i,c,a),r}function a2(t,e,r,n){let s=new Array(n),o=new x,i=new x,a=new x,c=new x,l=new j,f=new rt,u=new x,h={},d=new O,p=[],A=[],m=[],y=[];for(let b=0;b<n;b++){let E;if(e.hasProperty("POSITION"))E=e.getProperty("POSITION",N.FLOAT,3,b,o);else if(e.hasProperty("POSITION_QUANTIZED")){E=e.getProperty("POSITION_QUANTIZED",N.UNSIGNED_SHORT,3,b,o);let g=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",N.FLOAT,3);if(!g)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");let S=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",N.FLOAT,3);if(!S)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");let F=65535;for(let R=0;R<3;R++)E[R]=E[R]/F*S[R]+g[R]}if(!E)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");o.copy(E),h.translation=o,t.normalUp=e.getProperty("NORMAL_UP",N.FLOAT,3,b,p),t.normalRight=e.getProperty("NORMAL_RIGHT",N.FLOAT,3,b,A);let M=!1;if(t.normalUp){if(!t.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");t.hasCustomOrientation=!0}else{if(t.octNormalUp=e.getProperty("NORMAL_UP_OCT32P",N.UNSIGNED_SHORT,2,b,p),t.octNormalRight=e.getProperty("NORMAL_RIGHT_OCT32P",N.UNSIGNED_SHORT,2,b,A),t.octNormalUp)throw t.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");t.eastNorthUp?(U.WGS84.eastNorthUpToFixedFrame(o,d),d.getRotationMatrix3(l)):l.identity()}M&&(c.copy(i).cross(a).normalize(),l.setColumn(0,i),l.setColumn(1,a),l.setColumn(2,c)),f.fromMatrix3(l),h.rotation=f,u.set(1,1,1);let B=e.getProperty("SCALE",N.FLOAT,1,b,m);Number.isFinite(B)&&u.multiplyByScalar(B);let C=e.getProperty("SCALE_NON_UNIFORM",N.FLOAT,3,b,p);C&&u.scale(C),h.scale=u;let v=e.getProperty("BATCH_ID",N.UNSIGNED_SHORT,1,b,y);v===void 0&&(v=b);let _=new O().fromQuaternion(h.rotation);d.identity(),d.translate(h.translation),d.multiplyRight(_),d.scale(h.scale);let T=d.clone();s[b]={modelMatrix:T,batchId:v}}t.instances=s}async function Og(t,e,r,n,s,o){r=Gt(t,e,r);let i=new DataView(e);for(t.tilesLength=i.getUint32(r,!0),r+=4,t.tiles=[];t.tiles.length<t.tilesLength&&(t.byteLength||0)-r>12;){let a={shape:"tile3d"};t.tiles.push(a),r=await o(e,r,n,s,a)}return r}async function Ng(t,e,r,n){if(t.rotateYtoZ=!0,t.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!n)return e.byteLength;let s=await Fe(e,gr,r,n);t.gltf=As(s),t.gpuMemoryUsageInBytes=ds(t.gltf)}else t.gltfArrayBuffer=e;return e.byteLength}async function Ol(t,e=0,r,n,s={shape:"tile3d"}){switch(s.byteOffset=e,s.type=zm(t,e),s.type){case hr.COMPOSITE:return await Og(s,t,e,r,n,Ol);case hr.BATCHED_3D_MODEL:return await Rg(s,t,e,r,n);case hr.GLTF:return await Ng(s,t,r,n);case hr.INSTANCED_3D_MODEL:return await Pg(s,t,e,r,n);case hr.POINT_CLOUD:return await fg(s,t,e,r,n);default:throw new Error(`3DTileLoader: unknown type ${s.type}`)}}async function Nl(t,e,r){if(new Uint32Array(t.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(t.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let o=Dg(t.slice(8,16)),i=new Uint8Array(t,24,o),c=new TextDecoder("utf8").decode(i),l=JSON.parse(c),f=Dg(t.slice(16,24)),u=new ArrayBuffer(0);if(f&&(u=t.slice(24+o)),await Mi(l,l.tileAvailability,u,r),Array.isArray(l.contentAvailability))for(let h of l.contentAvailability)await Mi(l,h,u,r);else await Mi(l,l.contentAvailability,u,r);return await Mi(l,l.childSubtreeAvailability,u,r),l}async function Mi(t,e,r,n){let s=Number.isFinite(e.bitstream)?e.bitstream:e.bufferView;if(typeof s!="number")return;let o=t.bufferViews[s],i=t.buffers[o.buffer];if(!n?.baseUrl)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(i.uri){let c=`${n?.baseUrl||""}/${i.uri}`,f=await(await n.fetch(c)).arrayBuffer();e.explicitBitstream=new Uint8Array(f,o.byteOffset,o.byteLength);return}let a=t.buffers.slice(0,o.buffer).reduce((c,l)=>c+l.byteLength,0);e.explicitBitstream=new Uint8Array(r.slice(a,a+i.byteLength),o.byteOffset,o.byteLength)}function Dg(t){let e=new DataView(t),r=e.getUint32(0,!0),n=e.getUint32(4,!0);return r+2**32*n}var _i={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:ii,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:Nl,options:{}};var o0=D(Kt(),1);var t0=D(Kt(),1);var ze=null;try{ze=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Z(t,e,r){this.low=t|0,this.high=e|0,this.unsigned=!!r}Z.prototype.__isLong__;Object.defineProperty(Z.prototype,"__isLong__",{value:!0});function xe(t){return(t&&t.__isLong__)===!0}function Gg(t){var e=Math.clz32(t&-t);return t?31-e:e}Z.isLong=xe;var Ug={},Vg={};function Ar(t,e){var r,n,s;return e?(t>>>=0,(s=0<=t&&t<256)&&(n=Vg[t],n)?n:(r=q(t,0,!0),s&&(Vg[t]=r),r)):(t|=0,(s=-128<=t&&t<128)&&(n=Ug[t],n)?n:(r=q(t,t<0?-1:0,!1),s&&(Ug[t]=r),r))}Z.fromInt=Ar;function ke(t,e){if(isNaN(t))return e?yt:Ze;if(e){if(t<0)return yt;if(t>=qg)return Wg}else{if(t<=-zg)return Se;if(t+1>=zg)return Jg}return t<0?ke(-t,e).neg():q(t%on|0,t/on|0,e)}Z.fromNumber=ke;function q(t,e,r){return new Z(t,e,r)}Z.fromBits=q;var Bi=Math.pow;function Gl(t,e,r){if(t.length===0)throw Error("empty string");if(typeof e=="number"?(r=e,e=!1):e=!!e,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e?yt:Ze;if(r=r||10,r<2||36<r)throw RangeError("radix");var n;if((n=t.indexOf("-"))>0)throw Error("interior hyphen");if(n===0)return Gl(t.substring(1),e,r).neg();for(var s=ke(Bi(r,8)),o=Ze,i=0;i<t.length;i+=8){var a=Math.min(8,t.length-i),c=parseInt(t.substring(i,i+a),r);if(a<8){var l=ke(Bi(r,a));o=o.mul(l).add(ke(c))}else o=o.mul(s),o=o.add(ke(c))}return o.unsigned=e,o}Z.fromString=Gl;function $e(t,e){return typeof t=="number"?ke(t,e):typeof t=="string"?Gl(t,e):q(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}Z.fromValue=$e;var Hg=1<<16,c2=1<<24,on=Hg*Hg,qg=on*on,zg=qg/2,kg=Ar(c2),Ze=Ar(0);Z.ZERO=Ze;var yt=Ar(0,!0);Z.UZERO=yt;var sn=Ar(1);Z.ONE=sn;var jg=Ar(1,!0);Z.UONE=jg;var Dl=Ar(-1);Z.NEG_ONE=Dl;var Jg=q(-1,2147483647,!1);Z.MAX_VALUE=Jg;var Wg=q(-1,-1,!0);Z.MAX_UNSIGNED_VALUE=Wg;var Se=q(0,-2147483648,!1);Z.MIN_VALUE=Se;var I=Z.prototype;I.toInt=function(){return this.unsigned?this.low>>>0:this.low};I.toNumber=function(){return this.unsigned?(this.high>>>0)*on+(this.low>>>0):this.high*on+(this.low>>>0)};I.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Se)){var r=ke(e),n=this.div(r),s=n.mul(r).sub(this);return n.toString(e)+s.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var o=ke(Bi(e,6),this.unsigned),i=this,a="";;){var c=i.div(o),l=i.sub(c.mul(o)).toInt()>>>0,f=l.toString(e);if(i=c,i.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}};I.getHighBits=function(){return this.high};I.getHighBitsUnsigned=function(){return this.high>>>0};I.getLowBits=function(){return this.low};I.getLowBitsUnsigned=function(){return this.low>>>0};I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Se)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&!(e&1<<r);r--);return this.high!=0?r+33:r+1};I.isZero=function(){return this.high===0&&this.low===0};I.eqz=I.isZero;I.isNegative=function(){return!this.unsigned&&this.high<0};I.isPositive=function(){return this.unsigned||this.high>=0};I.isOdd=function(){return(this.low&1)===1};I.isEven=function(){return(this.low&1)===0};I.equals=function(e){return xe(e)||(e=$e(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};I.eq=I.equals;I.notEquals=function(e){return!this.eq(e)};I.neq=I.notEquals;I.ne=I.notEquals;I.lessThan=function(e){return this.comp(e)<0};I.lt=I.lessThan;I.lessThanOrEqual=function(e){return this.comp(e)<=0};I.lte=I.lessThanOrEqual;I.le=I.lessThanOrEqual;I.greaterThan=function(e){return this.comp(e)>0};I.gt=I.greaterThan;I.greaterThanOrEqual=function(e){return this.comp(e)>=0};I.gte=I.greaterThanOrEqual;I.ge=I.greaterThanOrEqual;I.compare=function(e){if(xe(e)||(e=$e(e)),this.eq(e))return 0;var r=this.isNegative(),n=e.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};I.comp=I.compare;I.negate=function(){return!this.unsigned&&this.eq(Se)?Se:this.not().add(sn)};I.neg=I.negate;I.add=function(e){xe(e)||(e=$e(e));var r=this.high>>>16,n=this.high&65535,s=this.low>>>16,o=this.low&65535,i=e.high>>>16,a=e.high&65535,c=e.low>>>16,l=e.low&65535,f=0,u=0,h=0,d=0;return d+=o+l,h+=d>>>16,d&=65535,h+=s+c,u+=h>>>16,h&=65535,u+=n+a,f+=u>>>16,u&=65535,f+=r+i,f&=65535,q(h<<16|d,f<<16|u,this.unsigned)};I.subtract=function(e){return xe(e)||(e=$e(e)),this.add(e.neg())};I.sub=I.subtract;I.multiply=function(e){if(this.isZero())return this;if(xe(e)||(e=$e(e)),ze){var r=ze.mul(this.low,this.high,e.low,e.high);return q(r,ze.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?yt:Ze;if(this.eq(Se))return e.isOdd()?Se:Ze;if(e.eq(Se))return this.isOdd()?Se:Ze;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(kg)&&e.lt(kg))return ke(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,s=this.high&65535,o=this.low>>>16,i=this.low&65535,a=e.high>>>16,c=e.high&65535,l=e.low>>>16,f=e.low&65535,u=0,h=0,d=0,p=0;return p+=i*f,d+=p>>>16,p&=65535,d+=o*f,h+=d>>>16,d&=65535,d+=i*l,h+=d>>>16,d&=65535,h+=s*f,u+=h>>>16,h&=65535,h+=o*l,u+=h>>>16,h&=65535,h+=i*c,u+=h>>>16,h&=65535,u+=n*f+s*l+o*c+i*a,u&=65535,q(d<<16|p,u<<16|h,this.unsigned)};I.mul=I.multiply;I.divide=function(e){if(xe(e)||(e=$e(e)),e.isZero())throw Error("division by zero");if(ze){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?ze.div_u:ze.div_s)(this.low,this.high,e.low,e.high);return q(r,ze.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?yt:Ze;var n,s,o;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return yt;if(e.gt(this.shru(1)))return jg;o=yt}else{if(this.eq(Se)){if(e.eq(sn)||e.eq(Dl))return Se;if(e.eq(Se))return sn;var i=this.shr(1);return n=i.div(e).shl(1),n.eq(Ze)?e.isNegative()?sn:Dl:(s=this.sub(e.mul(n)),o=n.add(s.div(e)),o)}else if(e.eq(Se))return this.unsigned?yt:Ze;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();o=Ze}for(s=this;s.gte(e);){n=Math.max(1,Math.floor(s.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),c=a<=48?1:Bi(2,a-48),l=ke(n),f=l.mul(e);f.isNegative()||f.gt(s);)n-=c,l=ke(n,this.unsigned),f=l.mul(e);l.isZero()&&(l=sn),o=o.add(l),s=s.sub(f)}return o};I.div=I.divide;I.modulo=function(e){if(xe(e)||(e=$e(e)),ze){var r=(this.unsigned?ze.rem_u:ze.rem_s)(this.low,this.high,e.low,e.high);return q(r,ze.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};I.mod=I.modulo;I.rem=I.modulo;I.not=function(){return q(~this.low,~this.high,this.unsigned)};I.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};I.clz=I.countLeadingZeros;I.countTrailingZeros=function(){return this.low?Gg(this.low):Gg(this.high)+32};I.ctz=I.countTrailingZeros;I.and=function(e){return xe(e)||(e=$e(e)),q(this.low&e.low,this.high&e.high,this.unsigned)};I.or=function(e){return xe(e)||(e=$e(e)),q(this.low|e.low,this.high|e.high,this.unsigned)};I.xor=function(e){return xe(e)||(e=$e(e)),q(this.low^e.low,this.high^e.high,this.unsigned)};I.shiftLeft=function(e){return xe(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?q(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):q(0,this.low<<e-32,this.unsigned)};I.shl=I.shiftLeft;I.shiftRight=function(e){return xe(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?q(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):q(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};I.shr=I.shiftRight;I.shiftRightUnsigned=function(e){return xe(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?q(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?q(this.high,0,this.unsigned):q(this.high>>>e-32,0,this.unsigned)};I.shru=I.shiftRightUnsigned;I.shr_u=I.shiftRightUnsigned;I.rotateLeft=function(e){var r;return xe(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?q(this.high,this.low,this.unsigned):e<32?(r=32-e,q(this.low<<e|this.high>>>r,this.high<<e|this.low>>>r,this.unsigned)):(e-=32,r=32-e,q(this.high<<e|this.low>>>r,this.low<<e|this.high>>>r,this.unsigned))};I.rotl=I.rotateLeft;I.rotateRight=function(e){var r;return xe(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?q(this.high,this.low,this.unsigned):e<32?(r=32-e,q(this.high<<r|this.low>>>e,this.low<<r|this.high>>>e,this.unsigned)):(e-=32,r=32-e,q(this.low<<r|this.high>>>e,this.high<<r|this.low>>>e,this.unsigned))};I.rotr=I.rotateRight;I.toSigned=function(){return this.unsigned?q(this.low,this.high,!1):this};I.toUnsigned=function(){return this.unsigned?this:q(this.low,this.high,!0)};I.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};I.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};I.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};Z.fromBytes=function(e,r,n){return n?Z.fromBytesLE(e,r):Z.fromBytesBE(e,r)};Z.fromBytesLE=function(e,r){return new Z(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)};Z.fromBytesBE=function(e,r){return new Z(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)};var an=Z;var l2=16;function xs(t){t==="X"&&(t="");let e=t.padEnd(l2,"0");return an.fromString(e,!0,16)}function Ul(t){if(t.isZero())return"X";let e=t.countTrailingZeros(),r=e%4;e=(e-r)/4;let n=e;e*=4;let o=t.shiftRightUnsigned(e).toString(16).replace(/0+$/,"");return Array(17-n-o.length).join("0")+o}function Vl(t,e){let r=f2(t).shiftRightUnsigned(2);return t.add(an.fromNumber(2*e+1-4).multiply(r))}function f2(t){return t.and(t.not().add(1))}var u2=3,h2=30,d2=2*h2+1,Xg=180/Math.PI;function Kg(t){if(t.length===0)throw new Error(`Invalid Hilbert quad key ${t}`);let e=t.split("/"),r=parseInt(e[0],10),n=e[1],s=n.length,o=0,i=[0,0];for(let a=s-1;a>=0;a--){o=s-a;let c=n[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,o-1);p2(u,i,l,f),i[0]+=u*l,i[1]+=u*f}if(r%2===1){let a=i[0];i[0]=i[1],i[1]=a}return{face:r,ij:i,level:o}}function Qg(t){if(t.isZero())return"";let e=t.toString(2);for(;e.length<u2+d2;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),s=e.substring(3,r),o=s.length/2,i=an.fromString(n,!0,2).toString(10),a="";if(o!==0)for(a=an.fromString(s,!0,2).toString(4);a.length<o;)a="0"+a;return`${i}/${a}`}function Hl(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function Yg(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function zl(t){return[Yg(t[0]),Yg(t[1])]}function kl(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function ql([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*Xg,n*Xg]}function p2(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let s=e[0];e[0]=e[1],e[1]=s}}function Zg(t){let e=Hl(t.ij,t.level,[.5,.5]),r=zl(e),n=kl(t.face,r);return ql(n)}var m2=100;function jl(t){let{face:e,ij:r,level:n}=t,s=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(m2*Math.pow(2,-n))),i=new Float64Array(4*o*2+2),a=0,c=0;for(let l=0;l<4;l++){let f=s[l].slice(0),u=s[l+1],h=(u[0]-f[0])/o,d=(u[1]-f[1])/o;for(let p=0;p<o;p++){f[0]+=h,f[1]+=d;let A=Hl(r,n,f),m=zl(A),y=kl(e,m),b=ql(y);Math.abs(b[1])>89.999&&(b[0]=c);let E=b[0]-c;b[0]+=E>180?-360:E<-180?360:0,i[a++]=b[0],i[a++]=b[1],c=b[0]}}return i[a++]=i[0],i[a++]=i[1],i}function cn(t){let e=g2(t);return Kg(e)}function g2(t){if(t.indexOf("/")>0)return t;let e=xs(t);return Qg(e)}function Jl(t){let e=cn(t);return Zg(e)}function e0(t){let e;if(t.face===2||t.face===5){let r=null,n=0;for(let s=0;s<4;s++){let o=`${t.face}/${s}`,i=cn(o),a=jl(i);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,n),n+=a.length}e=$g(r)}else{let r=jl(t);e=$g(r)}return e}function $g(t){if(t.length%2!==0)throw new Error("Invalid corners");let e=[],r=[];for(let n=0;n<t.length;n+=2)e.push(t[n]),r.push(t[n+1]);return e.sort((n,s)=>n-s),r.sort((n,s)=>n-s),{west:e[0],east:e[e.length-1],north:r[r.length-1],south:r[0]}}function Wl(t,e){let r=e?.minimumHeight||0,n=e?.maximumHeight||0,s=cn(t),o=e0(s),i=o.west,a=o.south,c=o.east,l=o.north,f=[];return f.push(new x(i,l,r)),f.push(new x(c,l,r)),f.push(new x(c,a,r)),f.push(new x(i,a,r)),f.push(new x(i,l,n)),f.push(new x(c,l,n)),f.push(new x(c,a,n)),f.push(new x(i,a,n)),f}function Ci(t){let e=t.token,r={minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight},n=Wl(e,r),s=Jl(e),o=s[0],i=s[1],a=U.WGS84.cartographicToCartesian([o,i,r.maximumHeight]),c=new x(a[0],a[1],a[2]);n.push(c);let l=Kn(n);return[...l.center,...l.halfAxes]}var A2=4,x2=8,y2={QUADTREE:A2,OCTREE:x2};function T2(t,e,r){if(t?.box){let n=xs(t.s2VolumeInfo.token),s=Vl(n,e),o=Ul(s),i={...t.s2VolumeInfo};switch(i.token=o,r){case"OCTREE":let l=t.s2VolumeInfo,f=l.maximumHeight-l.minimumHeight,u=f/2,h=l.minimumHeight+f/2;l.minimumHeight=h-u,l.maximumHeight=h+u;break;default:break}return{box:Ci(i),s2VolumeInfo:i}}}async function Yl(t){let{subtree:e,subtreeData:r={level:0,x:0,y:0,z:0},parentData:n={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:s=0,implicitOptions:o,loaderOptions:i,s2VolumeBox:a}=t,{subdivisionScheme:c,subtreeLevels:l,maximumLevel:f,contentUrlTemplate:u,subtreesUriTemplate:h,basePath:d}=o,p={children:[],lodMetricValue:0,contentUrl:""};if(!f)return ec.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${u} won't be loaded...`),p;let A=n.localLevel+1,m=r.level+A;if(m>f)return p;let y=y2[c],b=Math.log2(y),E=s&1,M=s>>1&1,B=s>>2&1,C=xr(n.localX,E,1),v=xr(n.localY,M,1),_=xr(n.localZ,B,1),T=xr(r.x,C,A),g=xr(r.y,v,A),S=xr(r.z,_,A),F=xr(n.mortonIndex,s,b),R=A===l&&Xl(e.childSubtreeAvailability,F),L,G,W,z;if(R){let Y=`${d}/${h}`,$=Si(Y,m,T,g,S);L=await(0,t0.load)($,_i,i),z=0,G={level:m,x:T,y:g,z:S},W={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else L=e,z=(y**A-1)/(y-1)+F,G=r,W={mortonIndex:F,localLevel:A,localX:C,localY:v,localZ:_};if(!Xl(L.tileAvailability,z))return p;Xl(L.contentAvailability,z)&&(p.contentUrl=Si(u,m,T,g,S));for(let Y=0;Y<y;Y++){let $=T2(a,Y,c),_e=await Yl({subtree:L,subtreeData:G,parentData:W,childIndex:Y,implicitOptions:o,loaderOptions:i,s2VolumeBox:$});(_e.contentUrl||_e.children.length)&&p.children.push(_e)}return p.contentUrl||p.children.length?b2(p,{level:m,x:T,y:g,z:S},o,a):p}function Xl(t,e){let r;return Array.isArray(t)?(r=t[0],t.length>1&&ec.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=t,"constant"in r?Boolean(r.constant):r.explicitBitstream?_2(e,r.explicitBitstream):!1}function b2(t,e,r,n){let{basePath:s,refine:o,getRefine:i,lodMetricType:a,getTileType:c,rootLodMetricValue:l,rootBoundingVolume:f}=r,u=t.contentUrl&&t.contentUrl.replace(`${s}/`,""),h=l/2**e.level,d=n?.box?{box:n.box}:f,p=E2(d,e,r.subdivisionScheme);return{children:t.children,contentUrl:t.contentUrl,content:{uri:u},id:t.contentUrl,refine:i(o),type:c(t),lodMetricType:a,lodMetricValue:h,geometricError:h,transform:t.transform,boundingVolume:p}}function E2(t,e,r){if(t.region){let{level:n,x:s,y:o,z:i}=e,[a,c,l,f,u,h]=t.region,d=2**n,p=(l-a)/d,[A,m]=[a+p*s,a+p*(s+1)],y=(f-c)/d,[b,E]=[c+y*o,c+y*(o+1)],M,B;if(r==="OCTREE"){let C=(h-u)/d;[M,B]=[u+C*i,u+C*(i+1)]}else[M,B]=[u,h];return{region:[A,b,m,E,M,B]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}function xr(t,e,r){return(t<<r)+e}function Si(t,e,r,n,s){let o=M2({level:e,x:r,y:n,z:s});return t.replace(/{level}|{x}|{y}|{z}/gi,i=>o[i])}function M2(t){let e={};for(let r in t)e[`{${r}}`]=t[r];return e}function _2(t,e){let r=Math.floor(t/8),n=t%8;return(e[r]>>n&1)===1}function Ql(t,e=""){if(!e)return Ve.EMPTY;let n=e.split("?")[0].split(".").pop();switch(n){case"pnts":return Ve.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Ve.SCENEGRAPH;default:return n||Ve.EMPTY}}function Zl(t){switch(t){case"REPLACE":case"replace":return ge.REPLACE;case"ADD":case"add":return ge.ADD;default:return t}}function Kl(t,e){if(/^[a-z][0-9a-z+.-]*:/i.test(e)){let n=new URL(t,`${e}/`);return decodeURI(n.toString())}else if(t.startsWith("/"))return t;return vt.resolve(e,t)}function r0(t,e){if(!t)return null;let r;if(t.content){let s=t.content.uri||t.content?.url;typeof s<"u"&&(r=Kl(s,e))}return{...t,id:r,contentUrl:r,lodMetricType:At.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:Ql(t,r),refine:Zl(t.refine)}}async function i0(t,e,r){let n=null,s=s0(t.root);s&&t.root?n=await n0(t.root,t,e,s,r):n=r0(t.root,e);let o=[];for(o.push(n);o.length>0;){let i=o.pop()||{},a=i.children||[],c=[];for(let l of a){let f=s0(l),u;f?u=await n0(l,t,e,f,r):u=r0(l,e),u&&(c.push(u),o.push(u))}i.children=c}return n}async function n0(t,e,r,n,s){let{subdivisionScheme:o,maximumLevel:i,availableLevels:a,subtreeLevels:c,subtrees:{uri:l}}=n,f=Si(l,0,0,0,0),u=Kl(f,r),h=await(0,o0.load)(u,_i,s),d=t.content?.uri,p=d?Kl(d,r):"",A=e?.root?.refine,m=t.geometricError,y=t.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(y){let B={box:Ci(y),s2VolumeInfo:y};t.boundingVolume=B}let b=t.boundingVolume,E={contentUrlTemplate:p,subtreesUriTemplate:l,subdivisionScheme:o,subtreeLevels:c,maximumLevel:Number.isFinite(a)?a-1:i,refine:A,basePath:r,lodMetricType:At.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:b,getTileType:Ql,getRefine:Zl};return await B2(t,r,h,E,s)}async function B2(t,e,r,n,s){if(!t)return null;let{children:o,contentUrl:i}=await Yl({subtree:r,implicitOptions:n,loaderOptions:s}),a,c=null;return i&&(a=i,c={uri:i.replace(`${e}/`,"")}),{...t,id:a,contentUrl:a,lodMetricType:At.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:Ql(t,a),refine:Zl(t.refine),content:c||t.content,children:o}}function s0(t){return t?.extensions?.["3DTILES_implicit_tiling"]||t?.implicitTiling}var Ii={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:ii,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:C2,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function C2(t,e={},r){let n=e["3d-tiles"]||{},s;return n.isTileset==="auto"?s=r?.url&&r.url.indexOf(".json")!==-1:s=n.isTileset,s?S2(t,e,r):I2(t,e,r)}async function S2(t,e,r){let n=JSON.parse(new TextDecoder().decode(t)),s=r?.url||"",o=w2(s),i=await i0(n,o,e||{});return{...n,shape:"tileset3d",loader:Ii,url:s,queryString:r?.queryString||"",basePath:o,root:i||n.root,type:he.TILES3D,lodMetricType:At.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0}}async function I2(t,e,r){let n={content:{shape:"tile3d",featureIds:null}};return await Ol(t,0,e,r,n.content),n.content}function w2(t){return vt.dirname(t)}var a0=[0],v2={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Ii,onTilesetLoad:{type:"function",value:t=>{}},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:(t,e,r)=>{}},_getMeshColor:{type:"function",value:t=>[255,255,255]}},ys=class extends Ht.CompositeLayer{initializeState(){"onTileLoadFail"in this.props&&Ht.log.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:r,changeFlags:n}){if(e.data&&e.data!==r.data&&this._loadTileset(e.data),n.viewportChanged){let{activeViewports:s}=this.state;Object.keys(s).length&&(this._updateTileset(s),this.state.lastUpdatedViewports=s,this.state.activeViewports={})}if(n.propsChanged){let{layerMap:s}=this.state;for(let o in s)s[o].needsUpdate=!0}}activateViewport(e){let{activeViewports:r,lastUpdatedViewports:n}=this.state;this.internalState.viewport=e,r[e.id]=e;let s=n?.[e.id];(!s||!e.equals(s))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:r}){let n=r&&r.props.tile;return e.picked&&(e.object=n),e.sourceTile=n,e}filterSubLayer({layer:e,viewport:r}){let{tile:n}=e.props,{id:s}=r;return n.selected&&n.viewportIds.includes(s)}_updateAutoHighlight(e){let r=e.sourceTile,n=this.state.layerMap[r?.id];n&&n.layer&&n.layer.updateAutoHighlight(e)}async _loadTileset(e){let r=this.props.loadOptions||{},n=this.props.loaders?.length?this.props.loaders:this.props.loader,s=Array.isArray(n)?n[0]:n,{tileset:o,...i}=r,a={loadOptions:{...i},...o},c=e;if("preload"in s&&typeof s.preload=="function"){let u=await s.preload(e,r);u.url&&(c=u.url),u.headers&&(a.loadOptions.core={...a.loadOptions.core,fetch:{...a.loadOptions.core?.fetch,headers:u.headers}}),Object.assign(a,u)}let l=await(0,u0.load)(c,s,a.loadOptions),f=new ls(l,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...a});this.setState({tileset3d:f,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(f)}_onTileLoad(e){let{lastUpdatedViewports:r}=this.state;e.tileDrawn=!1,this.props.onTileLoad(e),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;let{tileset3d:r}=this.state,{timeline:n}=this.context,s=Object.keys(e).length;!n||!s||!r||r.selectTiles(Object.values(e)).then(o=>{this.state.frameNumber!==o&&this.setState({frameNumber:o})})}_getSubLayer(e,r){if(!e.content)return null;switch(e.type){case Ve.POINTCLOUD:return this._makePointCloudLayer(e,r);case Ve.SCENEGRAPH:return this._make3DModelLayer(e);case Ve.MESH:return this._makeSimpleMeshLayer(e,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){let{attributes:n,pointCount:s,constantRGBA:o,cartographicOrigin:i,modelMatrix:a}=e.content,{positions:c,normals:l,colors:f}=n;if(!c)return null;let u=r&&r.props.data||{header:{vertexCount:s},attributes:{POSITION:c,NORMAL:l,COLOR_0:f}},{pointSize:h,getPointColor:d}=this.props,p=this.getSubLayerClass("pointcloud",l0.PointCloudLayer);return new p({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:u,coordinateSystem:Ht.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:i,modelMatrix:a,getColor:o||d,_offset:0})}_make3DModelLayer(e){let{gltf:r,instances:n,cartographicOrigin:s,modelMatrix:o}=e.content,i=this.getSubLayerClass("scenegraph",f0.ScenegraphLayer);return new i({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:n||a0,scenegraph:r,coordinateSystem:Ht.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:s,modelMatrix:o,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,r){let n=e.content,{attributes:s,indices:o,modelMatrix:i,cartographicOrigin:a,coordinateSystem:c=Ht.COORDINATE_SYSTEM.METER_OFFSETS,material:l,featureIds:f}=n,{_getMeshColor:u}=this.props,h=r&&r.props.mesh||new c0.Geometry({topology:"triangle-list",attributes:L2(s),indices:o}),d=this.getSubLayerClass("mesh",nm);return new d(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:h,data:a0,getColor:u(e),pbrMaterial:l,modelMatrix:i,coordinateOrigin:a,coordinateSystem:c,featureIds:f,_offset:0})}renderLayers(){let{tileset3d:e,layerMap:r}=this.state;return e?e.tiles.map(n=>{let s=r[n.id]=r[n.id]||{tile:n},{layer:o}=s;return n.selected&&(o?s.needsUpdate&&(o=this._getSubLayer(n,o),s.needsUpdate=!1):o=this._getSubLayer(n)),s.layer=o,o}).filter(Boolean):null}};ys.defaultProps=v2;ys.layerName="Tile3DLayer";var h0=ys;function L2(t){let e={};return e.positions={...t.positions,value:new Float32Array(t.positions.value)},t.normals&&(e.normals=t.normals),t.texCoords&&(e.texCoords=t.texCoords),t.colors&&(e.colors=t.colors),t.uvRegions&&(e.uvRegions=t.uvRegions),e}var Ri=D(Je(),1),nf=D(zo(),1),y0=D(Je(),1);var F2=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function $l(t){return t>>1^-(t&1)}function R2(t){let e=0,r={};for(let[n,s]of F2){let o=s===8?t.getFloat64:t.getFloat32;r[n]=o.call(t,e,!0),e+=s}return{header:r,headerEndPosition:e}}function P2(t,e){let r=e,n=3,s=t.getUint32(r,!0),o=new Uint16Array(s*n);r+=Uint32Array.BYTES_PER_ELEMENT;let i=Uint16Array.BYTES_PER_ELEMENT,a=s*i,c=r,l=c+a,f=l+a,u=0,h=0,d=0;for(let p=0;p<s;p++)u+=$l(t.getUint16(c+i*p,!0)),h+=$l(t.getUint16(l+i*p,!0)),d+=$l(t.getUint16(f+i*p,!0)),o[p]=u,o[p+s]=h,o[p+s*2]=d;return r+=a*3,{vertexData:o,vertexDataEndPosition:r}}function Ts(t,e,r,n,s=!0){let o;if(n===2?o=new Uint16Array(t,e,r):o=new Uint32Array(t,e,r),!s)return o;let i=0;for(let a=0;a<o.length;++a){let c=o[a];o[a]=i-c,c===0&&++i}return o}function O2(t,e,r){let n=r,s=3,i=e.length/s>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;n%i!==0&&(n+=i-n%i);let a=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=a*3,l=Ts(t.buffer,n,c,i);return n+=c*i,{triangleIndicesEndPosition:n,triangleIndices:l}}function N2(t,e,r){let n=r,s=3,i=e.length/s>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=Ts(t.buffer,n,a,i,!1);n+=a*i;let l=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let f=Ts(t.buffer,n,l,i,!1);n+=l*i;let u=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let h=Ts(t.buffer,n,u,i,!1);n+=u*i;let d=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let p=Ts(t.buffer,n,d,i,!1);return n+=d*i,{edgeIndicesEndPosition:n,westIndices:c,southIndices:f,eastIndices:h,northIndices:p}}function D2(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function G2(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function U2(t,e){let r={};if(t.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let n=e;for(;n<t.byteLength;){let s=t.getUint8(n,!0);n+=Uint8Array.BYTES_PER_ELEMENT;let o=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let i=new DataView(t.buffer,n,o);switch(s){case 1:{r.vertexNormals=D2(i);break}case 2:{r.waterMask=G2(i);break}default:}n+=o}return{extensions:r,extensionsEndPosition:n}}var yr={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},V2={maxDecodingStep:yr.extensions};function ef(t,e){let r=Object.assign({},V2,e),n=new DataView(t),{header:s,headerEndPosition:o}=R2(n);if(r.maxDecodingStep<yr.vertices)return{header:s};let{vertexData:i,vertexDataEndPosition:a}=P2(n,o);if(r.maxDecodingStep<yr.triangleIndices)return{header:s,vertexData:i};let{triangleIndices:c,triangleIndicesEndPosition:l}=O2(n,i,a);if(r.maxDecodingStep<yr.edgeIndices)return{header:s,vertexData:i,triangleIndices:c};let{westIndices:f,southIndices:u,eastIndices:h,northIndices:d,edgeIndicesEndPosition:p}=N2(n,i,l);if(r.maxDecodingStep<yr.extensions)return{header:s,vertexData:i,triangleIndices:c,westIndices:f,northIndices:d,eastIndices:h,southIndices:u};let{extensions:A}=U2(n,p);return{header:s,vertexData:i,triangleIndices:c,westIndices:f,northIndices:d,eastIndices:h,southIndices:u,extensions:A}}function wi(t,e,r,n){let s=n?z2(n,t.POSITION.value):H2(e),o=new t.POSITION.value.constructor(s.length*6),i=new t.TEXCOORD_0.value.constructor(s.length*4),a=new e.constructor(s.length*6);for(let l=0;l<s.length;l++){let f=s[l];k2({edge:f,edgeIndex:l,attributes:t,skirtHeight:r,newPosition:o,newTexcoord0:i,newTriangles:a})}t.POSITION.value=On(t.POSITION.value,o),t.TEXCOORD_0.value=On(t.TEXCOORD_0.value,i);let c=e instanceof Array?e.concat(a):On(e,a);return{attributes:t,triangles:c}}function H2(t){let e=[];for(let s=0;s<t.length;s+=3)e.push([t[s],t[s+1]]),e.push([t[s+1],t[s+2]]),e.push([t[s+2],t[s]]);e.sort((s,o)=>Math.min(...s)-Math.min(...o)||Math.max(...s)-Math.max(...o));let r=[],n=0;for(;n<e.length;)e[n][0]===e[n+1]?.[1]&&e[n][1]===e[n+1]?.[0]?n+=2:(r.push(e[n]),n++);return r}function z2(t,e){t.westIndices.sort((n,s)=>e[3*n+1]-e[3*s+1]),t.eastIndices.sort((n,s)=>e[3*s+1]-e[3*n+1]),t.southIndices.sort((n,s)=>e[3*s]-e[3*n]),t.northIndices.sort((n,s)=>e[3*n]-e[3*s]);let r=[];for(let n in t){let s=t[n];for(let o=0;o<s.length-1;o++)r.push([s[o],s[o+1]])}return r}function k2({edge:t,edgeIndex:e,attributes:r,skirtHeight:n,newPosition:s,newTexcoord0:o,newTriangles:i}){let a=r.POSITION.value.length,c=e*2,l=e*2+1;s.set(r.POSITION.value.subarray(t[0]*3,t[0]*3+3),c*3),s[c*3+2]=s[c*3+2]-n,s.set(r.POSITION.value.subarray(t[1]*3,t[1]*3+3),l*3),s[l*3+2]=s[l*3+2]-n,o.set(r.TEXCOORD_0.value.subarray(t[0]*2,t[0]*2+2),c*2),o.set(r.TEXCOORD_0.value.subarray(t[1]*2,t[1]*2+2),l*2);let f=e*2*3;i[f]=t[0],i[f+1]=a/3+l,i[f+2]=t[1],i[f+3]=a/3+l,i[f+4]=t[0],i[f+5]=a/3+c}function tf(t,e={}){let{bounds:r}=e,{header:n,vertexData:s,triangleIndices:o,westIndices:i,northIndices:a,eastIndices:c,southIndices:l}=ef(t,yr.triangleIndices),f=o,u=q2(s,n,r),h=dr(u);if(e?.skirtHeight){let{attributes:d,triangles:p}=wi(u,f,e.skirtHeight,{westIndices:i,northIndices:a,eastIndices:c,southIndices:l});u=d,f=p}return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:h},schema:void 0,topology:"triangle-list",mode:4,indices:{value:f,size:1},attributes:u}}function q2(t,e,r){let{minHeight:n,maxHeight:s}=e,[o,i,a,c]=r||[0,0,1,1],l=a-o,f=c-i,u=s-n,h=t.length/3,d=new Float32Array(h*3),p=new Float32Array(h*2);for(let A=0;A<h;A++){let m=t[A]/32767,y=t[A+h]/32767,b=t[A+h*2]/32767;d[3*A+0]=m*l+o,d[3*A+1]=y*f+i,d[3*A+2]=b*u+n,p[2*A+0]=m,p[2*A+1]=y}return{POSITION:{value:d,size:3},TEXCOORD_0:{value:p,size:2}}}var bs=class{constructor(e=257){this.gridSize=e;let r=e-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let s=n+2,o=0,i=0,a=0,c=0,l=0,f=0;for(s&1?a=c=l=r:o=i=f=r;(s>>=1)>1;){let h=o+a>>1,d=i+c>>1;s&1?(a=o,c=i,o=l,i=f):(o=a,i=c,a=l,c=f),l=h,f=d}let u=n*4;this.coords[u+0]=o,this.coords[u+1]=i,this.coords[u+2]=a,this.coords[u+3]=c}}createTile(e){return new rf(e,this)}},rf=class{constructor(e,r){let n=r.gridSize;if(e.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:n,gridSize:s}=this.martini,{terrain:o,errors:i}=this;for(let a=e-1;a>=0;a--){let c=a*4,l=n[c+0],f=n[c+1],u=n[c+2],h=n[c+3],d=l+u>>1,p=f+h>>1,A=d+p-f,m=p+l-d,y=(o[f*s+l]+o[h*s+u])/2,b=p*s+d,E=Math.abs(y-o[b]);if(i[b]=Math.max(i[b],E),a<r){let M=(f+m>>1)*s+(l+A>>1),B=(h+m>>1)*s+(u+A>>1);i[b]=Math.max(i[b],i[M],i[B])}}}getMesh(e=0){let{gridSize:r,indices:n}=this.martini,{errors:s}=this,o=0,i=0,a=r-1;n.fill(0);function c(d,p,A,m,y,b){let E=d+A>>1,M=p+m>>1;Math.abs(d-y)+Math.abs(p-b)>1&&s[M*r+E]>e?(c(y,b,d,p,E,M),c(A,m,y,b,E,M)):(n[p*r+d]=n[p*r+d]||++o,n[m*r+A]=n[m*r+A]||++o,n[b*r+y]=n[b*r+y]||++o,i++)}c(0,0,a,a,a,0),c(a,a,0,0,0,a);let l=new Uint16Array(o*2),f=new Uint32Array(i*3),u=0;function h(d,p,A,m,y,b){let E=d+A>>1,M=p+m>>1;if(Math.abs(d-y)+Math.abs(p-b)>1&&s[M*r+E]>e)h(y,b,d,p,E,M),h(A,m,y,b,E,M);else{let B=n[p*r+d]-1,C=n[m*r+A]-1,v=n[b*r+y]-1;l[2*B]=d,l[2*B+1]=p,l[2*C]=A,l[2*C+1]=m,l[2*v]=y,l[2*v+1]=b,f[u++]=B,f[u++]=C,f[u++]=v}}return h(0,0,a,a,a,0),h(a,a,0,0,0,a),{vertices:l,triangles:f}}};var Es=class{constructor(e,r,n=r){this.data=e,this.width=r,this.height=n,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let s=r-1,o=n-1,i=this._addPoint(0,0),a=this._addPoint(s,0),c=this._addPoint(0,o),l=this._addPoint(s,o),f=this._addTriangle(l,i,c,-1,-1,-1);this._addTriangle(i,l,a,f,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r<this._pendingLen;r++){let n=this._pending[r],s=2*this.triangles[n*3+0],o=2*this.triangles[n*3+1],i=2*this.triangles[n*3+2];this._findCandidate(e[s],e[s+1],e[o],e[o+1],e[i],e[i+1],n)}this._pendingLen=0}_findCandidate(e,r,n,s,o,i,a){let c=Math.min(e,n,o),l=Math.min(r,s,i),f=Math.max(e,n,o),u=Math.max(r,s,i),h=Tr(n,s,o,i,c,l),d=Tr(o,i,e,r,c,l),p=Tr(e,r,n,s,c,l),A=s-r,m=e-n,y=i-s,b=n-o,E=r-i,M=o-e,B=Tr(e,r,n,s,o,i),C=this.heightAt(e,r)/B,v=this.heightAt(n,s)/B,_=this.heightAt(o,i)/B,T=0,g=0,S=0,F=0;for(let R=l;R<=u;R++){let L=0;h<0&&y!==0&&(L=Math.max(L,Math.floor(-h/y))),d<0&&E!==0&&(L=Math.max(L,Math.floor(-d/E))),p<0&&A!==0&&(L=Math.max(L,Math.floor(-p/A)));let G=h+y*L,W=d+E*L,z=p+A*L,te=!1;for(let K=c+L;K<=f;K++){if(G>=0&&W>=0&&z>=0){te=!0;let Y=C*G+v*W+_*z,$=Math.abs(Y-this.heightAt(K,R));F+=$*$,$>T&&(T=$,g=K,S=R)}else if(te)break;G+=y,W+=E,z+=A}h+=b,d+=M,p+=m}(g===e&&S===r||g===n&&S===s||g===o&&S===i)&&(T=0),this._candidates[2*a]=g,this._candidates[2*a+1]=S,this._rms[a]=F,this._queuePush(a,T,F)}_step(){let e=this._queuePop(),r=e*3+0,n=e*3+1,s=e*3+2,o=this.triangles[r],i=this.triangles[n],a=this.triangles[s],c=this.coords[2*o],l=this.coords[2*o+1],f=this.coords[2*i],u=this.coords[2*i+1],h=this.coords[2*a],d=this.coords[2*a+1],p=this._candidates[2*e],A=this._candidates[2*e+1],m=this._addPoint(p,A);if(Tr(c,l,f,u,p,A)===0)this._handleCollinear(m,r);else if(Tr(f,u,h,d,p,A)===0)this._handleCollinear(m,n);else if(Tr(h,d,c,l,p,A)===0)this._handleCollinear(m,s);else{let y=this._halfedges[r],b=this._halfedges[n],E=this._halfedges[s],M=this._addTriangle(o,i,m,y,-1,-1,r),B=this._addTriangle(i,a,m,b,-1,M+1),C=this._addTriangle(a,o,m,E,M+2,B+1);this._legalize(M),this._legalize(B),this._legalize(C)}}_addPoint(e,r){let n=this.coords.length>>1;return this.coords.push(e,r),n}_addTriangle(e,r,n,s,o,i,a=this.triangles.length){let c=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=n,this._halfedges[a+0]=s,this._halfedges[a+1]=o,this._halfedges[a+2]=i,s>=0&&(this._halfedges[s]=a+0),o>=0&&(this._halfedges[o]=a+1),i>=0&&(this._halfedges[i]=a+2),this._candidates[2*c+0]=0,this._candidates[2*c+1]=0,this._queueIndices[c]=-1,this._rms[c]=0,this._pending[this._pendingLen++]=c,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let n=e-e%3,s=r-r%3,o=n+(e+1)%3,i=n+(e+2)%3,a=s+(r+2)%3,c=s+(r+1)%3,l=this.triangles[i],f=this.triangles[e],u=this.triangles[o],h=this.triangles[a],d=this.coords;if(!j2(d[2*l],d[2*l+1],d[2*f],d[2*f+1],d[2*u],d[2*u+1],d[2*h],d[2*h+1]))return;let p=this._halfedges[o],A=this._halfedges[i],m=this._halfedges[a],y=this._halfedges[c];this._queueRemove(n/3),this._queueRemove(s/3);let b=this._addTriangle(l,h,u,-1,m,p,n),E=this._addTriangle(h,l,f,b,A,y,s);this._legalize(b+1),this._legalize(E+2)}_handleCollinear(e,r){let n=r-r%3,s=n+(r+1)%3,o=n+(r+2)%3,i=this.triangles[o],a=this.triangles[r],c=this.triangles[s],l=this._halfedges[s],f=this._halfedges[o],u=this._halfedges[r];if(u<0){let C=this._addTriangle(e,i,a,-1,f,-1,n),v=this._addTriangle(i,e,c,C,-1,l);this._legalize(C+1),this._legalize(v+2);return}let h=u-u%3,d=h+(u+2)%3,p=h+(u+1)%3,A=this.triangles[d],m=this._halfedges[d],y=this._halfedges[p];this._queueRemove(h/3);let b=this._addTriangle(i,a,e,f,-1,-1,n),E=this._addTriangle(a,A,e,y,-1,b+1,h),M=this._addTriangle(A,c,e,m,-1,E+1),B=this._addTriangle(c,i,e,l,b+2,M+1);this._legalize(b),this._legalize(E),this._legalize(M),this._legalize(B)}_queuePush(e,r,n){let s=this._queue.length;this._queueIndices[e]=s,this._queue.push(e),this._errors.push(r),this._rmsSum+=n,this._queueUp(s)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let s=this._pending.indexOf(e);if(s!==-1)this._pending[s]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let n=this._queue.length-1;n!==r&&(this._queueSwap(r,n),this._queueDown(r,n)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let n=this._queue[e],s=this._queue[r];this._queue[e]=s,this._queue[r]=n,this._queueIndices[n]=r,this._queueIndices[s]=e;let o=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=o}_queueUp(e){let r=e;for(;;){let n=r-1>>1;if(n===r||!this._queueLess(r,n))break;this._queueSwap(n,r),r=n}}_queueDown(e,r){let n=e;for(;;){let s=2*n+1;if(s>=r||s<0)break;let o=s+1,i=s;if(o<r&&this._queueLess(o,s)&&(i=o),!this._queueLess(i,n))break;this._queueSwap(n,i),n=i}return n>e}};function Tr(t,e,r,n,s,o){return(r-s)*(e-o)-(n-o)*(t-s)}function j2(t,e,r,n,s,o,i,a){let c=t-i,l=e-a,f=r-i,u=n-a,h=s-i,d=o-a,p=c*c+l*l,A=f*f+u*u,m=h*h+d*d;return c*(u*m-A*d)-l*(f*m-A*h)+p*(f*d-u*h)<0}function m0(t,e){let{meshMaxError:r,bounds:n,elevationDecoder:s}=e,{data:o,width:i,height:a}=t,c,l;switch(e.tesselator){case"martini":c=vi(o,i,a,s,e.tesselator),l=d0(r,i,c);break;case"delatin":c=vi(o,i,a,s,e.tesselator),l=p0(r,i,a,c);break;default:i===a&&!(a&i-1)?(c=vi(o,i,a,s,"martini"),l=d0(r,i,c)):(c=vi(o,i,a,s,"delatin"),l=p0(r,i,a,c));break}let{vertices:f}=l,{triangles:u}=l,h=J2(f,c,i,a,n),d=dr(h);if(e.skirtHeight){let{attributes:p,triangles:A}=wi(h,u,e.skirtHeight);h=p,u=A}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:d},mode:4,indices:{value:Uint32Array.from(u),size:1},attributes:h}}function d0(t,e,r){let n=e+1,o=new bs(n).createTile(r),{vertices:i,triangles:a}=o.getMesh(t);return{vertices:i,triangles:a}}function p0(t,e,r,n){let s=new Es(n,e+1,r+1);s.run(t);let{coords:o,triangles:i}=s;return{vertices:o,triangles:i}}function vi(t,e,r,n,s){let{rScaler:o,bScaler:i,gScaler:a,offset:c}=n,l=new Float32Array((e+1)*(r+1));for(let f=0,u=0;u<r;u++)for(let h=0;h<e;h++,f++){let d=f*4,p=t[d+0],A=t[d+1],m=t[d+2];l[f+u]=p*o+A*a+m*i+c}if(s==="martini"){for(let f=(e+1)*e,u=0;u<e;u++,f++)l[f]=l[f-e-1];for(let f=r,u=0;u<r+1;u++,f+=r+1)l[f]=l[f-1]}return l}function J2(t,e,r,n,s){let o=r+1,i=t.length/2,a=new Float32Array(i*3),c=new Float32Array(i*2),[l,f,u,h]=s||[0,0,r,n],d=(u-l)/r,p=(h-f)/n;for(let A=0;A<i;A++){let m=t[A*2],y=t[A*2+1],b=y*o+m;a[3*A+0]=m*d+l,a[3*A+1]=-y*p+h,a[3*A+2]=e[b],c[2*A+0]=m/r,c[2*A+1]=y/n}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:c,size:2}}}var Li="4.4.0-alpha.18";var Fi={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:Li,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var g0={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:Li,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var W2={...Fi,parse:X2};async function X2(t,e,r){let n={...e,core:{...e?.core,mimeType:"application/x.image"},image:{...e?.image,type:"data"}},s=await Fe(t,[],n,r),o={...W2.options.terrain,...e?.terrain};return m0(s,o)}var wz={...g0,parseSync:(t,e)=>tf(t,e?.["quantized-mesh"]),parse:async(t,e)=>tf(t,e?.["quantized-mesh"])};var A0=[1],Y2={...lr.defaultProps,elevationData:Ot,texture:{...Ot,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[Fi]};function x0(t){return Array.isArray(t)?t.join(";"):t||""}var Ms=class extends Ri.CompositeLayer{updateState({props:e,oldProps:r}){let n=e.elevationData!==r.elevationData;if(n){let{elevationData:o}=e,i=o&&(Array.isArray(o)||K2(o));this.setState({isTiled:i})}let s=n||e.meshMaxError!==r.meshMaxError||e.elevationDecoder!==r.elevationDecoder||e.bounds!==r.bounds;if(!this.state.isTiled&&s){let o=this.loadTerrain(e);this.setState({terrain:o})}e.workerUrl&&Ri.log.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:r,elevationDecoder:n,meshMaxError:s,signal:o}){if(!e)return null;let i=this.getLoadOptions();i={...i,terrain:{skirtHeight:this.state.isTiled?s*2:0,...i?.terrain,bounds:r,meshMaxError:s,elevationDecoder:n}};let{fetch:a}=this.props;return a(e,{propName:"elevationData",layer:this,loadOptions:i,signal:o})}getTiledTerrainData(e){let{elevationData:r,fetch:n,texture:s,elevationDecoder:o,meshMaxError:i}=this.props,{viewport:a}=this.context,c=at(r,e),l=s&&at(s,e),{signal:f}=e,u=[0,0],h=[0,0];if(a.isGeospatial){let m=e.bbox;u=a.projectFlat([m.west,m.south]),h=a.projectFlat([m.east,m.north])}else{let m=e.bbox;u=[m.left,m.bottom],h=[m.right,m.top]}let d=[u[0],u[1],h[0],h[1]],p=this.loadTerrain({elevationData:c,bounds:d,elevationDecoder:o,meshMaxError:i,signal:f}),A=l?n(l,{propName:"texture",layer:this,loaders:[],signal:f}).catch(m=>null):Promise.resolve(null);return Promise.all([p,A])}renderSubLayers(e){let r=this.getSubLayerClass("mesh",nf.SimpleMeshLayer),{color:n,wireframe:s,material:o}=this.props,{data:i}=e;if(!i)return null;let[a,c]=i;return new r(e,{data:A0,mesh:a,texture:c,_instanced:!1,coordinateSystem:y0.COORDINATE_SYSTEM.CARTESIAN,getPosition:l=>[0,0,0],getColor:n,wireframe:s,material:o})}onViewportLoad(e){if(!e)return;let{zRange:r}=this.state,n=e.map(i=>i.content).filter(Boolean).map(i=>i[0].header.boundingBox.map(c=>c[2]));if(n.length===0)return;let s=Math.min(...n.map(i=>i[0])),o=Math.max(...n.map(i=>i[1]));(!r||s<r[0]||o>r[1])&&this.setState({zRange:[s,o]})}renderLayers(){let{color:e,material:r,elevationData:n,texture:s,wireframe:o,meshMaxError:i,elevationDecoder:a,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:h,onTileLoad:d,onTileUnload:p,onTileError:A,maxCacheSize:m,maxCacheByteSize:y,refinementStrategy:b}=this.props;if(this.state.isTiled)return new lr(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:x0(n),texture:x0(s),meshMaxError:i,elevationDecoder:a}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:h,onTileLoad:d,onTileUnload:p,onTileError:A,maxCacheSize:m,maxCacheByteSize:y,refinementStrategy:b});if(!n)return null;let E=this.getSubLayerClass("mesh",nf.SimpleMeshLayer);return new E(this.getSubLayerProps({id:"mesh"}),{data:A0,mesh:this.state.terrain,texture:s,_instanced:!1,getPosition:M=>[0,0,0],getColor:e,material:r,wireframe:o})}};Ms.defaultProps=Y2;Ms.layerName="TerrainLayer";var T0=Ms,K2=t=>t.includes("{x}")&&(t.includes("{y}")||t.includes("{-y}"));var qi=D(Je(),1),bf=D(je(),1),e1=D(E0(),1);function M0(t,e,r){switch(t.type){case"Point":return Z2(t,e,r);case"LineString":return Q2(t,e,r);case"Polygon":return _0(t,e,r);default:let n=t;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function _0(t,e=-1/0,r=1/0){let{positions:n}=t,s=t.polygonIndices.value.filter(c=>c>=e&&c<=r),o=t.primitivePolygonIndices.value.filter(c=>c>=e&&c<=r);if(!(s.length>2)){let c=[];for(let l=0;l<o.length-1;l++){let f=o[l],u=o[l+1],h=Pi(n,f,u);c.push(h)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<s.length-1;c++){let l=s[c],f=s[c+1],u=_0(t,l,f).coordinates;a.push(u)}return{type:"MultiPolygon",coordinates:a}}function Q2(t,e=-1/0,r=1/0){let{positions:n}=t,s=t.pathIndices.value.filter(a=>a>=e&&a<=r);if(!(s.length>2))return{type:"LineString",coordinates:Pi(n,s[0],s[1])};let i=[];for(let a=0;a<s.length-1;a++){let c=Pi(n,s[a],s[a+1]);i.push(c)}return{type:"MultiLineString",coordinates:i}}function Z2(t,e,r){let{positions:n}=t,s=Pi(n,e,r);return s.length>1?{type:"MultiPoint",coordinates:s}:{type:"Point",coordinates:s[0]}}function Pi(t,e,r){e=e||0,r=r||t.value.length/t.size;let n=[];for(let s=e;s<r;s++){let o=Array();for(let i=s*t.size;i<(s+1)*t.size;i++)o.push(Number(t.value[i]));n.push(o)}return n}var _s={x:0,y:1,z:2};function br(t,e={}){let{start:r=0,end:n=t.length,plane:s="xy"}=e,o=e.size||2,i=0,a=_s[s[0]],c=_s[s[1]];for(let l=r,f=n-o;l<n;l+=o)i+=(t[l+a]-t[f+a])*(t[l+c]+t[f+c]),f=l;return i/2}function of(t,e,r=2,n,s="xy"){let o=e&&e.length,i=o?e[0]*r:t.length,a=C0(t,0,i,r,!0,n&&n[0],s),c=[];if(!a||a.next===a.prev)return c;let l,f,u,h,d,p,A;if(o&&(a=ow(t,e,a,r,n,s)),t.length>80*r){h=f=t[0],d=u=t[1];for(let m=r;m<i;m+=r)p=t[m],A=t[m+1],p<h&&(h=p),A<d&&(d=A),p>f&&(f=p),A>u&&(u=A);l=Math.max(f-h,u-d),l=l!==0?32767/l:0}return Bs(a,c,r,h,d,l,0),c}function C0(t,e,r,n,s,o,i){let a,c;o===void 0&&(o=br(t,{start:e,end:r,size:n,plane:i}));let l=_s[i[0]],f=_s[i[1]];if(s===o<0)for(a=e;a<r;a+=n)c=B0(a,t[a+l],t[a+f],c);else for(a=r-n;a>=e;a-=n)c=B0(a,t[a+l],t[a+f],c);return c&&Di(c,c.next)&&(Ss(c),c=c.next),c}function Er(t,e){if(!t)return t;e||(e=t);let r=t,n;do if(n=!1,!r.steiner&&(Di(r,r.next)||re(r.prev,r,r.next)===0)){if(Ss(r),r=e=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==e);return e}function Bs(t,e,r,n,s,o,i){if(!t)return;!i&&o&&fw(t,n,s,o);let a=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,o?rw(t,n,s,o):tw(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),Ss(t),t=l.next,a=l.next;continue}if(t=l,t===a){i?i===1?(t=nw(Er(t),e,r),Bs(t,e,r,n,s,o,2)):i===2&&sw(t,e,r,n,s,o):Bs(Er(t),e,r,n,s,o,1);break}}}function tw(t){let e=t.prev,r=t,n=t.next;if(re(e,r,n)>=0)return!1;let s=e.x,o=r.x,i=n.x,a=e.y,c=r.y,l=n.y,f=s<o?s<i?s:i:o<i?o:i,u=a<c?a<l?a:l:c<l?c:l,h=s>o?s>i?s:i:o>i?o:i,d=a>c?a>l?a:l:c>l?c:l,p=n.next;for(;p!==e;){if(p.x>=f&&p.x<=h&&p.y>=u&&p.y<=d&&ln(s,a,o,c,i,l,p.x,p.y)&&re(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function rw(t,e,r,n){let s=t.prev,o=t,i=t.next;if(re(s,o,i)>=0)return!1;let a=s.x,c=o.x,l=i.x,f=s.y,u=o.y,h=i.y,d=a<c?a<l?a:l:c<l?c:l,p=f<u?f<h?f:h:u<h?u:h,A=a>c?a>l?a:l:c>l?c:l,m=f>u?f>h?f:h:u>h?u:h,y=sf(d,p,e,r,n),b=sf(A,m,e,r,n),E=t.prevZ,M=t.nextZ;for(;E&&E.z>=y&&M&&M.z<=b;){if(E.x>=d&&E.x<=A&&E.y>=p&&E.y<=m&&E!==s&&E!==i&&ln(a,f,c,u,l,h,E.x,E.y)&&re(E.prev,E,E.next)>=0||(E=E.prevZ,M.x>=d&&M.x<=A&&M.y>=p&&M.y<=m&&M!==s&&M!==i&&ln(a,f,c,u,l,h,M.x,M.y)&&re(M.prev,M,M.next)>=0))return!1;M=M.nextZ}for(;E&&E.z>=y;){if(E.x>=d&&E.x<=A&&E.y>=p&&E.y<=m&&E!==s&&E!==i&&ln(a,f,c,u,l,h,E.x,E.y)&&re(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;M&&M.z<=b;){if(M.x>=d&&M.x<=A&&M.y>=p&&M.y<=m&&M!==s&&M!==i&&ln(a,f,c,u,l,h,M.x,M.y)&&re(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function nw(t,e,r){let n=t;do{let s=n.prev,o=n.next.next;!Di(s,o)&&S0(s,n,n.next,o)&&Cs(s,o)&&Cs(o,s)&&(e.push(s.i/r|0),e.push(n.i/r|0),e.push(o.i/r|0),Ss(n),Ss(n.next),n=t=o),n=n.next}while(n!==t);return Er(n)}function sw(t,e,r,n,s,o){let i=t;do{let a=i.next.next;for(;a!==i.prev;){if(i.i!==a.i&&dw(i,a)){let c=I0(i,a);i=Er(i,i.next),c=Er(c,c.next),Bs(i,e,r,n,s,o,0),Bs(c,e,r,n,s,o,0);return}a=a.next}i=i.next}while(i!==t)}function ow(t,e,r,n,s,o){let i=[],a,c,l,f,u;for(a=0,c=e.length;a<c;a++)l=e[a]*n,f=a<c-1?e[a+1]*n:t.length,u=C0(t,l,f,n,!1,s&&s[a+1],o),u===u.next&&(u.steiner=!0),i.push(hw(u));for(i.sort(iw),a=0;a<i.length;a++)r=aw(i[a],r);return r}function iw(t,e){return t.x-e.x}function aw(t,e){let r=cw(t,e);if(!r)return e;let n=I0(r,t);return Er(n,n.next),Er(r,r.next)}function cw(t,e){let r=e,n=t.x,s=t.y,o=-1/0,i;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){let h=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(h<=n&&h>o&&(o=h,i=r.x<r.next.x?r:r.next,h===n))return i}r=r.next}while(r!==e);if(!i)return null;let a=i,c=i.x,l=i.y,f=1/0,u;r=i;do n>=r.x&&r.x>=c&&n!==r.x&&ln(s<l?n:o,s,c,l,s<l?o:n,s,r.x,r.y)&&(u=Math.abs(s-r.y)/(n-r.x),Cs(r,t)&&(u<f||u===f&&(r.x>i.x||r.x===i.x&&lw(i,r)))&&(i=r,f=u)),r=r.next;while(r!==a);return i}function lw(t,e){return re(t.prev,t,e.prev)<0&&re(e.next,t,t.next)<0}function fw(t,e,r,n){let s=t;do s.z===0&&(s.z=sf(s.x,s.y,e,r,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,uw(s)}function uw(t){let e,r,n=1,s,o,i,a,c,l;do{for(o=t,t=null,l=null,s=0;o;){for(s++,a=o,i=0,r=0;r<n&&(i++,a=a.nextZ,!!a);r++);for(c=n;i>0||c>0&&a;)i!==0&&(c===0||!a||o.z<=a.z)?(e=o,o=o.nextZ,i--):(e=a,a=a.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;o=a}l.nextZ=null,n*=2}while(s>1);return t}function sf(t,e,r,n,s){return t=(t-r)*s|0,e=(e-n)*s|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function hw(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function ln(t,e,r,n,s,o,i,a){return(s-i)*(e-a)>=(t-i)*(o-a)&&(t-i)*(n-a)>=(r-i)*(e-a)&&(r-i)*(o-a)>=(s-i)*(n-a)}function dw(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!pw(t,e)&&(Cs(t,e)&&Cs(e,t)&&mw(t,e)&&(re(t.prev,t,e.prev)||re(t,e.prev,e))||Di(t,e)&&re(t.prev,t,t.next)>0&&re(e.prev,e,e.next)>0)}function re(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Di(t,e){return t.x===e.x&&t.y===e.y}function S0(t,e,r,n){let s=Ni(re(t,e,r)),o=Ni(re(t,e,n)),i=Ni(re(r,n,t)),a=Ni(re(r,n,e));return!!(s!==o&&i!==a||s===0&&Oi(t,r,e)||o===0&&Oi(t,n,e)||i===0&&Oi(r,t,n)||a===0&&Oi(r,e,n))}function Oi(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Ni(t){return t>0?1:t<0?-1:0}function pw(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&S0(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function Cs(t,e){return re(t.prev,t,t.next)<0?re(t,e,t.next)>=0&&re(t,t.prev,e)>=0:re(t,e,t.prev)<0||re(t,t.next,e)<0}function mw(t,e){let r=t,n=!1,s=(t.x+e.x)/2,o=(t.y+e.y)/2;do r.y>o!=r.next.y>o&&r.next.y!==r.y&&s<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==t);return n}function I0(t,e){let r=new Is(t.i,t.x,t.y),n=new Is(e.i,e.x,e.y),s=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=s,s.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function B0(t,e,r,n){let s=new Is(t,e,r);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Ss(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}var Is=class{constructor(e,r,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=n}};function Gi(t,e,r){let n=Tw(t),s=Object.keys(n).filter(o=>n[o]!==Array);return bw(t,{propArrayTypes:n,...e},{numericPropKeys:r&&r.numericPropKeys||s,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function Tw(t){let e={};for(let r of t)if(r.properties)for(let n in r.properties){let s=r.properties[n];e[n]=Sw(s,e[n])}return e}function bw(t,e,r){let{pointPositionsCount:n,pointFeaturesCount:s,linePositionsCount:o,linePathsCount:i,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:h,coordLength:d}=e,{numericPropKeys:p=[],PositionDataType:A=Float32Array,triangulate:m=!0}=r,y=t[0]&&"id"in t[0],b=t.length>65535?Uint32Array:Uint16Array,E={type:"Point",positions:new A(n*d),globalFeatureIds:new b(n),featureIds:s>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},M={type:"LineString",pathIndices:o>65535?new Uint32Array(i+1):new Uint16Array(i+1),positions:new A(o*d),globalFeatureIds:new b(o),featureIds:a>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},B={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new A(c*d),globalFeatureIds:new b(c),featureIds:u>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};m&&(B.triangles=[]);for(let v of[E,M,B])for(let _ of p){let T=h[_];v.numericProps[_]=new T(v.positions.length/d)}M.pathIndices[i]=o,B.polygonIndices[l]=c,B.primitivePolygonIndices[f]=c;let C={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let v of t){let _=v.geometry,T=v.properties||{};switch(_.type){case"Point":Ew(_,E,C,d,T),E.properties.push(cf(T,p)),y&&E.fields.push({id:v.id}),C.pointFeature++;break;case"LineString":Mw(_,M,C,d,T),M.properties.push(cf(T,p)),y&&M.fields.push({id:v.id}),C.lineFeature++;break;case"Polygon":_w(_,B,C,d,T),B.properties.push(cf(T,p)),y&&B.fields.push({id:v.id}),C.polygonFeature++;break;default:throw new Error("Invalid geometry type")}C.feature++}return Cw(E,M,B,d)}function Ew(t,e,r,n,s){e.positions.set(t.data,r.pointPosition*n);let o=t.data.length/n;lf(e,s,r.pointPosition,o),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+o),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+o),r.pointPosition+=o}function Mw(t,e,r,n,s){e.positions.set(t.data,r.linePosition*n);let o=t.data.length/n;lf(e,s,r.linePosition,o),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+o),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+o);for(let i=0,a=t.indices.length;i<a;++i){let c=t.indices[i],l=i===a-1?t.data.length:t.indices[i+1];e.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/n}}function _w(t,e,r,n,s){e.positions.set(t.data,r.polygonPosition*n);let o=t.data.length/n;lf(e,s,r.polygonPosition,o),e.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+o),e.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+o);for(let i=0,a=t.indices.length;i<a;++i){let c=r.polygonPosition;e.polygonIndices[r.polygonObject++]=c;let l=t.areas[i],f=t.indices[i],u=t.indices[i+1];for(let d=0,p=f.length;d<p;++d){let A=f[d],m=d===p-1?u===void 0?t.data.length:u[0]:f[d+1];e.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(m-A)/n}let h=r.polygonPosition;Bw(e,l,f,{startPosition:c,endPosition:h,coordLength:n})}}function Bw(t,e,r,{startPosition:n,endPosition:s,coordLength:o}){if(!t.triangles)return;let i=n*o,a=s*o,c=t.positions.subarray(i,a),l=r[0],f=r.slice(1).map(h=>(h-l)/o),u=of(c,f,o,e);for(let h=0,d=u.length;h<d;++h)t.triangles.push(n+u[h])}function af(t,e){let r={};for(let n in t)r[n]={value:t[n],size:e};return r}function Cw(t,e,r,n){let s={shape:"binary-feature-collection",points:{...t,positions:{value:t.positions,size:n},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:af(t.numericProps,1)},lines:{...e,positions:{value:e.positions,size:n},pathIndices:{value:e.pathIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:af(e.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:n},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:af(r.numericProps,1)}};return s.polygons&&r.triangles&&(s.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),s}function lf(t,e,r,n){for(let s in t.numericProps)if(s in e){let o=e[s];t.numericProps[s].fill(o,r,r+n)}}function cf(t,e){let r={};for(let n in t)e.includes(n)||(r[n]=t[n]);return r}function Sw(t,e){return e===Array||!Number.isFinite(t)?Array:e===Float64Array||Math.fround(t)!==t?Float64Array:Float32Array}function ws(t,e){let r=e?.globalFeatureId;return r!==void 0?Iw(t,r):ww(t,e?.type)}function Iw(t,e){let r=L0(t);for(let n of r){let s=0,o=n.featureIds.value[0];for(let i=0;i<n.featureIds.value.length;i++){let a=n.featureIds.value[i];if(a!==o){if(e===n.globalFeatureIds.value[s])return Ui(n,s,i);s=i,o=a}}if(e===n.globalFeatureIds.value[s])return Ui(n,s,n.featureIds.value.length)}throw new Error(`featureId:${e} not found`)}function ww(t,e){let r=L0(t,e);return vw(r)}function L0(t,e){let r=[];return t.points&&(t.points.type="Point",r.push(t.points)),t.lines&&(t.lines.type="LineString",r.push(t.lines)),t.polygons&&(t.polygons.type="Polygon",r.push(t.polygons)),r}function vw(t){let e=[];for(let r of t){if(r.featureIds.value.length===0)continue;let n=0,s=r.featureIds.value[0];for(let o=0;o<r.featureIds.value.length;o++){let i=r.featureIds.value[o];i!==s&&(e.push(Ui(r,n,o)),n=o,s=i)}e.push(Ui(r,n,r.featureIds.value.length))}return e}function Ui(t,e,r){let n=M0(t,e,r),s=Fw(t,e,r),o=Lw(t,e,r);return{type:"Feature",geometry:n,properties:s,...o}}function Lw(t,e=0,r){return t.fields&&t.fields[t.featureIds.value[e]]}function Fw(t,e=0,r){let n=Object.assign({},t.properties[t.featureIds.value[e]]);for(let s in t.numericProps)n[s]=t.numericProps[s].value[e];return n}var mf=D(G0(),1);function Kw(t){let e=0;for(let r=0,n=t.length-1,s,o;r<t.length;n=r++)s=t[r],o=t[n],e+=(o[0]-s[0])*(s[1]+o[1]);return e}function hf(t,e){if(Array.isArray(t[0])){for(let n of t)hf(n,e);return}let r=t;r[0]/=e,r[1]/=e}function U0(t,e){for(let r=0;r<t.length;++r)t[r]/=e}function df(t,e,r){if(typeof t[0][0]!="number"){for(let i of t)df(i,e,r);return}let n=r*Math.pow(2,e.z),s=r*e.x,o=r*e.y;for(let i=0;i<t.length;i++){let a=t[i];a[0]=(a[0]+s)*360/n-180;let c=180-(a[1]+o)*360/n;a[1]=360/Math.PI*Math.atan(Math.exp(c*Math.PI/180))-90}}function V0(t,e,r){let{x:n,y:s,z:o}=e,i=r*Math.pow(2,o),a=r*n,c=r*s;for(let l=0,f=t.length;l<f;l+=2){t[l]=(t[l]+a)*360/i-180;let u=180-(t[l+1]+c)*360/i;t[l+1]=360/Math.PI*Math.atan(Math.exp(u*Math.PI/180))-90}}function H0(t){let e=t.length;if(e<=1)return[t];let r=[],n,s;for(let o=0;o<e;o++){let i=Kw(t[o]);i!==0&&(s===void 0&&(s=i<0),s===i<0?(n&&r.push(n),n=[t[o]]):n&&n.push(t[o]))}return n&&r.push(n),r}function z0(t){let e=t.indices.length,r="Polygon";if(e<=1)return{type:r,data:t.data,areas:[[br(t.data)]],indices:[t.indices]};let n=[],s=[],o=[],i=[],a,c=0;for(let l,f=0,u;f<e;f++){u=t.indices[f]-c,l=t.indices[f+1]-c||t.data.length;let h=t.data.slice(u,l),d=br(h);if(d===0){let p=t.data.slice(0,u),A=t.data.slice(l);t.data=p.concat(A),c+=l-u;continue}a===void 0&&(a=d<0),a===d<0?(i.length&&(n.push(o),s.push(i)),i=[u],o=[d]):(o.push(d),i.push(u))}return o&&n.push(o),i.length&&s.push(i),{type:r,areas:n,indices:s,data:t.data}}var Mr=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(e,r,n,s,o,i){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=e,this._geometry=-1,this._keys=s,this._values=o,this._geometryInfo=i,e.readFields(Qw,this,r)}toGeoJSONFeature(e,r){let n=this.loadGeometry();switch(e){case"wgs84":return k0(this,n,s=>df(s,r,this.extent));default:return k0(this,n,hf)}}toBinaryFeature(e,r){let n=this.loadFlatGeometry();switch(e){case"wgs84":return this._toBinaryCoordinates(n,s=>V0(s,r,this.extent));default:return this._toBinaryCoordinates(n,U0)}}bbox(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,s=0,o=0,i=0,a=1/0,c=-1/0,l=1/0,f=-1/0;for(;e.pos<r;){if(s<=0){let u=e.readVarint();n=u&7,s=u>>3}if(s--,n===1||n===2)o+=e.readSVarint(),i+=e.readSVarint(),o<a&&(a=o),o>c&&(c=o),i<l&&(l=i),i>f&&(f=i);else if(n!==7)throw new Error(`unknown command ${n}`)}return[a,l,c,f]}_toBinaryCoordinates(e,r){let n;r(e.data,this.extent);let s=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=e.indices.length,n={type:"Point",...e};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=e.indices.length,this._geometryInfo.linePositionsCount+=e.data.length/s,n={type:"LineString",...e};break;case 3:n=z0(e),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=n.indices.length;for(let i of n.indices)this._geometryInfo.polygonRingsCount+=i.length;this._geometryInfo.polygonPositionsCount+=n.data.length/s;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let o={type:"Feature",geometry:n,properties:this.properties};return this.id!==null&&(o.id=this.id),o}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,s=0,o=0,i=0,a=[],c;for(;e.pos<r;){if(s<=0){let l=e.readVarint();n=l&7,s=l>>3}switch(s--,n){case 1:case 2:o+=e.readSVarint(),i+=e.readSVarint(),n===1&&(c&&a.push(c),c=[]),c&&c.push([o,i]);break;case 7:c&&c.push(c[0].slice());break;default:throw new Error(`unknown command ${n}`)}}return c&&a.push(c),a}loadFlatGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,s,o=0,i=0,a=0,c=0,l=[],f=[];for(;e.pos<r;)if(o<=0&&(s=e.readVarint(),n=s&7,o=s>>3),o--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),n===1&&l.push(c),f.push(i,a),c+=2;else if(n===7){if(c>0){let u=l[l.length-1];f.push(f[u],f[u+1]),c+=2}}else throw new Error(`unknown command ${n}`);return{data:f,indices:l}}};zt(Mr,"types",["Unknown","Point","LineString","Polygon"]);function k0(t,e,r){let n=Mr.types[t.type],s,o,i;switch(t.type){case 1:let c=[];for(s=0;s<e.length;s++)c[s]=e[s][0];i=c,r(i,t.extent);break;case 2:for(i=e,s=0;s<i.length;s++)r(i[s],t.extent);break;case 3:for(i=H0(e),s=0;s<i.length;s++)for(o=0;o<i[s].length;o++)r(i[s][o],t.extent);break;default:throw new Error("illegal vector tile type")}i.length===1?i=i[0]:n=`Multi${n}`;let a={type:"Feature",geometry:{type:n,coordinates:i},properties:t.properties};return t.id!==null&&(a.properties||={},a.properties.id=t.id),a}function Qw(t,e,r){e&&r&&(t===1?e.id=r.readVarint():t===2?Zw(r,e):t===3?e.type=r.readVarint():t===4&&(e._geometry=r.pos))}function Zw(t,e){let r=t.readVarint()+t.pos;for(;t.pos<r;){let n=e._keys[t.readVarint()],s=e._values[t.readVarint()];e.properties[n]=s}}var zi=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields($w,this,r),this.length=this._features.length}getGeoJSONFeature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let r=this._pbf.readVarint()+this._pbf.pos;return new Mr(this._pbf,r,this.extent,this._keys,this._values)}getBinaryFeature(e,r){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let n=this._pbf.readVarint()+this._pbf.pos;return new Mr(this._pbf,n,this.extent,this._keys,this._values,r)}};function $w(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(e3(r)))}function e3(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos<r;){let n=t.readVarint()>>3;e=n===1?t.readString():n===2?t.readFloat():n===3?t.readDouble():n===4?t.readVarint64():n===5?t.readVarint():n===6?t.readSVarint():n===7?t.readBoolean():null}return e}var vs=class{layers;constructor(e,r){this.layers=e.readFields(t3,{},r)}};function t3(t,e,r){if(t===3&&r){let n=new zi(r,r.readVarint()+r.pos);n.length&&e&&(e[n.name]=n)}}function gf(t,e){let r=n3(e),n=e?.gis?.format||e?.mvt?.shape||e?.shape;switch(n){case"columnar-table":return{shape:"columnar-table",data:pf(t,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:q0(t,r)};case"geojson":return q0(t,r);case"binary-geometry":return pf(t,r);case"binary":return pf(t,r);default:throw new Error(n||"undefined shape")}}function pf(t,e){let[r,n]=r3(t,e),s=Gi(r,n);return s.byteLength=t.byteLength,s}function r3(t,e){let r=[],n={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength<=0)return[r,n];let s=new vs(new mf.default(t));return(e&&Array.isArray(e.layers)?e.layers:Object.keys(s.layers)).forEach(i=>{let a=s.layers[i];if(a)for(let c=0;c<a.length;c++){let l=a.getBinaryFeature(c,n),f=o3(l,e,i);r.push(f)}}),[r,n]}function q0(t,e){if(t.byteLength<=0)return[];let r=[],n=new vs(new mf.default(t));return(Array.isArray(e.layers)?e.layers:Object.keys(n.layers)).forEach(o=>{let i=n.layers[o];if(i)for(let a=0;a<i.length;a++){let c=i.getGeoJSONFeature(a),l=s3(c,e,o);r.push(l)}}),r}function n3(t){if(!t?.mvt)throw new Error("mvt options required");if(t.mvt?.coordinates==="wgs84"&&!t.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return t.gis&&rc.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),t.mvt}function s3(t,e,r){let n=t.toGeoJSONFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&(n.properties||={},n.properties[e.layerProperty]=r),n}function o3(t,e,r){let n=t.toBinaryFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&n.properties&&(n.properties[e.layerProperty]=r),n}var j0={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],category:"geometry"};var i3="4.4.0-alpha.18",ki={...j0,dataType:null,batchType:null,version:i3,worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},a3={...ki,parse:async(t,e)=>gf(t,e),parseSync:gf,binary:!0};var c3={Point:J0,MultiPoint:l3,LineString:W0,MultiLineString:f3,Polygon:X0,MultiPolygon:u3};function J0([t,e],[r,n],s){let o=Et(r[0],n[0],t),i=Et(r[1],n[1],e);return s.unprojectFlat([o,i])}function Af(t,e,r){return t.map(n=>J0(n,e,r))}function l3(t,e,r){return Af(t,e,r)}function W0(t,e,r){return Af(t,e,r)}function f3(t,e,r){return t.map(n=>W0(n,e,r))}function X0(t,e,r){return t.map(n=>Af(n,e,r))}function u3(t,e,r){return t.map(n=>X0(n,e,r))}function Y0(t,e,r){let n=r.projectFlat([e.west,e.north]),s=r.projectFlat([e.east,e.south]),o=[n,s];return{...t,coordinates:c3[t.type](t.coordinates,o,r)}}var h3=["points","lines","polygons"];function xf(t,e,r,n){for(let s of h3){let o=t[s]&&d3(t[s],e,r,n);if(o>=0)return o}return-1}function d3(t,e,r,n){let s=t.featureIds.value;if(!s.length)return-1;let o=0,i=s[s.length-1]+1;if(n){let c=p3(t,n);if(c)o=c[0],i=c[1]+1;else return-1}let a=-1;if(e in t.numericProps){let c=t.numericProps[e].value.findIndex((l,f)=>l===r&&s[f]>=o&&s[f]<i);return c>=0?t.globalFeatureIds.value[c]:-1}else e?a=K0(t.properties,c=>c[e]===r,o,i):t.fields&&(a=K0(t.fields,c=>c.id===r,o,i));return a>=0?m3(t,a):-1}function p3(t,e){if(!t.__layers){let r={},{properties:n}=t;for(let s=0;s<n.length;s++){let{layerName:o}=n[s];o&&(r[o]?r[o][1]=s:r[o]=[s,s])}t.__layers=r}return t.__layers[e]}function m3(t,e){if(!t.__ids){let r=[],n=t.featureIds.value,s=t.globalFeatureIds.value;for(let o=0;o<n.length;o++)r[n[o]]=s[o];t.__ids=r}return t.__ids[e]}function K0(t,e,r,n){for(let s=r;s<n;s++)if(e(t[s],s))return s;return-1}var yf=512,g3={...bf.GeoJsonLayer.defaultProps,data:Ot,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[ki],binary:!0},Ls=class extends lr{initializeState(){super.initializeState();let e=this.context.viewport.resolution!==void 0?!1:this.props.binary;this.setState({binary:e,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return Boolean(this.state?.data&&super.isLoaded)}updateState({props:e,oldProps:r,context:n,changeFlags:s}){s.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:r,context:n,changeFlags:s}),this._setWGS84PropertyForTiles());let{highlightColor:o}=e;o!==r.highlightColor&&Array.isArray(o)&&this.setState({highlightColor:o})}async _updateTileData(){let e=this.props.data,r=null;if(typeof e=="string"&&!vc(e)){let{onDataLoad:n,fetch:s}=this.props;this.setState({data:null,tileJSON:null});try{r=await s(e,{propName:"data",layer:this,loaders:[]})}catch(o){this.raiseError(o,"loading TileJSON"),e=null}n&&n(r,{propName:"data",layer:this})}else e&&typeof e=="object"&&"tilejson"in e&&(r=e);r&&(e=r.tiles),this.setState({data:e,tileJSON:r})}_getTilesetOptions(){let e=super._getTilesetOptions(),r=this.state.tileJSON,{minZoom:n,maxZoom:s}=this.props;return r&&(Number.isFinite(r.minzoom)&&r.minzoom>n&&(e.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(s)||r.maxzoom<s)&&(e.maxZoom=r.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){let{data:r,binary:n}=this.state,{index:s,signal:o}=e,i=at(r,e);if(!i)return Promise.reject("Invalid URL");let a=this.getLoadOptions(),{fetch:c}=this.props;return a={...a,mimeType:"application/x-protobuf",mvt:{...a?.mvt,coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:s},gis:n?{format:"binary"}:{}},c(i,{propName:"data",layer:this,loadOptions:a,signal:o})}renderSubLayers(e){let{x:r,y:n,z:s}=e.tile.index,o=Math.pow(2,s),i=yf/o,a=-i,c=yf*r/o,l=yf*(1-n/o),f=new O().scale([i,a,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=f,e.coordinateOrigin=[c,l,0],e.coordinateSystem=qi.COORDINATE_SYSTEM.CARTESIAN,e.extensions=[...e.extensions||[],new e1.ClipExtension]);let u=super.renderSubLayers(e);return this.state.binary&&!(u instanceof bf.GeoJsonLayer)&&qi.log.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),u}_updateAutoHighlight(e){let{uniqueIdProperty:r}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:s}=this.state,o=e.object,i=null,a=null;o&&(i=Tf(o,r),a=Q0(o));let{highlightColor:c}=this.props;typeof c=="function"&&(c=c(e)),(n!==i||s!==a)&&this.setState({highlightColor:c,hoveredFeatureId:i,hoveredFeatureLayerName:a})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(e){let r=super.getPickingInfo(e);if(this.state.binary&&r.index!==-1){let{data:n}=e.sourceLayer.props;r.object=ws(n,{globalFeatureId:r.index})}return r.object&&!this._isWGS84()&&(r.object=$0(r.object,r.tile.bbox,this.context.viewport)),r}getSubLayerPropsByTile(e){return{highlightedObjectIndex:this.getHighlightedObjectIndex(e),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(e){let{hoveredFeatureId:r,hoveredFeatureLayerName:n,binary:s}=this.state,{uniqueIdProperty:o,highlightedFeatureId:i}=this.props,a=e.content,c=Z0(i);if(!(Z0(r)||c))return-1;let f=c?i:r;return Array.isArray(a)?a.findIndex(u=>{let h=Tf(u,o)===f,d=c||Q0(u)===n;return h&&d}):a&&s?xf(a,o,f,c?"":n):-1}_pickObjects(e){let{deck:r,viewport:n}=this.context,s=n.width,o=n.height,i=n.x,a=n.y,c=[this.id];return r.pickObjects({x:i,y:a,width:s,height:o,layerIds:c,maxObjects:e})}getRenderedFeatures(e=null){let r=this._pickObjects(e),n=new Set,s=[];for(let o of r){let i=Tf(o.object,this.props.uniqueIdProperty);i===void 0?s.push(o.object):n.has(i)||(n.add(i),s.push(o.object))}return s}_setWGS84PropertyForTiles(){let e="dataInWGS84";this.state.tileset.selectedTiles.forEach(n=>{n.hasOwnProperty(e)||Object.defineProperty(n,e,{get:()=>{if(!n.content)return null;if(this.state.binary&&Array.isArray(n.content)&&!n.content.length)return[];let{bbox:s}=n;if(n._contentWGS84===void 0&&Lc(s)){let o=this.state.binary?ws(n.content):n.content;n._contentWGS84=o.map(i=>$0(i,s,this.context.viewport))}return n._contentWGS84}})})}};Ls.layerName="MVTLayer";Ls.defaultProps=g3;var t1=Ls;function Tf(t,e){if(t.properties&&e)return t.properties[e];if("id"in t)return t.id}function Q0(t){return t.properties?.layerName||null}function Z0(t){return t!=null&&t!==""}function $0(t,e,r){let n={...t,geometry:{type:t.geometry.type}};return Object.defineProperty(n.geometry,"coordinates",{get:()=>Y0(t.geometry,e,r).coordinates}),n}var r1="0123456789bcdefghjkmnpqrstuvwxyz",n1={};for(let t=0;t<r1.length;t++)n1[r1.charAt(t)]=t;var A3=-90,x3=90,y3=-180,T3=180;function b3(t){let e=!0,r=x3,n=A3,s=T3,o=y3,i,a=0;for(let c=0,l=t.length;c<l;c++){let f=t[c].toLowerCase();a=n1[f];for(let u=4;u>=0;u--){let h=a>>u&1;e?(i=(s+o)/2,h===1?o=i:s=i):(i=(r+n)/2,h===1?n=i:r=i),e=!e}}return[n,o,r,s]}function s1(t){let[e,r,n,s]=b3(t);return[s,n,s,e,r,e,r,n,s,n]}var E3={getGeohash:{type:"accessor",value:t=>t.geohash}},Fs=class extends Oe{indexToBounds(){let{data:e,getGeohash:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(n,s)=>s1(r(n,s))}}};Fs.layerName="GeohashLayer";Fs.defaultProps=E3;var o1=Fs;return h1(Rs);})();
2374
+ `;function qS(t){let e=t.positions||t.POSITION,r=e.value.length/e.size;t.COLOR_0||t.colors||(t.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var jS={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},io=class extends im.SimpleMeshLayer{getShaders(){let e=super.getShaders();return e.modules.push(qc,rm),{...e,vs:nm,fs:om}}initializeState(){let{featureIds:e}=this.props;super.initializeState();let r=this.getAttributeManager();e&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);let{props:r,oldProps:n}=e;r.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(e){let{featureIds:r}=this.props,{model:n}=this.state;if(!n)return;let o={pickFeatureIds:Boolean(r)},s={camera:this.context.viewport.cameraPosition};n.shaderInputs.setProps({pbrProjection:s,mesh:o}),super.draw(e)}getModel(e){let{id:r}=this.props,n=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:n});let o=this.getShaders();return qS(e.attributes),new sm.Model(this.context.device,{...this.getShaders(),id:r,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...o.defines,...n?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:n?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){let{model:r}=this.state;if(r){let{mesh:n}=this.props,o=this.parseMaterial(e,n);this.setState({parsedPBRMaterial:o});let{pbr_baseColorSampler:s}=o.bindings,{emptyTexture:i}=this.state,a={sampler:s||i,hasTexture:Boolean(s)},{camera:c,...l}={...o.bindings,...o.uniforms};r.shaderInputs.setProps({simpleMesh:a,pbrMaterial:l})}}parseMaterial(e,r){let n=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return zc(this.context.device,{unlit:n,...e},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){let r=this.props.featureIds,n=new Uint8ClampedArray(r.length*e.size),o=[];for(let s=0;s<r.length;s++)this.encodePickingColor(r[s],o),n[s*3]=o[0],n[s*3+1]=o[1],n[s*3+2]=o[2];e.value=n}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}};io.layerName="MeshLayer";io.defaultProps=jS;var am=io;var m0=D(Zt(),1);var xt=6356752314245179e-9,JS={radii:[6378137,6378137,xt],radiiSquared:[6378137*6378137,6378137*6378137,xt*xt],oneOverRadii:[1/6378137,1/6378137,1/xt],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(xt*xt)],maximumRadius:Math.max(6378137,6378137,xt),centerToleranceSquared:.1};function Ws(t){return t}var c4=new x;function WS(t,e=[],r=Ws){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function cm(t,e=[]){return WS(t,e,Q._cartographicRadians?Ws:ua)}function XS(t,e,r=Ws){return"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):"x"in e?(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function lm(t,e){return XS(t,e,Q._cartographicRadians?Ws:ha)}var fm=1e-14,YS=new x,um={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},jc={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},ao={east:new x,north:new x,up:new x,west:new x,south:new x,down:new x},KS=new x,QS=new x,ZS=new x;function Jc(t,e,r,n,o,s){let i=um[e]&&um[e][r];ue(i&&(!n||n===i));let a,c,l,f=YS.copy(o);if(Me(f.x,0,fm)&&Me(f.y,0,fm)){let h=Math.sign(f.z);a=KS.fromArray(jc[e]),e!=="east"&&e!=="west"&&a.scale(h),c=QS.fromArray(jc[r]),r!=="east"&&r!=="west"&&c.scale(h),l=ZS.fromArray(jc[n]),n!=="east"&&n!=="west"&&l.scale(h)}else{let{up:h,east:p,north:d}=ao;p.set(-f.y,f.x,0).normalize(),t.geodeticSurfaceNormal(f,h),d.copy(h).cross(p);let{down:A,west:m,south:b}=ao;A.copy(h).scale(-1),m.copy(p).scale(-1),b.copy(d).scale(-1),a=ao[e],c=ao[r],l=ao[n]}return s[0]=a.x,s[1]=a.y,s[2]=a.z,s[3]=0,s[4]=c.x,s[5]=c.y,s[6]=c.z,s[7]=0,s[8]=l.x,s[9]=l.y,s[10]=l.z,s[11]=0,s[12]=f.x,s[13]=f.y,s[14]=f.z,s[15]=1,s}var Wr=new x,$S=new x,eC=new x;function hm(t,e,r=[]){let{oneOverRadii:n,oneOverRadiiSquared:o,centerToleranceSquared:s}=e;Wr.from(t);let i=Wr.x,a=Wr.y,c=Wr.z,l=n.x,f=n.y,u=n.z,h=i*i*l*l,p=a*a*f*f,d=c*c*u*u,A=h+p+d,m=Math.sqrt(1/A);if(!Number.isFinite(m))return;let b=$S;if(b.copy(t).scale(m),A<s)return b.to(r);let T=o.x,E=o.y,_=o.z,S=eC;S.set(b.x*T*2,b.y*E*2,b.z*_*2);let C=(1-m)*Wr.len()/(.5*S.len()),v=0,M,y,g,B;do{C-=v,M=1/(1+C*T),y=1/(1+C*E),g=1/(1+C*_);let L=M*M,F=y*y,w=g*g,U=L*M,W=F*y,z=w*g;B=h*L+p*F+d*w-1;let K=-2*(h*U*T+p*W*E+d*z*_);v=B/K}while(Math.abs(B)>Ue.EPSILON12);return Wr.scale([M,y,g]).to(r)}var Xs=new x,pm=new x,nC=new x,$e=new x,oC=new x,Ys=new x,G=class{constructor(e=0,r=0,n=0){this.centerToleranceSquared=Ue.EPSILON1,ue(e>=0),ue(r>=0),ue(n>=0),this.radii=new x(e,r,n),this.radiiSquared=new x(e*e,r*r,n*n),this.radiiToTheFourth=new x(e*e*e*e,r*r*r*r,n*n*n*n),this.oneOverRadii=new x(e===0?0:1/e,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new x(e===0?0:1/(e*e),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(e,r,n),this.maximumRadius=Math.max(e,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){let n=pm,o=nC,[,,s]=e;this.geodeticSurfaceNormalCartographic(e,n),o.copy(this.radiiSquared).scale(n);let i=Math.sqrt(n.dot(o));return o.scale(1/i),n.scale(s),o.add(n),o.to(r)}cartesianToCartographic(e,r=[0,0,0]){Ys.from(e);let n=this.scaleToGeodeticSurface(Ys,$e);if(!n)return;let o=this.geodeticSurfaceNormal(n,pm),s=oC;s.copy(Ys).subtract(n);let i=Math.atan2(o.y,o.x),a=Math.asin(o.z),c=Math.sign(Qt.dot(s,Ys))*Qt.length(s);return lm([i,a,c],r)}eastNorthUpToFixedFrame(e,r=new N){return Jc(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,n,o,s=new N){return Jc(this,e,r,n,o,s)}geocentricSurfaceNormal(e,r=[0,0,0]){return Xs.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let n=cm(e),o=n[0],s=n[1],i=Math.cos(s);return Xs.set(i*Math.cos(o),i*Math.sin(o),Math.sin(s)).normalize(),Xs.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return Xs.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return hm(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){$e.from(e);let n=$e.x,o=$e.y,s=$e.z,i=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*i.x+o*o*i.y+s*s*i.z);return $e.multiplyScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return $e.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return $e.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,n=[0,0,0]){ue(Me(this.radii.x,this.radii.y,Ue.EPSILON15)),ue(this.radii.z>0),$e.from(e);let o=$e.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(o)>=this.radii.z-r))return $e.set(0,0,o).to(n)}};G.WGS84=new G(6378137,6378137,xt);var Ks=class{item;previous;next;constructor(e,r,n){this.item=e,this.previous=r,this.next=n}};var Qs=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new Ks(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let n=e.next;e.next=r,this.tail===e?this.tail=r:n.previous=r,r.next=n,r.previous=e,++this._length}};var Zs=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Qs,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(e,r))}unloadTile(e,r,n){let o=r._cacheNode;o&&(this._list.remove(o),r._cacheNode=null,n&&n(e,r))}unloadTiles(e,r){let n=this._trimTiles;this._trimTiles=!1;let o=this._list,s=e.maximumMemoryUsage*1024*1024,i=this._sentinel,a=o.head;for(;a!==i&&(e.gpuMemoryUsageInBytes>s||n);){let c=a.item;a=a.next,this.unloadTile(e,c,r)}}trim(){this._trimTiles=!0}};function dm(t,e){V(t),V(e);let{rtcCenter:r,gltfUpAxis:n}=e,{computedTransform:o,boundingVolume:{center:s}}=t,i=new N(o);switch(r&&i.translate(r),n){case"Z":break;case"Y":let h=new N().rotateX(Math.PI/2);i=i.multiplyRight(h);break;case"X":let p=new N().rotateY(-Math.PI/2);i=i.multiplyRight(p);break;default:break}e.isQuantized&&i.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new x(s);e.cartesianModelMatrix=i,e.cartesianOrigin=a;let c=G.WGS84.cartesianToCartographic(a,new x),f=G.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=f.multiplyRight(i),e.cartographicOrigin=c;let u=iC(e);u&&(e.cartesianModelMatrix=new N(i).multiplyRight(u.matrix),e.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=N.IDENTITY),e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var sC=1e6**2;function iC(t){let e=t.gltf;if(!e)return null;let r=typeof e.scene=="number"?e.scene:0,o=e.scenes?.[r]?.nodes?.[0];if(!o?.matrix)return null;let s=o.matrix;return s[12]*s[12]+s[13]*s[13]+s[14]*s[14]<=sC?null:o}var mm=new x,Wc=new x,Xc=new ce([new he,new he,new he,new he,new he,new he]);function Am(t,e){let{cameraDirection:r,cameraUp:n,height:o}=t,{metersPerUnit:s}=t.distanceScales,i=$s(t,t.center),a=G.WGS84.eastNorthUpToFixedFrame(i),c=t.unprojectPosition(t.cameraPosition),l=G.WGS84.cartographicToCartesian(c,new x),f=new x(a.transformAsVector(new x(r).scale(s))).normalize(),u=new x(a.transformAsVector(new x(n).scale(s))).normalize();aC(t);let h=t.constructor,{longitude:p,latitude:d,width:A,bearing:m,zoom:b}=t,T=new h({longitude:p,latitude:d,height:o,width:A,bearing:m,zoom:b,pitch:0});return{camera:{position:l,direction:f,up:u},viewport:t,topDownViewport:T,height:o,cullingVolume:Xc,frameNumber:e,sseDenominator:1.15}}function xm(t,e,r){if(r===0||t.length<=r)return[t,[]];let n=[],{longitude:o,latitude:s}=e.viewport;for(let[l,f]of t.entries()){let[u,h]=f.header.mbs,p=Math.abs(o-u),d=Math.abs(s-h),A=Math.sqrt(d*d+p*p);n.push([l,A])}let i=n.sort((l,f)=>l[1]-f[1]),a=[];for(let l=0;l<r;l++)a.push(t[i[l][0]]);let c=[];for(let l=r;l<i.length;l++)c.push(t[i[l][0]]);return[a,c]}function aC(t){let e=t.getFrustumPlanes(),r=gm(e.near,t.cameraPosition),n=$s(t,r),o=$s(t,t.cameraPosition,Wc),s=0;Xc.planes[s++].fromPointNormal(n,mm.copy(n).subtract(o));for(let i in e){if(i==="near")continue;let a=e[i],c=gm(a,r,Wc),l=$s(t,c,Wc);Xc.planes[s++].fromPointNormal(l,mm.copy(n).subtract(l))}}function gm(t,e,r=new x){let n=t.normal.dot(e);return r.copy(t.normal).scale(t.distance-n).add(e),r}function $s(t,e,r=new x){let n=t.unprojectPosition(e);return G.WGS84.cartographicToCartesian(n,r)}var cC=6378137,lC=6378137,Yc=6356752314245179e-9,Xr=new x;function bm(t,e){if(t instanceof Ze){let{halfAxes:r}=t,n=fC(r);return Math.log2(Yc/(n+e[2]))}else if(t instanceof He){let{radius:r}=t;return Math.log2(Yc/(r+e[2]))}else if(t.width&&t.height){let{width:r,height:n}=t,o=Math.log2(cC/r),s=Math.log2(lC/n);return(o+s)/2}return 1}function Kc(t,e,r){G.WGS84.cartographicToCartesian([t.xmax,t.ymax,t.zmax],Xr);let n=Math.sqrt(Math.pow(Xr[0]-r[0],2)+Math.pow(Xr[1]-r[1],2)+Math.pow(Xr[2]-r[2],2));return Math.log2(Yc/(n+e[2]))}function ym(t,e,r){let[n,o,s,i]=t;return Kc({xmin:n,xmax:s,ymin:o,ymax:i,zmin:0,zmax:0},e,r)}function fC(t){t.getColumn(0,Xr);let e=t.getColumn(1),r=t.getColumn(2);return Xr.add(e).add(r).len()}var Dm=D(Zt(),1);var Ce={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},be;(function(t){t[t.ADD=1]="ADD",t[t.REPLACE=2]="REPLACE"})(be||(be={}));var ze;(function(t){t.EMPTY="empty",t.SCENEGRAPH="scenegraph",t.POINTCLOUD="pointcloud",t.MESH="mesh"})(ze||(ze={}));var pe;(function(t){t.I3S="I3S",t.TILES3D="TILES3D"})(pe||(pe={}));var bt;(function(t){t.GEOMETRIC_ERROR="geometricError",t.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(bt||(bt={}));var Tm={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function Sm(t){return t!=null}var ye=new x,ei=new x,uC=new x,hC=new x,pr=new x,Em=new x,_m=new x,Mm=new x;function ti(t,e,r){if(V(t,"3D Tile: boundingVolume must be defined"),t.box)return Bm(t.box,e,r);if(t.region)return dC(t.region);if(t.sphere)return pC(t.sphere,e,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Cm(t,e){if(t.box)return mC(e);if(t.region){let[r,n,o,s,i,a]=t.region;return[[Fe(r),Fe(n),i],[Fe(o),Fe(s),a]]}if(t.sphere)return gC(e);throw new Error("Unkown boundingVolume type")}function Bm(t,e,r){let n=new x(t[0],t[1],t[2]);e.transform(n,n);let o=[];if(t.length===10){let l=t.slice(3,6),f=new ot;f.fromArray(t,6);let u=new x([1,0,0]),h=new x([0,1,0]),p=new x([0,0,1]);u.transformByQuaternion(f),u.scale(l[0]),h.transformByQuaternion(f),h.scale(l[1]),p.transformByQuaternion(f),p.scale(l[2]),o=[...u.toArray(),...h.toArray(),...p.toArray()]}else o=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];let s=e.transformAsVector(o.slice(0,3)),i=e.transformAsVector(o.slice(3,6)),a=e.transformAsVector(o.slice(6,9)),c=new j([s[0],s[1],s[2],i[0],i[1],i[2],a[0],a[1],a[2]]);return Sm(r)?(r.center=n,r.halfAxes=c,r):new Ze(n,c)}function pC(t,e,r){let n=new x(t[0],t[1],t[2]);e.transform(n,n);let o=e.getScale(ei),s=Math.max(Math.max(o[0],o[1]),o[2]),i=t[3]*s;return Sm(r)?(r.center=n,r.radius=i,r):new He(n,i)}function dC(t){let[e,r,n,o,s,i]=t,a=G.WGS84.cartographicToCartesian([Fe(e),Fe(o),s],uC),c=G.WGS84.cartographicToCartesian([Fe(n),Fe(r),i],hC),l=new x().addVectors(a,c).multiplyByScalar(.5);return G.WGS84.cartesianToCartographic(l,pr),G.WGS84.cartographicToCartesian([Fe(n),pr[1],pr[2]],Em),G.WGS84.cartographicToCartesian([pr[0],Fe(o),pr[2]],_m),G.WGS84.cartographicToCartesian([pr[0],pr[1],i],Mm),Bm([...l,...Em.subtract(l),..._m.subtract(l),...Mm.subtract(l)],new N)}function mC(t){let e=Im(),{halfAxes:r}=t,n=new x(r.getColumn(0)),o=new x(r.getColumn(1)),s=new x(r.getColumn(2));for(let i=0;i<2;i++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)ye.copy(t.center),ye.add(n),ye.add(o),ye.add(s),Rm(e,ye),s.negate();o.negate()}n.negate()}return e}function gC(t){let e=Im(),{center:r,radius:n}=t,o=G.WGS84.scaleToGeodeticSurface(r,ye),s;o?s=G.WGS84.geodeticSurfaceNormal(o):s=new x(0,0,1);let i=new x(s[2],-s[1],0);i.len()>0?i.normalize():i=new x(0,1,0);let a=i.clone().cross(s);for(let c of[i,a,s]){ei.copy(c).scale(n);for(let l=0;l<2;l++)ye.copy(r),ye.add(ei),Rm(e,ye),ei.negate()}return e}function Im(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Rm(t,e){G.WGS84.cartesianToCartographic(e,ye),t[0][0]=Math.min(t[0][0],ye[0]),t[0][1]=Math.min(t[0][1],ye[1]),t[0][2]=Math.min(t[0][2],ye[2]),t[1][0]=Math.max(t[1][0],ye[0]),t[1][1]=Math.max(t[1][1],ye[1]),t[1][2]=Math.max(t[1][2],ye[2])}var X4=new x,Y4=new x,K4=new N,Q4=new x,Z4=new x,$4=new x;function AC(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function xC(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){let r=t.dynamicScreenSpaceErrorComputedDensity,n=t.dynamicScreenSpaceErrorFactor;return AC(e,r)*n}return 0}function vm(t,e,r){let n=t.tileset,o=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,s=r?o:t.lodMetricValue;if(s===0)return 0;let i=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:c}=e,{viewDistanceScale:l}=n.options,f=s*a*(l||1)/(i*c);return f-=xC(n,i),f}var Qc=new x,wm=new x,Gt=new x,Lm=new x,bC=new x,Zc=new N,Fm=new N;function Pm(t,e){if(t.lodMetricValue===0||isNaN(t.lodMetricValue))return"DIG";let r=2*$c(t,e);return r<2?"OUT":!t.header.children||r<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function $c(t,e){let{topDownViewport:r}=e,n=t.header.mbs[1],o=t.header.mbs[0],s=t.header.mbs[2],i=t.header.mbs[3],a=[...t.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);G.WGS84.cartographicToCartesian(c,Qc),wm.copy(Qc).subtract(a).normalize(),G.WGS84.eastNorthUpToFixedFrame(a,Zc),Fm.copy(Zc).invert(),Gt.copy(Qc).transform(Fm);let l=Math.sqrt(Gt[0]*Gt[0]+Gt[1]*Gt[1]),f=l*l/Gt[2];Lm.copy([Gt[0],Gt[1],f]);let h=Lm.transform(Zc).subtract(a).normalize(),d=wm.cross(h).normalize().scale(i).add(a),A=G.WGS84.cartesianToCartographic(d),m=r.project([o,n,s]),b=r.project(A);return bC.copy(m).subtract(b).magnitude()}function Nm(t){return{assetGltfUpAxis:t.asset&&t.asset.gltfUpAxis||"Y"}}var co=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return V(e<this._array.length),this._array[e]}set(e,r){V(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){V(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){V(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var yC={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},ft=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new co;_emptyTraversalStack=new co;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...yC,...e}}traverse(e,r,n){this.root=e,this.options={...this.options,...n},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let n=this._traversalStack;for(e._selectionDepth=1,n.push(e);n.length>0;){let s=n.pop(),i=!1;this.canTraverse(s,r)&&(this.updateChildTiles(s,r),i=this.updateAndPushChildren(s,r,n,s.hasRenderContent?s._selectionDepth+1:s._selectionDepth));let a=s.parent,c=Boolean(!a||a._shouldRefine),l=!i;s.hasRenderContent?s.refine===be.ADD?(this.loadTile(s,r),this.selectTile(s,r)):s.refine===be.REPLACE&&(this.loadTile(s,r),l&&this.selectTile(s,r)):(this.emptyTiles[s.id]=s,this.loadTile(s,r),l&&this.selectTile(s,r)),this.touchTile(s,r),s._shouldRefine=i&&c}let o=new Date().getTime();(this.traversalFinished(r)||o-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=o,this.options.onTraversalEnd(r))}updateChildTiles(e,r){let n=e.children;for(let o of n)this.updateTile(o,r)}updateAndPushChildren(e,r,n,o){let{loadSiblings:s,skipLevelOfDetail:i}=this.options,a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let c=e.refine===be.REPLACE&&e.hasRenderContent&&!i,l=!1,f=!0;for(let u of a)if(u._selectionDepth=o,u.isVisibleAndInRequestVolume?(n.find(u)&&n.delete(u),n.push(u),l=!0):(c||s)&&(this.loadTile(u,r),this.touchTile(u,r)),c){let h;if(u._inRequestVolume?u.hasRenderContent?h=u.contentAvailable:h=this.executeEmptyTraversal(u,r):h=!1,f=f&&h,!f)return!1}return l||(f=!1),f}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){this.shouldLoadTile(e)&&(e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,r):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,r,n=!1){let o=e._screenSpaceError;return n&&(o=e.getScreenSpaceError(r,!0)),o>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let n=[];if(this.options.viewportTraversersMap)for(let o in this.options.viewportTraversersMap)this.options.viewportTraversersMap[o]===r.viewport.id&&n.push(o);else n.push(r.viewport.id);e.updateVisibility(r,n)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let n=!1;for(let o of e.children)o.updateVisibility(r),n=n||o.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,r){let n=!0,o=this._emptyTraversalStack;for(o.push(e);o.length>0;){let s=o.pop(),i=!s.hasRenderContent&&this.canTraverse(s,r),a=!s.hasRenderContent&&s.children.length===0;if(!i&&!s.contentAvailable&&!a&&(n=!1),this.updateTile(s,r),s.isVisibleAndInRequestVolume||(this.loadTile(s,r),this.touchTile(s,r)),i){let c=s.children;for(let l of c)o.push(l)}}return e.hasEmptyContent||n}};var Om=new x;function TC(t){return t!=null}var dr=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Ce.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new N;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new ft({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new N;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(e,r,n,o=""){this.header=r,this.tileset=e,this.id=o||r.id,this.url=r.url,this.parent=n,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this._initializeLodMetric(r),this._initializeTransforms(r),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Ce.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Ce.UNLOADED}get contentExpired(){return this.contentState===Ce.EXPIRED}get contentFailed(){return this.contentState===Ce.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Cm(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,r){switch(this.tileset.type){case pe.I3S:return $c(this,e);case pe.TILES3D:return vm(this,e,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let e=this.tileset._traverser,{skipLevelOfDetail:r}=e.options,n=this.refine===be.ADD||r;if(n&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Ce.UNLOADED)return-1;let o=this.parent,i=o&&(!n||this._screenSpaceError===0||o.hasTilesetContent)?o._screenSpaceError:this._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-i,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Ce.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Ce.UNLOADED,!1;try{let n=this.tileset.getTileUrl(this.contentUrl),o=this.tileset.loader,s=this.tileset.loadOptions[o.id]||{},i={...this.tileset.loadOptions,[o.id]:{...s,isTileset:this.type==="json",...this._getLoaderSpecificOptions(o.id)}};return this.content=await(0,Dm.load)(n,o,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Ce.READY,this._onContentLoaded(),!0}catch(n){throw this.contentState=Ce.FAILED,n}finally{r.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Ce.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let n=this.parent,o=n?n._visibilityPlaneMask:ce.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let s=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(s)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,o),this._visible=this._visibilityPlaneMask!==ce.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}visibility(e,r){let{cullingVolume:n}=e,{boundingVolume:o}=this;return n.computeVisibilityWithPlaneMask(o,r)}contentVisibility(){return!0}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return Om.subVectors(r.center,e.position),e.direction.dot(Om)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(TC(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=Ce.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new N(e.transform):new N;let r=this.parent,n=this.tileset,o=r&&r.computedTransform?r.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new N(o).multiplyRight(this.transform);let s=r&&r._initialTransform?r._initialTransform.clone():new N;this._initialTransform=new N(s).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Ce.UNLOADED,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=ce.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||be.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=ti(e.boundingVolume,this.computedTransform,this.boundingVolume);let r=e.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=ti(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=ti(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new N){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return Nm(this.tileset.tileset)}}};var ri=class extends ft{compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let n=e.children.length>0;if(e.hasTilesetContent&&n){let i=e.children[0];this.updateTileVisibility(i,r),e._visible=i._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let o=e.refine===be.REPLACE,s=e._optimChildrenWithinParent===Tm.USE_OPTIMIZATION;if(o&&s&&n&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:n}=e;return!n||n.hasTilesetContent||n.refine!==be.ADD?!1:!this.shouldRefine(e,r,!0)}};var Um=D(Zt(),1);var ni=class{frameNumberMap=new Map;register(e,r){let n=this.frameNumberMap.get(e)||new Map,o=n.get(r)||0;n.set(r,o+1),this.frameNumberMap.set(e,n)}deregister(e,r){let n=this.frameNumberMap.get(e);if(!n)return;let o=n.get(r)||1;n.set(r,o-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var el={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},oi=class{_statusMap;pendingTilesRegister=new ni;constructor(){this._statusMap={}}add(e,r,n,o){if(!this._statusMap[r]){let{frameNumber:s,viewport:{id:i}}=o;this._statusMap[r]={request:e,callback:n,key:r,frameState:o,status:el.REQUESTED},this.pendingTilesRegister.register(i,s),e().then(a=>{this._statusMap[r].status=el.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,o)}).catch(a=>{this._statusMap[r].status=el.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),n(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:n,viewport:{id:o}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(o,n);let{frameNumber:s,viewport:{id:i}}=r;this.pendingTilesRegister.register(i,s),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var si=class extends ft{_tileManager;constructor(e){super(e),this._tileManager=new oi}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=Pm(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let n=e.header.children||[],o=e.children,s=e.tileset;for(let i of n){let a=`${i.id}-${r.viewport.id}`,c=o&&o.find(l=>l.id===a);if(c)c&&this.updateTile(c,r);else{let l=()=>this._loadTile(i.id,s);this._tileManager.find(a)?this._tileManager.update(a,r):(s.tileset.nodePages&&(l=()=>s.tileset.nodePagesTile.formTileFromNodePages(i.id)),this._tileManager.add(l,a,u=>this._onTileLoad(u,e,a),r))}}return!1}async _loadTile(e,r){let{loader:n}=r,o=r.getTileUrl(`${r.url}/nodes/${e}`),s={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await(0,Um.load)(o,n,s)}_onTileLoad(e,r,n){let o=new dr(r.tileset,e,r,n);r.children.push(o);let s=this._tileManager.find(o.id).frameState;this.updateTile(o,s),this._frameNumber===s.frameNumber&&(this.traversalFinished(s)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(o,s)}};var EC={description:"",ellipsoid:G.WGS84,modelMatrix:new N,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},ii="Tiles In Tileset(s)",tl="Tiles In Memory",Gm="Tiles In View",Hm="Tiles To Render",Vm="Tiles Loaded",rl="Tiles Loading",zm="Tiles Unloaded",km="Failed Tile Loads",qm="Points/Vertices",nl="Tile Memory Use",jm="Maximum Screen Space Error",lo=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new Zs;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,r){this.options={...EC,...r},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||Lt.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new vt({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new Rt({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let n=e;return this.queryParams.length&&(n=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),n}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let n=[];for(let o of r){let s=o.id;this._needTraverse(s)?n.push(s):this.traverseCounter--}for(let o of r){let s=o.id;if(this.roots[s]||(this.roots[s]=this._initializeTileHeaders(this.tileset,null)),!n.includes(s))continue;let i=Am(o,this._frameNumber);this._traverser.traverse(this.roots[s],i,this.options)}}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],o=Object.values(this._traverser.selectedTiles),[s,i]=xm(o,e,this.options.maximumTilesSelected);n.selectedTiles=s;for(let a of i)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let s in this.frameStateData){let i=this.frameStateData[s];this.selectedTiles=this.selectedTiles.concat(i.selectedTiles),this._requestedTiles=this._requestedTiles.concat(i._requestedTiles),this._emptyTiles=this._emptyTiles.concat(i._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles.map(s=>s.id)),n=this.selectedTiles.some(s=>!s.tileDrawn),o=0;if(n){for(let s of r)this._heldTiles.add(s);for(let s of this._heldTiles){if(r.has(s))continue;let i=this._tiles[s];i&&i.contentAvailable?(i._selectedFrame=this._frameNumber,this.selectedTiles.push(i),o++):this._heldTiles.delete(s)}}else this._heldTiles=r;o>0&&setTimeout(()=>{this.selectTiles()},0);for(let s of this.selectedTiles)this._tiles[s.id]=s;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(e,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(e,r){if(e.length!==r.length)return!0;let n=new Set(e.map(i=>i.id)),o=new Set(r.map(i=>i.id)),s=e.filter(i=>!o.has(i.id)).length>0;return s=s||r.filter(i=>!n.has(i.id)).length>0,s}_loadTiles(){this._requestedTiles.sort((e,r)=>e._priority-r._priority);for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r))}_updateStats(){let e=0,r=0;for(let n of this.selectedTiles)n.contentAvailable&&n.content&&(e++,n.content.pointCount?r+=n.content.pointCount:r+=n.content.vertexCount);this.stats.get(Gm).count=this.selectedTiles.length,this.stats.get(Hm).count=e,this.stats.get(qm).count=r,this.stats.get(jm).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===pe.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===pe.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===pe.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let e=this.tileset.fullExtent;if(e){let{xmin:n,xmax:o,ymin:s,ymax:i,zmin:a,zmax:c}=e;this.cartographicCenter=new x(n+(o-n)/2,s+(i-s)/2,a+(c-a)/2),this.cartesianCenter=new x,G.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=Kc(e,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[n,o,s,i]=r;this.cartographicCenter=new x(n+(s-n)/2,o+(i-o)/2,0),this.cartesianCenter=new x,G.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=ym(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new x,this.zoom=1}calculateViewPropsTiles3D(){let e=this.root,{center:r}=e.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new x,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new x,G.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new x(0,0,-G.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=bm(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(ii),this.stats.get(rl),this.stats.get(tl),this.stats.get(Gm),this.stats.get(Hm),this.stats.get(Vm),this.stats.get(zm),this.stats.get(km),this.stats.get(qm),this.stats.get(nl,"memory"),this.stats.get(jm)}_initializeTileHeaders(e,r){let n=new dr(this,e.root,r);if(r&&(r.children.push(n),n.depth=r.depth+1),this.type===pe.TILES3D){let o=[];for(o.push(n);o.length>0;){let s=o.pop();this.stats.get(ii).incrementCount();let i=s.header.children||[];for(let a of i){let c=new dr(this,a,s);if(c.contentUrl?.includes("?session=")){let f=new URL(c.contentUrl).searchParams.get("session");f&&(this._queryParams.session=f)}s.children.push(c),c.depth=s.depth+1,o.push(c)}}}return n}_initializeTraverser(){let e;switch(this.type){case pe.TILES3D:e=ri;break;case pe.I3S:e=si;break;default:e=ft}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r;try{this._onStartTileLoading(),r=await e.loadContent()}catch(n){this._onTileLoadError(e,n instanceof Error?n:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}_onTileLoadError(e,r){this.stats.get(km).incrementCount();let n=r.message||r.toString(),o=e.url;console.error(`A 3D tile failed to load: ${e.url} ${n}`),this.options.onTileError(e,n,o)}_onTileLoad(e,r){if(r){if(this.type===pe.I3S){let n=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(ii).reset(),this.stats.get(ii).addCount(n)}e&&e.content&&dm(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===pe.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===pe.TILES3D){let{extensionsRemoved:r=[]}=e.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(rl).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(rl).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(Vm).incrementCount(),this.stats.get(tl).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(nl).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(tl).decrementCount(),this.stats.get(zm).incrementCount(),this.stats.get(nl).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let n of r.children)e.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,n=[];for(n.push(r);n.length>0;){e=n.pop();for(let o of e.children)n.push(o);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){let r=new URLSearchParams(e.queryString),n=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){let e=this.loadOptions.i3s;e&&typeof e=="object"&&"token"in e&&(this._queryParams.token=e.token)}};var ai="4.4.0-alpha.18";var mr={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},XH=Object.keys(mr);function ol(t,e,r){V(t instanceof ArrayBuffer);let n=new TextDecoder("utf8"),o=new Uint8Array(t,e,r);return n.decode(o)}function Jm(t,e=0){let r=new DataView(t);return`${String.fromCharCode(r.getUint8(e+0))}${String.fromCharCode(r.getUint8(e+1))}${String.fromCharCode(r.getUint8(e+2))}${String.fromCharCode(r.getUint8(e+3))}`}var _C="1.5.6",MC="1.4.1",sl=`https://www.gstatic.com/draco/versioned/decoders/${_C}`,de={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},fo={[de.DECODER]:`${sl}/${de.DECODER}`,[de.DECODER_WASM]:`${sl}/${de.DECODER_WASM}`,[de.FALLBACK_DECODER]:`${sl}/${de.FALLBACK_DECODER}`,[de.ENCODER]:`https://raw.githubusercontent.com/google/draco/${MC}/javascript/${de.ENCODER}`},il;async function Xm(t={},e){let r=t.modules||{};return r.draco3d?il||=r.draco3d.createDecoderModule({}).then(n=>({draco:n})):il||=SC(t,e),await il}function Wm(t,e){if(t&&typeof t=="object"){if(t.default)return t.default;if(t[e])return t[e]}return t}async function SC(t,e){let r,n;switch(e){case"js":r=await Ge(fo[de.FALLBACK_DECODER],"draco",t,de.FALLBACK_DECODER);break;case"wasm":default:try{[r,n]=await Promise.all([await Ge(fo[de.DECODER],"draco",t,de.DECODER),await Ge(fo[de.DECODER_WASM],"draco",t,de.DECODER_WASM)])}catch{r=null,n=null}}return r=Wm(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule,!r&&!pt&&([r,n]=await Promise.all([await Ge(fo[de.DECODER],"draco",{...t,useLocalLibraries:!0},de.DECODER),await Ge(fo[de.DECODER_WASM],"draco",{...t,useLocalLibraries:!0},de.DECODER_WASM)]),r=Wm(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule),await CC(r,n)}function CC(t,e){if(typeof t!="function")throw new Error("DracoDecoderModule could not be loaded");let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t({...r,onModuleLoaded:o=>n({draco:o})})})}var Ym="4.4.0-alpha.18";function Km(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function gr(t){let e=1/0,r=1/0,n=1/0,o=-1/0,s=-1/0,i=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let f=a[l],u=a[l+1],h=a[l+2];e=f<e?f:e,r=u<r?u:r,n=h<n?h:n,o=f>o?f:o,s=u>s?u:s,i=h>i?h:i}return[[e,r,n],[o,s,i]]}function al(t,e,r){let n=Km(e.value),o=r||Qm(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:n}]},nullable:!1,metadata:o}}function Qm(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}function $m(t,e,r){let n=eg(e.metadata),o=[],s=BC(e.attributes);for(let i in t){let a=t[i],c=Zm(i,a,s[i]);o.push(c)}if(r){let i=Zm("indices",r);o.push(i)}return{fields:o,metadata:n}}function BC(t){let e={};for(let r in t){let n=t[r];e[n.name||"undefined"]=n}return e}function Zm(t,e,r){let n=r?eg(r.metadata):void 0;return al(t,e,n)}function eg(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var tg={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},IC={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},RC=4,uo=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let o=this.decoder.GetEncodedGeometryType(n),s=o===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(o){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(n,s);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(n,s);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!s.ptr){let h=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(h)}let a=this._getDracoLoaderData(s,o,r),c=this._getMeshData(s,a,r),l=gr(c.attributes),f=$m(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:s.num_points(),boundingBox:l},...c,schema:f}}finally{this.draco.destroy(n),s&&this.draco.destroy(s)}}_getDracoLoaderData(e,r,n){let o=this._getTopLevelMetadata(e),s=this._getDracoAttributes(e,n);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:o,attributes:s}}_getDracoAttributes(e,r){let n={};for(let o=0;o<e.num_attributes();o++){let s=this.decoder.GetAttribute(e,o),i=this._getAttributeMetadata(e,o);n[s.unique_id()]={unique_id:s.unique_id(),attribute_type:s.attribute_type(),data_type:s.data_type(),num_components:s.num_components(),byte_offset:s.byte_offset(),byte_stride:s.byte_stride(),normalized:s.normalized(),attribute_index:o,metadata:i};let a=this._getQuantizationTransform(s,r);a&&(n[s.unique_id()].quantization_transform=a);let c=this._getOctahedronTransform(s,r);c&&(n[s.unique_id()].octahedron_transform=c)}return n}_getMeshData(e,r,n){let o=this._getMeshAttributes(r,e,n);if(!o.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(n.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:o,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:o,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:o}}_getMeshAttributes(e,r,n){let o={};for(let s of Object.values(e.attributes)){let i=this._deduceAttributeName(s,n);s.name=i;let a=this._getAttributeValues(r,s);if(a){let{value:c,size:l}=a;o[i]={value:c,size:l,byteOffset:s.byte_offset,byteStride:s.byte_stride,normalized:s.normalized}}}return o}_getTriangleListIndices(e){let n=e.num_faces()*3,o=n*RC,s=this.draco._malloc(o);try{return this.decoder.GetTrianglesUInt32Array(e,o,s),new Uint32Array(this.draco.HEAPF32.buffer,s,n).slice()}finally{this.draco._free(s)}}_getTriangleStripIndices(e){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,r),LC(r)}finally{this.draco.destroy(r)}}_getAttributeValues(e,r){let n=IC[r.data_type];if(!n)return console.warn(`DRACO: Unsupported attribute type ${r.data_type}`),null;let o=r.num_components,i=e.num_points()*o,a=i*n.BYTES_PER_ELEMENT,c=vC(this.draco,n),l,f=this.draco._malloc(a);try{let u=this.decoder.GetAttribute(e,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,u,c,a,f),l=new n(this.draco.HEAPF32.buffer,f,i).slice()}finally{this.draco._free(f)}return{value:l,size:o}}_deduceAttributeName(e,r){let n=e.unique_id;for(let[i,a]of Object.entries(r.extraAttributes||{}))if(a===n)return i;let o=e.attribute_type;for(let i in tg)if(this.draco[i]===o)return tg[i];let s=r.attributeNameEntry||"name";return e.metadata[s]?e.metadata[s].string:`CUSTOM_ATTRIBUTE_${n}`}_getTopLevelMetadata(e){let r=this.decoder.GetMetadata(e);return this._getDracoMetadata(r)}_getAttributeMetadata(e,r){let n=this.decoder.GetAttributeMetadata(e,r);return this._getDracoMetadata(n)}_getDracoMetadata(e){if(!e||!e.ptr)return{};let r={},n=this.metadataQuerier.NumEntries(e);for(let o=0;o<n;o++){let s=this.metadataQuerier.GetEntryName(e,o);r[s]=this._getDracoMetadataField(e,s)}return r}_getDracoMetadataField(e,r){let n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,r,n);let o=wC(n);return{int:this.metadataQuerier.GetIntEntry(e,r),string:this.metadataQuerier.GetStringEntry(e,r),double:this.metadataQuerier.GetDoubleEntry(e,r),intArray:o}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){let{quantizedAttributes:r=[],octahedronAttributes:n=[]}=e,o=[...r,...n];for(let s of o)this.decoder.SkipAttributeTransform(this.draco[s])}_getQuantizationTransform(e,r){let{quantizedAttributes:n=[]}=r,o=e.attribute_type();if(n.map(i=>this.decoder[i]).includes(o)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(a=>i.min_value(a))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:n=[]}=r,o=e.attribute_type();if(n.map(i=>this.decoder[i]).includes(o)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function vC(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function wC(t){let e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}function LC(t){let e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}var rg={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:Ym,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",extraAttributes:{},attributeNameEntry:void 0}}},ho={...rg,parse:FC};async function FC(t,e){let{draco:r}=await Xm(Dn(e),e?.draco?.decoderType||"wasm"),n=new uo(r);try{return n.parseSync(t,e?.draco)}finally{n.destroy()}}var PC={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ae={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},O={...PC,...ae};var cl={[ae.DOUBLE]:Float64Array,[ae.FLOAT]:Float32Array,[ae.UNSIGNED_SHORT]:Uint16Array,[ae.UNSIGNED_INT]:Uint32Array,[ae.UNSIGNED_BYTE]:Uint8Array,[ae.BYTE]:Int8Array,[ae.SHORT]:Int16Array,[ae.INT]:Int32Array},NC={DOUBLE:ae.DOUBLE,FLOAT:ae.FLOAT,UNSIGNED_SHORT:ae.UNSIGNED_SHORT,UNSIGNED_INT:ae.UNSIGNED_INT,UNSIGNED_BYTE:ae.UNSIGNED_BYTE,BYTE:ae.BYTE,SHORT:ae.SHORT,INT:ae.INT},ll="Failed to convert GL type",le=class{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(let r in cl)if(cl[r]===e)return r;throw new Error(ll)}static fromName(e){let r=NC[e];if(!r)throw new Error(ll);return r}static getArrayType(e){switch(e){case ae.UNSIGNED_SHORT_5_6_5:case ae.UNSIGNED_SHORT_4_4_4_4:case ae.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=cl[e];if(!r)throw new Error(ll);return r}}static getByteSize(e){return le.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(le.getArrayType(e))}static createTypedArray(e,r,n=0,o){o===void 0&&(o=(r.byteLength-n)/le.getByteSize(e));let s=ArrayBuffer.isView(r)?r.buffer:r,i=le.getArrayType(e);return new i(s,n,o)}};function ng(t,e){if(!t)throw new Error(`math.gl assertion failed. ${e}`)}function fl(t,e=[0,0,0]){let r=t>>11&31,n=t>>5&63,o=t&31;return e[0]=r<<3,e[1]=n<<2,e[2]=o<<3,e}var RV=1/256;var vV=new Xt,wV=new x,LV=new Xt,FV=new Xt,PV=new Uint8Array(1);function og(t,e=255){return es(t,0,e)/e*2-1}function sg(t){return t<0?-1:1}function ig(t,e,r,n){if(ng(n),t<0||t>r||e<0||e>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(n.x=og(t,r),n.y=og(e,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){let o=n.x;n.x=(1-Math.abs(n.y))*sg(o),n.y=(1-Math.abs(o))*sg(n.y)}return n.normalize()}function ul(t,e,r){return ig(t,e,255,r)}var yt=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,r){this.json=e,this.buffer=r}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,r=O.UNSIGNED_INT,n=1){let o=this.json[e];return o&&Number.isFinite(o.byteOffset)?this._getTypedArrayFromBinary(e,r,n,1,o.byteOffset):o}getPropertyArray(e,r,n){let o=this.json[e];return o&&Number.isFinite(o.byteOffset)?("componentType"in o&&(r=le.fromName(o.componentType)),this._getTypedArrayFromBinary(e,r,n,this.featuresLength,o.byteOffset)):this._getTypedArrayFromArray(e,r,o)}getProperty(e,r,n,o,s){let i=this.json[e];if(!i)return i;let a=this.getPropertyArray(e,r,n);if(n===1)return a[o];for(let c=0;c<n;++c)s[c]=a[n*o+c];return s}_getTypedArrayFromBinary(e,r,n,o,s){let i=this._cachedTypedArrays,a=i[e];return a||(a=le.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+s,o*n),i[e]=a),a}_getTypedArrayFromArray(e,r,n){let o=this._cachedTypedArrays,s=o[e];if(!s){if(ArrayBuffer.isView(n)){let i=n.byteOffset,c=n.byteLength/le.getByteSize(r);s=le.createTypedArray(r,n.buffer,i,c)}else if(n instanceof ArrayBuffer)s=le.createTypedArray(r,n);else{let i=le.getArrayType(r);s=new i(n)}o[e]=s}return s}};var OC={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},DC={SCALAR:(t,e)=>t[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},UC={SCALAR:(t,e,r)=>{e[r]=t},VEC2:(t,e,r)=>{e[2*r+0]=t[0],e[2*r+1]=t[1]},VEC3:(t,e,r)=>{e[3*r+0]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2]},VEC4:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT2:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT3:(t,e,r)=>{e[9*r+0]=t[0],e[9*r+1]=t[1],e[9*r+2]=t[2],e[9*r+3]=t[3],e[9*r+4]=t[4],e[9*r+5]=t[5],e[9*r+6]=t[6],e[9*r+7]=t[7],e[9*r+8]=t[8],e[9*r+9]=t[9]},MAT4:(t,e,r)=>{e[16*r+0]=t[0],e[16*r+1]=t[1],e[16*r+2]=t[2],e[16*r+3]=t[3],e[16*r+4]=t[4],e[16*r+5]=t[5],e[16*r+6]=t[6],e[16*r+7]=t[7],e[16*r+8]=t[8],e[16*r+9]=t[9],e[16*r+10]=t[10],e[16*r+11]=t[11],e[16*r+12]=t[12],e[16*r+13]=t[13],e[16*r+14]=t[14],e[16*r+15]=t[15]}};function ag(t,e,r,n){let{componentType:o}=t;V(t.componentType);let s=typeof o=="string"?le.fromName(o):o,i=OC[t.type],a=DC[t.type],c=UC[t.type];return r+=t.byteOffset,{values:le.createTypedArray(s,e,r,i*n),type:s,size:i,unpacker:a,packer:c}}var ut=t=>t!==void 0;function cg(t,e,r){if(!e)return null;let n=t.getExtension("3DTILES_batch_table_hierarchy"),o=e.HIERARCHY;return o&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=o,n=o),n?GC(n,r):null}function GC(t,e){let r,n,o,s=t.instancesLength,i=t.classes,a=t.classIds,c=t.parentCounts,l=t.parentIds,f=s;ut(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,o=getBinaryAccessor(a),a=o.createArrayBufferView(e.buffer,e.byteOffset+a.byteOffset,s));let u;if(ut(c))for(ut(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,o=getBinaryAccessor(c),c=o.createArrayBufferView(e.buffer,e.byteOffset+c.byteOffset,s)),u=new Uint16Array(s),f=0,r=0;r<s;++r)u[r]=f,f+=c[r];ut(l)&&ut(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,o=getBinaryAccessor(l),l=o.createArrayBufferView(e.buffer,e.byteOffset+l.byteOffset,f));let h=i.length;for(r=0;r<h;++r){let m=i[r].length,b=i[r].instances,T=getBinaryProperties(m,b,e);i[r].instances=combine(T,b)}let p=new Array(h).fill(0),d=new Uint16Array(s);for(r=0;r<s;++r)n=a[r],d[r]=p[n],++p[n];let A={classes:i,classIds:a,classIndexes:d,parentCounts:c,parentIndexes:u,parentIds:l};return zC(A),A}function Yr(t,e,r){if(!t)return;let n=t.parentCounts;return t.parentIds?r(t,e):n>0?HC(t,e,r):VC(t,e,r)}function HC(t,e,r){let n=t.classIds,o=t.parentCounts,s=t.parentIds,i=t.parentIndexes,a=n.length,c=scratchVisited;c.length=Math.max(c.length,a);let l=++marker,f=scratchStack;for(f.length=0,f.push(e);f.length>0;){if(e=f.pop(),c[e]===l)continue;c[e]=l;let u=r(t,e);if(ut(u))return u;let h=o[e],p=i[e];for(let d=0;d<h;++d){let A=s[p+d];A!==e&&f.push(A)}}return null}function VC(t,e,r){let n=!0;for(;n;){let o=r(t,e);if(ut(o))return o;let s=t.parentIds[e];n=s!==e,e=s}throw new Error("traverseHierarchySingleParent")}function zC(t){let e=[],n=t.classIds.length;for(let o=0;o<n;++o)lg(t,o,stack)}function lg(t,e,r){let n=t.parentCounts,o=t.parentIds,s=t.parentIndexes,a=t.classIds.length;if(!ut(o))return;assert(e<a,`Parent index ${e} exceeds the total number of instances: ${a}`),assert(r.indexOf(e)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(e);let c=ut(n)?n[e]:1,l=ut(n)?s[e]:e;for(let f=0;f<c;++f){let u=o[l+f];u!==e&&lg(t,u,r)}r.pop(e)}function Re(t){return t!=null}var ci=(t,e)=>t,kC={HIERARCHY:!0,extensions:!0,extras:!0},Ar=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,r,n,o={}){V(n>=0),this.json=e||{},this.binary=r,this.featureCount=n,this._extensions=this.json?.extensions||{},this._properties={};for(let s in this.json)kC[s]||(this._properties[s]=this.json[s]);this._binaryProperties=this._initializeBinaryProperties(),o["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=cg(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,r){if(this._checkBatchId(e),V(typeof r=="string",r),this._hierarchy){let n=Yr(this._hierarchy,e,(o,s)=>{let i=o.classIds[s];return o.classes[i].name===r});return Re(n)}return!1}isExactClass(e,r){return V(typeof r=="string",r),this.getExactClassName(e)===r}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){let r=this._hierarchy.classIds[e];return this._hierarchy.classes[r].name}}hasProperty(e,r){return this._checkBatchId(e),V(typeof r=="string",r),Re(this._properties[r])||this._hasPropertyInHierarchy(e,r)}getPropertyNames(e,r){this._checkBatchId(e),r=Re(r)?r:[],r.length=0;let n=Object.keys(this._properties);return r.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(e,r),r}getProperty(e,r){if(this._checkBatchId(e),V(typeof r=="string",r),this._binaryProperties){let o=this._binaryProperties[r];if(Re(o))return this._getBinaryProperty(o,e)}let n=this._properties[r];if(Re(n))return ci(n[e],!0);if(this._hierarchy){let o=this._getHierarchyProperty(e,r);if(Re(o))return o}}setProperty(e,r,n){let o=this.featureCount;if(this._checkBatchId(e),V(typeof r=="string",r),this._binaryProperties){let i=this._binaryProperties[r];if(i){this._setBinaryProperty(i,e,n);return}}if(this._hierarchy&&this._setHierarchyProperty(this,e,r,n))return;let s=this._properties[r];Re(s)||(this._properties[r]=new Array(o),s=this._properties[r]),s[e]=ci(n,!0)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,r){return e.unpack(e.typedArray,r)}_setBinaryProperty(e,r,n){e.pack(n,e.typedArray,r)}_initializeBinaryProperties(){let e=null;for(let r in this._properties){let n=this._properties[r],o=this._initializeBinaryProperty(r,n);o&&(e=e||{},e[r]=o)}return e}_initializeBinaryProperty(e,r){if("byteOffset"in r){let n=r;V(this.binary,`Property ${e} requires a batch table binary.`),V(n.type,`Property ${e} requires a type.`);let o=ag(n,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:o.values,componentCount:o.size,unpack:o.unpacker,pack:o.packer}}return null}_hasPropertyInHierarchy(e,r){if(!this._hierarchy)return!1;let n=Yr(this._hierarchy,e,(o,s)=>{let i=o.classIds[s],a=o.classes[i].instances;return Re(a[r])});return Re(n)}_getPropertyNamesInHierarchy(e,r){Yr(this._hierarchy,e,(n,o)=>{let s=n.classIds[o],i=n.classes[s].instances;for(let a in i)i.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(e,r){return Yr(this._hierarchy,e,(n,o)=>{let s=n.classIds[o],i=n.classes[s],a=n.classIndexes[o],c=i.instances[r];return Re(c)?Re(c.typedArray)?this._getBinaryProperty(c,a):ci(c[a],!0):null})}_setHierarchyProperty(e,r,n,o){let s=Yr(this._hierarchy,r,(i,a)=>{let c=i.classIds[a],l=i.classes[c],f=i.classIndexes[a],u=l.instances[n];return Re(u)?(V(a===r,`Inherited property "${n}" is read-only.`),Re(u.typedArray)?this._setBinaryProperty(u,f,o):u[f]=ci(o,!0),!0):!1});return Re(s)}};function Ht(t,e,r=0){let n=new DataView(e);if(t.magic=n.getUint32(r,!0),r+=4,t.version=n.getUint32(r,!0),r+=4,t.byteLength=n.getUint32(r,!0),r+=4,t.version!==1)throw new Error(`3D Tile Version ${t.version} not supported`);return r}var Kr=4,fg="b3dm tile in legacy format.";function Qr(t,e,r){let n=new DataView(e),o;t.header=t.header||{};let s=n.getUint32(r,!0);r+=Kr;let i=n.getUint32(r,!0);r+=Kr;let a=n.getUint32(r,!0);r+=Kr;let c=n.getUint32(r,!0);return r+=Kr,a>=570425344?(r-=Kr*2,o=s,a=i,c=0,s=0,i=0,console.warn(fg)):c>=570425344&&(r-=Kr,o=a,a=s,c=i,s=0,i=0,console.warn(fg)),t.header.featureTableJsonByteLength=s,t.header.featureTableBinaryByteLength=i,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=c,t.header.batchLength=o,r}function Zr(t,e,r,n){return r=qC(t,e,r,n),r=jC(t,e,r,n),r}function qC(t,e,r,n){let{featureTableJsonByteLength:o,featureTableBinaryByteLength:s,batchLength:i}=t.header||{};if(t.featureTableJson={BATCH_LENGTH:i||0},o&&o>0){let a=ol(e,r,o);t.featureTableJson=JSON.parse(a)}return r+=o||0,t.featureTableBinary=new Uint8Array(e,r,s),r+=s||0,r}function jC(t,e,r,n){let{batchTableJsonByteLength:o,batchTableBinaryByteLength:s}=t.header||{};if(o&&o>0){let i=ol(e,r,o);t.batchTableJson=JSON.parse(i),r+=o,s&&s>0&&(t.batchTableBinary=new Uint8Array(e,r,s),t.batchTableBinary=new Uint8Array(t.batchTableBinary),r+=s)}return r}function hl(t,e,r){if(!e&&(!t||!t.batchIds||!r))return null;let{batchIds:n,isRGB565:o,pointCount:s=0}=t;if(n&&r){let i=new Uint8ClampedArray(s*3);for(let a=0;a<s;a++){let c=n[a],f=r.getProperty(c,"dimensions").map(u=>u*255);i[a*3]=f[0],i[a*3+1]=f[1],i[a*3+2]=f[2]}return{type:O.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}if(e&&o){let i=new Uint8ClampedArray(s*3);for(let a=0;a<s;a++){let c=fl(e[a]);i[a*3]=c[0],i[a*3+1]=c[1],i[a*3+2]=c[2]}return{type:O.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}return e&&e.length===s*3?{type:O.UNSIGNED_BYTE,value:e,size:3,normalized:!0}:{type:O.UNSIGNED_BYTE,value:e||new Uint8ClampedArray,size:4,normalized:!0}}var ug=new x;function hg(t,e){if(!e)return null;if(t.isOctEncoded16P){let r=new Float32Array((t.pointsLength||0)*3);for(let n=0;n<(t.pointsLength||0);n++)ul(e[n*2],e[n*2+1],ug),ug.toArray(r,n*3);return{type:O.FLOAT,size:2,value:r}}return{type:O.FLOAT,size:2,value:e}}function pg(t,e,r){return t.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(t.isQuantized=!1,JC(t,e)):{type:O.UNSIGNED_SHORT,value:e,size:3,normalized:!0}:e}function JC(t,e){let r=new x,n=new Float32Array(t.pointCount*3);for(let o=0;o<t.pointCount;o++)r.set(e[o*3],e[o*3+1],e[o*3+2]).scale(1/t.quantizedRange).multiply(t.quantizedVolumeScale).add(t.quantizedVolumeOffset).toArray(n,o*3);return n}async function dg(t,e,r,n,o){r=Ht(t,e,r),r=Qr(t,e,r),r=Zr(t,e,r,n),WC(t);let{featureTable:s,batchTable:i}=XC(t);return await $C(t,s,i,n,o),YC(t,s,n),KC(t,s,i),QC(t,s),r}function WC(t){t.attributes={positions:null,colors:null,normals:null,batchIds:null},t.isQuantized=!1,t.isTranslucent=!1,t.isRGB565=!1,t.isOctEncoded16P=!1}function XC(t){let e=new yt(t.featureTableJson,t.featureTableBinary),r=e.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");e.featuresLength=r,t.featuresLength=r,t.pointsLength=r,t.pointCount=r,t.rtcCenter=e.getGlobalProperty("RTC_CENTER",O.FLOAT,3);let n=ZC(t,e);return{featureTable:e,batchTable:n}}function YC(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.positions){if(e.hasProperty("POSITION"))t.attributes.positions=e.getPropertyArray("POSITION",O.FLOAT,3);else if(e.hasProperty("POSITION_QUANTIZED")){let n=e.getPropertyArray("POSITION_QUANTIZED",O.UNSIGNED_SHORT,3);if(t.isQuantized=!0,t.quantizedRange=(1<<16)-1,t.quantizedVolumeScale=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",O.FLOAT,3),!t.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(t.quantizedVolumeOffset=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",O.FLOAT,3),!t.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");t.attributes.positions=pg(t,n,r)}}if(!t.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function KC(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.colors){let n=null;e.hasProperty("RGBA")?(n=e.getPropertyArray("RGBA",O.UNSIGNED_BYTE,4),t.isTranslucent=!0):e.hasProperty("RGB")?n=e.getPropertyArray("RGB",O.UNSIGNED_BYTE,3):e.hasProperty("RGB565")&&(n=e.getPropertyArray("RGB565",O.UNSIGNED_SHORT,1),t.isRGB565=!0),t.attributes.colors=hl(t,n,r)}e.hasProperty("CONSTANT_RGBA")&&(t.constantRGBA=e.getGlobalProperty("CONSTANT_RGBA",O.UNSIGNED_BYTE,4))}function QC(t,e){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.normals){let r=null;e.hasProperty("NORMAL")?r=e.getPropertyArray("NORMAL",O.FLOAT,3):e.hasProperty("NORMAL_OCT16P")&&(r=e.getPropertyArray("NORMAL_OCT16P",O.UNSIGNED_BYTE,2),t.isOctEncoded16P=!0),t.attributes.normals=hg(t,r)}}function ZC(t,e){let r=null;if(!t.batchIds&&e.hasProperty("BATCH_ID")&&(t.batchIds=e.getPropertyArray("BATCH_ID",O.UNSIGNED_SHORT,1),t.batchIds)){let n=e.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");let{batchTableJson:o,batchTableBinary:s}=t;r=new Ar(o,s,n)}return r}async function $C(t,e,r,n,o){let s,i,a,c=t.batchTableJson&&t.batchTableJson.extensions&&t.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);let l=e.getExtension("3DTILES_draco_point_compression");if(l){i=l.properties;let u=l.byteOffset,h=l.byteLength;if(!i||!Number.isFinite(u)||!h)throw new Error("Draco properties, byteOffset, and byteLength must be defined");s=(t.featureTableBinary||[]).slice(u,u+h),t.hasPositions=Number.isFinite(i.POSITION),t.hasColors=Number.isFinite(i.RGB)||Number.isFinite(i.RGBA),t.hasNormals=Number.isFinite(i.NORMAL),t.hasBatchIds=Number.isFinite(i.BATCH_ID),t.isTranslucent=Number.isFinite(i.RGBA)}if(!s)return!0;let f={buffer:s,properties:{...i,...a},featureTableProperties:i,batchTableProperties:a,dequantizeInShader:!1};return await eB(t,f,n,o)}async function eB(t,e,r,n){if(!n)return;let o={...r,draco:{...r?.draco,extraAttributes:e.batchTableProperties||{}}};delete o["3d-tiles"];let s=await Ne(e.buffer,ho,o,n),i=s.attributes.POSITION&&s.attributes.POSITION.value,a=s.attributes.COLOR_0&&s.attributes.COLOR_0.value,c=s.attributes.NORMAL&&s.attributes.NORMAL.value,l=s.attributes.BATCH_ID&&s.attributes.BATCH_ID.value,f=i&&s.attributes.POSITION.value.quantization,u=c&&s.attributes.NORMAL.value.quantization;if(f){let p=s.POSITION.data.quantization,d=p.range;t.quantizedVolumeScale=new x(d,d,d),t.quantizedVolumeOffset=new x(p.minValues),t.quantizedRange=(1<<p.quantizationBits)-1,t.isQuantizedDraco=!0}u&&(t.octEncodedRange=(1<<s.NORMAL.data.quantization.quantizationBits)-1,t.isOctEncodedDraco=!0);let h={};if(e.batchTableProperties)for(let p of Object.keys(e.batchTableProperties))s.attributes[p]&&s.attributes[p].value&&(h[p.toLowerCase()]=s.attributes[p].value);t.attributes={positions:i,colors:hl(t,a,void 0),normals:c,batchIds:l,...h}}var pl={};xe(pl,{createExtMeshFeatures:()=>AB,decode:()=>hB,encode:()=>pB,name:()=>uB});function fe(t,e){if(!t)throw new Error(e||"assert failed: gltf")}var li={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fi={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var tB=1.33,mg=["SCALAR","VEC2","VEC3","VEC4"],rB=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],nB=new Map(rB),oB={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},sB={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},iB={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function ui(t){return mg[t-1]||mg[0]}function Vt(t){let e=nB.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function $r(t,e){let r=iB[t.componentType],n=oB[t.type],o=sB[t.componentType],s=t.count*n,i=t.count*n*o;fe(i>=0&&i<=e.byteLength);let a=fi[t.componentType],c=li[t.type];return{ArrayType:r,length:s,byteLength:i,componentByteSize:a,numberOfComponentsInElement:c}}function po(t){let{images:e,bufferViews:r}=t;e=e||[],r=r||[];let n=e.map(i=>i.bufferView);r=r.filter(i=>!n.includes(i));let o=r.reduce((i,a)=>i+a.byteLength,0),s=e.reduce((i,a)=>{let{width:c,height:l}=a.image;return i+c*l},0);return o+Math.ceil(4*s*tB)}function gg(t,e,r){let n=t.bufferViews[r];fe(n);let o=n.buffer,s=e[o];fe(s);let i=(n.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,i,n.byteLength)}function Ag(t,e,r){let n=typeof r=="number"?t.accessors?.[r]:r;if(!n)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let o=t.bufferViews?.[n.bufferView||0];if(!o)throw new Error(`No gltf buffer view for accessor ${o}`);let{arrayBuffer:s,byteOffset:i}=e[o.buffer],a=(i||0)+(n.byteOffset||0)+(o.byteOffset||0),{ArrayType:c,length:l,componentByteSize:f,numberOfComponentsInElement:u}=$r(n,o),h=f*u,p=o.byteStride||h;if(typeof o.byteStride>"u"||o.byteStride===h)return new c(s,a,l);let d=new c(l);for(let A=0;A<n.count;A++){let m=new c(s,a+A*p,u);d.set(m,A*u)}return d}function aB(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}var k=class{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||aB(),buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){let r=this.getUsedExtensions().find(o=>o===e),n=this.getRequiredExtensions().find(o=>o===e);return typeof r=="string"||typeof n=="string"}getExtension(e){let r=this.getUsedExtensions().find(o=>o===e),n=this.json.extensions||{};return r?n[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(n=>n===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,r){return(e.extensions||{})[r]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,r){if(typeof r=="object")return r;let n=this.json[e]&&this.json[e][r];if(!n)throw new Error(`glTF file error: Could not find ${e}[${r}]`);return n}getTypedArrayForBufferView(e){e=this.getBufferView(e);let r=e.buffer,n=this.gltf.buffers[r];fe(n);let o=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,o,e.byteLength)}getTypedArrayForAccessor(e){let r=this.getAccessor(e);return Ag(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);let r=this.getBufferView(e.bufferView),o=this.getBuffer(r.buffer).data,s=r.byteOffset||0;return new Uint8Array(o,s,r.byteLength)}addApplicationData(e,r){return this.json[e]=r,this}addExtraData(e,r){return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addObjectExtension(e,r,n){return e.extensions=e.extensions||{},e.extensions[r]=n,this.registerUsedExtension(r),this}setObjectExtension(e,r,n){let o=e.extensions||{};o[r]=n}removeObjectExtension(e,r){let n=e?.extensions||{};if(n[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let o=this.json.extensionsRemoved;o.includes(r)||o.push(r)}delete n[r]}addExtension(e,r={}){return fe(r),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),r}addRequiredExtension(e,r={}){return fe(r),this.addExtension(e,r),this.registerRequiredExtension(e),r}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(e)||r.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){let{nodeIndices:r}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(e){let{meshIndex:r,matrix:n}=e;this.json.nodes=this.json.nodes||[];let o={mesh:r};return n&&(o.matrix=n),this.json.nodes.push(o),this.json.nodes.length-1}addMesh(e){let{attributes:r,indices:n,material:o,mode:s=4}=e,a={primitives:[{attributes:this._addAttributes(r),mode:s}]};if(n){let c=this._addIndices(n);a.primitives[0].indices=c}return Number.isFinite(o)&&(a.primitives[0].material=o),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){let n={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(n),this.json.meshes.length-1}addImage(e,r){let n=ar(e),o=r||n?.mimeType,i={bufferView:this.addBufferView(e),mimeType:o};return this.json.images=this.json.images||[],this.json.images.push(i),this.json.images.length-1}addBufferView(e,r=0,n=this.byteLength){let o=e.byteLength;fe(Number.isFinite(o)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);let s={buffer:r,byteOffset:n,byteLength:o};return this.byteLength+=It(o,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(s),this.json.bufferViews.length-1}addAccessor(e,r){let n={bufferView:e,type:ui(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e,r={size:3}){let n=this.addBufferView(e),o={min:r.min,max:r.max};(!o.min||!o.max)&&(o=this._getAccessorMinMax(e,r.size));let s={size:r.size,componentType:Vt(e),count:Math.round(e.length/r.size),min:o.min,max:o.max};return this.addAccessor(n,Object.assign(s,r))}addTexture(e){let{imageIndex:r}=e,n={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){let e=this.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r),o=0;for(let s of this.sourceBuffers||[])o=cc(s,n,o);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=r,this.sourceBuffers=[r],this.gltf.buffers=[{arrayBuffer:r,byteOffset:0,byteLength:r.byteLength}]}_removeStringFromArray(e,r){let n=!0;for(;n;){let o=e.indexOf(r);o>-1?e.splice(o,1):n=!1}}_addAttributes(e={}){let r={};for(let n in e){let o=e[n],s=this._getGltfAttributeName(n),i=this.addBinaryBuffer(o.value,o);r[s]=i}return r}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,r){let n={min:null,max:null};if(e.length<r)return n;n.min=[],n.max=[];let o=e.subarray(0,r);for(let s of o)n.min.push(s),n.max.push(s);for(let s=r;s<e.length;s+=r)for(let i=0;i<r;i++)n.min[0+i]=Math.min(n.min[0+i],e[s+i]),n.max[0+i]=Math.max(n.max[0+i],e[s+i]);return n}};function xg(t){return(t%1+1)%1}var bg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},cB={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},yg={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function mo(t,e){return yg[e]*bg[t]}function en(t,e,r,n){if(r!=="UINT8"&&r!=="UINT16"&&r!=="UINT32"&&r!=="UINT64")return null;let o=t.getTypedArrayForBufferView(e),s=tn(o,"SCALAR",r,n+1);return s instanceof BigInt64Array||s instanceof BigUint64Array?null:s}function tn(t,e,r,n=1){let o=bg[e],s=cB[r],i=yg[r],a=n*o,c=a*i,l=t.buffer,f=t.byteOffset;return f%i!==0&&(l=new Uint8Array(l).slice(f,f+c).buffer,f=0),new s(wt(l),f,a)}function rn(t,e,r){let n=`TEXCOORD_${e.texCoord||0}`,o=r.attributes[n],s=t.getTypedArrayForAccessor(o),i=t.gltf.json,a=e.index,c=i.textures?.[a]?.source;if(typeof c<"u"){let l=i.images?.[c]?.mimeType,f=t.gltf.images?.[c];if(f&&typeof f.width<"u"){let u=[];for(let h=0;h<s.length;h+=2){let p=lB(f,l,s,h,e.channels);u.push(p)}return u}}return[]}function hi(t,e,r,n,o){if(!r?.length)return;let s=[];for(let f of r){let u=n.findIndex(h=>h===f);u===-1&&(u=n.push(f)-1),s.push(u)}let i=new Uint32Array(s),a=t.gltf.buffers.push({arrayBuffer:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength})-1,c=t.addBufferView(i,a,0),l=t.addAccessor(c,{size:1,componentType:Vt(i),count:i.length});o.attributes[e]=l}function lB(t,e,r,n,o=[0]){let s={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},i=r[n],a=r[n+1],c=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(c=4);let l=fB(i,a,t,c),f=0;for(let u of o){let h=typeof u=="number"?Object.values(s)[u]:s[u],p=l+h.offset,d=jn(t);if(d.data.length<=p)throw new Error(`${d.data.length} <= ${p}`);let A=d.data[p];f|=A<<h.shift}return f}function fB(t,e,r,n=1){let o=r.width,s=xg(t)*(o-1),i=Math.round(s),a=r.height,c=xg(e)*(a-1),l=Math.round(c),f=r.components?r.components:n;return(l*o+i)*f}function pi(t,e,r,n,o){let s=[];for(let i=0;i<e;i++){let a=r[i],c=r[i+1]-r[i];if(c+a>n)break;let l=a/o,f=c/o;s.push(t.slice(l,l+f))}return s}function di(t,e,r){let n=[];for(let o=0;o<e;o++){let s=o*r;n.push(t.slice(s,s+r))}return n}function mi(t,e,r,n){if(r)throw new Error("Not implemented - arrayOffsets for strings is specified");if(n){let o=[],s=new TextDecoder("utf8"),i=0;for(let a=0;a<t;a++){let c=n[a+1]-n[a];if(c+i<=e.length){let l=e.subarray(i,c+i),f=s.decode(l);o.push(f),i+=c}}return o}return[]}var nn="EXT_mesh_features",uB=nn;async function hB(t,e){let r=new k(t);dB(r,e)}function pB(t,e){let r=new k(t);return gB(r,e),r.createBinaryChunk(),r.gltf}function dB(t,e){let r=t.gltf.json;if(r.meshes)for(let n of r.meshes)for(let o of n.primitives)mB(t,o,e)}function mB(t,e,r){if(!r?.gltf?.loadBuffers)return;let o=e.extensions?.[nn]?.featureIds;if(o)for(let s of o){let i;if(typeof s.attribute<"u"){let a=`_FEATURE_ID_${s.attribute}`,c=e.attributes[a];i=t.getTypedArrayForAccessor(c)}else typeof s.texture<"u"&&r?.gltf?.loadImages?i=rn(t,s.texture,e):i=[];s.data=i}}function gB(t,e){let r=t.gltf.json.meshes;if(r)for(let n of r)for(let o of n.primitives)xB(t,o)}function AB(t,e,r,n){e.extensions||(e.extensions={});let o=e.extensions[nn];o||(o={featureIds:[]},e.extensions[nn]=o);let{featureIds:s}=o,i={featureCount:r.length,propertyTable:n,data:r};s.push(i),t.addObjectExtension(e,nn,o)}function xB(t,e){let r=e.extensions?.[nn];if(!r)return;let n=r.featureIds;n.forEach((o,s)=>{if(o.data){let{accessorKey:i,index:a}=bB(e.attributes),c=new Uint32Array(o.data);n[s]={featureCount:c.length,propertyTable:o.propertyTable,attribute:a},t.gltf.buffers.push({arrayBuffer:c.buffer,byteOffset:c.byteOffset,byteLength:c.byteLength});let l=t.addBufferView(c),f=t.addAccessor(l,{size:1,componentType:Vt(c),count:c.length});e.attributes[i]=f}})}function bB(t){let e="_FEATURE_ID_",r=Object.keys(t).filter(s=>s.indexOf(e)===0),n=-1;for(let s of r){let i=Number(s.substring(e.length));i>n&&(n=i)}return n++,{accessorKey:`${e}${n}`,index:n}}var gl={};xe(gl,{createExtStructuralMetadata:()=>VB,decode:()=>TB,encode:()=>EB,name:()=>yB});var on="EXT_structural_metadata",yB=on;async function TB(t,e){let r=new k(t);_B(r,e)}function EB(t,e){let r=new k(t);return GB(r,e),r.createBinaryChunk(),r.gltf}function _B(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(on);r&&(e.gltf?.loadImages&&MB(t,r),SB(t,r))}function MB(t,e){let r=e.propertyTextures,n=t.gltf.json;if(r&&n.meshes)for(let o of n.meshes)for(let s of o.primitives)BB(t,r,s,e)}function SB(t,e){let r=e.schema;if(!r)return;let n=r.classes,o=e.propertyTables;if(n&&o)for(let s in n){let i=CB(o,s);i&&RB(t,r,i)}}function CB(t,e){for(let r of t)if(r.class===e)return r;return null}function BB(t,e,r,n){if(!e)return;let s=r.extensions?.[on]?.propertyTextures;if(s)for(let i of s){let a=e[i];IB(t,a,r,n)}}function IB(t,e,r,n){if(!e.properties)return;n.dataAttributeNames||(n.dataAttributeNames=[]);let o=e.class;for(let s in e.properties){let i=`${o}_${s}`,a=e.properties?.[s];if(!a)continue;a.data||(a.data=[]);let c=a.data,l=rn(t,a,r);l!==null&&(hi(t,i,l,c,r),a.data=c,n.dataAttributeNames.push(i))}}function RB(t,e,r){let n=e.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let o=r.count;for(let s in n.properties){let i=n.properties[s],a=r.properties?.[s];if(a){let c=vB(t,e,i,o,a);a.data=c}}}function vB(t,e,r,n,o){let s=[],i=o.values,a=t.getTypedArrayForBufferView(i),c=wB(t,r,o,n),l=LB(t,o,n);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{s=FB(r,n,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{s=mi(n,a,c,l);break}case"ENUM":{s=PB(e,r,n,a,c);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return s}function wB(t,e,r,n){return e.array&&typeof e.count>"u"&&typeof r.arrayOffsets<"u"?en(t,r.arrayOffsets,r.arrayOffsetType||"UINT32",n):null}function LB(t,e,r){return typeof e.stringOffsets<"u"?en(t,e.stringOffsets,e.stringOffsetType||"UINT32",r):null}function FB(t,e,r,n){let o=t.array,s=t.count,i=mo(t.type,t.componentType),a=r.byteLength/i,c;return t.componentType?c=tn(r,t.type,t.componentType,a):c=r,o?n?pi(c,e,n,r.length,i):s?di(c,e,s):[]:c}function PB(t,e,r,n,o){let s=e.enumType;if(!s)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let i=t.enums?.[s];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${s}`);let a=i.valueType||"UINT16",c=mo(e.type,a),l=n.byteLength/c,f=tn(n,e.type,a,l);if(f||(f=n),e.array){if(o)return NB({valuesData:f,numberOfElements:r,arrayOffsets:o,valuesDataBytesLength:n.length,elementSize:c,enumEntry:i});let u=e.count;return u?OB(f,r,u,i):[]}return ml(f,0,r,i)}function NB(t){let{valuesData:e,numberOfElements:r,arrayOffsets:n,valuesDataBytesLength:o,elementSize:s,enumEntry:i}=t,a=[];for(let c=0;c<r;c++){let l=n[c],f=n[c+1]-n[c];if(f+l>o)break;let u=l/s,h=f/s,p=ml(e,u,h,i);a.push(p)}return a}function OB(t,e,r,n){let o=[];for(let s=0;s<e;s++){let i=r*s,a=ml(t,i,r,n);o.push(a)}return o}function ml(t,e,r,n){let o=[];for(let s=0;s<r;s++)if(t instanceof BigInt64Array||t instanceof BigUint64Array)o.push("");else{let i=t[e+s],a=DB(n,i);a?o.push(a.name):o.push("")}return o}function DB(t,e){for(let r of t.values)if(r.value===e)return r;return null}var UB="schemaClassId";function GB(t,e){let r=t.getExtension(on);if(r&&r.propertyTables)for(let n of r.propertyTables){let o=n.class,s=r.schema?.classes?.[o];n.properties&&s&&HB(n,s,t)}}function HB(t,e,r){for(let n in t.properties){let o=t.properties[n].data;if(o){let s=e.properties[n];if(s){let i=qB(o,s,r);t.properties[n]=i}}}}function VB(t,e,r=UB){let n=t.getExtension(on);n||(n=t.addExtension(on)),n.schema=zB(e,r,n.schema);let o=kB(e,r,n.schema);return n.propertyTables||(n.propertyTables=[]),n.propertyTables.push(o)-1}function zB(t,e,r){let n=r??{id:"schema_id"},o={properties:{}};for(let s of t){let i={type:s.elementType,componentType:s.componentType};o.properties[s.name]=i}return n.classes={},n.classes[e]=o,n}function kB(t,e,r){let n={class:e,count:0},o=0,s=r.classes?.[e];for(let i of t){if(o===0&&(o=i.values.length),o!==i.values.length&&i.values.length)throw new Error("Illegal values in attributes");s?.properties[i.name]&&(n.properties||(n.properties={}),n.properties[i.name]={values:0,data:i.values})}return n.count=o,n}function qB(t,e,r){let n={values:0};if(e.type==="STRING"){let{stringData:o,stringOffsets:s}=WB(t);n.stringOffsets=dl(s,r),n.values=dl(o,r)}else if(e.type==="SCALAR"&&e.componentType){let o=JB(t,e.componentType);n.values=dl(o,r)}return n}var jB={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function JB(t,e){let r=[];for(let o of t)r.push(Number(o));let n=jB[e];if(!n)throw new Error("Illegal component type");return new n(r)}function WB(t){let e=new TextEncoder,r=[],n=0;for(let c of t){let l=e.encode(c);n+=l.length,r.push(l)}let o=new Uint8Array(n),s=[],i=0;for(let c of r)o.set(c,i),s.push(i),i+=c.length;s.push(i);let a=new Uint32Array(s);return{stringData:o,stringOffsets:a}}function dl(t,e){return e.gltf.buffers.push({arrayBuffer:wt(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength}),e.addBufferView(t)}var Al={};xe(Al,{decode:()=>YB,name:()=>XB});var Tg="EXT_feature_metadata",XB=Tg;async function YB(t,e){let r=new k(t);KB(r,e)}function KB(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(Tg);r&&(e.gltf?.loadImages&&QB(t,r),ZB(t,r))}function QB(t,e){let r=e.schema;if(!r)return;let n=r.classes,{featureTextures:o}=e;if(n&&o)for(let s in n){let i=n[s],a=eI(o,s);a&&rI(t,a,i)}}function ZB(t,e){let r=e.schema;if(!r)return;let n=r.classes,o=e.featureTables;if(n&&o)for(let s in n){let i=$B(o,s);i&&tI(t,r,i)}}function $B(t,e){for(let r in t){let n=t[r];if(n.class===e)return n}return null}function eI(t,e){for(let r in t){let n=t[r];if(n.class===e)return n}return null}function tI(t,e,r){if(!r.class)return;let n=e.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let o=r.count;for(let s in n.properties){let i=n.properties[s],a=r.properties?.[s];if(a){let c=nI(t,e,i,o,a);a.data=c}}}function rI(t,e,r){let n=e.class;for(let o in r.properties){let s=e?.properties?.[o];if(s){let i=cI(t,s,n);s.data=i}}}function nI(t,e,r,n,o){let s=[],i=o.bufferView,a=t.getTypedArrayForBufferView(i),c=oI(t,r,o,n),l=sI(t,r,o,n);return r.type==="STRING"||r.componentType==="STRING"?s=mi(n,a,c,l):iI(r)&&(s=aI(r,n,a,c)),s}function oI(t,e,r,n){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?en(t,r.arrayOffsetBufferView,r.offsetType||"UINT32",n):null}function sI(t,e,r,n){return typeof r.stringOffsetBufferView<"u"?en(t,r.stringOffsetBufferView,r.offsetType||"UINT32",n):null}function iI(t){let e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function aI(t,e,r,n){let o=t.type==="ARRAY",s=t.componentCount,i="SCALAR",a=t.componentType||t.type,c=mo(i,a),l=r.byteLength/c,f=tn(r,i,a,l);return o?n?pi(f,e,n,r.length,c):s?di(f,e,s):[]:f}function cI(t,e,r){let n=t.gltf.json;if(!n.meshes)return[];let o=[];for(let s of n.meshes)for(let i of s.primitives)lI(t,r,e,o,i);return o}function lI(t,e,r,n,o){let s={channels:r.channels,...r.texture},i=rn(t,s,o);i&&hi(t,e,i,n,o)}var Eg="4.4.0-alpha.18";var sn=!0,_g=1735152710,yl=12,gi=8,fI=1313821514,uI=5130562,hI=0,pI=0,dI=1;function mI(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function Mg(t,e=0,r={}){let n=new DataView(t),{magic:o=_g}=r,s=n.getUint32(e,!1);return s===o||s===_g}function Sg(t,e,r=0,n={}){let o=new DataView(e),s=mI(o,r+0),i=o.getUint32(r+4,sn),a=o.getUint32(r+8,sn);switch(Object.assign(t,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:s,version:i,json:{},binChunks:[]}),r+=yl,t.version){case 1:return gI(t,o,r);case 2:return AI(t,o,r,n={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function gI(t,e,r){V(t.header.byteLength>yl+gi);let n=e.getUint32(r+0,sn),o=e.getUint32(r+4,sn);return r+=gi,V(o===hI),xl(t,e,r,n),r+=n,r+=bl(t,e,r,t.header.byteLength),r}function AI(t,e,r,n){return V(t.header.byteLength>yl+gi),xI(t,e,r,n),r+t.header.byteLength}function xI(t,e,r,n){for(;r+8<=t.header.byteLength;){let o=e.getUint32(r+0,sn),s=e.getUint32(r+4,sn);switch(r+=gi,s){case fI:xl(t,e,r,o);break;case uI:bl(t,e,r,o);break;case pI:n.strict||xl(t,e,r,o);break;case dI:n.strict||bl(t,e,r,o);break;default:break}r+=It(o,4)}return r}function xl(t,e,r,n){let o=new Uint8Array(e.buffer,r,n),i=new TextDecoder("utf8").decode(o);return t.json=JSON.parse(i),It(n,4)}function bl(t,e,r,n){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:n,arrayBuffer:e.buffer}),It(n,4)}function Tl(t,e){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;let n=e?.core?.baseUri||e.baseUri||e.uri;if(!n)throw new Error(`'baseUri' must be provided to resolve relative url ${t}`);return n.substr(0,n.lastIndexOf("/")+1)+t}var _l={};xe(_l,{decode:()=>vI,name:()=>RI});var bI="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",yI="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",TI=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),EI=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),_I={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},MI={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function Cg(t,e,r,n,o,s="NONE"){let i=await SI();II(i,i.exports[MI[o]],t,e,r,n,i.exports[_I[s||"NONE"]])}var El;async function SI(){return El||(El=CI()),El}async function CI(){let t=bI;WebAssembly.validate(TI)&&(t=yI,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let e=await WebAssembly.instantiate(BI(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function BI(t){let e=new Uint8Array(t.length);for(let n=0;n<t.length;++n){let o=t.charCodeAt(n);e[n]=o>96?o-71:o>64?o-65:o>47?o+4:o>46?63:62}let r=0;for(let n=0;n<t.length;++n)e[r++]=e[n]<60?EI[e[n]]:(e[n]-60)*64+e[++n];return e.buffer.slice(0,r)}function II(t,e,r,n,o,s,i){let a=t.exports.sbrk,c=n+3&-4,l=a(c*o),f=a(s.length),u=new Uint8Array(t.exports.memory.buffer);u.set(s,f);let h=e(l,n,o,f,s.length);if(h===0&&i&&i(l,c,o),r.set(u.subarray(l,l+n*o)),a(l-a(0)),h!==0)throw new Error(`Malformed buffer data: ${h}`)}var Ai="EXT_meshopt_compression",RI=Ai;async function vI(t,e){let r=new k(t);if(!e?.gltf?.decompressMeshes||!e.gltf?.loadBuffers)return;let n=[];for(let o of t.json.bufferViews||[])n.push(wI(r,o));await Promise.all(n),r.removeExtension(Ai)}async function wI(t,e){let r=t.getObjectExtension(e,Ai);if(r){let{byteOffset:n=0,byteLength:o=0,byteStride:s,count:i,mode:a,filter:c="NONE",buffer:l}=r,f=t.gltf.buffers[l],u=new Uint8Array(f.arrayBuffer,f.byteOffset+n,o),h=new Uint8Array(t.gltf.buffers[e.buffer].arrayBuffer,e.byteOffset,e.byteLength);await Cg(h,i,s,u,a,c),t.removeObjectExtension(e,Ai)}}var Ml={};xe(Ml,{name:()=>LI,preprocess:()=>FI});var an="EXT_texture_webp",LI=an;function FI(t,e){let r=new k(t);if(!yc("image/webp")){if(r.getRequiredExtensions().includes(an))throw new Error(`gltf: Required extension ${an} not supported by browser`);return}let{json:n}=r;for(let o of n.textures||[]){let s=r.getObjectExtension(o,an);s&&(o.source=s.source),r.removeObjectExtension(o,an)}r.removeExtension(an)}var Sl={};xe(Sl,{name:()=>PI,preprocess:()=>NI});var xi="KHR_texture_basisu",PI=xi;function NI(t,e){let r=new k(t),{json:n}=r;for(let o of n.textures||[]){let s=r.getObjectExtension(o,xi);s&&(o.source=s.source,r.removeObjectExtension(o,xi))}r.removeExtension(xi)}var Bl={};xe(Bl,{decode:()=>HI,encode:()=>VI,name:()=>UI,preprocess:()=>GI});function Bg(t){let e={};for(let r in t){let n=t[r];if(r!=="indices"){let o=Cl(n);e[r]=o}}return e}function Cl(t){let{buffer:e,size:r,count:n}=OI(t);return{value:e,size:r,byteOffset:0,count:n,type:ui(r),componentType:Vt(e)}}function OI(t){let e=t,r=1,n=0;return t&&t.value&&(e=t.value,r=t.size||1),e&&(ArrayBuffer.isView(e)||(e=DI(e,Float32Array)),n=e.length/r),{buffer:e,size:r,count:n}}function DI(t,e,r=!1){return t?Array.isArray(t)?new e(t):r&&!(t instanceof e)?new e(t):t:null}var zt="KHR_draco_mesh_compression",UI=zt;function GI(t,e,r){let n=new k(t);for(let o of Ig(n))n.getObjectExtension(o,zt)}async function HI(t,e,r){if(!e?.gltf?.decompressMeshes)return;let n=new k(t),o=[];for(let s of Ig(n))n.getObjectExtension(s,zt)&&o.push(zI(n,s,e,r));await Promise.all(o),n.removeExtension(zt)}function VI(t,e={}){let r=new k(t);for(let n of r.json.meshes||[])kI(n,e),r.addRequiredExtension(zt)}async function zI(t,e,r,n){let o=t.getObjectExtension(e,zt);if(!o)return;let s=t.getTypedArrayForBufferView(o.bufferView),i=nr(s.buffer,s.byteOffset),a={...r};delete a["3d-tiles"];let c=await Ne(i,ho,a,n),l=Bg(c.attributes);for(let[f,u]of Object.entries(l))if(f in e.attributes){let h=e.attributes[f],p=t.getAccessor(h);p?.min&&p?.max&&(u.min=p.min,u.max=p.max)}e.attributes=l,c.indices&&(e.indices=Cl(c.indices)),t.removeObjectExtension(e,zt),qI(e)}function kI(t,e,r=4,n,o){if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let s=n.DracoWriter.encodeSync({attributes:t}),i=o?.parseSync?.({attributes:t}),a=n._addFauxAttributes(i.attributes),c=n.addBufferView(s);return{primitives:[{attributes:a,mode:r,extensions:{[zt]:{bufferView:c,attributes:a}}}]}}function qI(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*Ig(t){for(let e of t.json.meshes||[])for(let r of e.primitives)yield r}var Il={};xe(Il,{decode:()=>XI,name:()=>jI});var yi="KHR_texture_transform",jI=yi,bi=new x,JI=new j,WI=new j;async function XI(t,e){if(!new k(t).hasExtension(yi)||!e.gltf?.loadBuffers)return;let o=t.json.materials||[];for(let s=0;s<o.length;s++)YI(s,t)}function YI(t,e){let r=e.json.materials?.[t],n=[r?.pbrMetallicRoughness?.baseColorTexture,r?.emissiveTexture,r?.normalTexture,r?.occlusionTexture,r?.pbrMetallicRoughness?.metallicRoughnessTexture],o=[];for(let s of n)s&&s?.extensions?.[yi]&&KI(e,t,s,o)}function KI(t,e,r,n){let o=QI(r,n);if(!o)return;let s=t.json.meshes||[];for(let i of s)for(let a of i.primitives){let c=a.material;Number.isFinite(c)&&e===c&&ZI(t,a,o)}}function QI(t,e){let r=t.extensions?.[yi],{texCoord:n=0}=t,{texCoord:o=n}=r;if(!(e.findIndex(([i,a])=>i===n&&a===o)!==-1)){let i=t2(r);return n!==o&&(t.texCoord=o),e.push([n,o]),{originalTexCoord:n,texCoord:o,matrix:i}}return null}function ZI(t,e,r){let{originalTexCoord:n,texCoord:o,matrix:s}=r,i=e.attributes[`TEXCOORD_${n}`];if(Number.isFinite(i)){let a=t.json.accessors?.[i];if(a&&a.bufferView!==void 0){let c=t.json.bufferViews?.[a.bufferView];if(c){let{arrayBuffer:l,byteOffset:f}=t.buffers[c.buffer],u=(f||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:h,length:p}=$r(a,c),d=fi[a.componentType],A=li[a.type],m=c.byteStride||d*A,b=new Float32Array(p);for(let T=0;T<a.count;T++){let E=new h(l,u+T*m,2);bi.set(E[0],E[1],1),bi.transformByMatrix3(s),b.set([bi[0],bi[1]],T*A)}n===o?$I(a,t,b,a.bufferView):e2(o,a,e,t,b)}}}}function $I(t,e,r,n){t.componentType=5126,t.byteOffset=0;let i=(e.json.accessors||[]).reduce((l,f)=>f.bufferView===n?l+1:l,0)>1;e.buffers.push({arrayBuffer:wt(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength});let a=e.buffers.length-1;if(e.json.bufferViews=e.json.bufferViews||[],i){e.json.bufferViews.push({buffer:a,byteLength:r.buffer.byteLength,byteOffset:0}),t.bufferView=e.json.bufferViews.length-1;return}let c=e.json.bufferViews[n];c&&(c.buffer=a,c.byteOffset=0,c.byteLength=r.buffer.byteLength,c.byteStride!==void 0&&delete c.byteStride)}function e2(t,e,r,n,o){n.buffers.push({arrayBuffer:wt(o.buffer),byteOffset:0,byteLength:o.buffer.byteLength}),n.json.bufferViews=n.json.bufferViews||[];let s=n.json.bufferViews;s.push({buffer:n.buffers.length-1,byteLength:o.buffer.byteLength,byteOffset:0});let i=n.json.accessors;i&&(i.push({bufferView:s?.length-1,byteOffset:0,componentType:5126,count:e.count,type:"VEC2"}),r.attributes[`TEXCOORD_${t}`]=i.length-1)}function t2(t){let{offset:e=[0,0],rotation:r=0,scale:n=[1,1]}=t,o=new j().set(1,0,0,0,1,0,e[0],e[1],1),s=JI.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),i=WI.set(n[0],0,0,0,n[1],0,0,0,1);return o.multiplyRight(s).multiplyRight(i)}var Rl={};xe(Rl,{decode:()=>n2,encode:()=>o2,name:()=>r2});var xr="KHR_lights_punctual",r2=xr;async function n2(t){let e=new k(t),{json:r}=e,n=e.getExtension(xr);n&&(e.json.lights=n.lights,e.removeExtension(xr));for(let o of r.nodes||[]){let s=e.getObjectExtension(o,xr);s&&(o.light=s.light),e.removeObjectExtension(o,xr)}}async function o2(t){let e=new k(t),{json:r}=e;if(r.lights){let n=e.addExtension(xr);fe(!n.lights),n.lights=r.lights,delete r.lights}if(e.json.lights){for(let n of e.json.lights){let o=n.node;e.addObjectExtension(o,xr,n)}delete e.json.lights}}var vl={};xe(vl,{decode:()=>i2,encode:()=>a2,name:()=>s2});var go="KHR_materials_unlit",s2=go;async function i2(t){let e=new k(t),{json:r}=e;for(let n of r.materials||[])n.extensions&&n.extensions.KHR_materials_unlit&&(n.unlit=!0),e.removeObjectExtension(n,go);e.removeExtension(go)}function a2(t){let e=new k(t),{json:r}=e;if(e.materials)for(let n of r.materials||[])n.unlit&&(delete n.unlit,e.addObjectExtension(n,go,{}),e.addExtension(go))}var wl={};xe(wl,{decode:()=>l2,encode:()=>f2,name:()=>c2});var Ao="KHR_techniques_webgl",c2=Ao;async function l2(t){let e=new k(t),{json:r}=e,n=e.getExtension(Ao);if(n){let o=u2(n,e);for(let s of r.materials||[]){let i=e.getObjectExtension(s,Ao);i&&(s.technique=Object.assign({},i,o[i.technique]),s.technique.values=h2(s.technique,e)),e.removeObjectExtension(s,Ao)}e.removeExtension(Ao)}}async function f2(t,e){}function u2(t,e){let{programs:r=[],shaders:n=[],techniques:o=[]}=t,s=new TextDecoder;return n.forEach(i=>{if(Number.isFinite(i.bufferView))i.code=s.decode(e.getTypedArrayForBufferView(i.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(i=>{i.fragmentShader=n[i.fragmentShader],i.vertexShader=n[i.vertexShader]}),o.forEach(i=>{i.program=r[i.program]}),o}function h2(t,e){let r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(n=>{t.uniforms[n].value&&!(n in r)&&(r[n]=t.uniforms[n].value)}),Object.keys(r).forEach(n=>{typeof r[n]=="object"&&r[n].index!==void 0&&(r[n].texture=e.getTexture(r[n].index))}),r}var Rg=[gl,pl,_l,Ml,Sl,Bl,Rl,vl,wl,Il,Al];function vg(t,e={},r){let n=Rg.filter(o=>Lg(o.name,e));for(let o of n)o.preprocess?.(t,e,r)}async function wg(t,e={},r){let n=Rg.filter(o=>Lg(o.name,e));for(let o of n)await o.decode?.(t,e,r)}function Lg(t,e){let r=e?.gltf?.excludeExtensions||{};return!(t in r&&!r[t])}var Ll="KHR_binary_glTF";function Fg(t){let e=new k(t),{json:r}=e;for(let n of r.images||[]){let o=e.getObjectExtension(n,Ll);o&&Object.assign(n,o),e.removeObjectExtension(n,Ll)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(Ll)}var Pg={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},d2={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},Fl=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,r){this.json=e.json;let n=e.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${n.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),Fg(e),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(let r in Pg)this._convertTopLevelObjectToArray(e,r)}_convertTopLevelObjectToArray(e,r){let n=e[r];if(!(!n||Array.isArray(n))){e[r]=[];for(let o in n){let s=n[o];s.id=s.id||o;let i=e[r].length;e[r].push(s),this.idToIndexMap[r][o]=i}}}_convertObjectIdsToArrayIndices(e){for(let r in Pg)this._convertIdsToIndices(e,r);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(let r of e.textures)this._convertTextureIds(r);for(let r of e.meshes)this._convertMeshIds(r);for(let r of e.nodes)this._convertNodeIds(r);for(let r of e.scenes)this._convertSceneIds(r)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(let r of e.primitives){let{attributes:n,indices:o,material:s}=r;for(let i in n)n[i]=this._convertIdToIndex(n[i],"accessor");o&&(r.indices=this._convertIdToIndex(o,"accessor")),s&&(r.material=this._convertIdToIndex(s,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(r=>this._convertIdToIndex(r,"node"))),e.meshes&&(e.meshes=e.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(e,r){e[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),e[r]=[]);for(let n of e[r])for(let o in n){let s=n[o],i=this._convertIdToIndex(s,o);n[o]=i}}_convertIdToIndex(e,r){let n=d2[r];if(n in this.idToIndexMap){let o=this.idToIndexMap[n][e];if(!Number.isFinite(o))throw new Error(`gltf v1: failed to resolve ${r} with id ${e}`);return o}return e}_updateObjects(e){for(let r of this.json.buffers)delete r.type}_updateMaterial(e){for(let r of e.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let n=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,o=e.textures.findIndex(s=>s.id===n);o!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:o})}}};function Ng(t,e={}){return new Fl().normalize(t,e)}async function Og(t,e,r=0,n,o){return m2(t,e,r,n),Ng(t,{normalize:n?.gltf?.normalize}),vg(t,n,o),n?.gltf?.loadBuffers&&t.json.buffers&&await g2(t,n,o),n?.gltf?.loadImages&&await A2(t,n,o),await wg(t,n,o),t}function m2(t,e,r,n){if(n.core?.baseUri&&(t.baseUri=n.core?.baseUri),e instanceof ArrayBuffer&&!Mg(e,r,n.glb)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=ac(e);else if(e instanceof ArrayBuffer){let i={};r=Sg(i,e,r,n.glb),fe(i.type==="glTF",`Invalid GLB magic string ${i.type}`),t._glb=i,t.json=i.json}else fe(!1,"GLTF: must be ArrayBuffer or string");let o=t.json.buffers||[];if(t.buffers=new Array(o.length).fill(null),t._glb&&t._glb.header.hasBinChunk){let{binChunks:i}=t._glb;t.buffers[0]={arrayBuffer:i[0].arrayBuffer,byteOffset:i[0].byteOffset,byteLength:i[0].byteLength}}let s=t.json.images||[];t.images=new Array(s.length).fill({})}async function g2(t,e,r){let n=t.json.buffers||[];for(let o=0;o<n.length;++o){let s=n[o];if(s.uri){let{fetch:i}=r;fe(i);let a=Tl(s.uri,e),l=await(await r?.fetch?.(a))?.arrayBuffer?.();t.buffers[o]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete s.uri}else t.buffers[o]===null&&(t.buffers[o]={arrayBuffer:new ArrayBuffer(s.byteLength),byteOffset:0,byteLength:s.byteLength})}}async function A2(t,e,r){let n=x2(t),o=t.json.images||[],s=[];for(let i of n)s.push(b2(t,o[i],i,e,r));return await Promise.all(s)}function x2(t){let e=new Set,r=t.json.textures||[];for(let n of r)n.source!==void 0&&e.add(n.source);return Array.from(e).sort()}async function b2(t,e,r,n,o){let s;if(e.uri&&!e.hasOwnProperty("bufferView")){let l=Tl(e.uri,n),{fetch:f}=o;s=await(await f(l)).arrayBuffer(),e.bufferView={data:s}}if(Number.isFinite(e.bufferView)){let l=gg(t.json,t.buffers,e.bufferView);s=nr(l.buffer,l.byteOffset,l.byteLength)}fe(s,"glTF image has no data");let i=n,a={...i,core:{...i?.core,mimeType:e.mimeType}},c=await Ne(s,[kr,Gc],a,o);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c[0]}),t.images=t.images||[],t.images[r]=c}var br={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:Eg,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:y2,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};async function y2(t,e={},r){let n={...br.options,...e};n.gltf={...br.options.gltf,...n.gltf};let o=e?.glb?.byteOffset||0;return await Og({},t,o,n,r)}var T2={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},E2={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},ke={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},_2={magFilter:ke.TEXTURE_MAG_FILTER,minFilter:ke.TEXTURE_MIN_FILTER,wrapS:ke.TEXTURE_WRAP_S,wrapT:ke.TEXTURE_WRAP_T},M2={[ke.TEXTURE_MAG_FILTER]:ke.LINEAR,[ke.TEXTURE_MIN_FILTER]:ke.NEAREST_MIPMAP_LINEAR,[ke.TEXTURE_WRAP_S]:ke.REPEAT,[ke.TEXTURE_WRAP_T]:ke.REPEAT};function S2(){return{id:"default-sampler",parameters:M2}}function C2(t){return E2[t]}function B2(t){return T2[t]}var Pl=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,r={}){let{json:n,buffers:o=[],images:s=[]}=e,{baseUri:i=""}=e;return fe(n),this.baseUri=i,this.buffers=o,this.images=s,this.jsonUnprocessed=n,this.json=this._resolveTree(e.json,r),this.json}_resolveTree(e,r={}){let n={...e};return this.json=n,e.bufferViews&&(n.bufferViews=e.bufferViews.map((o,s)=>this._resolveBufferView(o,s))),e.images&&(n.images=e.images.map((o,s)=>this._resolveImage(o,s))),e.samplers&&(n.samplers=e.samplers.map((o,s)=>this._resolveSampler(o,s))),e.textures&&(n.textures=e.textures.map((o,s)=>this._resolveTexture(o,s))),e.accessors&&(n.accessors=e.accessors.map((o,s)=>this._resolveAccessor(o,s))),e.materials&&(n.materials=e.materials.map((o,s)=>this._resolveMaterial(o,s))),e.meshes&&(n.meshes=e.meshes.map((o,s)=>this._resolveMesh(o,s))),e.nodes&&(n.nodes=e.nodes.map((o,s)=>this._resolveNode(o,s)),n.nodes=n.nodes.map((o,s)=>this._resolveNodeChildren(o))),e.skins&&(n.skins=e.skins.map((o,s)=>this._resolveSkin(o,s))),e.scenes&&(n.scenes=e.scenes.map((o,s)=>this._resolveScene(o,s))),typeof this.json.scene=="number"&&n.scenes&&(n.scene=n.scenes[this.json.scene]),n}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,r){if(typeof r=="object")return r;let n=e&&e[r];return n||console.warn(`glTF file error: Could not find ${e}[${r}]`),n}_resolveScene(e,r){return{...e,id:e.id||`scene-${r}`,nodes:(e.nodes||[]).map(n=>this.getNode(n))}}_resolveNode(e,r){let n={...e,id:e?.id||`node-${r}`};return e.mesh!==void 0&&(n.mesh=this.getMesh(e.mesh)),e.camera!==void 0&&(n.camera=this.getCamera(e.camera)),e.skin!==void 0&&(n.skin=this.getSkin(e.skin)),e.meshes!==void 0&&e.meshes.length&&(n.mesh=e.meshes.reduce((o,s)=>{let i=this.getMesh(s);return o.id=i.id,o.primitives=o.primitives.concat(i.primitives),o},{primitives:[]})),n}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(r=>this.getNode(r))),e}_resolveSkin(e,r){let n=typeof e.inverseBindMatrices=="number"?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${r}`,inverseBindMatrices:n}}_resolveMesh(e,r){let n={...e,id:e.id||`mesh-${r}`,primitives:[]};return e.primitives&&(n.primitives=e.primitives.map(o=>{let s={...o,attributes:{},indices:void 0,material:void 0},i=o.attributes;for(let a in i)s.attributes[a]=this.getAccessor(i[a]);return o.indices!==void 0&&(s.indices=this.getAccessor(o.indices)),o.material!==void 0&&(s.material=this.getMaterial(o.material)),s})),n}_resolveMaterial(e,r){let n={...e,id:e.id||`material-${r}`};if(n.normalTexture&&(n.normalTexture={...n.normalTexture},n.normalTexture.texture=this.getTexture(n.normalTexture.index)),n.occlusionTexture&&(n.occlusionTexture={...n.occlusionTexture},n.occlusionTexture.texture=this.getTexture(n.occlusionTexture.index)),n.emissiveTexture&&(n.emissiveTexture={...n.emissiveTexture},n.emissiveTexture.texture=this.getTexture(n.emissiveTexture.index)),n.emissiveFactor||(n.emissiveFactor=n.emissiveTexture?[1,1,1]:[0,0,0]),n.pbrMetallicRoughness){n.pbrMetallicRoughness={...n.pbrMetallicRoughness};let o=n.pbrMetallicRoughness;o.baseColorTexture&&(o.baseColorTexture={...o.baseColorTexture},o.baseColorTexture.texture=this.getTexture(o.baseColorTexture.index)),o.metallicRoughnessTexture&&(o.metallicRoughnessTexture={...o.metallicRoughnessTexture},o.metallicRoughnessTexture.texture=this.getTexture(o.metallicRoughnessTexture.index))}return n}_resolveAccessor(e,r){let n=C2(e.componentType),o=B2(e.type),s=n*o,i={...e,id:e.id||`accessor-${r}`,bytesPerComponent:n,components:o,bytesPerElement:s,value:void 0,bufferView:void 0,sparse:void 0};if(e.bufferView!==void 0&&(i.bufferView=this.getBufferView(e.bufferView)),i.bufferView){let a=i.bufferView.buffer,{ArrayType:c,byteLength:l}=$r(i,i.bufferView),f=(i.bufferView.byteOffset||0)+(i.byteOffset||0)+a.byteOffset,u=Hn(a.arrayBuffer,f,l);i.bufferView.byteStride&&(u=this._getValueFromInterleavedBuffer(a,f,i.bufferView.byteStride,i.bytesPerElement,i.count)),i.value=new c(u)}return i}_getValueFromInterleavedBuffer(e,r,n,o,s){let i=new Uint8Array(s*o);for(let a=0;a<s;a++){let c=r+a*n;i.set(new Uint8Array(e.arrayBuffer.slice(c,c+o)),a*o)}return i.buffer}_resolveTexture(e,r){return{...e,id:e.id||`texture-${r}`,sampler:typeof e.sampler=="number"?this.getSampler(e.sampler):S2(),source:typeof e.source=="number"?this.getImage(e.source):void 0}}_resolveSampler(e,r){let n={id:e.id||`sampler-${r}`,...e,parameters:{}};for(let o in n){let s=this._enumSamplerParameter(o);s!==void 0&&(n.parameters[s]=n[o])}return n}_enumSamplerParameter(e){return _2[e]}_resolveImage(e,r){let n={...e,id:e.id||`image-${r}`,image:null,bufferView:e.bufferView!==void 0?this.getBufferView(e.bufferView):void 0},o=this.images[r];return o&&(n.image=o),n}_resolveBufferView(e,r){let n=e.buffer,o=this.buffers[n].arrayBuffer,s=this.buffers[n].byteOffset||0;return e.byteOffset&&(s+=e.byteOffset),{id:`bufferView-${r}`,...e,buffer:this.buffers[n],data:new Uint8Array(o,s,e.byteLength)}}_resolveCamera(e,r){let n={...e,id:e.id||`camera-${r}`};return n.perspective,n.orthographic,n}};function xo(t,e){return new Pl().postProcess(t,e)}var Ti={URI:0,EMBEDDED:1};function Ei(t,e,r,n){t.rotateYtoZ=!0;let o=(t.byteOffset||0)+(t.byteLength||0)-r;if(o===0)throw new Error("glTF byte length must be greater than 0.");return t.gltfUpAxis=n?.["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",t.gltfArrayBuffer=nr(e,r,o),t.gltfByteOffset=0,t.gltfByteLength=o,r%4===0||console.warn(`${t.type}: embedded glb is not aligned to a 4-byte boundary.`),(t.byteOffset||0)+(t.byteLength||0)}async function _i(t,e,r,n){let o=r?.["3d-tiles"]||{};if(I2(t,e,r),o.loadGLTF){if(!n)return;if(t.gltfUrl){let{fetch:s}=n,i=await s(t.gltfUrl,r?.core);t.gltfArrayBuffer=await i.arrayBuffer(),t.gltfByteOffset=0}if(t.gltfArrayBuffer){let s=await Ne(t.gltfArrayBuffer,br,r,n);t.gltf=xo(s),t.gpuMemoryUsageInBytes=po(t.gltf),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength}}}function I2(t,e,r){switch(e){case Ti.URI:if(t.gltfArrayBuffer){let n=new Uint8Array(t.gltfArrayBuffer,t.gltfByteOffset),s=new TextDecoder().decode(n);t.gltfUrl=s.replace(/[\s\0]+$/,"")}delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength;break;case Ti.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function Dg(t,e,r,n,o){r=R2(t,e,r,n,o),await _i(t,Ti.EMBEDDED,n,o);let s=t?.gltf?.extensions;return s&&s.CESIUM_RTC&&(t.rtcCenter=s.CESIUM_RTC.center),r}function R2(t,e,r,n,o){r=Ht(t,e,r),r=Qr(t,e,r),r=Zr(t,e,r,n),r=Ei(t,e,r,n);let s=new yt(t.featureTableJson,t.featureTableBinary);return t.rtcCenter=s.getGlobalProperty("RTC_CENTER",O.FLOAT,3),r}async function Ug(t,e,r,n,o){return r=v2(t,e,r,n,o),await _i(t,t.gltfFormat||0,n,o),r}function v2(t,e,r,n,o){if(r=Ht(t,e,r),t.version!==1)throw new Error(`Instanced 3D Model version ${t.version} is not supported`);r=Qr(t,e,r);let s=new DataView(e);if(t.gltfFormat=s.getUint32(r,!0),r+=4,r=Zr(t,e,r,n),r=Ei(t,e,r,n),!t?.header?.featureTableJsonByteLength||t.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");let i=new yt(t.featureTableJson,t.featureTableBinary),a=i.getGlobalProperty("INSTANCES_LENGTH");if(i.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");t.eastNorthUp=i.getGlobalProperty("EAST_NORTH_UP"),t.rtcCenter=i.getGlobalProperty("RTC_CENTER",O.FLOAT,3);let c=new Ar(t.batchTableJson,t.batchTableBinary,a);return w2(t,i,c,a),r}function w2(t,e,r,n){let o=new Array(n),s=new x,i=new x,a=new x,c=new x,l=new j,f=new ot,u=new x,h={},p=new N,d=[],A=[],m=[],b=[];for(let T=0;T<n;T++){let E;if(e.hasProperty("POSITION"))E=e.getProperty("POSITION",O.FLOAT,3,T,s);else if(e.hasProperty("POSITION_QUANTIZED")){E=e.getProperty("POSITION_QUANTIZED",O.UNSIGNED_SHORT,3,T,s);let g=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",O.FLOAT,3);if(!g)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");let B=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",O.FLOAT,3);if(!B)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");let L=65535;for(let F=0;F<3;F++)E[F]=E[F]/L*B[F]+g[F]}if(!E)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");s.copy(E),h.translation=s,t.normalUp=e.getProperty("NORMAL_UP",O.FLOAT,3,T,d),t.normalRight=e.getProperty("NORMAL_RIGHT",O.FLOAT,3,T,A);let _=!1;if(t.normalUp){if(!t.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");t.hasCustomOrientation=!0}else{if(t.octNormalUp=e.getProperty("NORMAL_UP_OCT32P",O.UNSIGNED_SHORT,2,T,d),t.octNormalRight=e.getProperty("NORMAL_RIGHT_OCT32P",O.UNSIGNED_SHORT,2,T,A),t.octNormalUp)throw t.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");t.eastNorthUp?(G.WGS84.eastNorthUpToFixedFrame(s,p),p.getRotationMatrix3(l)):l.identity()}_&&(c.copy(i).cross(a).normalize(),l.setColumn(0,i),l.setColumn(1,a),l.setColumn(2,c)),f.fromMatrix3(l),h.rotation=f,u.set(1,1,1);let S=e.getProperty("SCALE",O.FLOAT,1,T,m);Number.isFinite(S)&&u.multiplyByScalar(S);let C=e.getProperty("SCALE_NON_UNIFORM",O.FLOAT,3,T,d);C&&u.scale(C),h.scale=u;let v=e.getProperty("BATCH_ID",O.UNSIGNED_SHORT,1,T,b);v===void 0&&(v=T);let M=new N().fromQuaternion(h.rotation);p.identity(),p.translate(h.translation),p.multiplyRight(M),p.scale(h.scale);let y=p.clone();o[T]={modelMatrix:y,batchId:v}}t.instances=o}async function Gg(t,e,r,n,o,s){r=Ht(t,e,r);let i=new DataView(e);for(t.tilesLength=i.getUint32(r,!0),r+=4,t.tiles=[];t.tiles.length<t.tilesLength&&(t.byteLength||0)-r>12;){let a={shape:"tile3d"};t.tiles.push(a),r=await s(e,r,n,o,a)}return r}async function Hg(t,e,r,n){if(t.rotateYtoZ=!0,t.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!n)return e.byteLength;let o=await Ne(e,br,r,n);t.gltf=xo(o),t.gpuMemoryUsageInBytes=po(t.gltf)}else t.gltfArrayBuffer=e;return e.byteLength}async function Nl(t,e=0,r,n,o={shape:"tile3d"}){switch(o.byteOffset=e,o.type=Jm(t,e),o.type){case mr.COMPOSITE:return await Gg(o,t,e,r,n,Nl);case mr.BATCHED_3D_MODEL:return await Dg(o,t,e,r,n);case mr.GLTF:return await Hg(o,t,r,n);case mr.INSTANCED_3D_MODEL:return await Ug(o,t,e,r,n);case mr.POINT_CLOUD:return await dg(o,t,e,r,n);default:throw new Error(`3DTileLoader: unknown type ${o.type}`)}}async function Ol(t,e,r){if(new Uint32Array(t.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(t.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let s=Vg(t.slice(8,16)),i=new Uint8Array(t,24,s),c=new TextDecoder("utf8").decode(i),l=JSON.parse(c),f=Vg(t.slice(16,24)),u=new ArrayBuffer(0);if(f&&(u=t.slice(24+s)),await Mi(l,l.tileAvailability,u,r),Array.isArray(l.contentAvailability))for(let h of l.contentAvailability)await Mi(l,h,u,r);else await Mi(l,l.contentAvailability,u,r);return await Mi(l,l.childSubtreeAvailability,u,r),l}async function Mi(t,e,r,n){let o=Number.isFinite(e.bitstream)?e.bitstream:e.bufferView;if(typeof o!="number")return;let s=t.bufferViews[o],i=t.buffers[s.buffer];if(!n?.baseUrl)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(i.uri){let c=`${n?.baseUrl||""}/${i.uri}`,f=await(await n.fetch(c)).arrayBuffer();e.explicitBitstream=new Uint8Array(f,s.byteOffset,s.byteLength);return}let a=t.buffers.slice(0,s.buffer).reduce((c,l)=>c+l.byteLength,0);e.explicitBitstream=new Uint8Array(r.slice(a,a+i.byteLength),s.byteOffset,s.byteLength)}function Vg(t){let e=new DataView(t),r=e.getUint32(0,!0),n=e.getUint32(4,!0);return r+2**32*n}var Si={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:ai,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:Ol,options:{}};var l0=D(Zt(),1);var s0=D(Zt(),1);var qe=null;try{qe=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Z(t,e,r){this.low=t|0,this.high=e|0,this.unsigned=!!r}Z.prototype.__isLong__;Object.defineProperty(Z.prototype,"__isLong__",{value:!0});function Te(t){return(t&&t.__isLong__)===!0}function zg(t){var e=Math.clz32(t&-t);return t?31-e:e}Z.isLong=Te;var kg={},qg={};function yr(t,e){var r,n,o;return e?(t>>>=0,(o=0<=t&&t<256)&&(n=qg[t],n)?n:(r=q(t,0,!0),o&&(qg[t]=r),r)):(t|=0,(o=-128<=t&&t<128)&&(n=kg[t],n)?n:(r=q(t,t<0?-1:0,!1),o&&(kg[t]=r),r))}Z.fromInt=yr;function je(t,e){if(isNaN(t))return e?Tt:et;if(e){if(t<0)return Tt;if(t>=Xg)return Qg}else{if(t<=-Jg)return ve;if(t+1>=Jg)return Kg}return t<0?je(-t,e).neg():q(t%ln|0,t/ln|0,e)}Z.fromNumber=je;function q(t,e,r){return new Z(t,e,r)}Z.fromBits=q;var Ci=Math.pow;function Ul(t,e,r){if(t.length===0)throw Error("empty string");if(typeof e=="number"?(r=e,e=!1):e=!!e,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e?Tt:et;if(r=r||10,r<2||36<r)throw RangeError("radix");var n;if((n=t.indexOf("-"))>0)throw Error("interior hyphen");if(n===0)return Ul(t.substring(1),e,r).neg();for(var o=je(Ci(r,8)),s=et,i=0;i<t.length;i+=8){var a=Math.min(8,t.length-i),c=parseInt(t.substring(i,i+a),r);if(a<8){var l=je(Ci(r,a));s=s.mul(l).add(je(c))}else s=s.mul(o),s=s.add(je(c))}return s.unsigned=e,s}Z.fromString=Ul;function tt(t,e){return typeof t=="number"?je(t,e):typeof t=="string"?Ul(t,e):q(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}Z.fromValue=tt;var jg=1<<16,L2=1<<24,ln=jg*jg,Xg=ln*ln,Jg=Xg/2,Wg=yr(L2),et=yr(0);Z.ZERO=et;var Tt=yr(0,!0);Z.UZERO=Tt;var cn=yr(1);Z.ONE=cn;var Yg=yr(1,!0);Z.UONE=Yg;var Dl=yr(-1);Z.NEG_ONE=Dl;var Kg=q(-1,2147483647,!1);Z.MAX_VALUE=Kg;var Qg=q(-1,-1,!0);Z.MAX_UNSIGNED_VALUE=Qg;var ve=q(0,-2147483648,!1);Z.MIN_VALUE=ve;var I=Z.prototype;I.toInt=function(){return this.unsigned?this.low>>>0:this.low};I.toNumber=function(){return this.unsigned?(this.high>>>0)*ln+(this.low>>>0):this.high*ln+(this.low>>>0)};I.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(ve)){var r=je(e),n=this.div(r),o=n.mul(r).sub(this);return n.toString(e)+o.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var s=je(Ci(e,6),this.unsigned),i=this,a="";;){var c=i.div(s),l=i.sub(c.mul(s)).toInt()>>>0,f=l.toString(e);if(i=c,i.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}};I.getHighBits=function(){return this.high};I.getHighBitsUnsigned=function(){return this.high>>>0};I.getLowBits=function(){return this.low};I.getLowBitsUnsigned=function(){return this.low>>>0};I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(ve)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&!(e&1<<r);r--);return this.high!=0?r+33:r+1};I.isZero=function(){return this.high===0&&this.low===0};I.eqz=I.isZero;I.isNegative=function(){return!this.unsigned&&this.high<0};I.isPositive=function(){return this.unsigned||this.high>=0};I.isOdd=function(){return(this.low&1)===1};I.isEven=function(){return(this.low&1)===0};I.equals=function(e){return Te(e)||(e=tt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};I.eq=I.equals;I.notEquals=function(e){return!this.eq(e)};I.neq=I.notEquals;I.ne=I.notEquals;I.lessThan=function(e){return this.comp(e)<0};I.lt=I.lessThan;I.lessThanOrEqual=function(e){return this.comp(e)<=0};I.lte=I.lessThanOrEqual;I.le=I.lessThanOrEqual;I.greaterThan=function(e){return this.comp(e)>0};I.gt=I.greaterThan;I.greaterThanOrEqual=function(e){return this.comp(e)>=0};I.gte=I.greaterThanOrEqual;I.ge=I.greaterThanOrEqual;I.compare=function(e){if(Te(e)||(e=tt(e)),this.eq(e))return 0;var r=this.isNegative(),n=e.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};I.comp=I.compare;I.negate=function(){return!this.unsigned&&this.eq(ve)?ve:this.not().add(cn)};I.neg=I.negate;I.add=function(e){Te(e)||(e=tt(e));var r=this.high>>>16,n=this.high&65535,o=this.low>>>16,s=this.low&65535,i=e.high>>>16,a=e.high&65535,c=e.low>>>16,l=e.low&65535,f=0,u=0,h=0,p=0;return p+=s+l,h+=p>>>16,p&=65535,h+=o+c,u+=h>>>16,h&=65535,u+=n+a,f+=u>>>16,u&=65535,f+=r+i,f&=65535,q(h<<16|p,f<<16|u,this.unsigned)};I.subtract=function(e){return Te(e)||(e=tt(e)),this.add(e.neg())};I.sub=I.subtract;I.multiply=function(e){if(this.isZero())return this;if(Te(e)||(e=tt(e)),qe){var r=qe.mul(this.low,this.high,e.low,e.high);return q(r,qe.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?Tt:et;if(this.eq(ve))return e.isOdd()?ve:et;if(e.eq(ve))return this.isOdd()?ve:et;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Wg)&&e.lt(Wg))return je(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,o=this.high&65535,s=this.low>>>16,i=this.low&65535,a=e.high>>>16,c=e.high&65535,l=e.low>>>16,f=e.low&65535,u=0,h=0,p=0,d=0;return d+=i*f,p+=d>>>16,d&=65535,p+=s*f,h+=p>>>16,p&=65535,p+=i*l,h+=p>>>16,p&=65535,h+=o*f,u+=h>>>16,h&=65535,h+=s*l,u+=h>>>16,h&=65535,h+=i*c,u+=h>>>16,h&=65535,u+=n*f+o*l+s*c+i*a,u&=65535,q(p<<16|d,u<<16|h,this.unsigned)};I.mul=I.multiply;I.divide=function(e){if(Te(e)||(e=tt(e)),e.isZero())throw Error("division by zero");if(qe){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?qe.div_u:qe.div_s)(this.low,this.high,e.low,e.high);return q(r,qe.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Tt:et;var n,o,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Tt;if(e.gt(this.shru(1)))return Yg;s=Tt}else{if(this.eq(ve)){if(e.eq(cn)||e.eq(Dl))return ve;if(e.eq(ve))return cn;var i=this.shr(1);return n=i.div(e).shl(1),n.eq(et)?e.isNegative()?cn:Dl:(o=this.sub(e.mul(n)),s=n.add(o.div(e)),s)}else if(e.eq(ve))return this.unsigned?Tt:et;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=et}for(o=this;o.gte(e);){n=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),c=a<=48?1:Ci(2,a-48),l=je(n),f=l.mul(e);f.isNegative()||f.gt(o);)n-=c,l=je(n,this.unsigned),f=l.mul(e);l.isZero()&&(l=cn),s=s.add(l),o=o.sub(f)}return s};I.div=I.divide;I.modulo=function(e){if(Te(e)||(e=tt(e)),qe){var r=(this.unsigned?qe.rem_u:qe.rem_s)(this.low,this.high,e.low,e.high);return q(r,qe.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};I.mod=I.modulo;I.rem=I.modulo;I.not=function(){return q(~this.low,~this.high,this.unsigned)};I.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};I.clz=I.countLeadingZeros;I.countTrailingZeros=function(){return this.low?zg(this.low):zg(this.high)+32};I.ctz=I.countTrailingZeros;I.and=function(e){return Te(e)||(e=tt(e)),q(this.low&e.low,this.high&e.high,this.unsigned)};I.or=function(e){return Te(e)||(e=tt(e)),q(this.low|e.low,this.high|e.high,this.unsigned)};I.xor=function(e){return Te(e)||(e=tt(e)),q(this.low^e.low,this.high^e.high,this.unsigned)};I.shiftLeft=function(e){return Te(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?q(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):q(0,this.low<<e-32,this.unsigned)};I.shl=I.shiftLeft;I.shiftRight=function(e){return Te(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?q(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):q(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};I.shr=I.shiftRight;I.shiftRightUnsigned=function(e){return Te(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?q(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?q(this.high,0,this.unsigned):q(this.high>>>e-32,0,this.unsigned)};I.shru=I.shiftRightUnsigned;I.shr_u=I.shiftRightUnsigned;I.rotateLeft=function(e){var r;return Te(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?q(this.high,this.low,this.unsigned):e<32?(r=32-e,q(this.low<<e|this.high>>>r,this.high<<e|this.low>>>r,this.unsigned)):(e-=32,r=32-e,q(this.high<<e|this.low>>>r,this.low<<e|this.high>>>r,this.unsigned))};I.rotl=I.rotateLeft;I.rotateRight=function(e){var r;return Te(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?q(this.high,this.low,this.unsigned):e<32?(r=32-e,q(this.high<<r|this.low>>>e,this.low<<r|this.high>>>e,this.unsigned)):(e-=32,r=32-e,q(this.low<<r|this.high>>>e,this.high<<r|this.low>>>e,this.unsigned))};I.rotr=I.rotateRight;I.toSigned=function(){return this.unsigned?q(this.low,this.high,!1):this};I.toUnsigned=function(){return this.unsigned?this:q(this.low,this.high,!0)};I.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};I.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};I.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};Z.fromBytes=function(e,r,n){return n?Z.fromBytesLE(e,r):Z.fromBytesBE(e,r)};Z.fromBytesLE=function(e,r){return new Z(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)};Z.fromBytesBE=function(e,r){return new Z(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)};var fn=Z;var F2=16;function bo(t){t==="X"&&(t="");let e=t.padEnd(F2,"0");return fn.fromString(e,!0,16)}function Gl(t){if(t.isZero())return"X";let e=t.countTrailingZeros(),r=e%4;e=(e-r)/4;let n=e;e*=4;let s=t.shiftRightUnsigned(e).toString(16).replace(/0+$/,"");return Array(17-n-s.length).join("0")+s}function Hl(t,e){let r=P2(t).shiftRightUnsigned(2);return t.add(fn.fromNumber(2*e+1-4).multiply(r))}function P2(t){return t.and(t.not().add(1))}var N2=3,O2=30,D2=2*O2+1,Zg=180/Math.PI;function e0(t){if(t.length===0)throw new Error(`Invalid Hilbert quad key ${t}`);let e=t.split("/"),r=parseInt(e[0],10),n=e[1],o=n.length,s=0,i=[0,0];for(let a=o-1;a>=0;a--){s=o-a;let c=n[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,s-1);U2(u,i,l,f),i[0]+=u*l,i[1]+=u*f}if(r%2===1){let a=i[0];i[0]=i[1],i[1]=a}return{face:r,ij:i,level:s}}function t0(t){if(t.isZero())return"";let e=t.toString(2);for(;e.length<N2+D2;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),o=e.substring(3,r),s=o.length/2,i=fn.fromString(n,!0,2).toString(10),a="";if(s!==0)for(a=fn.fromString(o,!0,2).toString(4);a.length<s;)a="0"+a;return`${i}/${a}`}function Vl(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function $g(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function zl(t){return[$g(t[0]),$g(t[1])]}function kl(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function ql([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*Zg,n*Zg]}function U2(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let o=e[0];e[0]=e[1],e[1]=o}}function r0(t){let e=Vl(t.ij,t.level,[.5,.5]),r=zl(e),n=kl(t.face,r);return ql(n)}var G2=100;function jl(t){let{face:e,ij:r,level:n}=t,o=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(G2*Math.pow(2,-n))),i=new Float64Array(4*s*2+2),a=0,c=0;for(let l=0;l<4;l++){let f=o[l].slice(0),u=o[l+1],h=(u[0]-f[0])/s,p=(u[1]-f[1])/s;for(let d=0;d<s;d++){f[0]+=h,f[1]+=p;let A=Vl(r,n,f),m=zl(A),b=kl(e,m),T=ql(b);Math.abs(T[1])>89.999&&(T[0]=c);let E=T[0]-c;T[0]+=E>180?-360:E<-180?360:0,i[a++]=T[0],i[a++]=T[1],c=T[0]}}return i[a++]=i[0],i[a++]=i[1],i}function un(t){let e=H2(t);return e0(e)}function H2(t){if(t.indexOf("/")>0)return t;let e=bo(t);return t0(e)}function Jl(t){let e=un(t);return r0(e)}function o0(t){let e;if(t.face===2||t.face===5){let r=null,n=0;for(let o=0;o<4;o++){let s=`${t.face}/${o}`,i=un(s),a=jl(i);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,n),n+=a.length}e=n0(r)}else{let r=jl(t);e=n0(r)}return e}function n0(t){if(t.length%2!==0)throw new Error("Invalid corners");let e=[],r=[];for(let n=0;n<t.length;n+=2)e.push(t[n]),r.push(t[n+1]);return e.sort((n,o)=>n-o),r.sort((n,o)=>n-o),{west:e[0],east:e[e.length-1],north:r[r.length-1],south:r[0]}}function Wl(t,e){let r=e?.minimumHeight||0,n=e?.maximumHeight||0,o=un(t),s=o0(o),i=s.west,a=s.south,c=s.east,l=s.north,f=[];return f.push(new x(i,l,r)),f.push(new x(c,l,r)),f.push(new x(c,a,r)),f.push(new x(i,a,r)),f.push(new x(i,l,n)),f.push(new x(c,l,n)),f.push(new x(c,a,n)),f.push(new x(i,a,n)),f}function Bi(t){let e=t.token,r={minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight},n=Wl(e,r),o=Jl(e),s=o[0],i=o[1],a=G.WGS84.cartographicToCartesian([s,i,r.maximumHeight]),c=new x(a[0],a[1],a[2]);n.push(c);let l=$n(n);return[...l.center,...l.halfAxes]}var V2=4,z2=8,k2={QUADTREE:V2,OCTREE:z2};function q2(t,e,r){if(t?.box){let n=bo(t.s2VolumeInfo.token),o=Hl(n,e),s=Gl(o),i={...t.s2VolumeInfo};switch(i.token=s,r){case"OCTREE":let l=t.s2VolumeInfo,f=l.maximumHeight-l.minimumHeight,u=f/2,h=l.minimumHeight+f/2;l.minimumHeight=h-u,l.maximumHeight=h+u;break;default:break}return{box:Bi(i),s2VolumeInfo:i}}}async function Yl(t){let{subtree:e,subtreeData:r={level:0,x:0,y:0,z:0},parentData:n={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:o=0,implicitOptions:s,loaderOptions:i,s2VolumeBox:a}=t,{subdivisionScheme:c,subtreeLevels:l,maximumLevel:f,contentUrlTemplate:u,subtreesUriTemplate:h,basePath:p}=s,d={children:[],lodMetricValue:0,contentUrl:""};if(!f)return tc.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${u} won't be loaded...`),d;let A=n.localLevel+1,m=r.level+A;if(m>f)return d;let b=k2[c],T=Math.log2(b),E=o&1,_=o>>1&1,S=o>>2&1,C=Tr(n.localX,E,1),v=Tr(n.localY,_,1),M=Tr(n.localZ,S,1),y=Tr(r.x,C,A),g=Tr(r.y,v,A),B=Tr(r.z,M,A),L=Tr(n.mortonIndex,o,T),F=A===l&&Xl(e.childSubtreeAvailability,L),w,U,W,z;if(F){let Y=`${p}/${h}`,ee=Ii(Y,m,y,g,B);w=await(0,s0.load)(ee,Si,i),z=0,U={level:m,x:y,y:g,z:B},W={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else w=e,z=(b**A-1)/(b-1)+L,U=r,W={mortonIndex:L,localLevel:A,localX:C,localY:v,localZ:M};if(!Xl(w.tileAvailability,z))return d;Xl(w.contentAvailability,z)&&(d.contentUrl=Ii(u,m,y,g,B));for(let Y=0;Y<b;Y++){let ee=q2(a,Y,c),Be=await Yl({subtree:w,subtreeData:U,parentData:W,childIndex:Y,implicitOptions:s,loaderOptions:i,s2VolumeBox:ee});(Be.contentUrl||Be.children.length)&&d.children.push(Be)}return d.contentUrl||d.children.length?j2(d,{level:m,x:y,y:g,z:B},s,a):d}function Xl(t,e){let r;return Array.isArray(t)?(r=t[0],t.length>1&&tc.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=t,"constant"in r?Boolean(r.constant):r.explicitBitstream?X2(e,r.explicitBitstream):!1}function j2(t,e,r,n){let{basePath:o,refine:s,getRefine:i,lodMetricType:a,getTileType:c,rootLodMetricValue:l,rootBoundingVolume:f}=r,u=t.contentUrl&&t.contentUrl.replace(`${o}/`,""),h=l/2**e.level,p=n?.box?{box:n.box}:f,d=J2(p,e,r.subdivisionScheme);return{children:t.children,contentUrl:t.contentUrl,content:{uri:u},id:t.contentUrl,refine:i(s),type:c(t),lodMetricType:a,lodMetricValue:h,geometricError:h,transform:t.transform,boundingVolume:d}}function J2(t,e,r){if(t.region){let{level:n,x:o,y:s,z:i}=e,[a,c,l,f,u,h]=t.region,p=2**n,d=(l-a)/p,[A,m]=[a+d*o,a+d*(o+1)],b=(f-c)/p,[T,E]=[c+b*s,c+b*(s+1)],_,S;if(r==="OCTREE"){let C=(h-u)/p;[_,S]=[u+C*i,u+C*(i+1)]}else[_,S]=[u,h];return{region:[A,T,m,E,_,S]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}function Tr(t,e,r){return(t<<r)+e}function Ii(t,e,r,n,o){let s=W2({level:e,x:r,y:n,z:o});return t.replace(/{level}|{x}|{y}|{z}/gi,i=>s[i])}function W2(t){let e={};for(let r in t)e[`{${r}}`]=t[r];return e}function X2(t,e){let r=Math.floor(t/8),n=t%8;return(e[r]>>n&1)===1}function Ql(t,e=""){if(!e)return ze.EMPTY;let n=e.split("?")[0].split(".").pop();switch(n){case"pnts":return ze.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return ze.SCENEGRAPH;default:return n||ze.EMPTY}}function Zl(t){switch(t){case"REPLACE":case"replace":return be.REPLACE;case"ADD":case"add":return be.ADD;default:return t}}function Kl(t,e){if(/^[a-z][0-9a-z+.-]*:/i.test(e)){let n=new URL(t,`${e}/`);return decodeURI(n.toString())}else if(t.startsWith("/"))return t;return Lt.resolve(e,t)}function i0(t,e){if(!t)return null;let r;if(t.content){let o=t.content.uri||t.content?.url;typeof o<"u"&&(r=Kl(o,e))}return{...t,id:r,contentUrl:r,lodMetricType:bt.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:Ql(t,r),refine:Zl(t.refine)}}async function f0(t,e,r){let n=null,o=c0(t.root);o&&t.root?n=await a0(t.root,t,e,o,r):n=i0(t.root,e);let s=[];for(s.push(n);s.length>0;){let i=s.pop()||{},a=i.children||[],c=[];for(let l of a){let f=c0(l),u;f?u=await a0(l,t,e,f,r):u=i0(l,e),u&&(c.push(u),s.push(u))}i.children=c}return n}async function a0(t,e,r,n,o){let{subdivisionScheme:s,maximumLevel:i,availableLevels:a,subtreeLevels:c,subtrees:{uri:l}}=n,f=Ii(l,0,0,0,0),u=Kl(f,r),h=await(0,l0.load)(u,Si,o),p=t.content?.uri,d=p?Kl(p,r):"",A=e?.root?.refine,m=t.geometricError,b=t.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(b){let S={box:Bi(b),s2VolumeInfo:b};t.boundingVolume=S}let T=t.boundingVolume,E={contentUrlTemplate:d,subtreesUriTemplate:l,subdivisionScheme:s,subtreeLevels:c,maximumLevel:Number.isFinite(a)?a-1:i,refine:A,basePath:r,lodMetricType:bt.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:T,getTileType:Ql,getRefine:Zl};return await Y2(t,r,h,E,o)}async function Y2(t,e,r,n,o){if(!t)return null;let{children:s,contentUrl:i}=await Yl({subtree:r,implicitOptions:n,loaderOptions:o}),a,c=null;return i&&(a=i,c={uri:i.replace(`${e}/`,"")}),{...t,id:a,contentUrl:a,lodMetricType:bt.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:Ql(t,a),refine:Zl(t.refine),content:c||t.content,children:s}}function c0(t){return t?.extensions?.["3DTILES_implicit_tiling"]||t?.implicitTiling}var Ri={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:ai,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:K2,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function K2(t,e={},r){let n=e["3d-tiles"]||{},o;return n.isTileset==="auto"?o=r?.url&&r.url.indexOf(".json")!==-1:o=n.isTileset,o?Q2(t,e,r):Z2(t,e,r)}async function Q2(t,e,r){let n=JSON.parse(new TextDecoder().decode(t)),o=r?.url||"",s=$2(o),i=await f0(n,s,e||{});return{...n,shape:"tileset3d",loader:Ri,url:o,queryString:r?.queryString||"",basePath:s,root:i||n.root,type:pe.TILES3D,lodMetricType:bt.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0}}async function Z2(t,e,r){let n={content:{shape:"tile3d",featureIds:null}};return await Nl(t,0,e,r,n.content),n.content}function $2(t){return Lt.dirname(t)}var u0=[0],eR={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Ri,onTilesetLoad:{type:"function",value:t=>{}},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:(t,e,r)=>{}},_getMeshColor:{type:"function",value:t=>[255,255,255]}},yo=class extends kt.CompositeLayer{initializeState(){"onTileLoadFail"in this.props&&kt.log.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:r,changeFlags:n}){if(e.data&&e.data!==r.data&&this._loadTileset(e.data),n.viewportChanged){let{activeViewports:o}=this.state;Object.keys(o).length&&(this._updateTileset(o),this.state.lastUpdatedViewports=o,this.state.activeViewports={})}if(n.propsChanged){let{layerMap:o}=this.state;for(let s in o)o[s].needsUpdate=!0}}finalizeState(e){this.state.tileset3d?.destroy(),this.state.tileset3d=null,this.state.layerMap={},this.state.activeViewports={},this.state.lastUpdatedViewports=null,super.finalizeState(e)}activateViewport(e){let{activeViewports:r,lastUpdatedViewports:n}=this.state;this.internalState.viewport=e,r[e.id]=e;let o=n?.[e.id];(!o||!e.equals(o))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:r}){let n=r&&r.props.tile;return e.picked&&(e.object=n),e.sourceTile=n,e}filterSubLayer({layer:e,viewport:r,cullRect:n,isPicking:o}){let{tile:s}=e.props,{id:i}=r;if(!s.selected||!s.viewportIds.includes(i))return!1;if(o&&n&&s.content?.cartographicOrigin){let[a,c]=r.project(s.content.cartographicOrigin),l=n.x+n.width/2,f=n.y+n.height/2,u=Math.max(r.width,r.height)/4,h=a-l,p=c-f;if(h*h+p*p>u*u)return!1}return!0}_updateAutoHighlight(e){let r=e.sourceTile,n=this.state.layerMap[r?.id];n&&n.layer&&n.layer.updateAutoHighlight(e)}async _loadTileset(e){let r=this.props.loadOptions||{},n=this.props.loaders?.length?this.props.loaders:this.props.loader,o=Array.isArray(n)?n[0]:n,{tileset:s,...i}=r,a={loadOptions:{...i},...s},c=e;if("preload"in o&&typeof o.preload=="function"){let u=await o.preload(e,r);u.url&&(c=u.url),u.headers&&(a.loadOptions.core={...a.loadOptions.core,fetch:{...a.loadOptions.core?.fetch,headers:u.headers}}),Object.assign(a,u)}let l=await(0,m0.load)(c,o,a.loadOptions),f=new lo(l,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...a});this.setState({tileset3d:f,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(f)}_onTileLoad(e){let{lastUpdatedViewports:r}=this.state;e.tileDrawn=!1,this.props.onTileLoad(e),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;let{tileset3d:r}=this.state,{timeline:n}=this.context,o=Object.keys(e).length;!n||!o||!r||r.selectTiles(Object.values(e)).then(s=>{this.state.frameNumber!==s&&this.setState({frameNumber:s})})}_getSubLayer(e,r){if(!e.content)return null;switch(e.type){case ze.POINTCLOUD:return this._makePointCloudLayer(e,r);case ze.SCENEGRAPH:return this._make3DModelLayer(e);case ze.MESH:return this._makeSimpleMeshLayer(e,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){let{attributes:n,pointCount:o,constantRGBA:s,cartographicOrigin:i,modelMatrix:a}=e.content,{positions:c,normals:l,colors:f}=n;if(!c)return null;let u=r&&r.props.data||{header:{vertexCount:o},attributes:{POSITION:c,NORMAL:l,COLOR_0:f}},{pointSize:h,getPointColor:p}=this.props,d=this.getSubLayerClass("pointcloud",p0.PointCloudLayer);return new d({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:u,coordinateSystem:kt.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:i,modelMatrix:a,getColor:s||p,_offset:0})}_make3DModelLayer(e){let{gltf:r,instances:n,cartographicOrigin:o,modelMatrix:s}=e.content,i=this.getSubLayerClass("scenegraph",d0.ScenegraphLayer);return new i({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:n||u0,scenegraph:r,coordinateSystem:kt.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:o,modelMatrix:s,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,r){let n=e.content,{attributes:o,indices:s,modelMatrix:i,cartographicOrigin:a,coordinateSystem:c=kt.COORDINATE_SYSTEM.METER_OFFSETS,material:l,featureIds:f}=n,{_getMeshColor:u}=this.props,h=r&&r.props.mesh||new h0.Geometry({topology:"triangle-list",attributes:tR(o),indices:s}),p=this.getSubLayerClass("mesh",am);return new p(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:h,data:u0,getColor:u(e),pbrMaterial:l,modelMatrix:i,coordinateOrigin:a,coordinateSystem:c,featureIds:f,_offset:0})}renderLayers(){let{tileset3d:e,layerMap:r}=this.state;return e?e.tiles.map(n=>{let o=r[n.id]=r[n.id]||{tile:n},{layer:s}=o;return n.selected&&(s?o.needsUpdate&&(s=this._getSubLayer(n,s),o.needsUpdate=!1):s=this._getSubLayer(n)),o.layer=s,s}).filter(Boolean):null}};yo.defaultProps=eR;yo.layerName="Tile3DLayer";var g0=yo;function tR(t){let e={};return e.positions={...t.positions,value:new Float32Array(t.positions.value)},t.normals&&(e.normals=t.normals),t.texCoords&&(e.texCoords=t.texCoords),t.colors&&(e.colors=t.colors),t.uvRegions&&(e.uvRegions=t.uvRegions),e}var Pi=D(Xe(),1),nf=D(zs(),1),_0=D(Xe(),1);var rR=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function $l(t){return t>>1^-(t&1)}function nR(t){let e=0,r={};for(let[n,o]of rR){let s=o===8?t.getFloat64:t.getFloat32;r[n]=s.call(t,e,!0),e+=o}return{header:r,headerEndPosition:e}}function oR(t,e){let r=e,n=3,o=t.getUint32(r,!0),s=new Uint16Array(o*n);r+=Uint32Array.BYTES_PER_ELEMENT;let i=Uint16Array.BYTES_PER_ELEMENT,a=o*i,c=r,l=c+a,f=l+a,u=0,h=0,p=0;for(let d=0;d<o;d++)u+=$l(t.getUint16(c+i*d,!0)),h+=$l(t.getUint16(l+i*d,!0)),p+=$l(t.getUint16(f+i*d,!0)),s[d]=u,s[d+o]=h,s[d+o*2]=p;return r+=a*3,{vertexData:s,vertexDataEndPosition:r}}function To(t,e,r,n,o=!0){let s;if(n===2?s=new Uint16Array(t,e,r):s=new Uint32Array(t,e,r),!o)return s;let i=0;for(let a=0;a<s.length;++a){let c=s[a];s[a]=i-c,c===0&&++i}return s}function sR(t,e,r){let n=r,o=3,i=e.length/o>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;n%i!==0&&(n+=i-n%i);let a=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=a*3,l=To(t.buffer,n,c,i);return n+=c*i,{triangleIndicesEndPosition:n,triangleIndices:l}}function iR(t,e,r){let n=r,o=3,i=e.length/o>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=To(t.buffer,n,a,i,!1);n+=a*i;let l=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let f=To(t.buffer,n,l,i,!1);n+=l*i;let u=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let h=To(t.buffer,n,u,i,!1);n+=u*i;let p=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let d=To(t.buffer,n,p,i,!1);return n+=p*i,{edgeIndicesEndPosition:n,westIndices:c,southIndices:f,eastIndices:h,northIndices:d}}function aR(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function cR(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function lR(t,e){let r={};if(t.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let n=e;for(;n<t.byteLength;){let o=t.getUint8(n,!0);n+=Uint8Array.BYTES_PER_ELEMENT;let s=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let i=new DataView(t.buffer,n,s);switch(o){case 1:{r.vertexNormals=aR(i);break}case 2:{r.waterMask=cR(i);break}default:}n+=s}return{extensions:r,extensionsEndPosition:n}}var Er={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},fR={maxDecodingStep:Er.extensions};function ef(t,e){let r=Object.assign({},fR,e),n=new DataView(t),{header:o,headerEndPosition:s}=nR(n);if(r.maxDecodingStep<Er.vertices)return{header:o};let{vertexData:i,vertexDataEndPosition:a}=oR(n,s);if(r.maxDecodingStep<Er.triangleIndices)return{header:o,vertexData:i};let{triangleIndices:c,triangleIndicesEndPosition:l}=sR(n,i,a);if(r.maxDecodingStep<Er.edgeIndices)return{header:o,vertexData:i,triangleIndices:c};let{westIndices:f,southIndices:u,eastIndices:h,northIndices:p,edgeIndicesEndPosition:d}=iR(n,i,l);if(r.maxDecodingStep<Er.extensions)return{header:o,vertexData:i,triangleIndices:c,westIndices:f,northIndices:p,eastIndices:h,southIndices:u};let{extensions:A}=lR(n,d);return{header:o,vertexData:i,triangleIndices:c,westIndices:f,northIndices:p,eastIndices:h,southIndices:u,extensions:A}}function vi(t,e,r,n){let o=n?hR(n,t.POSITION.value):uR(e),s=new t.POSITION.value.constructor(o.length*6),i=new t.TEXCOORD_0.value.constructor(o.length*4),a=new e.constructor(o.length*6);for(let l=0;l<o.length;l++){let f=o[l];pR({edge:f,edgeIndex:l,attributes:t,skirtHeight:r,newPosition:s,newTexcoord0:i,newTriangles:a})}t.POSITION.value=Un(t.POSITION.value,s),t.TEXCOORD_0.value=Un(t.TEXCOORD_0.value,i);let c=e instanceof Array?e.concat(a):Un(e,a);return{attributes:t,triangles:c}}function uR(t){let e=[];for(let o=0;o<t.length;o+=3)e.push([t[o],t[o+1]]),e.push([t[o+1],t[o+2]]),e.push([t[o+2],t[o]]);e.sort((o,s)=>Math.min(...o)-Math.min(...s)||Math.max(...o)-Math.max(...s));let r=[],n=0;for(;n<e.length;)e[n][0]===e[n+1]?.[1]&&e[n][1]===e[n+1]?.[0]?n+=2:(r.push(e[n]),n++);return r}function hR(t,e){t.westIndices.sort((n,o)=>e[3*n+1]-e[3*o+1]),t.eastIndices.sort((n,o)=>e[3*o+1]-e[3*n+1]),t.southIndices.sort((n,o)=>e[3*o]-e[3*n]),t.northIndices.sort((n,o)=>e[3*n]-e[3*o]);let r=[];for(let n in t){let o=t[n];for(let s=0;s<o.length-1;s++)r.push([o[s],o[s+1]])}return r}function pR({edge:t,edgeIndex:e,attributes:r,skirtHeight:n,newPosition:o,newTexcoord0:s,newTriangles:i}){let a=r.POSITION.value.length,c=e*2,l=e*2+1;o.set(r.POSITION.value.subarray(t[0]*3,t[0]*3+3),c*3),o[c*3+2]=o[c*3+2]-n,o.set(r.POSITION.value.subarray(t[1]*3,t[1]*3+3),l*3),o[l*3+2]=o[l*3+2]-n,s.set(r.TEXCOORD_0.value.subarray(t[0]*2,t[0]*2+2),c*2),s.set(r.TEXCOORD_0.value.subarray(t[1]*2,t[1]*2+2),l*2);let f=e*2*3;i[f]=t[0],i[f+1]=a/3+l,i[f+2]=t[1],i[f+3]=a/3+l,i[f+4]=t[0],i[f+5]=a/3+c}function tf(t,e={}){let{bounds:r}=e,{header:n,vertexData:o,triangleIndices:s,westIndices:i,northIndices:a,eastIndices:c,southIndices:l}=ef(t,Er.triangleIndices),f=s,u=dR(o,n,r),h=gr(u);if(e?.skirtHeight){let{attributes:p,triangles:d}=vi(u,f,e.skirtHeight,{westIndices:i,northIndices:a,eastIndices:c,southIndices:l});u=p,f=d}return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:h},schema:void 0,topology:"triangle-list",mode:4,indices:{value:f,size:1},attributes:u}}function dR(t,e,r){let{minHeight:n,maxHeight:o}=e,[s,i,a,c]=r||[0,0,1,1],l=a-s,f=c-i,u=o-n,h=t.length/3,p=new Float32Array(h*3),d=new Float32Array(h*2);for(let A=0;A<h;A++){let m=t[A]/32767,b=t[A+h]/32767,T=t[A+h*2]/32767;p[3*A+0]=m*l+s,p[3*A+1]=b*f+i,p[3*A+2]=T*u+n,d[2*A+0]=m,d[2*A+1]=b}return{POSITION:{value:p,size:3},TEXCOORD_0:{value:d,size:2}}}var Eo=class{constructor(e=257){this.gridSize=e;let r=e-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let o=n+2,s=0,i=0,a=0,c=0,l=0,f=0;for(o&1?a=c=l=r:s=i=f=r;(o>>=1)>1;){let h=s+a>>1,p=i+c>>1;o&1?(a=s,c=i,s=l,i=f):(s=a,i=c,a=l,c=f),l=h,f=p}let u=n*4;this.coords[u+0]=s,this.coords[u+1]=i,this.coords[u+2]=a,this.coords[u+3]=c}}createTile(e){return new rf(e,this)}},rf=class{constructor(e,r){let n=r.gridSize;if(e.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:n,gridSize:o}=this.martini,{terrain:s,errors:i}=this;for(let a=e-1;a>=0;a--){let c=a*4,l=n[c+0],f=n[c+1],u=n[c+2],h=n[c+3],p=l+u>>1,d=f+h>>1,A=p+d-f,m=d+l-p,b=(s[f*o+l]+s[h*o+u])/2,T=d*o+p,E=Math.abs(b-s[T]);if(i[T]=Math.max(i[T],E),a<r){let _=(f+m>>1)*o+(l+A>>1),S=(h+m>>1)*o+(u+A>>1);i[T]=Math.max(i[T],i[_],i[S])}}}getMesh(e=0){let{gridSize:r,indices:n}=this.martini,{errors:o}=this,s=0,i=0,a=r-1;n.fill(0);function c(p,d,A,m,b,T){let E=p+A>>1,_=d+m>>1;Math.abs(p-b)+Math.abs(d-T)>1&&o[_*r+E]>e?(c(b,T,p,d,E,_),c(A,m,b,T,E,_)):(n[d*r+p]=n[d*r+p]||++s,n[m*r+A]=n[m*r+A]||++s,n[T*r+b]=n[T*r+b]||++s,i++)}c(0,0,a,a,a,0),c(a,a,0,0,0,a);let l=new Uint16Array(s*2),f=new Uint32Array(i*3),u=0;function h(p,d,A,m,b,T){let E=p+A>>1,_=d+m>>1;if(Math.abs(p-b)+Math.abs(d-T)>1&&o[_*r+E]>e)h(b,T,p,d,E,_),h(A,m,b,T,E,_);else{let S=n[d*r+p]-1,C=n[m*r+A]-1,v=n[T*r+b]-1;l[2*S]=p,l[2*S+1]=d,l[2*C]=A,l[2*C+1]=m,l[2*v]=b,l[2*v+1]=T,f[u++]=S,f[u++]=C,f[u++]=v}}return h(0,0,a,a,a,0),h(a,a,0,0,0,a),{vertices:l,triangles:f}}};var _o=class{constructor(e,r,n=r){this.data=e,this.width=r,this.height=n,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let o=r-1,s=n-1,i=this._addPoint(0,0),a=this._addPoint(o,0),c=this._addPoint(0,s),l=this._addPoint(o,s),f=this._addTriangle(l,i,c,-1,-1,-1);this._addTriangle(i,l,a,f,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r<this._pendingLen;r++){let n=this._pending[r],o=2*this.triangles[n*3+0],s=2*this.triangles[n*3+1],i=2*this.triangles[n*3+2];this._findCandidate(e[o],e[o+1],e[s],e[s+1],e[i],e[i+1],n)}this._pendingLen=0}_findCandidate(e,r,n,o,s,i,a){let c=Math.min(e,n,s),l=Math.min(r,o,i),f=Math.max(e,n,s),u=Math.max(r,o,i),h=_r(n,o,s,i,c,l),p=_r(s,i,e,r,c,l),d=_r(e,r,n,o,c,l),A=o-r,m=e-n,b=i-o,T=n-s,E=r-i,_=s-e,S=_r(e,r,n,o,s,i),C=this.heightAt(e,r)/S,v=this.heightAt(n,o)/S,M=this.heightAt(s,i)/S,y=0,g=0,B=0,L=0;for(let F=l;F<=u;F++){let w=0;h<0&&b!==0&&(w=Math.max(w,Math.floor(-h/b))),p<0&&E!==0&&(w=Math.max(w,Math.floor(-p/E))),d<0&&A!==0&&(w=Math.max(w,Math.floor(-d/A)));let U=h+b*w,W=p+E*w,z=d+A*w,re=!1;for(let K=c+w;K<=f;K++){if(U>=0&&W>=0&&z>=0){re=!0;let Y=C*U+v*W+M*z,ee=Math.abs(Y-this.heightAt(K,F));L+=ee*ee,ee>y&&(y=ee,g=K,B=F)}else if(re)break;U+=b,W+=E,z+=A}h+=T,p+=_,d+=m}(g===e&&B===r||g===n&&B===o||g===s&&B===i)&&(y=0),this._candidates[2*a]=g,this._candidates[2*a+1]=B,this._rms[a]=L,this._queuePush(a,y,L)}_step(){let e=this._queuePop(),r=e*3+0,n=e*3+1,o=e*3+2,s=this.triangles[r],i=this.triangles[n],a=this.triangles[o],c=this.coords[2*s],l=this.coords[2*s+1],f=this.coords[2*i],u=this.coords[2*i+1],h=this.coords[2*a],p=this.coords[2*a+1],d=this._candidates[2*e],A=this._candidates[2*e+1],m=this._addPoint(d,A);if(_r(c,l,f,u,d,A)===0)this._handleCollinear(m,r);else if(_r(f,u,h,p,d,A)===0)this._handleCollinear(m,n);else if(_r(h,p,c,l,d,A)===0)this._handleCollinear(m,o);else{let b=this._halfedges[r],T=this._halfedges[n],E=this._halfedges[o],_=this._addTriangle(s,i,m,b,-1,-1,r),S=this._addTriangle(i,a,m,T,-1,_+1),C=this._addTriangle(a,s,m,E,_+2,S+1);this._legalize(_),this._legalize(S),this._legalize(C)}}_addPoint(e,r){let n=this.coords.length>>1;return this.coords.push(e,r),n}_addTriangle(e,r,n,o,s,i,a=this.triangles.length){let c=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=n,this._halfedges[a+0]=o,this._halfedges[a+1]=s,this._halfedges[a+2]=i,o>=0&&(this._halfedges[o]=a+0),s>=0&&(this._halfedges[s]=a+1),i>=0&&(this._halfedges[i]=a+2),this._candidates[2*c+0]=0,this._candidates[2*c+1]=0,this._queueIndices[c]=-1,this._rms[c]=0,this._pending[this._pendingLen++]=c,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let n=e-e%3,o=r-r%3,s=n+(e+1)%3,i=n+(e+2)%3,a=o+(r+2)%3,c=o+(r+1)%3,l=this.triangles[i],f=this.triangles[e],u=this.triangles[s],h=this.triangles[a],p=this.coords;if(!mR(p[2*l],p[2*l+1],p[2*f],p[2*f+1],p[2*u],p[2*u+1],p[2*h],p[2*h+1]))return;let d=this._halfedges[s],A=this._halfedges[i],m=this._halfedges[a],b=this._halfedges[c];this._queueRemove(n/3),this._queueRemove(o/3);let T=this._addTriangle(l,h,u,-1,m,d,n),E=this._addTriangle(h,l,f,T,A,b,o);this._legalize(T+1),this._legalize(E+2)}_handleCollinear(e,r){let n=r-r%3,o=n+(r+1)%3,s=n+(r+2)%3,i=this.triangles[s],a=this.triangles[r],c=this.triangles[o],l=this._halfedges[o],f=this._halfedges[s],u=this._halfedges[r];if(u<0){let C=this._addTriangle(e,i,a,-1,f,-1,n),v=this._addTriangle(i,e,c,C,-1,l);this._legalize(C+1),this._legalize(v+2);return}let h=u-u%3,p=h+(u+2)%3,d=h+(u+1)%3,A=this.triangles[p],m=this._halfedges[p],b=this._halfedges[d];this._queueRemove(h/3);let T=this._addTriangle(i,a,e,f,-1,-1,n),E=this._addTriangle(a,A,e,b,-1,T+1,h),_=this._addTriangle(A,c,e,m,-1,E+1),S=this._addTriangle(c,i,e,l,T+2,_+1);this._legalize(T),this._legalize(E),this._legalize(_),this._legalize(S)}_queuePush(e,r,n){let o=this._queue.length;this._queueIndices[e]=o,this._queue.push(e),this._errors.push(r),this._rmsSum+=n,this._queueUp(o)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let o=this._pending.indexOf(e);if(o!==-1)this._pending[o]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let n=this._queue.length-1;n!==r&&(this._queueSwap(r,n),this._queueDown(r,n)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let n=this._queue[e],o=this._queue[r];this._queue[e]=o,this._queue[r]=n,this._queueIndices[n]=r,this._queueIndices[o]=e;let s=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=s}_queueUp(e){let r=e;for(;;){let n=r-1>>1;if(n===r||!this._queueLess(r,n))break;this._queueSwap(n,r),r=n}}_queueDown(e,r){let n=e;for(;;){let o=2*n+1;if(o>=r||o<0)break;let s=o+1,i=o;if(s<r&&this._queueLess(s,o)&&(i=s),!this._queueLess(i,n))break;this._queueSwap(n,i),n=i}return n>e}};function _r(t,e,r,n,o,s){return(r-o)*(e-s)-(n-s)*(t-o)}function mR(t,e,r,n,o,s,i,a){let c=t-i,l=e-a,f=r-i,u=n-a,h=o-i,p=s-a,d=c*c+l*l,A=f*f+u*u,m=h*h+p*p;return c*(u*m-A*p)-l*(f*m-A*h)+d*(f*p-u*h)<0}function b0(t,e){let{meshMaxError:r,bounds:n,elevationDecoder:o}=e,{data:s,width:i,height:a}=t,c,l;switch(e.tesselator){case"martini":c=wi(s,i,a,o,e.tesselator),l=A0(r,i,c);break;case"delatin":c=wi(s,i,a,o,e.tesselator),l=x0(r,i,a,c);break;default:i===a&&!(a&i-1)?(c=wi(s,i,a,o,"martini"),l=A0(r,i,c)):(c=wi(s,i,a,o,"delatin"),l=x0(r,i,a,c));break}let{vertices:f}=l,{triangles:u}=l,h=gR(f,c,i,a,n),p=gr(h);if(e.skirtHeight){let{attributes:d,triangles:A}=vi(h,u,e.skirtHeight);h=d,u=A}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:p},mode:4,indices:{value:Uint32Array.from(u),size:1},attributes:h}}function A0(t,e,r){let n=e+1,s=new Eo(n).createTile(r),{vertices:i,triangles:a}=s.getMesh(t);return{vertices:i,triangles:a}}function x0(t,e,r,n){let o=new _o(n,e+1,r+1);o.run(t);let{coords:s,triangles:i}=o;return{vertices:s,triangles:i}}function wi(t,e,r,n,o){let{rScaler:s,bScaler:i,gScaler:a,offset:c}=n,l=new Float32Array((e+1)*(r+1));for(let f=0,u=0;u<r;u++)for(let h=0;h<e;h++,f++){let p=f*4,d=t[p+0],A=t[p+1],m=t[p+2];l[f+u]=d*s+A*a+m*i+c}if(o==="martini"){for(let f=(e+1)*e,u=0;u<e;u++,f++)l[f]=l[f-e-1];for(let f=r,u=0;u<r+1;u++,f+=r+1)l[f]=l[f-1]}return l}function gR(t,e,r,n,o){let s=r+1,i=t.length/2,a=new Float32Array(i*3),c=new Float32Array(i*2),[l,f,u,h]=o||[0,0,r,n],p=(u-l)/r,d=(h-f)/n;for(let A=0;A<i;A++){let m=t[A*2],b=t[A*2+1],T=b*s+m;a[3*A+0]=m*p+l,a[3*A+1]=-b*d+h,a[3*A+2]=e[T],c[2*A+0]=m/r,c[2*A+1]=b/n}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:c,size:2}}}var Li="4.4.0-alpha.18";var Fi={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:Li,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var y0={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:Li,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var AR={...Fi,parse:xR};async function xR(t,e,r){let n={...e,core:{...e?.core,mimeType:"application/x.image"},image:{...e?.image,type:"data"}},o=await Ne(t,[],n,r),s={...AR.options.terrain,...e?.terrain};return b0(o,s)}var ok={...y0,parseSync:(t,e)=>tf(t,e?.["quantized-mesh"]),parse:async(t,e)=>tf(t,e?.["quantized-mesh"])};var T0=[1],bR={...ur.defaultProps,elevationData:Dt,texture:{...Dt,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[Fi]};function E0(t){return Array.isArray(t)?t.join(";"):t||""}var Mo=class extends Pi.CompositeLayer{updateState({props:e,oldProps:r}){let n=e.elevationData!==r.elevationData;if(n){let{elevationData:s}=e,i=s&&(Array.isArray(s)||yR(s));this.setState({isTiled:i})}let o=n||e.meshMaxError!==r.meshMaxError||e.elevationDecoder!==r.elevationDecoder||e.bounds!==r.bounds;if(!this.state.isTiled&&o){let s=this.loadTerrain(e);this.setState({terrain:s})}e.workerUrl&&Pi.log.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:r,elevationDecoder:n,meshMaxError:o,signal:s}){if(!e)return null;let i=this.getLoadOptions();i={...i,terrain:{skirtHeight:this.state.isTiled?o*2:0,...i?.terrain,bounds:r,meshMaxError:o,elevationDecoder:n}};let{fetch:a}=this.props;return a(e,{propName:"elevationData",layer:this,loadOptions:i,signal:s})}getTiledTerrainData(e){let{elevationData:r,fetch:n,texture:o,elevationDecoder:s,meshMaxError:i}=this.props,{viewport:a}=this.context,c=lt(r,e),l=o&&lt(o,e),{signal:f}=e,u=[0,0],h=[0,0];if(a.isGeospatial){let m=e.bbox;u=a.projectFlat([m.west,m.south]),h=a.projectFlat([m.east,m.north])}else{let m=e.bbox;u=[m.left,m.bottom],h=[m.right,m.top]}let p=[u[0],u[1],h[0],h[1]],d=this.loadTerrain({elevationData:c,bounds:p,elevationDecoder:s,meshMaxError:i,signal:f}),A=l?n(l,{propName:"texture",layer:this,loaders:[],signal:f}).catch(m=>null):Promise.resolve(null);return Promise.all([d,A])}renderSubLayers(e){let r=this.getSubLayerClass("mesh",nf.SimpleMeshLayer),{color:n,wireframe:o,material:s}=this.props,{data:i}=e;if(!i)return null;let[a,c]=i;return new r(e,{data:T0,mesh:a,texture:c,_instanced:!1,coordinateSystem:_0.COORDINATE_SYSTEM.CARTESIAN,getPosition:l=>[0,0,0],getColor:n,wireframe:o,material:s})}onViewportLoad(e){if(!e)return;let{zRange:r}=this.state,n=e.map(i=>i.content).filter(Boolean).map(i=>i[0].header.boundingBox.map(c=>c[2]));if(n.length===0)return;let o=Math.min(...n.map(i=>i[0])),s=Math.max(...n.map(i=>i[1]));(!r||o<r[0]||s>r[1])&&this.setState({zRange:[o,s]})}renderLayers(){let{color:e,material:r,elevationData:n,texture:o,wireframe:s,meshMaxError:i,elevationDecoder:a,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:h,onTileLoad:p,onTileUnload:d,onTileError:A,maxCacheSize:m,maxCacheByteSize:b,refinementStrategy:T}=this.props;if(this.state.isTiled)return new ur(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:E0(n),texture:E0(o),meshMaxError:i,elevationDecoder:a}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:h,onTileLoad:p,onTileUnload:d,onTileError:A,maxCacheSize:m,maxCacheByteSize:b,refinementStrategy:T});if(!n)return null;let E=this.getSubLayerClass("mesh",nf.SimpleMeshLayer);return new E(this.getSubLayerProps({id:"mesh"}),{data:T0,mesh:this.state.terrain,texture:o,_instanced:!1,getPosition:_=>[0,0,0],getColor:e,material:r,wireframe:s})}};Mo.defaultProps=bR;Mo.layerName="TerrainLayer";var M0=Mo,yR=t=>t.includes("{x}")&&(t.includes("{y}")||t.includes("{-y}"));var ji=D(Xe(),1),Tf=D(We(),1),o1=D(C0(),1);function B0(t,e,r){switch(t.type){case"Point":return ER(t,e,r);case"LineString":return TR(t,e,r);case"Polygon":return I0(t,e,r);default:let n=t;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function I0(t,e=-1/0,r=1/0){let{positions:n}=t,o=t.polygonIndices.value.filter(c=>c>=e&&c<=r),s=t.primitivePolygonIndices.value.filter(c=>c>=e&&c<=r);if(!(o.length>2)){let c=[];for(let l=0;l<s.length-1;l++){let f=s[l],u=s[l+1],h=Ni(n,f,u);c.push(h)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<o.length-1;c++){let l=o[c],f=o[c+1],u=I0(t,l,f).coordinates;a.push(u)}return{type:"MultiPolygon",coordinates:a}}function TR(t,e=-1/0,r=1/0){let{positions:n}=t,o=t.pathIndices.value.filter(a=>a>=e&&a<=r);if(!(o.length>2))return{type:"LineString",coordinates:Ni(n,o[0],o[1])};let i=[];for(let a=0;a<o.length-1;a++){let c=Ni(n,o[a],o[a+1]);i.push(c)}return{type:"MultiLineString",coordinates:i}}function ER(t,e,r){let{positions:n}=t,o=Ni(n,e,r);return o.length>1?{type:"MultiPoint",coordinates:o}:{type:"Point",coordinates:o[0]}}function Ni(t,e,r){e=e||0,r=r||t.value.length/t.size;let n=[];for(let o=e;o<r;o++){let s=Array();for(let i=o*t.size;i<(o+1)*t.size;i++)s.push(Number(t.value[i]));n.push(s)}return n}var So={x:0,y:1,z:2};function Mr(t,e={}){let{start:r=0,end:n=t.length,plane:o="xy"}=e,s=e.size||2,i=0,a=So[o[0]],c=So[o[1]];for(let l=r,f=n-s;l<n;l+=s)i+=(t[l+a]-t[f+a])*(t[l+c]+t[f+c]),f=l;return i/2}function sf(t,e,r=2,n,o="xy"){let s=e&&e.length,i=s?e[0]*r:t.length,a=v0(t,0,i,r,!0,n&&n[0],o),c=[];if(!a||a.next===a.prev)return c;let l,f,u,h,p,d,A;if(s&&(a=RR(t,e,a,r,n,o)),t.length>80*r){h=f=t[0],p=u=t[1];for(let m=r;m<i;m+=r)d=t[m],A=t[m+1],d<h&&(h=d),A<p&&(p=A),d>f&&(f=d),A>u&&(u=A);l=Math.max(f-h,u-p),l=l!==0?32767/l:0}return Co(a,c,r,h,p,l,0),c}function v0(t,e,r,n,o,s,i){let a,c;s===void 0&&(s=Mr(t,{start:e,end:r,size:n,plane:i}));let l=So[i[0]],f=So[i[1]];if(o===s<0)for(a=e;a<r;a+=n)c=R0(a,t[a+l],t[a+f],c);else for(a=r-n;a>=e;a-=n)c=R0(a,t[a+l],t[a+f],c);return c&&Ui(c,c.next)&&(Io(c),c=c.next),c}function Sr(t,e){if(!t)return t;e||(e=t);let r=t,n;do if(n=!1,!r.steiner&&(Ui(r,r.next)||ne(r.prev,r,r.next)===0)){if(Io(r),r=e=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==e);return e}function Co(t,e,r,n,o,s,i){if(!t)return;!i&&s&&PR(t,n,o,s);let a=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,s?CR(t,n,o,s):SR(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),Io(t),t=l.next,a=l.next;continue}if(t=l,t===a){i?i===1?(t=BR(Sr(t),e,r),Co(t,e,r,n,o,s,2)):i===2&&IR(t,e,r,n,o,s):Co(Sr(t),e,r,n,o,s,1);break}}}function SR(t){let e=t.prev,r=t,n=t.next;if(ne(e,r,n)>=0)return!1;let o=e.x,s=r.x,i=n.x,a=e.y,c=r.y,l=n.y,f=o<s?o<i?o:i:s<i?s:i,u=a<c?a<l?a:l:c<l?c:l,h=o>s?o>i?o:i:s>i?s:i,p=a>c?a>l?a:l:c>l?c:l,d=n.next;for(;d!==e;){if(d.x>=f&&d.x<=h&&d.y>=u&&d.y<=p&&hn(o,a,s,c,i,l,d.x,d.y)&&ne(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function CR(t,e,r,n){let o=t.prev,s=t,i=t.next;if(ne(o,s,i)>=0)return!1;let a=o.x,c=s.x,l=i.x,f=o.y,u=s.y,h=i.y,p=a<c?a<l?a:l:c<l?c:l,d=f<u?f<h?f:h:u<h?u:h,A=a>c?a>l?a:l:c>l?c:l,m=f>u?f>h?f:h:u>h?u:h,b=of(p,d,e,r,n),T=of(A,m,e,r,n),E=t.prevZ,_=t.nextZ;for(;E&&E.z>=b&&_&&_.z<=T;){if(E.x>=p&&E.x<=A&&E.y>=d&&E.y<=m&&E!==o&&E!==i&&hn(a,f,c,u,l,h,E.x,E.y)&&ne(E.prev,E,E.next)>=0||(E=E.prevZ,_.x>=p&&_.x<=A&&_.y>=d&&_.y<=m&&_!==o&&_!==i&&hn(a,f,c,u,l,h,_.x,_.y)&&ne(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;E&&E.z>=b;){if(E.x>=p&&E.x<=A&&E.y>=d&&E.y<=m&&E!==o&&E!==i&&hn(a,f,c,u,l,h,E.x,E.y)&&ne(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;_&&_.z<=T;){if(_.x>=p&&_.x<=A&&_.y>=d&&_.y<=m&&_!==o&&_!==i&&hn(a,f,c,u,l,h,_.x,_.y)&&ne(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function BR(t,e,r){let n=t;do{let o=n.prev,s=n.next.next;!Ui(o,s)&&w0(o,n,n.next,s)&&Bo(o,s)&&Bo(s,o)&&(e.push(o.i/r|0),e.push(n.i/r|0),e.push(s.i/r|0),Io(n),Io(n.next),n=t=s),n=n.next}while(n!==t);return Sr(n)}function IR(t,e,r,n,o,s){let i=t;do{let a=i.next.next;for(;a!==i.prev;){if(i.i!==a.i&&DR(i,a)){let c=L0(i,a);i=Sr(i,i.next),c=Sr(c,c.next),Co(i,e,r,n,o,s,0),Co(c,e,r,n,o,s,0);return}a=a.next}i=i.next}while(i!==t)}function RR(t,e,r,n,o,s){let i=[],a,c,l,f,u;for(a=0,c=e.length;a<c;a++)l=e[a]*n,f=a<c-1?e[a+1]*n:t.length,u=v0(t,l,f,n,!1,o&&o[a+1],s),u===u.next&&(u.steiner=!0),i.push(OR(u));for(i.sort(vR),a=0;a<i.length;a++)r=wR(i[a],r);return r}function vR(t,e){return t.x-e.x}function wR(t,e){let r=LR(t,e);if(!r)return e;let n=L0(r,t);return Sr(n,n.next),Sr(r,r.next)}function LR(t,e){let r=e,n=t.x,o=t.y,s=-1/0,i;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){let h=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(h<=n&&h>s&&(s=h,i=r.x<r.next.x?r:r.next,h===n))return i}r=r.next}while(r!==e);if(!i)return null;let a=i,c=i.x,l=i.y,f=1/0,u;r=i;do n>=r.x&&r.x>=c&&n!==r.x&&hn(o<l?n:s,o,c,l,o<l?s:n,o,r.x,r.y)&&(u=Math.abs(o-r.y)/(n-r.x),Bo(r,t)&&(u<f||u===f&&(r.x>i.x||r.x===i.x&&FR(i,r)))&&(i=r,f=u)),r=r.next;while(r!==a);return i}function FR(t,e){return ne(t.prev,t,e.prev)<0&&ne(e.next,t,t.next)<0}function PR(t,e,r,n){let o=t;do o.z===0&&(o.z=of(o.x,o.y,e,r,n)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,NR(o)}function NR(t){let e,r,n=1,o,s,i,a,c,l;do{for(s=t,t=null,l=null,o=0;s;){for(o++,a=s,i=0,r=0;r<n&&(i++,a=a.nextZ,!!a);r++);for(c=n;i>0||c>0&&a;)i!==0&&(c===0||!a||s.z<=a.z)?(e=s,s=s.nextZ,i--):(e=a,a=a.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;s=a}l.nextZ=null,n*=2}while(o>1);return t}function of(t,e,r,n,o){return t=(t-r)*o|0,e=(e-n)*o|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function OR(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function hn(t,e,r,n,o,s,i,a){return(o-i)*(e-a)>=(t-i)*(s-a)&&(t-i)*(n-a)>=(r-i)*(e-a)&&(r-i)*(s-a)>=(o-i)*(n-a)}function DR(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!UR(t,e)&&(Bo(t,e)&&Bo(e,t)&&GR(t,e)&&(ne(t.prev,t,e.prev)||ne(t,e.prev,e))||Ui(t,e)&&ne(t.prev,t,t.next)>0&&ne(e.prev,e,e.next)>0)}function ne(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Ui(t,e){return t.x===e.x&&t.y===e.y}function w0(t,e,r,n){let o=Di(ne(t,e,r)),s=Di(ne(t,e,n)),i=Di(ne(r,n,t)),a=Di(ne(r,n,e));return!!(o!==s&&i!==a||o===0&&Oi(t,r,e)||s===0&&Oi(t,n,e)||i===0&&Oi(r,t,n)||a===0&&Oi(r,e,n))}function Oi(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Di(t){return t>0?1:t<0?-1:0}function UR(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&w0(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function Bo(t,e){return ne(t.prev,t,t.next)<0?ne(t,e,t.next)>=0&&ne(t,t.prev,e)>=0:ne(t,e,t.prev)<0||ne(t,t.next,e)<0}function GR(t,e){let r=t,n=!1,o=(t.x+e.x)/2,s=(t.y+e.y)/2;do r.y>s!=r.next.y>s&&r.next.y!==r.y&&o<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==t);return n}function L0(t,e){let r=new Ro(t.i,t.x,t.y),n=new Ro(e.i,e.x,e.y),o=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=o,o.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function R0(t,e,r,n){let o=new Ro(t,e,r);return n?(o.next=n.next,o.prev=n,n.next.prev=o,n.next=o):(o.prev=o,o.next=o),o}function Io(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}var Ro=class{constructor(e,r,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=n}};function Gi(t,e,r){let n=qR(t),o=Object.keys(n).filter(s=>n[s]!==Array);return jR(t,{propArrayTypes:n,...e},{numericPropKeys:r&&r.numericPropKeys||o,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function qR(t){let e={};for(let r of t)if(r.properties)for(let n in r.properties){let o=r.properties[n];e[n]=QR(o,e[n])}return e}function jR(t,e,r){let{pointPositionsCount:n,pointFeaturesCount:o,linePositionsCount:s,linePathsCount:i,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:h,coordLength:p}=e,{numericPropKeys:d=[],PositionDataType:A=Float32Array,triangulate:m=!0}=r,b=t[0]&&"id"in t[0],T=t.length>65535?Uint32Array:Uint16Array,E={type:"Point",positions:new A(n*p),globalFeatureIds:new T(n),featureIds:o>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},_={type:"LineString",pathIndices:s>65535?new Uint32Array(i+1):new Uint16Array(i+1),positions:new A(s*p),globalFeatureIds:new T(s),featureIds:a>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},S={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new A(c*p),globalFeatureIds:new T(c),featureIds:u>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};m&&(S.triangles=[]);for(let v of[E,_,S])for(let M of d){let y=h[M];v.numericProps[M]=new y(v.positions.length/p)}_.pathIndices[i]=s,S.polygonIndices[l]=c,S.primitivePolygonIndices[f]=c;let C={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let v of t){let M=v.geometry,y=v.properties||{};switch(M.type){case"Point":JR(M,E,C,p,y),E.properties.push(cf(y,d)),b&&E.fields.push({id:v.id}),C.pointFeature++;break;case"LineString":WR(M,_,C,p,y),_.properties.push(cf(y,d)),b&&_.fields.push({id:v.id}),C.lineFeature++;break;case"Polygon":XR(M,S,C,p,y),S.properties.push(cf(y,d)),b&&S.fields.push({id:v.id}),C.polygonFeature++;break;default:throw new Error("Invalid geometry type")}C.feature++}return KR(E,_,S,p)}function JR(t,e,r,n,o){e.positions.set(t.data,r.pointPosition*n);let s=t.data.length/n;lf(e,o,r.pointPosition,s),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+s),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+s),r.pointPosition+=s}function WR(t,e,r,n,o){e.positions.set(t.data,r.linePosition*n);let s=t.data.length/n;lf(e,o,r.linePosition,s),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+s),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+s);for(let i=0,a=t.indices.length;i<a;++i){let c=t.indices[i],l=i===a-1?t.data.length:t.indices[i+1];e.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/n}}function XR(t,e,r,n,o){e.positions.set(t.data,r.polygonPosition*n);let s=t.data.length/n;lf(e,o,r.polygonPosition,s),e.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+s),e.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+s);for(let i=0,a=t.indices.length;i<a;++i){let c=r.polygonPosition;e.polygonIndices[r.polygonObject++]=c;let l=t.areas[i],f=t.indices[i],u=t.indices[i+1];for(let p=0,d=f.length;p<d;++p){let A=f[p],m=p===d-1?u===void 0?t.data.length:u[0]:f[p+1];e.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(m-A)/n}let h=r.polygonPosition;YR(e,l,f,{startPosition:c,endPosition:h,coordLength:n})}}function YR(t,e,r,{startPosition:n,endPosition:o,coordLength:s}){if(!t.triangles)return;let i=n*s,a=o*s,c=t.positions.subarray(i,a),l=r[0],f=r.slice(1).map(h=>(h-l)/s),u=sf(c,f,s,e);for(let h=0,p=u.length;h<p;++h)t.triangles.push(n+u[h])}function af(t,e){let r={};for(let n in t)r[n]={value:t[n],size:e};return r}function KR(t,e,r,n){let o={shape:"binary-feature-collection",points:{...t,positions:{value:t.positions,size:n},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:af(t.numericProps,1)},lines:{...e,positions:{value:e.positions,size:n},pathIndices:{value:e.pathIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:af(e.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:n},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:af(r.numericProps,1)}};return o.polygons&&r.triangles&&(o.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),o}function lf(t,e,r,n){for(let o in t.numericProps)if(o in e){let s=e[o];t.numericProps[o].fill(s,r,r+n)}}function cf(t,e){let r={};for(let n in t)e.includes(n)||(r[n]=t[n]);return r}function QR(t,e){return e===Array||!Number.isFinite(t)?Array:e===Float64Array||Math.fround(t)!==t?Float64Array:Float32Array}function vo(t,e){let r=e?.globalFeatureId;return r!==void 0?ZR(t,r):$R(t,e?.type)}function ZR(t,e){let r=N0(t);for(let n of r){let o=0,s=n.featureIds.value[0];for(let i=0;i<n.featureIds.value.length;i++){let a=n.featureIds.value[i];if(a!==s){if(e===n.globalFeatureIds.value[o])return Hi(n,o,i);o=i,s=a}}if(e===n.globalFeatureIds.value[o])return Hi(n,o,n.featureIds.value.length)}throw new Error(`featureId:${e} not found`)}function $R(t,e){let r=N0(t,e);return ev(r)}function N0(t,e){let r=[];return t.points&&(t.points.type="Point",r.push(t.points)),t.lines&&(t.lines.type="LineString",r.push(t.lines)),t.polygons&&(t.polygons.type="Polygon",r.push(t.polygons)),r}function ev(t){let e=[];for(let r of t){if(r.featureIds.value.length===0)continue;let n=0,o=r.featureIds.value[0];for(let s=0;s<r.featureIds.value.length;s++){let i=r.featureIds.value[s];i!==o&&(e.push(Hi(r,n,s)),n=s,o=i)}e.push(Hi(r,n,r.featureIds.value.length))}return e}function Hi(t,e,r){let n=B0(t,e,r),o=rv(t,e,r),s=tv(t,e,r);return{type:"Feature",geometry:n,properties:o,...s}}function tv(t,e=0,r){return t.fields&&t.fields[t.featureIds.value[e]]}function rv(t,e=0,r){let n=Object.assign({},t.properties[t.featureIds.value[e]]);for(let o in t.numericProps)n[o]=t.numericProps[o].value[e];return n}var mf=D(z0(),1);function yv(t){let e=0;for(let r=0,n=t.length-1,o,s;r<t.length;n=r++)o=t[r],s=t[n],e+=(s[0]-o[0])*(o[1]+s[1]);return e}function hf(t,e){if(Array.isArray(t[0])){for(let n of t)hf(n,e);return}let r=t;r[0]/=e,r[1]/=e}function k0(t,e){for(let r=0;r<t.length;++r)t[r]/=e}function pf(t,e,r){if(typeof t[0][0]!="number"){for(let i of t)pf(i,e,r);return}let n=r*Math.pow(2,e.z),o=r*e.x,s=r*e.y;for(let i=0;i<t.length;i++){let a=t[i];a[0]=(a[0]+o)*360/n-180;let c=180-(a[1]+s)*360/n;a[1]=360/Math.PI*Math.atan(Math.exp(c*Math.PI/180))-90}}function q0(t,e,r){let{x:n,y:o,z:s}=e,i=r*Math.pow(2,s),a=r*n,c=r*o;for(let l=0,f=t.length;l<f;l+=2){t[l]=(t[l]+a)*360/i-180;let u=180-(t[l+1]+c)*360/i;t[l+1]=360/Math.PI*Math.atan(Math.exp(u*Math.PI/180))-90}}function j0(t){let e=t.length;if(e<=1)return[t];let r=[],n,o;for(let s=0;s<e;s++){let i=yv(t[s]);i!==0&&(o===void 0&&(o=i<0),o===i<0?(n&&r.push(n),n=[t[s]]):n&&n.push(t[s]))}return n&&r.push(n),r}function J0(t){let e=t.indices.length,r="Polygon";if(e<=1)return{type:r,data:t.data,areas:[[Mr(t.data)]],indices:[t.indices]};let n=[],o=[],s=[],i=[],a,c=0;for(let l,f=0,u;f<e;f++){u=t.indices[f]-c,l=t.indices[f+1]-c||t.data.length;let h=t.data.slice(u,l),p=Mr(h);if(p===0){let d=t.data.slice(0,u),A=t.data.slice(l);t.data=d.concat(A),c+=l-u;continue}a===void 0&&(a=p<0),a===p<0?(i.length&&(n.push(s),o.push(i)),i=[u],s=[p]):(s.push(p),i.push(u))}return s&&n.push(s),i.length&&o.push(i),{type:r,areas:n,indices:o,data:t.data}}var Cr=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(e,r,n,o,s,i){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=e,this._geometry=-1,this._keys=o,this._values=s,this._geometryInfo=i,e.readFields(Tv,this,r)}toGeoJSONFeature(e,r){let n=this.loadGeometry();switch(e){case"wgs84":return W0(this,n,o=>pf(o,r,this.extent));default:return W0(this,n,hf)}}toBinaryFeature(e,r){let n=this.loadFlatGeometry();switch(e){case"wgs84":return this._toBinaryCoordinates(n,o=>q0(o,r,this.extent));default:return this._toBinaryCoordinates(n,k0)}}bbox(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,o=0,s=0,i=0,a=1/0,c=-1/0,l=1/0,f=-1/0;for(;e.pos<r;){if(o<=0){let u=e.readVarint();n=u&7,o=u>>3}if(o--,n===1||n===2)s+=e.readSVarint(),i+=e.readSVarint(),s<a&&(a=s),s>c&&(c=s),i<l&&(l=i),i>f&&(f=i);else if(n!==7)throw new Error(`unknown command ${n}`)}return[a,l,c,f]}_toBinaryCoordinates(e,r){let n;r(e.data,this.extent);let o=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=e.indices.length,n={type:"Point",...e};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=e.indices.length,this._geometryInfo.linePositionsCount+=e.data.length/o,n={type:"LineString",...e};break;case 3:n=J0(e),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=n.indices.length;for(let i of n.indices)this._geometryInfo.polygonRingsCount+=i.length;this._geometryInfo.polygonPositionsCount+=n.data.length/o;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let s={type:"Feature",geometry:n,properties:this.properties};return this.id!==null&&(s.id=this.id),s}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,o=0,s=0,i=0,a=[],c;for(;e.pos<r;){if(o<=0){let l=e.readVarint();n=l&7,o=l>>3}switch(o--,n){case 1:case 2:s+=e.readSVarint(),i+=e.readSVarint(),n===1&&(c&&a.push(c),c=[]),c&&c.push([s,i]);break;case 7:c&&c.push(c[0].slice());break;default:throw new Error(`unknown command ${n}`)}}return c&&a.push(c),a}loadFlatGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,o,s=0,i=0,a=0,c=0,l=[],f=[];for(;e.pos<r;)if(s<=0&&(o=e.readVarint(),n=o&7,s=o>>3),s--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),n===1&&l.push(c),f.push(i,a),c+=2;else if(n===7){if(c>0){let u=l[l.length-1];f.push(f[u],f[u+1]),c+=2}}else throw new Error(`unknown command ${n}`);return{data:f,indices:l}}};qt(Cr,"types",["Unknown","Point","LineString","Polygon"]);function W0(t,e,r){let n=Cr.types[t.type],o,s,i;switch(t.type){case 1:let c=[];for(o=0;o<e.length;o++)c[o]=e[o][0];i=c,r(i,t.extent);break;case 2:for(i=e,o=0;o<i.length;o++)r(i[o],t.extent);break;case 3:for(i=j0(e),o=0;o<i.length;o++)for(s=0;s<i[o].length;s++)r(i[o][s],t.extent);break;default:throw new Error("illegal vector tile type")}i.length===1?i=i[0]:n=`Multi${n}`;let a={type:"Feature",geometry:{type:n,coordinates:i},properties:t.properties};return t.id!==null&&(a.properties||={},a.properties.id=t.id),a}function Tv(t,e,r){e&&r&&(t===1?e.id=r.readVarint():t===2?Ev(r,e):t===3?e.type=r.readVarint():t===4&&(e._geometry=r.pos))}function Ev(t,e){let r=t.readVarint()+t.pos;for(;t.pos<r;){let n=e._keys[t.readVarint()],o=e._values[t.readVarint()];e.properties[n]=o}}var ki=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(_v,this,r),this.length=this._features.length}getGeoJSONFeature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let r=this._pbf.readVarint()+this._pbf.pos;return new Cr(this._pbf,r,this.extent,this._keys,this._values)}getBinaryFeature(e,r){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let n=this._pbf.readVarint()+this._pbf.pos;return new Cr(this._pbf,n,this.extent,this._keys,this._values,r)}};function _v(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(Mv(r)))}function Mv(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos<r;){let n=t.readVarint()>>3;e=n===1?t.readString():n===2?t.readFloat():n===3?t.readDouble():n===4?t.readVarint64():n===5?t.readVarint():n===6?t.readSVarint():n===7?t.readBoolean():null}return e}var wo=class{layers;constructor(e,r){this.layers=e.readFields(Sv,{},r)}};function Sv(t,e,r){if(t===3&&r){let n=new ki(r,r.readVarint()+r.pos);n.length&&e&&(e[n.name]=n)}}function gf(t,e){let r=Bv(e),n=e?.gis?.format||e?.mvt?.shape||e?.shape;switch(n){case"columnar-table":return{shape:"columnar-table",data:df(t,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:X0(t,r)};case"geojson":return X0(t,r);case"binary-geometry":return df(t,r);case"binary":return df(t,r);default:throw new Error(n||"undefined shape")}}function df(t,e){let[r,n]=Cv(t,e),o=Gi(r,n);return o.byteLength=t.byteLength,o}function Cv(t,e){let r=[],n={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength<=0)return[r,n];let o=new wo(new mf.default(t));return(e&&Array.isArray(e.layers)?e.layers:Object.keys(o.layers)).forEach(i=>{let a=o.layers[i];if(a)for(let c=0;c<a.length;c++){let l=a.getBinaryFeature(c,n),f=Rv(l,e,i);r.push(f)}}),[r,n]}function X0(t,e){if(t.byteLength<=0)return[];let r=[],n=new wo(new mf.default(t));return(Array.isArray(e.layers)?e.layers:Object.keys(n.layers)).forEach(s=>{let i=n.layers[s];if(i)for(let a=0;a<i.length;a++){let c=i.getGeoJSONFeature(a),l=Iv(c,e,s);r.push(l)}}),r}function Bv(t){if(!t?.mvt)throw new Error("mvt options required");if(t.mvt?.coordinates==="wgs84"&&!t.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return t.gis&&nc.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),t.mvt}function Iv(t,e,r){let n=t.toGeoJSONFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&(n.properties||={},n.properties[e.layerProperty]=r),n}function Rv(t,e,r){let n=t.toBinaryFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&n.properties&&(n.properties[e.layerProperty]=r),n}var Y0={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],category:"geometry"};var vv="4.4.0-alpha.18",qi={...Y0,dataType:null,batchType:null,version:vv,worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},wv={...qi,parse:async(t,e)=>gf(t,e),parseSync:gf,binary:!0};var Lv={Point:K0,MultiPoint:Fv,LineString:Q0,MultiLineString:Pv,Polygon:Z0,MultiPolygon:Nv};function K0([t,e],[r,n],o){let s=Mt(r[0],n[0],t),i=Mt(r[1],n[1],e);return o.unprojectFlat([s,i])}function Af(t,e,r){return t.map(n=>K0(n,e,r))}function Fv(t,e,r){return Af(t,e,r)}function Q0(t,e,r){return Af(t,e,r)}function Pv(t,e,r){return t.map(n=>Q0(n,e,r))}function Z0(t,e,r){return t.map(n=>Af(n,e,r))}function Nv(t,e,r){return t.map(n=>Z0(n,e,r))}function $0(t,e,r){let n=r.projectFlat([e.west,e.north]),o=r.projectFlat([e.east,e.south]),s=[n,o];return{...t,coordinates:Lv[t.type](t.coordinates,s,r)}}var Ov=["points","lines","polygons"];function xf(t,e,r,n){for(let o of Ov){let s=t[o]&&Dv(t[o],e,r,n);if(s>=0)return s}return-1}function Dv(t,e,r,n){let o=t.featureIds.value;if(!o.length)return-1;let s=0,i=o[o.length-1]+1;if(n){let c=Uv(t,n);if(c)s=c[0],i=c[1]+1;else return-1}let a=-1;if(e in t.numericProps){let c=t.numericProps[e].value.findIndex((l,f)=>l===r&&o[f]>=s&&o[f]<i);return c>=0?t.globalFeatureIds.value[c]:-1}else e?a=e1(t.properties,c=>c[e]===r,s,i):t.fields&&(a=e1(t.fields,c=>c.id===r,s,i));return a>=0?Gv(t,a):-1}function Uv(t,e){if(!t.__layers){let r={},{properties:n}=t;for(let o=0;o<n.length;o++){let{layerName:s}=n[o];s&&(r[s]?r[s][1]=o:r[s]=[o,o])}t.__layers=r}return t.__layers[e]}function Gv(t,e){if(!t.__ids){let r=[],n=t.featureIds.value,o=t.globalFeatureIds.value;for(let s=0;s<n.length;s++)r[n[s]]=o[s];t.__ids=r}return t.__ids[e]}function e1(t,e,r,n){for(let o=r;o<n;o++)if(e(t[o],o))return o;return-1}var bf=512,Hv={...Tf.GeoJsonLayer.defaultProps,data:Dt,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[qi],binary:!0},Lo=class extends ur{initializeState(){super.initializeState();let e=this.context.viewport.resolution!==void 0?!1:this.props.binary;this.setState({binary:e,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return Boolean(this.state?.data&&super.isLoaded)}updateState({props:e,oldProps:r,context:n,changeFlags:o}){o.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:r,context:n,changeFlags:o}),this._setWGS84PropertyForTiles());let{highlightColor:s}=e;s!==r.highlightColor&&Array.isArray(s)&&this.setState({highlightColor:s})}async _updateTileData(){let e=this.props.data,r=null;if(typeof e=="string"&&!wc(e)){let{onDataLoad:n,fetch:o}=this.props;this.setState({data:null,tileJSON:null});try{r=await o(e,{propName:"data",layer:this,loaders:[]})}catch(s){this.raiseError(s,"loading TileJSON"),e=null}n&&n(r,{propName:"data",layer:this})}else e&&typeof e=="object"&&"tilejson"in e&&(r=e);r&&(e=r.tiles),this.setState({data:e,tileJSON:r})}_getTilesetOptions(){let e=super._getTilesetOptions(),r=this.state.tileJSON,{minZoom:n,maxZoom:o}=this.props;return r&&(Number.isFinite(r.minzoom)&&r.minzoom>n&&(e.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(o)||r.maxzoom<o)&&(e.maxZoom=r.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){let{data:r,binary:n}=this.state,{index:o,signal:s}=e,i=lt(r,e);if(!i)return Promise.reject("Invalid URL");let a=this.getLoadOptions(),{fetch:c}=this.props;return a={...a,core:{...a?.core,mimeType:"application/x-protobuf"},mvt:{...a?.mvt,shape:n?"binary":"geojson",coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:o}},c(i,{propName:"data",layer:this,loadOptions:a,signal:s})}renderSubLayers(e){let{x:r,y:n,z:o}=e.tile.index,s=Math.pow(2,o),i=bf/s,a=-i,c=bf*r/s,l=bf*(1-n/s),f=new N().scale([i,a,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=f,e.coordinateOrigin=[c,l,0],e.coordinateSystem=ji.COORDINATE_SYSTEM.CARTESIAN,e.extensions=[...e.extensions||[],new o1.ClipExtension]);let u=super.renderSubLayers(e);return this.state.binary&&!(u instanceof Tf.GeoJsonLayer)&&ji.log.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),u}_updateAutoHighlight(e){let{uniqueIdProperty:r}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:o}=this.state,s=e.object,i=null,a=null;s&&(i=yf(s,r),a=t1(s));let{highlightColor:c}=this.props;typeof c=="function"&&(c=c(e)),(n!==i||o!==a)&&this.setState({highlightColor:c,hoveredFeatureId:i,hoveredFeatureLayerName:a})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(e){let r=super.getPickingInfo(e);if(this.state.binary&&r.index!==-1){let{data:n}=e.sourceLayer.props;r.object=vo(n,{globalFeatureId:r.index})}return r.object&&!this._isWGS84()&&(r.object=n1(r.object,r.tile.bbox,this.context.viewport)),r}getSubLayerPropsByTile(e){return{highlightedObjectIndex:this.getHighlightedObjectIndex(e),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(e){let{hoveredFeatureId:r,hoveredFeatureLayerName:n,binary:o}=this.state,{uniqueIdProperty:s,highlightedFeatureId:i}=this.props,a=e.content,c=r1(i);if(!(r1(r)||c))return-1;let f=c?i:r;return Array.isArray(a)?a.findIndex(u=>{let h=yf(u,s)===f,p=c||t1(u)===n;return h&&p}):a&&o?xf(a,s,f,c?"":n):-1}_pickObjects(e){let{deck:r,viewport:n}=this.context,o=n.width,s=n.height,i=n.x,a=n.y,c=[this.id];return r.pickObjects({x:i,y:a,width:o,height:s,layerIds:c,maxObjects:e})}getRenderedFeatures(e=null){let r=this._pickObjects(e),n=new Set,o=[];for(let s of r){let i=yf(s.object,this.props.uniqueIdProperty);i===void 0?o.push(s.object):n.has(i)||(n.add(i),o.push(s.object))}return o}_setWGS84PropertyForTiles(){let e="dataInWGS84";this.state.tileset.selectedTiles.forEach(n=>{n.hasOwnProperty(e)||Object.defineProperty(n,e,{get:()=>{if(!n.content)return null;if(this.state.binary&&Array.isArray(n.content)&&!n.content.length)return[];let{bbox:o}=n;if(n._contentWGS84===void 0&&Lc(o)){let s=this.state.binary?vo(n.content):n.content;n._contentWGS84=s.map(i=>n1(i,o,this.context.viewport))}return n._contentWGS84}})})}};Lo.layerName="MVTLayer";Lo.defaultProps=Hv;var s1=Lo;function yf(t,e){if(t.properties&&e)return t.properties[e];if("id"in t)return t.id}function t1(t){return t.properties?.layerName||null}function r1(t){return t!=null&&t!==""}function n1(t,e,r){let n={...t,geometry:{type:t.geometry.type}};return Object.defineProperty(n.geometry,"coordinates",{get:()=>$0(t.geometry,e,r).coordinates}),n}var i1="0123456789bcdefghjkmnpqrstuvwxyz",a1={};for(let t=0;t<i1.length;t++)a1[i1.charAt(t)]=t;var Vv=-90,zv=90,kv=-180,qv=180;function jv(t){let e=!0,r=zv,n=Vv,o=qv,s=kv,i,a=0;for(let c=0,l=t.length;c<l;c++){let f=t[c].toLowerCase();a=a1[f];for(let u=4;u>=0;u--){let h=a>>u&1;e?(i=(o+s)/2,h===1?s=i:o=i):(i=(r+n)/2,h===1?n=i:r=i),e=!e}}return[n,s,r,o]}function c1(t){let[e,r,n,o]=jv(t);return[o,n,o,e,r,e,r,n,o,n]}var Jv={getGeohash:{type:"accessor",value:t=>t.geohash}},Fo=class extends De{indexToBounds(){let{data:e,getGeohash:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(n,o)=>c1(r(n,o))}}};Fo.layerName="GeohashLayer";Fo.defaultProps=Jv;var l1=Fo;return g1(Po);})();
1259
2375
  /*! Bundled license information:
1260
2376
 
1261
2377
  long/dist/long.js: