soonspacejs 2.5.45 → 2.5.46

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/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- var e="soonspacejs",t="2.5.45";
1
+ var e="soonspacejs",t="2.5.46";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2010-2022 Three.js Authors
@@ -29,10 +29,10 @@ fflate - fast JavaScript compression/decompression
29
29
  <https://101arrowz.github.io/fflate>
30
30
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
31
31
  version 0.6.9
32
- */var ww={},Mw=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Sw=function(e){return new Worker(e)};try{URL.revokeObjectURL(Mw(""))}catch(XC){Mw=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},Sw=function(e){return new Worker(e,{type:"module"})}}var Tw=Uint8Array,Cw=Uint16Array,Lw=Uint32Array,Gw=new Tw([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Rw=new Tw([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_w=new Tw([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Aw=function(e,t){for(var n=new Cw(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var s=new Lw(n[30]);for(i=1;i<30;++i)for(var r=n[i];r<n[i+1];++r)s[r]=r-n[i]<<5|i;return[n,s]},Iw=Aw(Gw,2),Xw=Iw[0],Ew=Iw[1];Xw[28]=258,Ew[258]=28;for(var zw=Aw(Rw,0),Pw=zw[0],Ww=zw[1],Zw=new Cw(32768),Nw=0;Nw<32768;++Nw){var Vw=(43690&Nw)>>>1|(21845&Nw)<<1;Vw=(61680&(Vw=(52428&Vw)>>>2|(13107&Vw)<<2))>>>4|(3855&Vw)<<4,Zw[Nw]=((65280&Vw)>>>8|(255&Vw)<<8)>>>1}var Dw=function(e,t,n){for(var i=e.length,s=0,r=new Cw(t);s<i;++s)++r[e[s]-1];var a,o=new Cw(t);for(s=0;s<t;++s)o[s]=o[s-1]+r[s-1]<<1;if(n){a=new Cw(1<<t);var l=15-t;for(s=0;s<i;++s)if(e[s])for(var c=s<<4|e[s],d=t-e[s],h=o[e[s]-1]++<<d,u=h|(1<<d)-1;h<=u;++h)a[Zw[h]>>>l]=c}else for(a=new Cw(i),s=0;s<i;++s)e[s]&&(a[s]=Zw[o[e[s]-1]++]>>>15-e[s]);return a},Hw=new Tw(288);for(Nw=0;Nw<144;++Nw)Hw[Nw]=8;for(Nw=144;Nw<256;++Nw)Hw[Nw]=9;for(Nw=256;Nw<280;++Nw)Hw[Nw]=7;for(Nw=280;Nw<288;++Nw)Hw[Nw]=8;var Bw=new Tw(32);for(Nw=0;Nw<32;++Nw)Bw[Nw]=5;var kw=Dw(Hw,9,0),Fw=Dw(Hw,9,1),Uw=Dw(Bw,5,0),Ow=Dw(Bw,5,1),Yw=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Kw=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},jw=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Jw=function(e){return(e/8|0)+(7&e&&1)},Qw=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof Cw?Cw:e instanceof Lw?Lw:Tw)(n-t);return i.set(e.subarray(t,n)),i},qw=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Tw(0);var s=!t||n,r=!n||n.i;n||(n={}),t||(t=new Tw(3*i));var a=function(e){var n=t.length;if(e>n){var i=new Tw(Math.max(2*n,e));i.set(t),t=i}},o=n.f||0,l=n.p||0,c=n.b||0,d=n.l,h=n.d,u=n.m,p=n.n,m=8*i;do{if(!d){n.f=o=Kw(e,l,1);var f=Kw(e,l+1,3);if(l+=3,!f){var g=e[(G=Jw(l)+4)-4]|e[G-3]<<8,y=G+g;if(y>i){if(r)throw"unexpected EOF";break}s&&a(c+g),t.set(e.subarray(G,y),c),n.b=c+=g,n.p=l=8*y;continue}if(1==f)d=Fw,h=Ow,u=9,p=5;else{if(2!=f)throw"invalid block type";var b=Kw(e,l,31)+257,v=Kw(e,l+10,15)+4,x=b+Kw(e,l+5,31)+1;l+=14;for(var w=new Tw(x),M=new Tw(19),S=0;S<v;++S)M[_w[S]]=Kw(e,l+3*S,7);l+=3*v;var T=Yw(M),C=(1<<T)-1,L=Dw(M,T,1);for(S=0;S<x;){var G,R=L[Kw(e,l,C)];if(l+=15&R,(G=R>>>4)<16)w[S++]=G;else{var _=0,A=0;for(16==G?(A=3+Kw(e,l,3),l+=2,_=w[S-1]):17==G?(A=3+Kw(e,l,7),l+=3):18==G&&(A=11+Kw(e,l,127),l+=7);A--;)w[S++]=_}}var I=w.subarray(0,b),X=w.subarray(b);u=Yw(I),p=Yw(X),d=Dw(I,u,1),h=Dw(X,p,1)}if(l>m){if(r)throw"unexpected EOF";break}}s&&a(c+131072);for(var E=(1<<u)-1,z=(1<<p)-1,P=l;;P=l){var W=(_=d[jw(e,l)&E])>>>4;if((l+=15&_)>m){if(r)throw"unexpected EOF";break}if(!_)throw"invalid length/literal";if(W<256)t[c++]=W;else{if(256==W){P=l,d=null;break}var Z=W-254;if(W>264){var N=Gw[S=W-257];Z=Kw(e,l,(1<<N)-1)+Xw[S],l+=N}var V=h[jw(e,l)&z],D=V>>>4;if(!V)throw"invalid distance";l+=15&V;X=Pw[D];if(D>3){N=Rw[D];X+=jw(e,l)&(1<<N)-1,l+=N}if(l>m){if(r)throw"unexpected EOF";break}s&&a(c+131072);for(var H=c+Z;c<H;c+=4)t[c]=t[c-X],t[c+1]=t[c+1-X],t[c+2]=t[c+2-X],t[c+3]=t[c+3-X];c=H}}n.l=d,n.p=P,n.b=c,d&&(o=1,n.m=u,n.d=h,n.n=p)}while(!o);return c==t.length?t:Qw(t,0,c)},$w=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8},eM=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8,e[i+2]|=n>>>16},tM=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var s=n.length,r=n.slice();if(!s)return[lM,0];if(1==s){var a=new Tw(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var o=n[0],l=n[1],c=0,d=1,h=2;for(n[0]={s:-1,f:o.f+l.f,l:o,r:l};d!=s-1;)o=n[n[c].f<n[h].f?c++:h++],l=n[c!=d&&n[c].f<n[h].f?c++:h++],n[d++]={s:-1,f:o.f+l.f,l:o,r:l};var u=r[0].s;for(i=1;i<s;++i)r[i].s>u&&(u=r[i].s);var p=new Cw(u+1),m=nM(n[d-1],p,0);if(m>t){i=0;var f=0,g=m-t,y=1<<g;for(r.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i<s;++i){var b=r[i].s;if(!(p[b]>t))break;f+=y-(1<<m-p[b]),p[b]=t}for(f>>>=g;f>0;){var v=r[i].s;p[v]<t?f-=1<<t-p[v]++-1:++i}for(;i>=0&&f;--i){var x=r[i].s;p[x]==t&&(--p[x],++f)}m=t}return[new Tw(p),m]},nM=function(e,t,n){return-1==e.s?Math.max(nM(e.l,t,n+1),nM(e.r,t,n+1)):t[e.s]=n},iM=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Cw(++t),i=0,s=e[0],r=1,a=function(e){n[i++]=e},o=1;o<=t;++o)if(e[o]==s&&o!=t)++r;else{if(!s&&r>2){for(;r>138;r-=138)a(32754);r>2&&(a(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(a(s),--r;r>6;r-=6)a(8304);r>2&&(a(r-3<<5|8208),r=0)}for(;r--;)a(s);r=1,s=e[o]}return[n.subarray(0,i),t]},sM=function(e,t){for(var n=0,i=0;i<t.length;++i)n+=e[i]*t[i];return n},rM=function(e,t,n){var i=n.length,s=Jw(t+2);e[s]=255&i,e[s+1]=i>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var r=0;r<i;++r)e[s+r+4]=n[r];return 8*(s+4+i)},aM=function(e,t,n,i,s,r,a,o,l,c,d){$w(t,d++,n),++s[256];for(var h=tM(s,15),u=h[0],p=h[1],m=tM(r,15),f=m[0],g=m[1],y=iM(u),b=y[0],v=y[1],x=iM(f),w=x[0],M=x[1],S=new Cw(19),T=0;T<b.length;++T)S[31&b[T]]++;for(T=0;T<w.length;++T)S[31&w[T]]++;for(var C=tM(S,7),L=C[0],G=C[1],R=19;R>4&&!L[_w[R-1]];--R);var _,A,I,X,E=c+5<<3,z=sM(s,Hw)+sM(r,Bw)+a,P=sM(s,u)+sM(r,f)+a+14+3*R+sM(S,L)+(2*S[16]+3*S[17]+7*S[18]);if(E<=z&&E<=P)return rM(t,d,e.subarray(l,l+c));if($w(t,d,1+(P<z)),d+=2,P<z){_=Dw(u,p,0),A=u,I=Dw(f,g,0),X=f;var W=Dw(L,G,0);$w(t,d,v-257),$w(t,d+5,M-1),$w(t,d+10,R-4),d+=14;for(T=0;T<R;++T)$w(t,d+3*T,L[_w[T]]);d+=3*R;for(var Z=[b,w],N=0;N<2;++N){var V=Z[N];for(T=0;T<V.length;++T){var D=31&V[T];$w(t,d,W[D]),d+=L[D],D>15&&($w(t,d,V[T]>>>5&127),d+=V[T]>>>12)}}}else _=kw,A=Hw,I=Uw,X=Bw;for(T=0;T<o;++T)if(i[T]>255){D=i[T]>>>18&31;eM(t,d,_[D+257]),d+=A[D+257],D>7&&($w(t,d,i[T]>>>23&31),d+=Gw[D]);var H=31&i[T];eM(t,d,I[H]),d+=X[H],H>3&&(eM(t,d,i[T]>>>5&8191),d+=Rw[H])}else eM(t,d,_[i[T]]),d+=A[i[T]];return eM(t,d,_[256]),d+A[256]},oM=new Lw([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),lM=new Tw(0),cM=function(e,t,n,i,s,r){var a=e.length,o=new Tw(i+a+5*(1+Math.ceil(a/7e3))+s),l=o.subarray(i,o.length-s),c=0;if(!t||a<8)for(var d=0;d<=a;d+=65535){var h=d+65535;h<a?c=rM(l,c,e.subarray(d,h)):(l[d]=r,c=rM(l,c,e.subarray(d,a)))}else{for(var u=oM[t-1],p=u>>>13,m=8191&u,f=(1<<n)-1,g=new Cw(32768),y=new Cw(f+1),b=Math.ceil(n/3),v=2*b,x=function(t){return(e[t]^e[t+1]<<b^e[t+2]<<v)&f},w=new Lw(25e3),M=new Cw(288),S=new Cw(32),T=0,C=0,L=(d=0,0),G=0,R=0;d<a;++d){var _=x(d),A=32767&d,I=y[_];if(g[A]=I,y[_]=A,G<=d){var X=a-d;if((T>7e3||L>24576)&&X>423){c=aM(e,l,0,w,M,S,C,L,R,d-R,c),L=T=C=0,R=d;for(var E=0;E<286;++E)M[E]=0;for(E=0;E<30;++E)S[E]=0}var z=2,P=0,W=m,Z=A-I&32767;if(X>2&&_==x(d-Z))for(var N=Math.min(p,X)-1,V=Math.min(32767,d),D=Math.min(258,X);Z<=V&&--W&&A!=I;){if(e[d+z]==e[d+z-Z]){for(var H=0;H<D&&e[d+H]==e[d+H-Z];++H);if(H>z){if(z=H,P=Z,H>N)break;var B=Math.min(Z,H-2),k=0;for(E=0;E<B;++E){var F=d-Z+E+32768&32767,U=F-g[F]+32768&32767;U>k&&(k=U,I=F)}}}Z+=(A=I)-(I=g[A])+32768&32767}if(P){w[L++]=268435456|Ew[z]<<18|Ww[P];var O=31&Ew[z],Y=31&Ww[P];C+=Gw[O]+Rw[Y],++M[257+O],++S[Y],G=d+z,++T}else w[L++]=e[d],++M[e[d]]}}c=aM(e,l,r,w,M,S,C,L,R,d-R,c),!r&&7&c&&(c=rM(l,c+1,lM))}return Qw(o,0,i+Jw(c)+s)},dM=function(){for(var e=new Lw(256),t=0;t<256;++t){for(var n=t,i=9;--i;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),hM=function(){var e=-1;return{p:function(t){for(var n=e,i=0;i<t.length;++i)n=dM[255&n^t[i]]^n>>>8;e=n},d:function(){return~e}}},uM=function(){var e=1,t=0;return{p:function(n){for(var i=e,s=t,r=n.length,a=0;a!=r;){for(var o=Math.min(a+2655,r);a<o;++a)s+=i+=n[a];i=(65535&i)+15*(i>>16),s=(65535&s)+15*(s>>16)}e=i,t=s},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},pM=function(e,t,n,i,s){return cM(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,i,!s)},mM=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n},fM=function(e,t,n){for(var i=e(),s=e.toString(),r=s.slice(s.indexOf("[")+1,s.lastIndexOf("]")).replace(/ /g,"").split(","),a=0;a<i.length;++a){var o=i[a],l=r[a];if("function"==typeof o){t+=";"+l+"=";var c=o.toString();if(o.prototype)if(-1!=c.indexOf("[native code]")){var d=c.indexOf(" ",8)+1;t+=c.slice(d,c.indexOf("(",d))}else for(var h in t+=c,o.prototype)t+=";"+l+".prototype."+h+"="+o.prototype[h].toString();else t+=c}else n[l]=o}return[t,n]},gM=[],yM=function(e,t,n,i){var s;if(!gM[n]){for(var r="",a={},o=e.length-1,l=0;l<o;++l)r=(s=fM(e[l],r,a))[0],a=s[1];gM[n]=fM(e[o],r,a)}var c=mM({},gM[n][1]);return function(e,t,n,i,s){var r=Sw(ww[t]||(ww[t]=Mw(e)));return r.onerror=function(e){return s(e.error,null)},r.onmessage=function(e){return s(null,e.data)},r.postMessage(n,i),r}(gM[n][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",n,c,function(e){var t=[];for(var n in e)(e[n]instanceof Tw||e[n]instanceof Cw||e[n]instanceof Lw)&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t}(c),i)},bM=function(){return[Tw,Cw,Lw,Gw,Rw,_w,Xw,Pw,Fw,Ow,Zw,Dw,Yw,Kw,jw,Jw,Qw,qw,YM,TM,CM]},vM=function(){return[Tw,Cw,Lw,Gw,Rw,_w,Ew,Ww,kw,Hw,Uw,Bw,Zw,oM,lM,Dw,$w,eM,tM,nM,iM,sM,rM,aM,Jw,Qw,cM,pM,kM,TM]},xM=function(){return[EM,WM,XM,hM,dM]},wM=function(){return[zM,PM]},MM=function(){return[ZM,XM,uM]},SM=function(){return[NM]},TM=function(e){return postMessage(e,[e.buffer])},CM=function(e){return e&&e.size&&new Tw(e.size)},LM=function(e,t,n,i,s,r){var a=yM(n,i,s,(function(e,t){a.terminate(),r(e,t)}));return a.postMessage([e,t],t.consume?[e.buffer]:[]),function(){a.terminate()}},GM=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){return e.push(t.data[0],t.data[1])}},RM=function(e,t,n,i,s){var r,a=yM(e,i,s,(function(e,n){e?(a.terminate(),t.ondata.call(t,e)):(n[1]&&a.terminate(),t.ondata.call(t,e,n[0],n[1]))}));a.postMessage(n),t.push=function(e,n){if(r)throw"stream finished";if(!t.ondata)throw"no stream handler";a.postMessage([e,r=n],[e.buffer])},t.terminate=function(){a.terminate()}},_M=function(e,t){return e[t]|e[t+1]<<8},AM=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},IM=function(e,t){return AM(e,t)+4294967296*AM(e,t+4)},XM=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},EM=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&XM(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var i=0;i<=n.length;++i)e[i+10]=n.charCodeAt(i)}},zM=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[n++]);return n+(2&t)},PM=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},WM=function(e){return 10+(e.filename&&e.filename.length+1||0)},ZM=function(e,t){var n=t.level,i=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=i<<6|(i?32-2*i:1)},NM=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function VM(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var DM=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(pM(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}(),HM=function(){return function(e,t){RM([vM,function(){return[GM,DM]}],this,VM.call(this,e,t),(function(e){var t=new DM(e.data);onmessage=GM(t)}),6)}}();function BM(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[vM],(function(e){return TM(kM(e.data[0],e.data[1]))}),0,n)}function kM(e,t){return pM(e,t||{},0,0)}var FM=function(){function e(e){this.s={},this.p=new Tw(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new Tw(t+e.length);n.set(this.p),n.set(e,t),this.p=n},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=qw(this.p,this.o,this.s);this.ondata(Qw(n,t,this.s.b),this.d),this.o=Qw(n,this.s.b-32768),this.s.b=this.o.length,this.p=Qw(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),UM=function(){return function(e){this.ondata=e,RM([bM,function(){return[GM,FM]}],this,0,(function(){var e=new FM;onmessage=GM(e)}),7)}}();function OM(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[bM],(function(e){return TM(YM(e.data[0],CM(e.data[1])))}),1,n)}function YM(e,t){return qw(e,t)}var KM=function(){function e(e,t){this.c=hM(),this.l=0,this.v=1,DM.call(this,e,t)}return e.prototype.push=function(e,t){DM.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=pM(e,this.o,this.v&&WM(this.o),t&&8,!t);this.v&&(EM(n,this.o),this.v=0),t&&(XM(n,n.length-8,this.c.d()),XM(n,n.length-4,this.l)),this.ondata(n,t)},e}(),jM=function(){return function(e,t){RM([vM,xM,function(){return[GM,DM,KM]}],this,VM.call(this,e,t),(function(e){var t=new KM(e.data);onmessage=GM(t)}),8)}}();function JM(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[vM,xM,function(){return[QM]}],(function(e){return TM(QM(e.data[0],e.data[1]))}),2,n)}function QM(e,t){t||(t={});var n=hM(),i=e.length;n.p(e);var s=pM(e,t,WM(t),8),r=s.length;return EM(s,t),XM(s,r-8,n.d()),XM(s,r-4,i),s}var qM=function(){function e(e){this.v=1,FM.call(this,e)}return e.prototype.push=function(e,t){if(FM.prototype.e.call(this,e),this.v){var n=this.p.length>3?zM(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}FM.prototype.c.call(this,t)},e}(),$M=function(){return function(e){this.ondata=e,RM([bM,wM,function(){return[GM,FM,qM]}],this,0,(function(){var e=new qM;onmessage=GM(e)}),9)}}();function eS(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[bM,wM,function(){return[tS]}],(function(e){return TM(tS(e.data[0]))}),3,n)}function tS(e,t){return qw(e.subarray(zM(e),-8),t||new Tw(PM(e)))}var nS=function(){function e(e,t){this.c=uM(),this.v=1,DM.call(this,e,t)}return e.prototype.push=function(e,t){DM.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var n=pM(e,this.o,this.v&&2,t&&4,!t);this.v&&(ZM(n,this.o),this.v=0),t&&XM(n,n.length-4,this.c.d()),this.ondata(n,t)},e}(),iS=function(){return function(e,t){RM([vM,MM,function(){return[GM,DM,nS]}],this,VM.call(this,e,t),(function(e){var t=new nS(e.data);onmessage=GM(t)}),10)}}();function sS(e,t){t||(t={});var n=uM();n.p(e);var i=pM(e,t,2,4);return ZM(i,t),XM(i,i.length-4,n.d()),i}var rS=function(){function e(e){this.v=1,FM.call(this,e)}return e.prototype.push=function(e,t){if(FM.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}FM.prototype.c.call(this,t)},e}(),aS=function(){return function(e){this.ondata=e,RM([bM,SM,function(){return[GM,FM,rS]}],this,0,(function(){var e=new rS;onmessage=GM(e)}),11)}}();function oS(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[bM,SM,function(){return[lS]}],(function(e){return TM(lS(e.data[0],CM(e.data[1])))}),5,n)}function lS(e,t){return qw((NM(e),e.subarray(2,-4)),t)}var cS=function(){function e(e){this.G=qM,this.I=FM,this.Z=rS,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new Tw(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var i=this,s=function(){i.ondata.apply(i,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(s):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(s):new this.Z(s),this.s.push(this.p,t),this.p=null}}},e}(),dS=function(){function e(e){this.G=$M,this.I=UM,this.Z=aS,this.ondata=e}return e.prototype.push=function(e,t){cS.prototype.push.call(this,e,t)},e}();var hS=function(e,t,n,i){for(var s in e){var r=e[s],a=t+s;r instanceof Tw?n[a]=[r,i]:Array.isArray(r)?n[a]=[r[0],mM(i,r[1])]:hS(r,a+"/",n,i)}},uS="undefined"!=typeof TextEncoder&&new TextEncoder,pS="undefined"!=typeof TextDecoder&&new TextDecoder,mS=0;try{pS.decode(lM,{stream:!0}),mS=1}catch(XC){}var fS=function(e){for(var t="",n=0;;){var i=e[n++],s=(i>127)+(i>223)+(i>239);if(n+s>e.length)return[t,Qw(e,n-1)];s?3==s?(i=((15&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|i>>10,56320|1023&i)):t+=1&s?String.fromCharCode((31&i)<<6|63&e[n++]):String.fromCharCode((15&i)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(i)}},gS=function(){function e(e){this.ondata=e,mS?this.t=new TextDecoder:this.p=lM}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var n=new Tw(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=fS(n),s=i[0],r=i[1];if(t){if(r.length)throw"invalid utf-8 data";this.p=null}else this.p=r;this.ondata(s,t)}},e}(),yS=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(bS(e),this.d=t||!1)},e}();function bS(e,t){if(t){for(var n=new Tw(e.length),i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(uS)return uS.encode(e);var s=e.length,r=new Tw(e.length+(e.length>>1)),a=0,o=function(e){r[a++]=e};for(i=0;i<s;++i){if(a+5>r.length){var l=new Tw(a+8+(s-i<<1));l.set(r),r=l}var c=e.charCodeAt(i);c<128||t?o(c):c<2048?(o(192|c>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|63&c)):(o(224|c>>12),o(128|c>>6&63),o(128|63&c))}return Qw(r,0,a)}function vS(e,t){if(t){for(var n="",i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}if(pS)return pS.decode(e);var s=fS(e),r=s[0];if(s[1].length)throw"invalid utf-8 data";return r}var xS=function(e){return 1==e?3:e<6?2:9==e?1:0},wS=function(e,t){return t+30+_M(e,t+26)+_M(e,t+28)},MS=function(e,t,n){var i=_M(e,t+28),s=vS(e.subarray(t+46,t+46+i),!(2048&_M(e,t+8))),r=t+46+i,a=AM(e,t+20),o=n&&4294967295==a?SS(e,r):[a,AM(e,t+24),AM(e,t+42)],l=o[0],c=o[1],d=o[2];return[_M(e,t+10),l,c,s,r+_M(e,t+30)+_M(e,t+32),d]},SS=function(e,t){for(;1!=_M(e,t);t+=4+_M(e,t+2));return[IM(e,t+12),IM(e,t+4),IM(e,t+20)]},TS=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)throw"extra field too long";t+=i+4}return t},CS=function(e,t,n,i,s,r,a,o){var l=i.length,c=n.extra,d=o&&o.length,h=TS(c);XM(e,t,null!=a?33639248:67324752),t+=4,null!=a&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(null==r&&8),e[t++]=s&&8,e[t++]=255&n.compression,e[t++]=n.compression>>8;var u=new Date(null==n.mtime?Date.now():n.mtime),p=u.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(XM(e,t,p<<25|u.getMonth()+1<<21|u.getDate()<<16|u.getHours()<<11|u.getMinutes()<<5|u.getSeconds()>>>1),t+=4,null!=r&&(XM(e,t,n.crc),XM(e,t+4,r),XM(e,t+8,n.size)),XM(e,t+12,l),XM(e,t+14,h),t+=16,null!=a&&(XM(e,t,d),XM(e,t+6,n.attrs),XM(e,t+10,a),t+=14),e.set(i,t),t+=l,h)for(var m in c){var f=c[m],g=f.length;XM(e,t,+m),XM(e,t+2,g),e.set(f,t+4),t+=4+g}return d&&(e.set(o,t),t+=d),t},LS=function(e,t,n,i,s){XM(e,t,101010256),XM(e,t+8,n),XM(e,t+10,n),XM(e,t+12,i),XM(e,t+16,s)},GS=function(){function e(e){this.filename=e,this.c=hM(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}(),RS=function(){function e(e,t){var n=this;t||(t={}),GS.call(this,e),this.d=new DM(t,(function(e,t){n.ondata(null,e,t)})),this.compression=8,this.flag=xS(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){GS.prototype.push.call(this,e,t)},e}(),_S=function(){function e(e,t){var n=this;t||(t={}),GS.call(this,e),this.d=new HM(t,(function(e,t,i){n.ondata(e,t,i)})),this.compression=8,this.flag=xS(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){GS.prototype.push.call(this,e,t)},e}(),AS=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var n=bS(e.filename),i=n.length,s=e.comment,r=s&&bS(s),a=i!=e.filename.length||r&&s.length!=r.length,o=i+TS(e.extra)+30;if(i>65535)throw"filename too long";var l=new Tw(o);CS(l,0,e,n,a);var c=[l],d=function(){for(var e=0,n=c;e<n.length;e++){var i=n[e];t.ondata(null,i,!1)}c=[]},h=this.d;this.d=0;var u=this.u.length,p=mM(e,{f:n,u:a,o:r,t:function(){e.terminate&&e.terminate()},r:function(){if(d(),h){var e=t.u[u+1];e?e.r():t.d=1}h=1}}),m=0;e.ondata=function(n,i,s){if(n)t.ondata(n,i,s),t.terminate();else if(m+=i.length,c.push(i),s){var r=new Tw(16);XM(r,0,134695760),XM(r,4,e.crc),XM(r,8,m),XM(r,12,e.size),c.push(r),p.c=m,p.b=o+m+16,p.crc=e.crc,p.size=e.size,h&&p.r(),h=1}else h&&d()},this.u.push(p)},e.prototype.end=function(){var e=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,n=0,i=0,s=this.u;i<s.length;i++){n+=46+(l=s[i]).f.length+TS(l.extra)+(l.o?l.o.length:0)}for(var r=new Tw(n+22),a=0,o=this.u;a<o.length;a++){var l=o[a];CS(r,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+TS(l.extra)+(l.o?l.o.length:0),t+=l.b}LS(r,e,this.u.length,n,t),this.ondata(null,r,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++){t[e].t()}this.d=2},e}();var IS=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),XS=function(){function e(){var e=this;this.i=new FM((function(t,n){e.ondata(null,t,n)}))}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(n){this.ondata(n,e,t)}},e.compression=8,e}(),ES=function(){function e(e,t){var n=this;t<32e4?this.i=new FM((function(e,t){n.ondata(null,e,t)})):(this.i=new UM((function(e,t,i){n.ondata(e,t,i)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=Qw(e,0)),this.i.push(e,t)},e.compression=8,e}(),zS=function(){function e(e){this.onfile=e,this.k=[],this.o={0:IS},this.p=lM}return e.prototype.push=function(e,t){var n=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var i=Math.min(this.c,e.length),s=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(s,!this.c):this.k[0].push(s),(e=e.subarray(i)).length)return this.push(e,t)}else{var r=0,a=0,o=void 0,l=void 0;this.p.length?e.length?((l=new Tw(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var c=l.length,d=this.c,h=d&&this.d,u=function(){var e,t=AM(l,a);if(67324752==t){r=1,o=a,p.d=null,p.c=0;var i=_M(l,a+6),s=_M(l,a+8),h=2048&i,u=8&i,m=_M(l,a+26),f=_M(l,a+28);if(c>a+30+m+f){var g=[];p.k.unshift(g),r=2;var y,b=AM(l,a+18),v=AM(l,a+22),x=vS(l.subarray(a+30,a+=30+m),!h);4294967295==b?(e=u?[-2]:SS(l,a),b=e[0],v=e[1]):u&&(b=-1),a+=f,p.c=b;var w={name:x,compression:s,start:function(){if(!w.ondata)throw"no callback";if(b){var e=n.o[s];if(!e)throw"unknown compression type "+s;(y=b<0?new e(x):new e(x,b,v)).ondata=function(e,t,n){w.ondata(e,t,n)};for(var t=0,i=g;t<i.length;t++){var r=i[t];y.push(r,!1)}n.k[0]==g&&n.c?n.d=y:y.push(lM,!0)}else w.ondata(null,lM,!0)},terminate:function(){y&&y.terminate&&y.terminate()}};b>=0&&(w.size=b,w.originalSize=v),p.onfile(w)}return"break"}if(d){if(134695760==t)return o=a+=12+(-2==d&&8),r=3,p.c=0,"break";if(33639248==t)return o=a-=4,r=3,p.c=0,"break"}},p=this;a<c-4;++a){if("break"===u())break}if(this.p=lM,d<0){var m=r?l.subarray(0,o-12-(-2==d&&8)-(134695760==AM(l,o-16)&&4)):l.subarray(0,a);h?h.push(m,!!r):this.k[+(2==r)].push(m)}if(2&r)return this.push(l.subarray(a),t);this.p=l.subarray(a)}if(t){if(this.c)throw"invalid zip file";this.p=null}},e.prototype.register=function(e){this.o[e.compression]=e},e}();var PS=Object.freeze({__proto__:null,Deflate:DM,AsyncDeflate:HM,deflate:BM,deflateSync:kM,Inflate:FM,AsyncInflate:UM,inflate:OM,inflateSync:YM,Gzip:KM,AsyncGzip:jM,gzip:JM,gzipSync:QM,Gunzip:qM,AsyncGunzip:$M,gunzip:eS,gunzipSync:tS,Zlib:nS,AsyncZlib:iS,zlib:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[vM,MM,function(){return[sS]}],(function(e){return TM(sS(e.data[0],e.data[1]))}),4,n)},zlibSync:sS,Unzlib:rS,AsyncUnzlib:aS,unzlib:oS,unzlibSync:lS,compress:JM,AsyncCompress:jM,compressSync:QM,Compress:KM,Decompress:cS,AsyncDecompress:dS,decompress:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?eS(e,t,n):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?OM(e,t,n):oS(e,t,n)},decompressSync:function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?tS(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?YM(e,t):lS(e,t)},DecodeUTF8:gS,EncodeUTF8:yS,strToU8:bS,strFromU8:vS,ZipPassThrough:GS,ZipDeflate:RS,AsyncZipDeflate:_S,Zip:AS,zip:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";var i={};hS(e,"",i,t);var s=Object.keys(i),r=s.length,a=0,o=0,l=r,c=new Array(r),d=[],h=function(){for(var e=0;e<d.length;++e)d[e]()},u=function(){var e=new Tw(o+22),t=a,i=o-a;o=0;for(var s=0;s<l;++s){var r=c[s];try{var d=r.c.length;CS(e,o,r,r.f,r.u,d);var h=30+r.f.length+TS(r.extra),u=o+h;e.set(r.c,u),CS(e,a,r,r.f,r.u,d,o,r.m),a+=16+h+(r.m?r.m.length:0),o=u+d}catch(e){return n(e,null)}}LS(e,a,c.length,i,t),n(null,e)};r||u();for(var p=function(e){var t=s[e],l=i[t],p=l[0],m=l[1],f=hM(),g=p.length;f.p(p);var y=bS(t),b=y.length,v=m.comment,x=v&&bS(v),w=x&&x.length,M=TS(m.extra),S=0==m.level?0:8,T=function(i,s){if(i)h(),n(i,null);else{var l=s.length;c[e]=mM(m,{size:g,crc:f.d(),c:s,f:y,m:x,u:b!=t.length||x&&v.length!=w,compression:S}),a+=30+b+M+l,o+=76+2*(b+M)+(w||0)+l,--r||u()}};if(b>65535&&T("filename too long",null),S)if(g<16e4)try{T(null,kM(p,m))}catch(e){T(e,null)}else d.push(BM(p,m,T));else T(null,p)},m=0;m<l;++m)p(m);return h},zipSync:function(e,t){t||(t={});var n={},i=[];hS(e,"",n,t);var s=0,r=0;for(var a in n){var o=n[a],l=o[0],c=o[1],d=0==c.level?0:8,h=(S=bS(a)).length,u=c.comment,p=u&&bS(u),m=p&&p.length,f=TS(c.extra);if(h>65535)throw"filename too long";var g=d?kM(l,c):l,y=g.length,b=hM();b.p(l),i.push(mM(c,{size:l.length,crc:b.d(),c:g,f:S,m:p,u:h!=a.length||p&&u.length!=m,o:s,compression:d})),s+=30+h+f+y,r+=76+2*(h+f)+(m||0)+y}for(var v=new Tw(r+22),x=s,w=r-s,M=0;M<i.length;++M){var S=i[M];CS(v,S.o,S,S.f,S.u,S.c.length);var T=30+S.f.length+TS(S.extra);v.set(S.c,S.o+T),CS(v,s,S,S.f,S.u,S.c.length,S.o,S.m),s+=16+T+(S.m?S.m.length:0)}return LS(v,s,i.length,w,x),v},UnzipPassThrough:IS,UnzipInflate:XS,AsyncUnzipInflate:ES,Unzip:zS,unzip:function(e,t){if("function"!=typeof t)throw"no callback";for(var n=[],i=function(){for(var e=0;e<n.length;++e)n[e]()},s={},r=e.length-22;101010256!=AM(e,r);--r)if(!r||e.length-r>65558)return void t("invalid zip file",null);var a=_M(e,r+8);a||t(null,{});var o=a,l=AM(e,r+16),c=4294967295==l;if(c){if(r=AM(e,r-12),101075792!=AM(e,r))return void t("invalid zip file",null);o=a=AM(e,r+32),l=AM(e,r+48)}for(var d=function(r){var o=MS(e,l,c),d=o[0],h=o[1],u=o[2],p=o[3],m=o[4],f=o[5],g=wS(e,f);l=m;var y=function(e,n){e?(i(),t(e,null)):(s[p]=n,--a||t(null,s))};if(d)if(8==d){var b=e.subarray(g,g+h);if(h<32e4)try{y(null,YM(b,new Tw(u)))}catch(e){y(e,null)}else n.push(OM(b,{size:u},y))}else y("unknown compression type "+d,null);else y(null,Qw(e,g,g+h))},h=0;h<o;++h)d();return i},unzipSync:function(e){for(var t={},n=e.length-22;101010256!=AM(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var i=_M(e,n+8);if(!i)return{};var s=AM(e,n+16),r=4294967295==s;if(r){if(n=AM(e,n-12),101075792!=AM(e,n))throw"invalid zip file";i=AM(e,n+32),s=AM(e,n+48)}for(var a=0;a<i;++a){var o=MS(e,s,r),l=o[0],c=o[1],d=o[2],h=o[3],u=o[4],p=o[5],m=wS(e,p);if(s=u,l){if(8!=l)throw"unknown compression type "+l;t[h]=YM(e.subarray(m,m+c),new Tw(d))}else t[h]=Qw(e,m,m+c)}return t}});function WS(e,t,n){const i=n.length-e-1;if(t>=n[i])return i-1;if(t<=n[e])return e;let s=e,r=i,a=Math.floor((s+r)/2);for(;t<n[a]||t>=n[a+1];)t<n[a]?r=a:s=a,a=Math.floor((s+r)/2);return a}function ZS(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let i=1;for(let e=2;e<=t;++e)i*=e;for(let n=2;n<=e-t;++n)i*=n;return n/i}function NS(e,t,n,i,s){return function(e){const t=e.length,n=[],i=[];for(let s=0;s<t;++s){const t=e[s];n[s]=new ri(t.x,t.y,t.z),i[s]=t.w}const s=[];for(let e=0;e<t;++e){const t=n[e].clone();for(let n=1;n<=e;++n)t.sub(s[e-n].clone().multiplyScalar(ZS(e,n)*i[n]));s[e]=t.divideScalar(i[0])}return s}(function(e,t,n,i,s){const r=s<e?s:e,a=[],o=WS(e,i,t),l=function(e,t,n,i,s){const r=[];for(let e=0;e<=n;++e)r[e]=0;const a=[];for(let e=0;e<=i;++e)a[e]=r.slice(0);const o=[];for(let e=0;e<=n;++e)o[e]=r.slice(0);o[0][0]=1;const l=r.slice(0),c=r.slice(0);for(let i=1;i<=n;++i){l[i]=t-s[e+1-i],c[i]=s[e+i]-t;let n=0;for(let e=0;e<i;++e){const t=c[e+1],s=l[i-e];o[i][e]=t+s;const r=o[e][i-1]/o[i][e];o[e][i]=n+t*r,n=s*r}o[i][i]=n}for(let e=0;e<=n;++e)a[0][e]=o[e][n];for(let e=0;e<=n;++e){let t=0,s=1;const l=[];for(let e=0;e<=n;++e)l[e]=r.slice(0);l[0][0]=1;for(let r=1;r<=i;++r){let i=0;const c=e-r,d=n-r;e>=r&&(l[s][0]=l[t][0]/o[d+1][c],i=l[s][0]*o[c][d]);const h=e-1<=d?r-1:n-e;for(let e=c>=-1?1:-c;e<=h;++e)l[s][e]=(l[t][e]-l[t][e-1])/o[d+1][c+e],i+=l[s][e]*o[c+e][d];e<=d&&(l[s][r]=-l[t][r-1]/o[d+1][e],i+=l[s][r]*o[e][d]),a[r][e]=i;const u=t;t=s,s=u}}let d=n;for(let e=1;e<=i;++e){for(let t=0;t<=n;++t)a[e][t]*=d;d*=n-e}return a}(o,i,e,r,t),c=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),i=t.w;t.x*=i,t.y*=i,t.z*=i,c[e]=t}for(let t=0;t<=r;++t){const n=c[o-e].clone().multiplyScalar(l[t][0]);for(let i=1;i<=e;++i)n.add(c[o-e+i].clone().multiplyScalar(l[t][i]));a[t]=n}for(let e=r+1;e<=s+1;++e)a[e]=new Qn(0,0,0);return a}(e,t,n,i,s))}class VS extends yc{constructor(e,t,n,i,s){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=s||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new Qn(t.x,t.y,t.z,t.w)}}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ri,n=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=function(e,t,n,i){const s=WS(e,i,t),r=function(e,t,n,i){const s=[],r=[],a=[];s[0]=1;for(let o=1;o<=n;++o){r[o]=t-i[e+1-o],a[o]=i[e+o]-t;let n=0;for(let e=0;e<o;++e){const t=a[e+1],i=r[o-e],l=s[e]/(t+i);s[e]=n+t*l,n=i*l}s[o]=n}return s}(s,i,e,t),a=new Qn(0,0,0,0);for(let t=0;t<=e;++t){const i=n[s-e+t],o=r[t],l=i.w*o;a.x+=i.x*l,a.y+=i.y*l,a.z+=i.z*l,a.w+=i.w*o}return a}(this.degree,this.knots,this.controlPoints,n);return 1!==i.w&&i.divideScalar(i.w),t.set(i.x,i.y,i.z)}getTangent(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ri,n=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=NS(this.degree,this.knots,this.controlPoints,n,1);return t.copy(i[1]).normalize(),t}}let DS,HS,BS;class kS extends fh{constructor(e){super(e)}load(e,t,n,i){const s=this,r=""===s.path?Fh.extractUrlBase(e):s.path,a=new yh(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,(function(n){try{t(s.parse(n,r))}catch(t){i?i(t):console.error(t),s.manager.itemError(e)}}),n,i)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===aT(e,0,t.length)}(e))DS=(new KS).parse(e);else{const t=aT(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function i(t){const i=e[t-1];return e=e.slice(n+t),n++,i}for(let e=0;e<t.length;++e){if(i(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(QS(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+QS(t));DS=(new YS).parse(t)}const n=new Sh(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new FS(n,this.manager).parse(DS)}}class FS{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){HS=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),s=(new US).parse(i);return this.parseScene(i,s,n),BS}parseConnections(){const e=new Map;if("Connections"in DS){DS.Connections.connections.forEach((function(t){const n=t[0],i=t[1],s=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const r={ID:i,relationship:s};e.get(n).parents.push(r),e.has(i)||e.set(i,{parents:[],children:[]});const a={ID:n,relationship:s};e.get(i).children.push(a)}))}return e}parseImages(){const e={},t={};if("Video"in DS.Objects){const n=DS.Objects.Video;for(const i in n){const s=n[i];if(e[parseInt(i)]=s.RelativeFilename||s.Filename,"Content"in s){const e=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,r="string"==typeof s.Content&&""!==s.Content;if(e||r){const e=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=e}}}}for(const n in e){const i=e[n];void 0!==t[i]?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+i+'" is not supported.')}if("string"==typeof t)return"data:"+s+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in DS.Objects){const n=DS.Objects.Texture;for(const i in n){const s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,r=void 0!==i?i.value:0,a=void 0!==s?s.value:0;if(n.wrapS=0===r?1e3:1001,n.wrapT=0===a?1e3:1001,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,s=HS.get(e.id).children;let r;void 0!==s&&s.length>0&&void 0!==t[s[0].ID]&&(n=t[s[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const a=e.FileName.slice(-3).toLowerCase();if("tga"===a){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),r=new Jn):(t.setPath(this.textureLoader.path),r=t.load(n))}else"psd"===a?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),r=new Jn):r=this.textureLoader.load(n);return this.textureLoader.setPath(i),r}parseMaterials(e){const t=new Map;if("Material"in DS.Objects){const n=DS.Objects.Material;for(const i in n){const s=this.parseMaterial(n[i],e);null!==s&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let s=e.ShadingModel;if("object"==typeof s&&(s=s.value),!HS.has(n))return null;const r=this.parseParameters(e,t,n);let a;switch(s.toLowerCase()){case"phong":a=new Ud;break;case"lambert":a=new Kd;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new Ud}return a.setValues(r),a.name=i,a}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new Fn).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(i.color=(new Fn).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new Fn).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(i.emissive=(new Fn).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new Fn).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new Fn).fromArray(e.SpecularColor.value));const s=this;return HS.get(n).children.forEach((function(e){const n=e.relationship;switch(n){case"Bump":i.bumpMap=s.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,e.ID),void 0!==i.map&&(i.map.encoding=3001);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=303,i.envMap.encoding=3001);break;case"SpecularColor":i.specularMap=s.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,e.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),i}getTexture(e,t){return"LayeredTexture"in DS.Objects&&t in DS.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=HS.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in DS.Objects){const n=DS.Objects.Deformer;for(const i in n){const s=n[i],r=HS.get(parseInt(i));if("Skin"===s.attrType){const t=this.parseSkeleton(r,n);t.ID=i,r.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=r.parents[0].ID,e[i]=t}else if("BlendShape"===s.attrType){const e={id:i};e.rawTargets=this.parseMorphTargets(r,n),e.id=i,r.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach((function(e){const i=t[e.ID];if("Cluster"!==i.attrType)return;const s={ID:e.ID,indices:[],weights:[],transformLink:(new Wi).fromArray(i.TransformLink.a)};"Indexes"in i&&(s.indices=i.Indexes.a,s.weights=i.Weights.a),n.push(s)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],r=t[s.ID],a={name:r.attrName,initialWeight:r.DeformPercent,id:r.id,fullWeights:r.FullWeights.a};if("BlendShapeChannel"!==r.attrType)return;a.geoID=HS.get(parseInt(s.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(a)}return n}parseScene(e,t,n){BS=new qo;const i=this.parseModels(e.skeletons,t,n),s=DS.Objects.Model,r=this;i.forEach((function(e){const t=s[e.ID];r.setLookAtProperties(e,t);HS.get(e.ID).parents.forEach((function(t){const n=i.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&BS.add(e)})),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),BS.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=iT(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const a=(new OS).parse();1===BS.children.length&&BS.children[0].isGroup&&(BS.children[0].animations=a,BS=BS.children[0]),BS.animations=a}parseModels(e,t,n){const i=new Map,s=DS.Objects.Model;for(const r in s){const a=parseInt(r),o=s[r],l=HS.get(a);let c=this.buildSkeleton(l,e,a,o.attrName);if(!c){switch(o.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,n);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new Nl;break;case"Null":default:c=new qo}c.name=o.attrName?Lu.sanitizeNodeName(o.attrName):"",c.ID=a}this.getTransformData(c,o),i.set(a,c)}return i}buildSkeleton(e,t,n,i){let s=null;return e.parents.forEach((function(e){for(const r in t){const a=t[r];a.rawBones.forEach((function(t,r){if(t.ID===e.ID){const e=s;s=new Nl,s.matrixWorld.copy(t.transformLink),s.name=i?Lu.sanitizeNodeName(i):"",s.ID=n,a.bones[r]=s,null!==e&&s.add(e)}}))}})),s}createCamera(e){let t,n;if(e.children.forEach((function(e){const t=DS.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new os;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let i=1;void 0!==n.NearPlane&&(i=n.NearPlane.value/1e3);let s=1e3;void 0!==n.FarPlane&&(s=n.FarPlane.value/1e3);let r=window.innerWidth,a=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(r=n.AspectWidth.value,a=n.AspectHeight.value);const o=r/a;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new mr(l,o,i,s),null!==c&&t.setFocalLength(c);break;case 1:t=new Zr(-r/2,r/2,a/2,-a/2,i,s);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new os}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){const t=DS.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new os;else{let e;e=void 0===n.LightType?0:n.LightType.value;let i=16777215;void 0!==n.Color&&(i=(new Fn).fromArray(n.Color.value));let s=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(s=0);let r=0;void 0!==n.FarAttenuationEnd&&(r=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const a=1;switch(e){case 0:t=new Wh(i,s,r,a);break;case 1:t=new Nh(i,s);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=Gn.degToRad(n.InnerAngle.value));let o=0;void 0!==n.OuterAngle&&(o=Gn.degToRad(n.OuterAngle.value),o=Math.max(o,1)),t=new Ih(i,s,r,e,o,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Wh(i,s)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,s=null,r=null;const a=[];return e.children.forEach((function(e){t.has(e.ID)&&(s=t.get(e.ID)),n.has(e.ID)&&a.push(n.get(e.ID))})),a.length>1?r=a:a.length>0?r=a[0]:(r=new Ud({color:13421772}),a.push(r)),"color"in s.attributes&&a.forEach((function(e){e.vertexColors=!0})),s.FBX_Deformer?(i=new Zl(s,r),i.normalizeSkinWeights()):i=new ar(s,r),i}createCurve(e,t){const n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),i=new jl({color:3342591,linewidth:1});return new tc(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?sT(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){if("LookAtProperty"in t){HS.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const n=DS.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),BS.add(e.target)):e.lookAt((new ri).fromArray(t))}}}))}}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const r=e[s];HS.get(parseInt(r.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;HS.get(t).parents.forEach((function(e){if(n.has(e.ID)){n.get(e.ID).bind(new Bl(r.bones),i[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in DS.Objects){const t=DS.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new Wi).fromArray(t.Matrix.a)})):e[i.Node]=(new Wi).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in DS&&"AmbientColor"in DS.GlobalSettings){const e=DS.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){const e=new Fn(t,n,i);BS.add(new Vh(e,1))}}}}class US{parse(e){const t=new Map;if("Geometry"in DS.Objects){const n=DS.Objects.Geometry;for(const i in n){const s=HS.get(parseInt(i)),r=this.parseGeometry(s,n[i],e);t.set(parseInt(i),r)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,s=[],r=e.parents.map((function(e){return DS.Objects.Model[e.ID]}));if(0===r.length)return;const a=e.children.reduce((function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&s.push(n.morphTargets[e.ID])}));const o=r[0],l={};"RotationOrder"in o&&(l.eulerOrder=sT(o.RotationOrder.value)),"InheritType"in o&&(l.inheritType=parseInt(o.InheritType.value)),"GeometricTranslation"in o&&(l.translation=o.GeometricTranslation.value),"GeometricRotation"in o&&(l.rotation=o.GeometricRotation.value),"GeometricScaling"in o&&(l.scale=o.GeometricScaling.value);const c=iT(l);return this.genGeometry(t,a,s,c)}genGeometry(e,t,n,i){const s=new Bs;e.attrName&&(s.name=e.attrName);const r=this.parseGeoNode(e,t),a=this.genBuffers(r),o=new Es(a.vertex,3);if(o.applyMatrix4(i),s.setAttribute("position",o),a.colors.length>0&&s.setAttribute("color",new Es(a.colors,3)),t&&(s.setAttribute("skinIndex",new _s(a.weightsIndices,4)),s.setAttribute("skinWeight",new Es(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){const e=(new _n).getNormalMatrix(i),t=new Es(a.normal,3);t.applyNormalMatrix(e),s.setAttribute("normal",t)}if(a.uvs.forEach((function(e,t){let n="uv"+(t+1).toString();0===t&&(n="uv"),s.setAttribute(n,new Es(a.uvs[t],2))})),r.material&&"AllSame"!==r.material.mappingType){let e=a.materialIndex[0],t=0;if(a.materialIndex.forEach((function(n,i){n!==e&&(s.addGroup(t,i-t,e),e=n,t=i)})),s.groups.length>0){const t=s.groups[s.groups.length-1],n=t.start+t.count;n!==a.materialIndex.length&&s.addGroup(n,a.materialIndex.length-n,e)}0===s.groups.length&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,s){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[s]})}))}))),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,s=!1,r=[],a=[],o=[],l=[],c=[],d=[];const h=this;return e.vertexIndices.forEach((function(u,p){let m,f=!1;u<0&&(u^=-1,f=!0);let g=[],y=[];if(r.push(3*u,3*u+1,3*u+2),e.color){const t=eT(p,n,u,e.color);o.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[u]&&e.weightTable[u].forEach((function(e){y.push(e.weight),g.push(e.id)})),y.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const e=[0,0,0,0],t=[0,0,0,0];y.forEach((function(n,i){let s=n,r=g[i];t.forEach((function(t,n,i){if(s>t){i[n]=s,s=t;const a=e[n];e[n]=r,r=a}}))})),g=e,y=t}for(;y.length<4;)y.push(0),g.push(0);for(let e=0;e<4;++e)c.push(y[e]),d.push(g[e])}if(e.normal){const t=eT(p,n,u,e.normal);a.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(m=eT(p,n,u,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){const i=eT(p,n,u,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,f&&(h.genFace(t,e,r,m,a,o,l,c,d,i),n++,i=0,r=[],a=[],o=[],l=[],c=[],d=[])})),t}genFace(e,t,n,i,s,r,a,o,l,c){for(let d=2;d<c;d++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(d-1)]]),e.vertex.push(t.vertexPositions[n[3*(d-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(d-1)+2]]),e.vertex.push(t.vertexPositions[n[3*d]]),e.vertex.push(t.vertexPositions[n[3*d+1]]),e.vertex.push(t.vertexPositions[n[3*d+2]]),t.skeleton&&(e.vertexWeights.push(o[0]),e.vertexWeights.push(o[1]),e.vertexWeights.push(o[2]),e.vertexWeights.push(o[3]),e.vertexWeights.push(o[4*(d-1)]),e.vertexWeights.push(o[4*(d-1)+1]),e.vertexWeights.push(o[4*(d-1)+2]),e.vertexWeights.push(o[4*(d-1)+3]),e.vertexWeights.push(o[4*d]),e.vertexWeights.push(o[4*d+1]),e.vertexWeights.push(o[4*d+2]),e.vertexWeights.push(o[4*d+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(d-1)]),e.weightsIndices.push(l[4*(d-1)+1]),e.weightsIndices.push(l[4*(d-1)+2]),e.weightsIndices.push(l[4*(d-1)+3]),e.weightsIndices.push(l[4*d]),e.weightsIndices.push(l[4*d+1]),e.weightsIndices.push(l[4*d+2]),e.weightsIndices.push(l[4*d+3])),t.color&&(e.colors.push(r[0]),e.colors.push(r[1]),e.colors.push(r[2]),e.colors.push(r[3*(d-1)]),e.colors.push(r[3*(d-1)+1]),e.colors.push(r[3*(d-1)+2]),e.colors.push(r[3*d]),e.colors.push(r[3*d+1]),e.colors.push(r[3*d+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(s[0]),e.normal.push(s[1]),e.normal.push(s[2]),e.normal.push(s[3*(d-1)]),e.normal.push(s[3*(d-1)+1]),e.normal.push(s[3*(d-1)+2]),e.normal.push(s[3*d]),e.normal.push(s[3*d+1]),e.normal.push(s[3*d+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(a[n][0]),e.uvs[n].push(a[n][1]),e.uvs[n].push(a[n][2*(d-1)]),e.uvs[n].push(a[n][2*(d-1)+1]),e.uvs[n].push(a[n][2*d]),e.uvs[n].push(a[n][2*d+1])}))}addMorphTargets(e,t,n,i){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const r=DS.Objects.Geometry[n.geoID];void 0!==r&&s.genMorphGeometry(e,t,r,i,n.name)}))}))}genMorphGeometry(e,t,n,i,s){const r=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],a=void 0!==n.Vertices?n.Vertices.a:[],o=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,c=new Float32Array(l);for(let e=0;e<o.length;e++){const t=3*o[e];c[t]=a[3*e],c[t+1]=a[3*e+1],c[t+2]=a[3*e+2]}const d={vertexIndices:r,vertexPositions:c},h=this.genBuffers(d),u=new Es(h.vertex,3);u.name=s||n.attrName,u.applyMatrix4(i),e.morphAttributes.position.push(u)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let s=[];return"IndexToDirect"===n&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:s,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let s=[];return"IndexToDirect"===n&&(s=e.UVIndex.a),{dataSize:2,buffer:i,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let s=[];return"IndexToDirect"===n&&(s=e.ColorIndex.a),{dataSize:4,buffer:i,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,s=[];for(let e=0;e<i.length;++e)s.push(e);return{dataSize:1,buffer:i,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(void 0===VS)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new Bs;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Bs;const n=t-1,i=e.KnotVector.a,s=[],r=e.Points.a;for(let e=0,t=r.length;e<t;e+=4)s.push((new Qn).fromArray(r,e));let a,o;if("Closed"===e.Form)s.push(s[0]);else if("Periodic"===e.Form){a=n,o=i.length-1-a;for(let e=0;e<n;++e)s.push(s[e])}const l=new VS(n,i,s,a,o).getPoints(12*s.length);return(new Bs).setFromPoints(l)}}class OS{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const i=t[n],s=this.addClip(i);e.push(s)}return e}parseClips(){if(void 0===DS.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=DS.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(null!==i.attrName.match(/S|R|T|DeformPercent/)){const e={id:i.id,attr:i.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=DS.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(qS),values:t[n].KeyValueFloat.a},s=HS.get(i.id);if(void 0!==s){const t=s.parents[0].ID,n=s.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=i:n.match(/Y/)?e.get(t).curves.y=i:n.match(/Z/)?e.get(t).curves.z=i:n.match(/d|DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=i)}}}parseAnimationLayers(e){const t=DS.Objects.AnimationLayer,n=new Map;for(const i in t){const t=[],s=HS.get(parseInt(i));if(void 0!==s){s.children.forEach((function(n,i){if(e.has(n.ID)){const s=e.get(n.ID);if(void 0!==s.curves.x||void 0!==s.curves.y||void 0!==s.curves.z){if(void 0===t[i]){const e=HS.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const s=DS.Objects.Model[e.toString()];if(void 0===s)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const r={modelName:s.attrName?Lu.sanitizeNodeName(s.attrName):"",ID:s.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};BS.traverse((function(e){e.ID===s.id&&(r.transform=e.matrix,e.userData.transformData&&(r.eulerOrder=e.userData.transformData.eulerOrder))})),r.transform||(r.transform=new Wi),"PreRotation"in s&&(r.preRotation=s.PreRotation.value),"PostRotation"in s&&(r.postRotation=s.PostRotation.value),t[i]=r}}t[i]&&(t[i][s.attr]=s)}else if(void 0!==s.curves.morph){if(void 0===t[i]){const e=HS.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,s=HS.get(e).parents[0].ID,r=HS.get(s).parents[0].ID,a=HS.get(r).parents[0].ID,o=DS.Objects.Model[a],l={modelName:o.attrName?Lu.sanitizeNodeName(o.attrName):"",morphName:DS.Objects.Deformer[e].attrName};t[i]=l}t[i][s.attr]=s}}})),n.set(parseInt(i),t)}}return n}parseAnimStacks(e){const t=DS.Objects.AnimationStack,n={};for(const i in t){const s=HS.get(parseInt(i)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const r=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:r}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new dh(e.name,-1,t)}generateTracks(e){const t=[];let n=new ri,i=new si,s=new ri;if(e.transform&&e.transform.decompose(n,i,s),n=n.toArray(),i=(new Oi).setFromQuaternion(i,e.eulerOrder).toArray(),s=s.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==i&&t.push(i)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,i){const s=this.getTimesForAllAxes(t),r=this.getKeyframeTrackValues(s,t,n);return new ch(e+"."+i,s,r)}generateRotationTrack(e,t,n,i,s,r){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Gn.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Gn.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Gn.degToRad));const a=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(a,t,n);void 0!==i&&((i=i.map(Gn.degToRad)).push(r),i=(new Oi).fromArray(i),i=(new si).setFromEuler(i)),void 0!==s&&((s=s.map(Gn.degToRad)).push(r),s=(new Oi).fromArray(s),s=(new si).setFromEuler(s).invert());const l=new si,c=new Oi,d=[];for(let e=0;e<o.length;e+=3)c.set(o[e],o[e+1],o[e+2],r),l.setFromEuler(c),void 0!==i&&l.premultiply(i),void 0!==s&&l.multiply(s),l.toArray(d,e/3*4);return new oh(e+".quaternion",a,d)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),i=BS.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new rh(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let i=1;i<t.length;i++){const s=t[i];s!==n&&(t[e]=s,n=s,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const i=n,s=[];let r=-1,a=-1,o=-1;return e.forEach((function(e){if(t.x&&(r=t.x.times.indexOf(e)),t.y&&(a=t.y.times.indexOf(e)),t.z&&(o=t.z.times.indexOf(e)),-1!==r){const e=t.x.values[r];s.push(e),i[0]=e}else s.push(i[0]);if(-1!==a){const e=t.y.values[a];s.push(e),i[1]=e}else s.push(i[1]);if(-1!==o){const e=t.z.values[o];s.push(e),i[2]=e}else s.push(i[2])})),s}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],i=e.values[t]-n,s=Math.abs(i);if(s>=180){const r=s/180,a=i/r;let o=n+a;const l=e.times[t-1],c=(e.times[t]-l)/r;let d=l+c;const h=[],u=[];for(;d<e.times[t];)h.push(d),d+=c,u.push(o),o+=a;e.times=oT(e.times,t,h),e.values=oT(e.values,t,u)}}}}class YS{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new JS,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,i){const s=e.match(/^[\s\t]*;/),r=e.match(/^[\s\t]*$/);if(s||r)return;const a=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),o=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(e,a):o?t.parseNodeProperty(e,o,n[++i]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),s={name:n},r=this.parseNodeAttr(i),a=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,s):n in a?("PoseNode"===n?a.PoseNode.push(s):void 0!==a[n].id&&(a[n]={},a[n][a[n].id]=a[n]),""!==r.id&&(a[n][r.id]=s)):"number"==typeof r.id?(a[n]={},a[n][r.id]=s):"Properties70"!==n&&(a[n]="PoseNode"===n?[s]:s),"number"==typeof r.id&&(s.id=r.id),""!==r.name&&(s.attrName=r.name),""!==r.type&&(s.attrType=r.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===s&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const r=this.getCurrentNode();if("Properties70"!==r.name){if("C"===i){const e=s.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let a=s.split(",").slice(3);a=a.map((function(e){return e.trim().replace(/^"/,"")})),i="connections",s=[t,n],function(e,t){for(let n=0,i=e.length,s=t.length;n<s;n++,i++)e[i]=t[n]}(s,a),void 0===r[i]&&(r[i]=[])}"Node"===i&&(r.id=s),i in r&&Array.isArray(r[i])?r[i].push(s):"a"!==i?r[i]=s:r.a=s,this.setCurrentProp(r,i),"a"===i&&","!==s.slice(-1)&&(r.a=rT(s))}else this.parseNodeSpecialProperty(e,i,s)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=rT(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),s=i[0],r=i[1],a=i[2],o=i[3];let l=i[4];switch(r){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=rT(l)}this.getPrevNode()[s]={type:r,type2:a,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),s)}}class KS{parse(e){const t=new jS(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new JS;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&i.add(e.name,e)}return i}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const r=e.getUint8(),a=e.getString(r);if(0===i)return null;const o=[];for(let t=0;t<s;t++)o.push(this.parseProperty(e));const l=o.length>0?o[0]:"",c=o.length>1?o[1]:"",d=o.length>2?o[2]:"";for(n.singleProperty=1===s&&e.getOffset()===i;i>e.getOffset();){const i=this.parseNode(e,t);null!==i&&this.parseSubNode(a,n,i)}return n.propertyList=o,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==d&&(n.attrType=d),""!==a&&(n.name=a),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach((function(e){t[e]=n[e]}))}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],i=n.propertyList[1];const s=n.propertyList[2],r=n.propertyList[3];let a;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),a="Color"===i||"ColorRGB"===i||"Vector"===i||"Vector3D"===i||0===i.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:i,type2:s,flag:r,value:a}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),r=e.getUint32();if(0===s)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}void 0===PS&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=lS(new Uint8Array(e.getArrayBuffer(r))),o=new jS(a.buffer);switch(t){case"b":case"c":return o.getBooleanArray(i);case"d":return o.getFloat64Array(i);case"f":return o.getFloat32Array(i);case"i":return o.getInt32Array(i);case"l":return o.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class jS{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let n=0;n<e;n++)t[n]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),Fh.decodeText(new Uint8Array(t))}}class JS{add(e,t){this[e]=t}}function QS(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function qS(e){return e/46186158e3}const $S=[];function eT(e,t,n,i){let s;switch(i.mappingType){case"ByPolygonVertex":s=e;break;case"ByPolygon":s=t;break;case"ByVertice":s=n;break;case"AllSame":s=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(s=i.indices[s]);const r=s*i.dataSize,a=r+i.dataSize;return function(e,t,n,i){for(let s=n,r=0;s<i;s++,r++)e[r]=t[s];return e}($S,i.buffer,r,a)}const tT=new Oi,nT=new ri;function iT(e){const t=new Wi,n=new Wi,i=new Wi,s=new Wi,r=new Wi,a=new Wi,o=new Wi,l=new Wi,c=new Wi,d=new Wi,h=new Wi,u=new Wi,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(nT.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(Gn.degToRad);t.push(e.eulerOrder),n.makeRotationFromEuler(tT.fromArray(t))}if(e.rotation){const t=e.rotation.map(Gn.degToRad);t.push(e.eulerOrder),i.makeRotationFromEuler(tT.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(Gn.degToRad);t.push(e.eulerOrder),s.makeRotationFromEuler(tT.fromArray(t)),s.invert()}e.scale&&r.scale(nT.fromArray(e.scale)),e.scalingOffset&&o.setPosition(nT.fromArray(e.scalingOffset)),e.scalingPivot&&a.setPosition(nT.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(nT.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(nT.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(h.copy(e.parentMatrix),d.copy(e.parentMatrixWorld));const m=n.clone().multiply(i).multiply(s),f=new Wi;f.extractRotation(d);const g=new Wi;g.copyPosition(d);const y=g.clone().invert().multiply(d),b=f.clone().invert().multiply(y),v=r,x=new Wi;if(0===p)x.copy(f).multiply(m).multiply(b).multiply(v);else if(1===p)x.copy(f).multiply(b).multiply(m).multiply(v);else{const e=(new Wi).scale((new ri).setFromMatrixScale(h)).clone().invert(),t=b.clone().multiply(e);x.copy(f).multiply(m).multiply(t).multiply(v)}const w=c.clone().invert(),M=a.clone().invert();let S=t.clone().multiply(l).multiply(c).multiply(n).multiply(i).multiply(s).multiply(w).multiply(o).multiply(a).multiply(r).multiply(M);const T=(new Wi).copyPosition(S),C=d.clone().multiply(T);return u.copyPosition(C),S=u.clone().multiply(x),S.premultiply(d.invert()),S}function sT(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function rT(e){return e.split(",").map((function(e){return parseFloat(e)}))}function aT(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),Fh.decodeText(new Uint8Array(e,t,n))}function oT(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}class lT extends Mh{constructor(e){super(e)}parse(e){const t=0,n=1,i=2,s=3,r=9,a=10,o=11,l=48,c=4,d=0,h=1,u=2,p=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let m=0;const f=new Uint8Array(e),g={id_length:f[m++],colormap_type:f[m++],image_type:f[m++],colormap_index:f[m++]|f[m++]<<8,colormap_length:f[m++]|f[m++]<<8,colormap_size:f[m++],origin:[f[m++]|f[m++]<<8,f[m++]|f[m++]<<8],width:f[m++]|f[m++]<<8,height:f[m++]|f[m++]<<8,pixel_size:f[m++],flags:f[m++]};!function(e){switch(e.image_type){case n:case r:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case i:case s:case a:case o:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(g),g.id_length+m>e.length&&console.error("THREE.TGALoader: No data."),m+=g.id_length;let y=!1,b=!1,v=!1;switch(g.image_type){case r:y=!0,b=!0;break;case n:b=!0;break;case a:y=!0;break;case i:break;case o:y=!0,v=!0;break;case s:v=!0}const x=new Uint8Array(g.width*g.height*4),w=function(e,t,n,i,s){let r,a;const o=n.pixel_size>>3,l=n.width*n.height*o;if(t&&(a=s.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;r=new Uint8Array(l);let a=0;const c=new Uint8Array(o);for(;a<l;)if(e=s[i++],t=1+(127&e),128&e){for(n=0;n<o;++n)c[n]=s[i++];for(n=0;n<t;++n)r.set(c,a+n*o);a+=o*t}else{for(t*=o,n=0;n<t;++n)r[a+n]=s[i++];a+=t}}else r=s.subarray(i,i+=t?n.width*n.height:l);return{pixel_data:r,palettes:a}}(y,b,g,m,f);return function(e,t,n,i,s){let r,a,o,m,f,y;switch((g.flags&l)>>c){default:case u:r=0,o=1,f=t,a=0,m=1,y=n;break;case d:r=0,o=1,f=t,a=n-1,m=-1,y=-1;break;case p:r=t-1,o=-1,f=-1,a=0,m=1,y=n;break;case h:r=t-1,o=-1,f=-1,a=n-1,m=-1,y=-1}if(v)switch(g.pixel_size){case 8:!function(e,t,n,i,s,r,a,o){let l,c,d,h=0;const u=g.width;for(d=t;d!==i;d+=n)for(c=s;c!==a;c+=r,h++)l=o[h],e[4*(c+u*d)+0]=l,e[4*(c+u*d)+1]=l,e[4*(c+u*d)+2]=l,e[4*(c+u*d)+3]=255}(e,a,m,y,r,o,f,i);break;case 16:!function(e,t,n,i,s,r,a,o){let l,c,d=0;const h=g.width;for(c=t;c!==i;c+=n)for(l=s;l!==a;l+=r,d+=2)e[4*(l+h*c)+0]=o[d+0],e[4*(l+h*c)+1]=o[d+0],e[4*(l+h*c)+2]=o[d+0],e[4*(l+h*c)+3]=o[d+1]}(e,a,m,y,r,o,f,i);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(e,t,n,i,s,r,a,o,l){const c=l;let d,h,u,p=0;const m=g.width;for(u=t;u!==i;u+=n)for(h=s;h!==a;h+=r,p++)d=o[p],e[4*(h+m*u)+3]=255,e[4*(h+m*u)+2]=c[3*d+0],e[4*(h+m*u)+1]=c[3*d+1],e[4*(h+m*u)+0]=c[3*d+2]}(e,a,m,y,r,o,f,i,s);break;case 16:!function(e,t,n,i,s,r,a,o){let l,c,d,h=0;const u=g.width;for(d=t;d!==i;d+=n)for(c=s;c!==a;c+=r,h+=2)l=o[h+0]+(o[h+1]<<8),e[4*(c+u*d)+0]=(31744&l)>>7,e[4*(c+u*d)+1]=(992&l)>>2,e[4*(c+u*d)+2]=(31&l)<<3,e[4*(c+u*d)+3]=32768&l?0:255}(e,a,m,y,r,o,f,i);break;case 24:!function(e,t,n,i,s,r,a,o){let l,c,d=0;const h=g.width;for(c=t;c!==i;c+=n)for(l=s;l!==a;l+=r,d+=3)e[4*(l+h*c)+3]=255,e[4*(l+h*c)+2]=o[d+0],e[4*(l+h*c)+1]=o[d+1],e[4*(l+h*c)+0]=o[d+2]}(e,a,m,y,r,o,f,i);break;case 32:!function(e,t,n,i,s,r,a,o){let l,c,d=0;const h=g.width;for(c=t;c!==i;c+=n)for(l=s;l!==a;l+=r,d+=4)e[4*(l+h*c)+2]=o[d+0],e[4*(l+h*c)+1]=o[d+1],e[4*(l+h*c)+0]=o[d+2],e[4*(l+h*c)+3]=o[d+3]}(e,a,m,y,r,o,f,i);break;default:console.error("THREE.TGALoader: Format not supported.")}}(x,g.width,g.height,w.pixel_data,w.palettes),{data:x,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:1008}}}class cT extends fh{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new fT(e)})),this.register((function(e){return new MT(e)})),this.register((function(e){return new ST(e)})),this.register((function(e){return new yT(e)})),this.register((function(e){return new bT(e)})),this.register((function(e){return new vT(e)})),this.register((function(e){return new xT(e)})),this.register((function(e){return new mT(e)})),this.register((function(e){return new wT(e)})),this.register((function(e){return new gT(e)})),this.register((function(e){return new uT(e)})),this.register((function(e){return new TT(e)}))}load(e,t,n,i){const s=this;let r;r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Fh.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){i?i(t):console.error(t),s.manager.itemError(e),s.manager.itemEnd(e)},o=new yh(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{s.parse(n,r,(function(n){t(n),s.manager.itemEnd(e)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s;const r={},a={};if("string"==typeof e)s=e;else{if(Fh.decodeText(new Uint8Array(e,0,4))===CT){try{r[hT.KHR_BINARY_GLTF]=new RT(e)}catch(e){return void(i&&i(e))}s=r[hT.KHR_BINARY_GLTF].content}else s=Fh.decodeText(new Uint8Array(e))}const o=JSON.parse(s);if(void 0===o.asset||o.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new oC(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);a[t.name]=t,r[t.name]=!0}if(o.extensionsUsed)for(let e=0;e<o.extensionsUsed.length;++e){const t=o.extensionsUsed[e],n=o.extensionsRequired||[];switch(t){case hT.KHR_MATERIALS_UNLIT:r[t]=new pT;break;case hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:r[t]=new XT;break;case hT.KHR_DRACO_MESH_COMPRESSION:r[t]=new _T(o,this.dracoLoader);break;case hT.KHR_TEXTURE_TRANSFORM:r[t]=new AT;break;case hT.KHR_MESH_QUANTIZATION:r[t]=new ET;break;default:n.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(r),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,s){n.parse(e,t,i,s)}))}}function dT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const hT={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class uT{constructor(e){this.parser=e,this.name=hT.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,r=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let a;const o=new Fn(16777215);void 0!==r.color&&o.fromArray(r.color);const l=void 0!==r.range?r.range:0;switch(r.type){case"directional":a=new Nh(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Wh(o),a.distance=l;break;case"spot":a=new Ih(o),a.distance=l,r.spot=r.spot||{},r.spot.innerConeAngle=void 0!==r.spot.innerConeAngle?r.spot.innerConeAngle:0,r.spot.outerConeAngle=void 0!==r.spot.outerConeAngle?r.spot.outerConeAngle:Math.PI/4,a.angle=r.spot.outerConeAngle,a.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return a.position.set(0,0,0),a.decay=2,void 0!==r.intensity&&(a.intensity=r.intensity),a.name=t.createUniqueName(r.name||"light_"+e),i=Promise.resolve(a),t.cache.add(n,i),i}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],s=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===s?null:this._loadLight(s).then((function(e){return n._getNodeRef(t.cache,s,e)}))}}class pT{constructor(){this.name=hT.KHR_MATERIALS_UNLIT}getMaterialType(){return ws}extendParams(e,t,n){const i=[];e.color=new Fn(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const t=s.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==s.baseColorTexture&&i.push(n.assignTexture(e,"map",s.baseColorTexture,3001))}return Promise.all(i)}}class mT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class fT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];if(void 0!==r.clearcoatFactor&&(t.clearcoat=r.clearcoatFactor),void 0!==r.clearcoatTexture&&s.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),void 0!==r.clearcoatRoughnessFactor&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),void 0!==r.clearcoatRoughnessTexture&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),void 0!==r.clearcoatNormalTexture&&(s.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),void 0!==r.clearcoatNormalTexture.scale)){const e=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Rn(e,e)}return Promise.all(s)}}class gT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return void 0!==r.iridescenceFactor&&(t.iridescence=r.iridescenceFactor),void 0!==r.iridescenceTexture&&s.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),void 0!==r.iridescenceIor&&(t.iridescenceIOR=r.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==r.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),void 0!==r.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),void 0!==r.iridescenceThicknessTexture&&s.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(s)}}class yT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new Fn(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];return void 0!==r.sheenColorFactor&&t.sheenColor.fromArray(r.sheenColorFactor),void 0!==r.sheenRoughnessFactor&&(t.sheenRoughness=r.sheenRoughnessFactor),void 0!==r.sheenColorTexture&&s.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,3001)),void 0!==r.sheenRoughnessTexture&&s.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(s)}}class bT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return void 0!==r.transmissionFactor&&(t.transmission=r.transmissionFactor),void 0!==r.transmissionTexture&&s.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(s)}}class vT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.thickness=void 0!==r.thicknessFactor?r.thicknessFactor:0,void 0!==r.thicknessTexture&&s.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new Fn(a[0],a[1],a[2]),Promise.all(s)}}class xT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class wT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.specularIntensity=void 0!==r.specularFactor?r.specularFactor:1,void 0!==r.specularTexture&&s.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new Fn(a[0],a[1],a[2]),void 0!==r.specularColorTexture&&s.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,3001)),Promise.all(s)}}class MT{constructor(e){this.parser=e,this.name=hT.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}}class ST{constructor(e){this.parser=e,this.name=hT.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],a=i.images[r.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(s){if(s)return n.loadTextureImage(e,r.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class TT{constructor(e){this.name=hT.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,s.ready]).then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,r=e.count,a=e.byteStride,o=new ArrayBuffer(r*a),l=new Uint8Array(t[0],n,i);return s.decodeGltfBuffer(new Uint8Array(o),r,a,l,e.mode,e.filter),o}))}return null}}const CT="glTF",LT=1313821514,GT=5130562;class RT{constructor(e){this.name=hT.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:Fh.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==CT)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,i=new DataView(e,12);let s=0;for(;s<n;){const t=i.getUint32(s,!0);s+=4;const n=i.getUint32(s,!0);if(s+=4,n===LT){const n=new Uint8Array(e,12+s,t);this.content=Fh.decodeText(n)}else if(n===GT){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class _T{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=hT.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},o={},l={};for(const e in r){const t=KT[e]||e.toLowerCase();a[t]=r[e]}for(const t in e.attributes){const i=KT[t]||t.toLowerCase();if(void 0!==r[t]){const s=n.accessors[e.attributes[t]],r=FT[s.componentType];l[i]=r,o[i]=!0===s.normalized}}return t.getDependency("bufferView",s).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=o[t];void 0!==i&&(n.normalized=i)}t(e)}),a,l)}))}))}}class AT{constructor(){this.name=hT.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class IT extends kd{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),i=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),s=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),r=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new Fn).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(const t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",s).replace("#include <lights_physical_fragment>",r)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class XT{constructor(){this.name=hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return IT}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new Fn(1,1,1),e.opacity=1;const s=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&s.push(n.assignTexture(e,"map",i.diffuseTexture,3001)),e.emissive=new Fn(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Fn(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;s.push(n.assignTexture(e,"glossinessMap",t)),s.push(n.assignTexture(e,"specularMap",t,3001))}return Promise.all(s)}createMaterial(e){const t=new IT(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=void 0===e.emissiveIntensity?1:e.emissiveIntensity,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=0,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class ET{constructor(){this.name=hT.KHR_MESH_QUANTIZATION}}class zT extends qd{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[s+e];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,c=i-t,d=(n-t)/c,h=d*d,u=h*d,p=e*l,m=p-l,f=-2*u+3*h,g=u-h,y=1-f,b=g-h+d;for(let e=0;e!==a;e++){const t=r[m+e+a],n=r[m+e+o]*c,i=r[p+e+a],l=r[p+e]*c;s[e]=y*t+b*n+f*i+g*l}return s}}const PT=new si;class WT extends zT{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return PT.fromArray(s).normalize().toArray(s),s}}const ZT=0,NT=1,VT=2,DT=3,HT=4,BT=5,kT=6,FT={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},UT={9728:1003,9729:1006,9984:1004,9985:1007,9986:1005,9987:1008},OT={33071:1001,33648:1002,10497:1e3},YT={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},KT={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},jT={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},JT={CUBICSPLINE:void 0,LINEAR:2301,STEP:2300},QT="OPAQUE",qT="MASK",$T="BLEND";function eC(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new kd({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function tC(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function nC(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function iC(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function sC(e){const t=e.extensions&&e.extensions[hT.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+rC(t.attributes):e.indices+":"+rC(e.attributes)+":"+e.mode,n}function rC(e){let t="";const n=Object.keys(e).sort();for(let i=0,s=n.length;i<s;i++)t+=n[i]+":"+e[n[i]]+";";return t}function aC(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class oC{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new dT,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1;"undefined"==typeof createImageBitmap||n||i&&s<98?this.textureLoader=new Sh(this.options.manager):this.textureLoader=new Qh(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new yh(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const r={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};tC(s,r,i),nC(r,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(r)}))).then((function(){e(r)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())s(i,t.children[n])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[hT.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,s){n.load(Fh.resolveURL(t.uri,i.path),e,void 0,(function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);const s=[];return void 0!==i.bufferView?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),void 0!==i.sparse&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then((function(e){const s=e[0],r=YT[i.type],a=FT[i.componentType],o=a.BYTES_PER_ELEMENT,l=o*r,c=i.byteOffset||0,d=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,h=!0===i.normalized;let u,p;if(d&&d!==l){const e=Math.floor(c/d),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(u=new a(s,e*d,i.count*d/o),l=new dl(u,d/o),t.cache.add(n,l)),p=new ul(l,r,c%d/o,h)}else u=null===s?new a(i.count*r):new a(s,c,i.count*r),p=new Ts(u,r,h);if(void 0!==i.sparse){const t=YT.SCALAR,n=FT[i.sparse.indices.componentType],o=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],o,i.sparse.count*t),d=new a(e[2],l,i.sparse.count*r);null!==s&&(p=new Ts(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,d[e*r]),r>=2&&p.setY(t,d[e*r+1]),r>=3&&p.setZ(t,d[e*r+2]),r>=4&&p.setW(t,d[e*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,s=t.images[i];let r=this.textureLoader;if(s.uri){const e=n.manager.getHandler(s.uri);null!==e&&(r=e)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],a=s.images[t],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,r.name&&(t.name=r.name);const n=(s.samplers||{})[r.sampler]||{};return t.magFilter=UT[n.magFilter]||1006,t.minFilter=UT[n.minFilter]||1008,t.wrapS=OT[n.wrapS]||1e3,t.wrapT=OT[n.wrapT]||1e3,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const r=i.images[e],a=self.URL||self.webkitURL;let o=r.uri||"",l=!1;if(void 0!==r.bufferView)o=n.getDependency("bufferView",r.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:r.mimeType});return o=a.createObjectURL(t),o}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(o).then((function(e){return new Promise((function(n,i){let r=n;!0===t.isImageBitmapLoader&&(r=function(e){const t=new Jn(e);t.needsUpdate=!0,n(t)}),t.load(Fh.resolveURL(e,s.path),r,void 0,i)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(o),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then((function(r){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),s.extensions[hT.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[hT.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=s.associations.get(r);r=s.extensions[hT.KHR_TEXTURE_TRANSFORM].extendTexture(r,e),s.associations.set(r,t)}}return void 0!==i&&(r.encoding=i),e[t]=r,r}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,r=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ac,xs.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new jl,xs.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(i||s||r){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),r&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),r&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return kd}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const a={},o=s.extensions||{},l=[];if(o[hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];r=e.getMaterialType(),l.push(e.extendParams(a,s,t))}else if(o[hT.KHR_MATERIALS_UNLIT]){const e=i[hT.KHR_MATERIALS_UNLIT];r=e.getMaterialType(),l.push(e.extendParams(a,s,t))}else{const n=s.pbrMetallicRoughness||{};if(a.color=new Fn(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(a,"map",n.baseColorTexture,3001)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),r=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===s.doubleSided&&(a.side=2);const c=s.alphaMode||QT;if(c===$T?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===qT&&(a.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&r!==ws&&(l.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Rn(1,1),void 0!==s.normalTexture.scale)){const e=s.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==s.occlusionTexture&&r!==ws&&(l.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(a.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&r!==ws&&(a.emissive=(new Fn).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&r!==ws&&l.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,3001)),Promise.all(l).then((function(){let n;return n=r===IT?i[hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new r(a),s.name&&(n.name=s.name),nC(n,s),t.associations.set(n,{materials:e}),s.extensions&&tC(i,n,s),n}))}createUniqueName(e){const t=Lu.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(e){return n[hT.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return cC(n,e,t)}))}const r=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],o=sC(a),l=i[o];if(l)r.push(l.promise);else{let e;e=a.extensions&&a.extensions[hT.KHR_DRACO_MESH_COMPRESSION]?s(a):cC(new Bs,a,t),i[o]={primitive:a,promise:e},r.push(e)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],r=s.primitives,a=[];for(let e=0,t=r.length;e<t;e++){const t=void 0===r[e].material?eC(this.cache):this.getDependency("material",r[e].material);a.push(t)}return a.push(t.loadGeometries(r)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,c=o.length;n<c;n++){const c=o[n],d=r[n];let h;const u=a[n];if(d.mode===HT||d.mode===BT||d.mode===kT||void 0===d.mode)h=!0===s.isSkinnedMesh?new Zl(c,u):new ar(c,u),!0!==h.isSkinnedMesh||h.geometry.attributes.skinWeight.normalized||h.normalizeSkinWeights(),d.mode===BT?h.geometry=dC(h.geometry,1):d.mode===kT&&(h.geometry=dC(h.geometry,2));else if(d.mode===NT)h=new sc(c,u);else if(d.mode===DT)h=new tc(c,u);else if(d.mode===VT)h=new rc(c,u);else{if(d.mode!==ZT)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);h=new hc(c,u)}Object.keys(h.geometry.morphAttributes).length>0&&iC(h,s),h.name=t.createUniqueName(s.name||"mesh_"+e),nC(h,s),d.extensions&&tC(i,h,d),t.assignFinalMaterial(h),l.push(h)}for(let n=0,i=l.length;n<i;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new qo;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new mr(Gn.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new Zr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),nC(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return n.inverseBindMatrices=e,n}))}loadAnimation(e){const t=this.json.animations[e],n=[],i=[],s=[],r=[],a=[];for(let e=0,o=t.channels.length;e<o;e++){const o=t.channels[e],l=t.samplers[o.sampler],c=o.target,d=void 0!==c.node?c.node:c.id,h=void 0!==t.parameters?t.parameters[l.input]:l.input,u=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",d)),i.push(this.getDependency("accessor",h)),s.push(this.getDependency("accessor",u)),r.push(l),a.push(c)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(s),Promise.all(r),Promise.all(a)]).then((function(n){const i=n[0],s=n[1],r=n[2],a=n[3],o=n[4],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],n=s[e],c=r[e],d=a[e],h=o[e];if(void 0===t)continue;let u;switch(t.updateMatrix(),t.matrixAutoUpdate=!0,jT[h.path]){case jT.weights:u=rh;break;case jT.rotation:u=oh;break;case jT.position:case jT.scale:default:u=ch}const p=t.name?t.name:t.uuid,m=void 0!==d.interpolation?JT[d.interpolation]:2301,f=[];jT[h.path]===jT.weights?t.traverse((function(e){e.morphTargetInfluences&&f.push(e.name?e.name:e.uuid)})):f.push(p);let g=c.array;if(c.normalized){const e=aC(g.constructor),t=new Float32Array(g.length);for(let n=0,i=g.length;n<i;n++)t[n]=g[n]*e;g=t}for(let e=0,t=f.length;e<t;e++){const t=new u(f[e]+"."+jT[h.path],n.array,g,m);"CUBICSPLINE"===d.interpolation&&(t.createInterpolant=function(e){return new(this instanceof oh?WT:zT)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new dh(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,i=this,s=t.nodes[e],r=s.name?i.createUniqueName(s.name):"";return function(){const t=[],n=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==s.camera&&t.push(i.getDependency("camera",s.camera).then((function(e){return i._getNodeRef(i.cameraCache,s.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let a;if(a=!0===s.isBone?new Nl:t.length>1?new qo:1===t.length?t[0]:new os,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(s.name&&(a.userData.name=s.name,a.name=r),nC(a,s),s.extensions&&tC(n,a,s),void 0!==s.matrix){const e=new Wi;e.fromArray(s.matrix),a.applyMatrix4(e)}else void 0!==s.translation&&a.position.fromArray(s.translation),void 0!==s.rotation&&a.quaternion.fromArray(s.rotation),void 0!==s.scale&&a.scale.fromArray(s.scale);return i.associations.has(a)||i.associations.set(a,{}),i.associations.get(a).nodes=e,a}))}loadScene(e){const t=this.json,n=this.extensions,i=this.json.scenes[e],s=this,r=new qo;i.name&&(r.name=s.createUniqueName(i.name)),nC(r,i),i.extensions&&tC(n,r,i);const a=i.nodes||[],o=[];for(let e=0,n=a.length;e<n;e++)o.push(lC(a[e],r,t,s));return Promise.all(o).then((function(){return s.associations=(e=>{const t=new Map;for(const[e,n]of s.associations)(e instanceof xs||e instanceof Jn)&&t.set(e,n);return e.traverse((e=>{const n=s.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}}function lC(e,t,n,i){const s=n.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===s.skin)return e;let t;return i.getDependency("skin",s.skin).then((function(e){t=e;const n=[];for(let e=0,s=t.joints.length;e<s;e++)n.push(i.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const i=[],s=[];for(let e=0,r=n.length;e<r;e++){const r=n[e];if(r){i.push(r);const n=new Wi;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),s.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new Bl(i,s),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const r=[];if(s.children){const t=s.children;for(let s=0,a=t.length;s<a;s++){const a=t[s];r.push(lC(a,e,n,i))}}return Promise.all(r)}))}function cC(e,t,n){const i=t.attributes,s=[];function r(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=KT[t]||t.toLowerCase();n in e.attributes||s.push(r(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));s.push(i)}return nC(e,t),function(e,t,n){const i=t.attributes,s=new li;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.POSITION],t=e.min,r=e.max;if(void 0===t||void 0===r)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(s.set(new ri(t[0],t[1],t[2]),new ri(r[0],r[1],r[2])),e.normalized){const t=aC(FT[e.componentType]);s.min.multiplyScalar(t),s.max.multiplyScalar(t)}}const r=t.targets;if(void 0!==r){const e=new ri,t=new ri;for(let i=0,s=r.length;i<s;i++){const s=r[i];if(void 0!==s.POSITION){const i=n.json.accessors[s.POSITION],r=i.min,a=i.max;if(void 0!==r&&void 0!==a){if(t.setX(Math.max(Math.abs(r[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(r[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(r[2]),Math.abs(a[2]))),i.normalized){const e=aC(FT[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(e)}e.boundingBox=s;const a=new Gi;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(s).then((function(){return void 0!==t.targets?function(e,t,n){let i=!1,s=!1,r=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(s=!0),void 0!==n.COLOR_0&&(r=!0),i&&s&&r)break}if(!i&&!s&&!r)return Promise.resolve(e);const a=[],o=[],l=[];for(let c=0,d=t.length;c<d;c++){const d=t[c];if(i){const t=void 0!==d.POSITION?n.getDependency("accessor",d.POSITION):e.attributes.position;a.push(t)}if(s){const t=void 0!==d.NORMAL?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(t)}if(r){const t=void 0!==d.COLOR_0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],o=t[2];return i&&(e.morphAttributes.position=n),s&&(e.morphAttributes.normal=a),r&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function dC(e,t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,s=[];if(2===t)for(let e=1;e<=i;e++)s.push(n.getX(0)),s.push(n.getX(e)),s.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(s.push(n.getX(e)),s.push(n.getX(e+1)),s.push(n.getX(e+2))):(s.push(n.getX(e+2)),s.push(n.getX(e+1)),s.push(n.getX(e)));s.length/3!==i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=e.clone();return r.setIndex(s),r}const hC=new WeakMap;class uC extends fh{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new yh(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(i)}),n,i)}decodeDracoFile(e,t,n,i){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const n=t.attributeTypes[e];void 0!==n.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=n.name)}const n=JSON.stringify(t);if(hC.has(e)){const t=hC.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(s,r).then((n=>(i=n,new Promise(((n,r)=>{i._callbacks[s]={resolve:n,reject:r},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return a.catch((()=>!0)).then((()=>{i&&s&&this._releaseTask(i,s)})),hC.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new Bs;e.index&&t.setIndex(new Ts(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],s=i.name,r=i.array,a=i.itemSize;t.setAttribute(s,new Ts(r,a))}return t}_loadLibrary(e,t){const n=new yh(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=pC.toString(),s=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([s]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function pC(){let e,t;function n(e,t,n,i,s,r){const a=r.num_components(),o=n.num_points()*a,l=o*s.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,s),d=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,r,c,l,d);const h=new s(e.HEAPF32.buffer,d,o).slice();return e._free(d),{name:i,array:h,itemSize:a}}onmessage=function(i){const s=i.data;switch(s.type){case"init":e=s.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=s.buffer,r=s.taskConfig;t.then((e=>{const t=e.draco,a=new t.Decoder,o=new t.DecoderBuffer;o.Init(new Int8Array(i),i.byteLength);try{const e=function(e,t,i,s){const r=s.attributeIDs,a=s.attributeTypes;let o,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeBufferToMesh(i,o);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const d={index:null,attributes:[]};for(const i in r){const l=self[a[i]];let c,h;if(s.useUniqueIDs)h=r[i],c=t.GetAttributeByUniqueId(o,h);else{if(h=t.GetAttributeId(o,e[r[i]]),-1===h)continue;c=t.GetAttribute(o,h)}d.attributes.push(n(e,t,o,i,l,c))}c===e.TRIANGULAR_MESH&&(d.index=function(e,t,n){const i=3*n.num_faces(),s=4*i,r=e._malloc(s);t.GetTrianglesUInt32Array(n,s,r);const a=new Uint32Array(e.HEAPF32.buffer,r,i).slice();return e._free(r),{array:a,itemSize:1}}(e,t,o));return e.destroy(o),d}(t,a,o,r),i=e.attributes.map((e=>e.array.buffer));e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}finally{t.destroy(o),t.destroy(a)}}))}}}
32
+ */var ww={},Mw=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Sw=function(e){return new Worker(e)};try{URL.revokeObjectURL(Mw(""))}catch(EC){Mw=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},Sw=function(e){return new Worker(e,{type:"module"})}}var Tw=Uint8Array,Cw=Uint16Array,Lw=Uint32Array,Gw=new Tw([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Rw=new Tw([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_w=new Tw([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Aw=function(e,t){for(var n=new Cw(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var s=new Lw(n[30]);for(i=1;i<30;++i)for(var r=n[i];r<n[i+1];++r)s[r]=r-n[i]<<5|i;return[n,s]},Iw=Aw(Gw,2),Xw=Iw[0],Ew=Iw[1];Xw[28]=258,Ew[258]=28;for(var zw=Aw(Rw,0),Pw=zw[0],Ww=zw[1],Zw=new Cw(32768),Nw=0;Nw<32768;++Nw){var Vw=(43690&Nw)>>>1|(21845&Nw)<<1;Vw=(61680&(Vw=(52428&Vw)>>>2|(13107&Vw)<<2))>>>4|(3855&Vw)<<4,Zw[Nw]=((65280&Vw)>>>8|(255&Vw)<<8)>>>1}var Dw=function(e,t,n){for(var i=e.length,s=0,r=new Cw(t);s<i;++s)++r[e[s]-1];var a,o=new Cw(t);for(s=0;s<t;++s)o[s]=o[s-1]+r[s-1]<<1;if(n){a=new Cw(1<<t);var l=15-t;for(s=0;s<i;++s)if(e[s])for(var c=s<<4|e[s],d=t-e[s],h=o[e[s]-1]++<<d,u=h|(1<<d)-1;h<=u;++h)a[Zw[h]>>>l]=c}else for(a=new Cw(i),s=0;s<i;++s)e[s]&&(a[s]=Zw[o[e[s]-1]++]>>>15-e[s]);return a},Hw=new Tw(288);for(Nw=0;Nw<144;++Nw)Hw[Nw]=8;for(Nw=144;Nw<256;++Nw)Hw[Nw]=9;for(Nw=256;Nw<280;++Nw)Hw[Nw]=7;for(Nw=280;Nw<288;++Nw)Hw[Nw]=8;var Bw=new Tw(32);for(Nw=0;Nw<32;++Nw)Bw[Nw]=5;var kw=Dw(Hw,9,0),Fw=Dw(Hw,9,1),Uw=Dw(Bw,5,0),Ow=Dw(Bw,5,1),Yw=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Kw=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},jw=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Jw=function(e){return(e/8|0)+(7&e&&1)},Qw=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof Cw?Cw:e instanceof Lw?Lw:Tw)(n-t);return i.set(e.subarray(t,n)),i},qw=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Tw(0);var s=!t||n,r=!n||n.i;n||(n={}),t||(t=new Tw(3*i));var a=function(e){var n=t.length;if(e>n){var i=new Tw(Math.max(2*n,e));i.set(t),t=i}},o=n.f||0,l=n.p||0,c=n.b||0,d=n.l,h=n.d,u=n.m,p=n.n,m=8*i;do{if(!d){n.f=o=Kw(e,l,1);var f=Kw(e,l+1,3);if(l+=3,!f){var g=e[(G=Jw(l)+4)-4]|e[G-3]<<8,y=G+g;if(y>i){if(r)throw"unexpected EOF";break}s&&a(c+g),t.set(e.subarray(G,y),c),n.b=c+=g,n.p=l=8*y;continue}if(1==f)d=Fw,h=Ow,u=9,p=5;else{if(2!=f)throw"invalid block type";var b=Kw(e,l,31)+257,v=Kw(e,l+10,15)+4,x=b+Kw(e,l+5,31)+1;l+=14;for(var w=new Tw(x),M=new Tw(19),S=0;S<v;++S)M[_w[S]]=Kw(e,l+3*S,7);l+=3*v;var T=Yw(M),C=(1<<T)-1,L=Dw(M,T,1);for(S=0;S<x;){var G,R=L[Kw(e,l,C)];if(l+=15&R,(G=R>>>4)<16)w[S++]=G;else{var _=0,A=0;for(16==G?(A=3+Kw(e,l,3),l+=2,_=w[S-1]):17==G?(A=3+Kw(e,l,7),l+=3):18==G&&(A=11+Kw(e,l,127),l+=7);A--;)w[S++]=_}}var I=w.subarray(0,b),X=w.subarray(b);u=Yw(I),p=Yw(X),d=Dw(I,u,1),h=Dw(X,p,1)}if(l>m){if(r)throw"unexpected EOF";break}}s&&a(c+131072);for(var E=(1<<u)-1,z=(1<<p)-1,P=l;;P=l){var W=(_=d[jw(e,l)&E])>>>4;if((l+=15&_)>m){if(r)throw"unexpected EOF";break}if(!_)throw"invalid length/literal";if(W<256)t[c++]=W;else{if(256==W){P=l,d=null;break}var Z=W-254;if(W>264){var N=Gw[S=W-257];Z=Kw(e,l,(1<<N)-1)+Xw[S],l+=N}var V=h[jw(e,l)&z],D=V>>>4;if(!V)throw"invalid distance";l+=15&V;X=Pw[D];if(D>3){N=Rw[D];X+=jw(e,l)&(1<<N)-1,l+=N}if(l>m){if(r)throw"unexpected EOF";break}s&&a(c+131072);for(var H=c+Z;c<H;c+=4)t[c]=t[c-X],t[c+1]=t[c+1-X],t[c+2]=t[c+2-X],t[c+3]=t[c+3-X];c=H}}n.l=d,n.p=P,n.b=c,d&&(o=1,n.m=u,n.d=h,n.n=p)}while(!o);return c==t.length?t:Qw(t,0,c)},$w=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8},eM=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8,e[i+2]|=n>>>16},tM=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var s=n.length,r=n.slice();if(!s)return[lM,0];if(1==s){var a=new Tw(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var o=n[0],l=n[1],c=0,d=1,h=2;for(n[0]={s:-1,f:o.f+l.f,l:o,r:l};d!=s-1;)o=n[n[c].f<n[h].f?c++:h++],l=n[c!=d&&n[c].f<n[h].f?c++:h++],n[d++]={s:-1,f:o.f+l.f,l:o,r:l};var u=r[0].s;for(i=1;i<s;++i)r[i].s>u&&(u=r[i].s);var p=new Cw(u+1),m=nM(n[d-1],p,0);if(m>t){i=0;var f=0,g=m-t,y=1<<g;for(r.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i<s;++i){var b=r[i].s;if(!(p[b]>t))break;f+=y-(1<<m-p[b]),p[b]=t}for(f>>>=g;f>0;){var v=r[i].s;p[v]<t?f-=1<<t-p[v]++-1:++i}for(;i>=0&&f;--i){var x=r[i].s;p[x]==t&&(--p[x],++f)}m=t}return[new Tw(p),m]},nM=function(e,t,n){return-1==e.s?Math.max(nM(e.l,t,n+1),nM(e.r,t,n+1)):t[e.s]=n},iM=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Cw(++t),i=0,s=e[0],r=1,a=function(e){n[i++]=e},o=1;o<=t;++o)if(e[o]==s&&o!=t)++r;else{if(!s&&r>2){for(;r>138;r-=138)a(32754);r>2&&(a(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(a(s),--r;r>6;r-=6)a(8304);r>2&&(a(r-3<<5|8208),r=0)}for(;r--;)a(s);r=1,s=e[o]}return[n.subarray(0,i),t]},sM=function(e,t){for(var n=0,i=0;i<t.length;++i)n+=e[i]*t[i];return n},rM=function(e,t,n){var i=n.length,s=Jw(t+2);e[s]=255&i,e[s+1]=i>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var r=0;r<i;++r)e[s+r+4]=n[r];return 8*(s+4+i)},aM=function(e,t,n,i,s,r,a,o,l,c,d){$w(t,d++,n),++s[256];for(var h=tM(s,15),u=h[0],p=h[1],m=tM(r,15),f=m[0],g=m[1],y=iM(u),b=y[0],v=y[1],x=iM(f),w=x[0],M=x[1],S=new Cw(19),T=0;T<b.length;++T)S[31&b[T]]++;for(T=0;T<w.length;++T)S[31&w[T]]++;for(var C=tM(S,7),L=C[0],G=C[1],R=19;R>4&&!L[_w[R-1]];--R);var _,A,I,X,E=c+5<<3,z=sM(s,Hw)+sM(r,Bw)+a,P=sM(s,u)+sM(r,f)+a+14+3*R+sM(S,L)+(2*S[16]+3*S[17]+7*S[18]);if(E<=z&&E<=P)return rM(t,d,e.subarray(l,l+c));if($w(t,d,1+(P<z)),d+=2,P<z){_=Dw(u,p,0),A=u,I=Dw(f,g,0),X=f;var W=Dw(L,G,0);$w(t,d,v-257),$w(t,d+5,M-1),$w(t,d+10,R-4),d+=14;for(T=0;T<R;++T)$w(t,d+3*T,L[_w[T]]);d+=3*R;for(var Z=[b,w],N=0;N<2;++N){var V=Z[N];for(T=0;T<V.length;++T){var D=31&V[T];$w(t,d,W[D]),d+=L[D],D>15&&($w(t,d,V[T]>>>5&127),d+=V[T]>>>12)}}}else _=kw,A=Hw,I=Uw,X=Bw;for(T=0;T<o;++T)if(i[T]>255){D=i[T]>>>18&31;eM(t,d,_[D+257]),d+=A[D+257],D>7&&($w(t,d,i[T]>>>23&31),d+=Gw[D]);var H=31&i[T];eM(t,d,I[H]),d+=X[H],H>3&&(eM(t,d,i[T]>>>5&8191),d+=Rw[H])}else eM(t,d,_[i[T]]),d+=A[i[T]];return eM(t,d,_[256]),d+A[256]},oM=new Lw([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),lM=new Tw(0),cM=function(e,t,n,i,s,r){var a=e.length,o=new Tw(i+a+5*(1+Math.ceil(a/7e3))+s),l=o.subarray(i,o.length-s),c=0;if(!t||a<8)for(var d=0;d<=a;d+=65535){var h=d+65535;h<a?c=rM(l,c,e.subarray(d,h)):(l[d]=r,c=rM(l,c,e.subarray(d,a)))}else{for(var u=oM[t-1],p=u>>>13,m=8191&u,f=(1<<n)-1,g=new Cw(32768),y=new Cw(f+1),b=Math.ceil(n/3),v=2*b,x=function(t){return(e[t]^e[t+1]<<b^e[t+2]<<v)&f},w=new Lw(25e3),M=new Cw(288),S=new Cw(32),T=0,C=0,L=(d=0,0),G=0,R=0;d<a;++d){var _=x(d),A=32767&d,I=y[_];if(g[A]=I,y[_]=A,G<=d){var X=a-d;if((T>7e3||L>24576)&&X>423){c=aM(e,l,0,w,M,S,C,L,R,d-R,c),L=T=C=0,R=d;for(var E=0;E<286;++E)M[E]=0;for(E=0;E<30;++E)S[E]=0}var z=2,P=0,W=m,Z=A-I&32767;if(X>2&&_==x(d-Z))for(var N=Math.min(p,X)-1,V=Math.min(32767,d),D=Math.min(258,X);Z<=V&&--W&&A!=I;){if(e[d+z]==e[d+z-Z]){for(var H=0;H<D&&e[d+H]==e[d+H-Z];++H);if(H>z){if(z=H,P=Z,H>N)break;var B=Math.min(Z,H-2),k=0;for(E=0;E<B;++E){var F=d-Z+E+32768&32767,U=F-g[F]+32768&32767;U>k&&(k=U,I=F)}}}Z+=(A=I)-(I=g[A])+32768&32767}if(P){w[L++]=268435456|Ew[z]<<18|Ww[P];var O=31&Ew[z],Y=31&Ww[P];C+=Gw[O]+Rw[Y],++M[257+O],++S[Y],G=d+z,++T}else w[L++]=e[d],++M[e[d]]}}c=aM(e,l,r,w,M,S,C,L,R,d-R,c),!r&&7&c&&(c=rM(l,c+1,lM))}return Qw(o,0,i+Jw(c)+s)},dM=function(){for(var e=new Lw(256),t=0;t<256;++t){for(var n=t,i=9;--i;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),hM=function(){var e=-1;return{p:function(t){for(var n=e,i=0;i<t.length;++i)n=dM[255&n^t[i]]^n>>>8;e=n},d:function(){return~e}}},uM=function(){var e=1,t=0;return{p:function(n){for(var i=e,s=t,r=n.length,a=0;a!=r;){for(var o=Math.min(a+2655,r);a<o;++a)s+=i+=n[a];i=(65535&i)+15*(i>>16),s=(65535&s)+15*(s>>16)}e=i,t=s},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},pM=function(e,t,n,i,s){return cM(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,i,!s)},mM=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n},fM=function(e,t,n){for(var i=e(),s=e.toString(),r=s.slice(s.indexOf("[")+1,s.lastIndexOf("]")).replace(/ /g,"").split(","),a=0;a<i.length;++a){var o=i[a],l=r[a];if("function"==typeof o){t+=";"+l+"=";var c=o.toString();if(o.prototype)if(-1!=c.indexOf("[native code]")){var d=c.indexOf(" ",8)+1;t+=c.slice(d,c.indexOf("(",d))}else for(var h in t+=c,o.prototype)t+=";"+l+".prototype."+h+"="+o.prototype[h].toString();else t+=c}else n[l]=o}return[t,n]},gM=[],yM=function(e,t,n,i){var s;if(!gM[n]){for(var r="",a={},o=e.length-1,l=0;l<o;++l)r=(s=fM(e[l],r,a))[0],a=s[1];gM[n]=fM(e[o],r,a)}var c=mM({},gM[n][1]);return function(e,t,n,i,s){var r=Sw(ww[t]||(ww[t]=Mw(e)));return r.onerror=function(e){return s(e.error,null)},r.onmessage=function(e){return s(null,e.data)},r.postMessage(n,i),r}(gM[n][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",n,c,function(e){var t=[];for(var n in e)(e[n]instanceof Tw||e[n]instanceof Cw||e[n]instanceof Lw)&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t}(c),i)},bM=function(){return[Tw,Cw,Lw,Gw,Rw,_w,Xw,Pw,Fw,Ow,Zw,Dw,Yw,Kw,jw,Jw,Qw,qw,YM,TM,CM]},vM=function(){return[Tw,Cw,Lw,Gw,Rw,_w,Ew,Ww,kw,Hw,Uw,Bw,Zw,oM,lM,Dw,$w,eM,tM,nM,iM,sM,rM,aM,Jw,Qw,cM,pM,kM,TM]},xM=function(){return[EM,WM,XM,hM,dM]},wM=function(){return[zM,PM]},MM=function(){return[ZM,XM,uM]},SM=function(){return[NM]},TM=function(e){return postMessage(e,[e.buffer])},CM=function(e){return e&&e.size&&new Tw(e.size)},LM=function(e,t,n,i,s,r){var a=yM(n,i,s,(function(e,t){a.terminate(),r(e,t)}));return a.postMessage([e,t],t.consume?[e.buffer]:[]),function(){a.terminate()}},GM=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){return e.push(t.data[0],t.data[1])}},RM=function(e,t,n,i,s){var r,a=yM(e,i,s,(function(e,n){e?(a.terminate(),t.ondata.call(t,e)):(n[1]&&a.terminate(),t.ondata.call(t,e,n[0],n[1]))}));a.postMessage(n),t.push=function(e,n){if(r)throw"stream finished";if(!t.ondata)throw"no stream handler";a.postMessage([e,r=n],[e.buffer])},t.terminate=function(){a.terminate()}},_M=function(e,t){return e[t]|e[t+1]<<8},AM=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},IM=function(e,t){return AM(e,t)+4294967296*AM(e,t+4)},XM=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},EM=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&XM(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var i=0;i<=n.length;++i)e[i+10]=n.charCodeAt(i)}},zM=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[n++]);return n+(2&t)},PM=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},WM=function(e){return 10+(e.filename&&e.filename.length+1||0)},ZM=function(e,t){var n=t.level,i=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=i<<6|(i?32-2*i:1)},NM=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function VM(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var DM=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(pM(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}(),HM=function(){return function(e,t){RM([vM,function(){return[GM,DM]}],this,VM.call(this,e,t),(function(e){var t=new DM(e.data);onmessage=GM(t)}),6)}}();function BM(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[vM],(function(e){return TM(kM(e.data[0],e.data[1]))}),0,n)}function kM(e,t){return pM(e,t||{},0,0)}var FM=function(){function e(e){this.s={},this.p=new Tw(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new Tw(t+e.length);n.set(this.p),n.set(e,t),this.p=n},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=qw(this.p,this.o,this.s);this.ondata(Qw(n,t,this.s.b),this.d),this.o=Qw(n,this.s.b-32768),this.s.b=this.o.length,this.p=Qw(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),UM=function(){return function(e){this.ondata=e,RM([bM,function(){return[GM,FM]}],this,0,(function(){var e=new FM;onmessage=GM(e)}),7)}}();function OM(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[bM],(function(e){return TM(YM(e.data[0],CM(e.data[1])))}),1,n)}function YM(e,t){return qw(e,t)}var KM=function(){function e(e,t){this.c=hM(),this.l=0,this.v=1,DM.call(this,e,t)}return e.prototype.push=function(e,t){DM.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=pM(e,this.o,this.v&&WM(this.o),t&&8,!t);this.v&&(EM(n,this.o),this.v=0),t&&(XM(n,n.length-8,this.c.d()),XM(n,n.length-4,this.l)),this.ondata(n,t)},e}(),jM=function(){return function(e,t){RM([vM,xM,function(){return[GM,DM,KM]}],this,VM.call(this,e,t),(function(e){var t=new KM(e.data);onmessage=GM(t)}),8)}}();function JM(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[vM,xM,function(){return[QM]}],(function(e){return TM(QM(e.data[0],e.data[1]))}),2,n)}function QM(e,t){t||(t={});var n=hM(),i=e.length;n.p(e);var s=pM(e,t,WM(t),8),r=s.length;return EM(s,t),XM(s,r-8,n.d()),XM(s,r-4,i),s}var qM=function(){function e(e){this.v=1,FM.call(this,e)}return e.prototype.push=function(e,t){if(FM.prototype.e.call(this,e),this.v){var n=this.p.length>3?zM(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}FM.prototype.c.call(this,t)},e}(),$M=function(){return function(e){this.ondata=e,RM([bM,wM,function(){return[GM,FM,qM]}],this,0,(function(){var e=new qM;onmessage=GM(e)}),9)}}();function eS(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[bM,wM,function(){return[tS]}],(function(e){return TM(tS(e.data[0]))}),3,n)}function tS(e,t){return qw(e.subarray(zM(e),-8),t||new Tw(PM(e)))}var nS=function(){function e(e,t){this.c=uM(),this.v=1,DM.call(this,e,t)}return e.prototype.push=function(e,t){DM.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var n=pM(e,this.o,this.v&&2,t&&4,!t);this.v&&(ZM(n,this.o),this.v=0),t&&XM(n,n.length-4,this.c.d()),this.ondata(n,t)},e}(),iS=function(){return function(e,t){RM([vM,MM,function(){return[GM,DM,nS]}],this,VM.call(this,e,t),(function(e){var t=new nS(e.data);onmessage=GM(t)}),10)}}();function sS(e,t){t||(t={});var n=uM();n.p(e);var i=pM(e,t,2,4);return ZM(i,t),XM(i,i.length-4,n.d()),i}var rS=function(){function e(e){this.v=1,FM.call(this,e)}return e.prototype.push=function(e,t){if(FM.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}FM.prototype.c.call(this,t)},e}(),aS=function(){return function(e){this.ondata=e,RM([bM,SM,function(){return[GM,FM,rS]}],this,0,(function(){var e=new rS;onmessage=GM(e)}),11)}}();function oS(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[bM,SM,function(){return[lS]}],(function(e){return TM(lS(e.data[0],CM(e.data[1])))}),5,n)}function lS(e,t){return qw((NM(e),e.subarray(2,-4)),t)}var cS=function(){function e(e){this.G=qM,this.I=FM,this.Z=rS,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new Tw(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var i=this,s=function(){i.ondata.apply(i,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(s):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(s):new this.Z(s),this.s.push(this.p,t),this.p=null}}},e}(),dS=function(){function e(e){this.G=$M,this.I=UM,this.Z=aS,this.ondata=e}return e.prototype.push=function(e,t){cS.prototype.push.call(this,e,t)},e}();var hS=function(e,t,n,i){for(var s in e){var r=e[s],a=t+s;r instanceof Tw?n[a]=[r,i]:Array.isArray(r)?n[a]=[r[0],mM(i,r[1])]:hS(r,a+"/",n,i)}},uS="undefined"!=typeof TextEncoder&&new TextEncoder,pS="undefined"!=typeof TextDecoder&&new TextDecoder,mS=0;try{pS.decode(lM,{stream:!0}),mS=1}catch(EC){}var fS=function(e){for(var t="",n=0;;){var i=e[n++],s=(i>127)+(i>223)+(i>239);if(n+s>e.length)return[t,Qw(e,n-1)];s?3==s?(i=((15&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|i>>10,56320|1023&i)):t+=1&s?String.fromCharCode((31&i)<<6|63&e[n++]):String.fromCharCode((15&i)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(i)}},gS=function(){function e(e){this.ondata=e,mS?this.t=new TextDecoder:this.p=lM}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var n=new Tw(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=fS(n),s=i[0],r=i[1];if(t){if(r.length)throw"invalid utf-8 data";this.p=null}else this.p=r;this.ondata(s,t)}},e}(),yS=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(bS(e),this.d=t||!1)},e}();function bS(e,t){if(t){for(var n=new Tw(e.length),i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(uS)return uS.encode(e);var s=e.length,r=new Tw(e.length+(e.length>>1)),a=0,o=function(e){r[a++]=e};for(i=0;i<s;++i){if(a+5>r.length){var l=new Tw(a+8+(s-i<<1));l.set(r),r=l}var c=e.charCodeAt(i);c<128||t?o(c):c<2048?(o(192|c>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|63&c)):(o(224|c>>12),o(128|c>>6&63),o(128|63&c))}return Qw(r,0,a)}function vS(e,t){if(t){for(var n="",i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}if(pS)return pS.decode(e);var s=fS(e),r=s[0];if(s[1].length)throw"invalid utf-8 data";return r}var xS=function(e){return 1==e?3:e<6?2:9==e?1:0},wS=function(e,t){return t+30+_M(e,t+26)+_M(e,t+28)},MS=function(e,t,n){var i=_M(e,t+28),s=vS(e.subarray(t+46,t+46+i),!(2048&_M(e,t+8))),r=t+46+i,a=AM(e,t+20),o=n&&4294967295==a?SS(e,r):[a,AM(e,t+24),AM(e,t+42)],l=o[0],c=o[1],d=o[2];return[_M(e,t+10),l,c,s,r+_M(e,t+30)+_M(e,t+32),d]},SS=function(e,t){for(;1!=_M(e,t);t+=4+_M(e,t+2));return[IM(e,t+12),IM(e,t+4),IM(e,t+20)]},TS=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)throw"extra field too long";t+=i+4}return t},CS=function(e,t,n,i,s,r,a,o){var l=i.length,c=n.extra,d=o&&o.length,h=TS(c);XM(e,t,null!=a?33639248:67324752),t+=4,null!=a&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(null==r&&8),e[t++]=s&&8,e[t++]=255&n.compression,e[t++]=n.compression>>8;var u=new Date(null==n.mtime?Date.now():n.mtime),p=u.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(XM(e,t,p<<25|u.getMonth()+1<<21|u.getDate()<<16|u.getHours()<<11|u.getMinutes()<<5|u.getSeconds()>>>1),t+=4,null!=r&&(XM(e,t,n.crc),XM(e,t+4,r),XM(e,t+8,n.size)),XM(e,t+12,l),XM(e,t+14,h),t+=16,null!=a&&(XM(e,t,d),XM(e,t+6,n.attrs),XM(e,t+10,a),t+=14),e.set(i,t),t+=l,h)for(var m in c){var f=c[m],g=f.length;XM(e,t,+m),XM(e,t+2,g),e.set(f,t+4),t+=4+g}return d&&(e.set(o,t),t+=d),t},LS=function(e,t,n,i,s){XM(e,t,101010256),XM(e,t+8,n),XM(e,t+10,n),XM(e,t+12,i),XM(e,t+16,s)},GS=function(){function e(e){this.filename=e,this.c=hM(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}(),RS=function(){function e(e,t){var n=this;t||(t={}),GS.call(this,e),this.d=new DM(t,(function(e,t){n.ondata(null,e,t)})),this.compression=8,this.flag=xS(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){GS.prototype.push.call(this,e,t)},e}(),_S=function(){function e(e,t){var n=this;t||(t={}),GS.call(this,e),this.d=new HM(t,(function(e,t,i){n.ondata(e,t,i)})),this.compression=8,this.flag=xS(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){GS.prototype.push.call(this,e,t)},e}(),AS=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var n=bS(e.filename),i=n.length,s=e.comment,r=s&&bS(s),a=i!=e.filename.length||r&&s.length!=r.length,o=i+TS(e.extra)+30;if(i>65535)throw"filename too long";var l=new Tw(o);CS(l,0,e,n,a);var c=[l],d=function(){for(var e=0,n=c;e<n.length;e++){var i=n[e];t.ondata(null,i,!1)}c=[]},h=this.d;this.d=0;var u=this.u.length,p=mM(e,{f:n,u:a,o:r,t:function(){e.terminate&&e.terminate()},r:function(){if(d(),h){var e=t.u[u+1];e?e.r():t.d=1}h=1}}),m=0;e.ondata=function(n,i,s){if(n)t.ondata(n,i,s),t.terminate();else if(m+=i.length,c.push(i),s){var r=new Tw(16);XM(r,0,134695760),XM(r,4,e.crc),XM(r,8,m),XM(r,12,e.size),c.push(r),p.c=m,p.b=o+m+16,p.crc=e.crc,p.size=e.size,h&&p.r(),h=1}else h&&d()},this.u.push(p)},e.prototype.end=function(){var e=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,n=0,i=0,s=this.u;i<s.length;i++){n+=46+(l=s[i]).f.length+TS(l.extra)+(l.o?l.o.length:0)}for(var r=new Tw(n+22),a=0,o=this.u;a<o.length;a++){var l=o[a];CS(r,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+TS(l.extra)+(l.o?l.o.length:0),t+=l.b}LS(r,e,this.u.length,n,t),this.ondata(null,r,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++){t[e].t()}this.d=2},e}();var IS=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),XS=function(){function e(){var e=this;this.i=new FM((function(t,n){e.ondata(null,t,n)}))}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(n){this.ondata(n,e,t)}},e.compression=8,e}(),ES=function(){function e(e,t){var n=this;t<32e4?this.i=new FM((function(e,t){n.ondata(null,e,t)})):(this.i=new UM((function(e,t,i){n.ondata(e,t,i)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=Qw(e,0)),this.i.push(e,t)},e.compression=8,e}(),zS=function(){function e(e){this.onfile=e,this.k=[],this.o={0:IS},this.p=lM}return e.prototype.push=function(e,t){var n=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var i=Math.min(this.c,e.length),s=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(s,!this.c):this.k[0].push(s),(e=e.subarray(i)).length)return this.push(e,t)}else{var r=0,a=0,o=void 0,l=void 0;this.p.length?e.length?((l=new Tw(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var c=l.length,d=this.c,h=d&&this.d,u=function(){var e,t=AM(l,a);if(67324752==t){r=1,o=a,p.d=null,p.c=0;var i=_M(l,a+6),s=_M(l,a+8),h=2048&i,u=8&i,m=_M(l,a+26),f=_M(l,a+28);if(c>a+30+m+f){var g=[];p.k.unshift(g),r=2;var y,b=AM(l,a+18),v=AM(l,a+22),x=vS(l.subarray(a+30,a+=30+m),!h);4294967295==b?(e=u?[-2]:SS(l,a),b=e[0],v=e[1]):u&&(b=-1),a+=f,p.c=b;var w={name:x,compression:s,start:function(){if(!w.ondata)throw"no callback";if(b){var e=n.o[s];if(!e)throw"unknown compression type "+s;(y=b<0?new e(x):new e(x,b,v)).ondata=function(e,t,n){w.ondata(e,t,n)};for(var t=0,i=g;t<i.length;t++){var r=i[t];y.push(r,!1)}n.k[0]==g&&n.c?n.d=y:y.push(lM,!0)}else w.ondata(null,lM,!0)},terminate:function(){y&&y.terminate&&y.terminate()}};b>=0&&(w.size=b,w.originalSize=v),p.onfile(w)}return"break"}if(d){if(134695760==t)return o=a+=12+(-2==d&&8),r=3,p.c=0,"break";if(33639248==t)return o=a-=4,r=3,p.c=0,"break"}},p=this;a<c-4;++a){if("break"===u())break}if(this.p=lM,d<0){var m=r?l.subarray(0,o-12-(-2==d&&8)-(134695760==AM(l,o-16)&&4)):l.subarray(0,a);h?h.push(m,!!r):this.k[+(2==r)].push(m)}if(2&r)return this.push(l.subarray(a),t);this.p=l.subarray(a)}if(t){if(this.c)throw"invalid zip file";this.p=null}},e.prototype.register=function(e){this.o[e.compression]=e},e}();var PS=Object.freeze({__proto__:null,Deflate:DM,AsyncDeflate:HM,deflate:BM,deflateSync:kM,Inflate:FM,AsyncInflate:UM,inflate:OM,inflateSync:YM,Gzip:KM,AsyncGzip:jM,gzip:JM,gzipSync:QM,Gunzip:qM,AsyncGunzip:$M,gunzip:eS,gunzipSync:tS,Zlib:nS,AsyncZlib:iS,zlib:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return LM(e,t,[vM,MM,function(){return[sS]}],(function(e){return TM(sS(e.data[0],e.data[1]))}),4,n)},zlibSync:sS,Unzlib:rS,AsyncUnzlib:aS,unzlib:oS,unzlibSync:lS,compress:JM,AsyncCompress:jM,compressSync:QM,Compress:KM,Decompress:cS,AsyncDecompress:dS,decompress:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?eS(e,t,n):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?OM(e,t,n):oS(e,t,n)},decompressSync:function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?tS(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?YM(e,t):lS(e,t)},DecodeUTF8:gS,EncodeUTF8:yS,strToU8:bS,strFromU8:vS,ZipPassThrough:GS,ZipDeflate:RS,AsyncZipDeflate:_S,Zip:AS,zip:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";var i={};hS(e,"",i,t);var s=Object.keys(i),r=s.length,a=0,o=0,l=r,c=new Array(r),d=[],h=function(){for(var e=0;e<d.length;++e)d[e]()},u=function(){var e=new Tw(o+22),t=a,i=o-a;o=0;for(var s=0;s<l;++s){var r=c[s];try{var d=r.c.length;CS(e,o,r,r.f,r.u,d);var h=30+r.f.length+TS(r.extra),u=o+h;e.set(r.c,u),CS(e,a,r,r.f,r.u,d,o,r.m),a+=16+h+(r.m?r.m.length:0),o=u+d}catch(e){return n(e,null)}}LS(e,a,c.length,i,t),n(null,e)};r||u();for(var p=function(e){var t=s[e],l=i[t],p=l[0],m=l[1],f=hM(),g=p.length;f.p(p);var y=bS(t),b=y.length,v=m.comment,x=v&&bS(v),w=x&&x.length,M=TS(m.extra),S=0==m.level?0:8,T=function(i,s){if(i)h(),n(i,null);else{var l=s.length;c[e]=mM(m,{size:g,crc:f.d(),c:s,f:y,m:x,u:b!=t.length||x&&v.length!=w,compression:S}),a+=30+b+M+l,o+=76+2*(b+M)+(w||0)+l,--r||u()}};if(b>65535&&T("filename too long",null),S)if(g<16e4)try{T(null,kM(p,m))}catch(e){T(e,null)}else d.push(BM(p,m,T));else T(null,p)},m=0;m<l;++m)p(m);return h},zipSync:function(e,t){t||(t={});var n={},i=[];hS(e,"",n,t);var s=0,r=0;for(var a in n){var o=n[a],l=o[0],c=o[1],d=0==c.level?0:8,h=(S=bS(a)).length,u=c.comment,p=u&&bS(u),m=p&&p.length,f=TS(c.extra);if(h>65535)throw"filename too long";var g=d?kM(l,c):l,y=g.length,b=hM();b.p(l),i.push(mM(c,{size:l.length,crc:b.d(),c:g,f:S,m:p,u:h!=a.length||p&&u.length!=m,o:s,compression:d})),s+=30+h+f+y,r+=76+2*(h+f)+(m||0)+y}for(var v=new Tw(r+22),x=s,w=r-s,M=0;M<i.length;++M){var S=i[M];CS(v,S.o,S,S.f,S.u,S.c.length);var T=30+S.f.length+TS(S.extra);v.set(S.c,S.o+T),CS(v,s,S,S.f,S.u,S.c.length,S.o,S.m),s+=16+T+(S.m?S.m.length:0)}return LS(v,s,i.length,w,x),v},UnzipPassThrough:IS,UnzipInflate:XS,AsyncUnzipInflate:ES,Unzip:zS,unzip:function(e,t){if("function"!=typeof t)throw"no callback";for(var n=[],i=function(){for(var e=0;e<n.length;++e)n[e]()},s={},r=e.length-22;101010256!=AM(e,r);--r)if(!r||e.length-r>65558)return void t("invalid zip file",null);var a=_M(e,r+8);a||t(null,{});var o=a,l=AM(e,r+16),c=4294967295==l;if(c){if(r=AM(e,r-12),101075792!=AM(e,r))return void t("invalid zip file",null);o=a=AM(e,r+32),l=AM(e,r+48)}for(var d=function(r){var o=MS(e,l,c),d=o[0],h=o[1],u=o[2],p=o[3],m=o[4],f=o[5],g=wS(e,f);l=m;var y=function(e,n){e?(i(),t(e,null)):(s[p]=n,--a||t(null,s))};if(d)if(8==d){var b=e.subarray(g,g+h);if(h<32e4)try{y(null,YM(b,new Tw(u)))}catch(e){y(e,null)}else n.push(OM(b,{size:u},y))}else y("unknown compression type "+d,null);else y(null,Qw(e,g,g+h))},h=0;h<o;++h)d();return i},unzipSync:function(e){for(var t={},n=e.length-22;101010256!=AM(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var i=_M(e,n+8);if(!i)return{};var s=AM(e,n+16),r=4294967295==s;if(r){if(n=AM(e,n-12),101075792!=AM(e,n))throw"invalid zip file";i=AM(e,n+32),s=AM(e,n+48)}for(var a=0;a<i;++a){var o=MS(e,s,r),l=o[0],c=o[1],d=o[2],h=o[3],u=o[4],p=o[5],m=wS(e,p);if(s=u,l){if(8!=l)throw"unknown compression type "+l;t[h]=YM(e.subarray(m,m+c),new Tw(d))}else t[h]=Qw(e,m,m+c)}return t}});function WS(e,t,n){const i=n.length-e-1;if(t>=n[i])return i-1;if(t<=n[e])return e;let s=e,r=i,a=Math.floor((s+r)/2);for(;t<n[a]||t>=n[a+1];)t<n[a]?r=a:s=a,a=Math.floor((s+r)/2);return a}function ZS(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let i=1;for(let e=2;e<=t;++e)i*=e;for(let n=2;n<=e-t;++n)i*=n;return n/i}function NS(e,t,n,i,s){return function(e){const t=e.length,n=[],i=[];for(let s=0;s<t;++s){const t=e[s];n[s]=new ri(t.x,t.y,t.z),i[s]=t.w}const s=[];for(let e=0;e<t;++e){const t=n[e].clone();for(let n=1;n<=e;++n)t.sub(s[e-n].clone().multiplyScalar(ZS(e,n)*i[n]));s[e]=t.divideScalar(i[0])}return s}(function(e,t,n,i,s){const r=s<e?s:e,a=[],o=WS(e,i,t),l=function(e,t,n,i,s){const r=[];for(let e=0;e<=n;++e)r[e]=0;const a=[];for(let e=0;e<=i;++e)a[e]=r.slice(0);const o=[];for(let e=0;e<=n;++e)o[e]=r.slice(0);o[0][0]=1;const l=r.slice(0),c=r.slice(0);for(let i=1;i<=n;++i){l[i]=t-s[e+1-i],c[i]=s[e+i]-t;let n=0;for(let e=0;e<i;++e){const t=c[e+1],s=l[i-e];o[i][e]=t+s;const r=o[e][i-1]/o[i][e];o[e][i]=n+t*r,n=s*r}o[i][i]=n}for(let e=0;e<=n;++e)a[0][e]=o[e][n];for(let e=0;e<=n;++e){let t=0,s=1;const l=[];for(let e=0;e<=n;++e)l[e]=r.slice(0);l[0][0]=1;for(let r=1;r<=i;++r){let i=0;const c=e-r,d=n-r;e>=r&&(l[s][0]=l[t][0]/o[d+1][c],i=l[s][0]*o[c][d]);const h=e-1<=d?r-1:n-e;for(let e=c>=-1?1:-c;e<=h;++e)l[s][e]=(l[t][e]-l[t][e-1])/o[d+1][c+e],i+=l[s][e]*o[c+e][d];e<=d&&(l[s][r]=-l[t][r-1]/o[d+1][e],i+=l[s][r]*o[e][d]),a[r][e]=i;const u=t;t=s,s=u}}let d=n;for(let e=1;e<=i;++e){for(let t=0;t<=n;++t)a[e][t]*=d;d*=n-e}return a}(o,i,e,r,t),c=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),i=t.w;t.x*=i,t.y*=i,t.z*=i,c[e]=t}for(let t=0;t<=r;++t){const n=c[o-e].clone().multiplyScalar(l[t][0]);for(let i=1;i<=e;++i)n.add(c[o-e+i].clone().multiplyScalar(l[t][i]));a[t]=n}for(let e=r+1;e<=s+1;++e)a[e]=new Qn(0,0,0);return a}(e,t,n,i,s))}class VS extends yc{constructor(e,t,n,i,s){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=s||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new Qn(t.x,t.y,t.z,t.w)}}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ri,n=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=function(e,t,n,i){const s=WS(e,i,t),r=function(e,t,n,i){const s=[],r=[],a=[];s[0]=1;for(let o=1;o<=n;++o){r[o]=t-i[e+1-o],a[o]=i[e+o]-t;let n=0;for(let e=0;e<o;++e){const t=a[e+1],i=r[o-e],l=s[e]/(t+i);s[e]=n+t*l,n=i*l}s[o]=n}return s}(s,i,e,t),a=new Qn(0,0,0,0);for(let t=0;t<=e;++t){const i=n[s-e+t],o=r[t],l=i.w*o;a.x+=i.x*l,a.y+=i.y*l,a.z+=i.z*l,a.w+=i.w*o}return a}(this.degree,this.knots,this.controlPoints,n);return 1!==i.w&&i.divideScalar(i.w),t.set(i.x,i.y,i.z)}getTangent(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ri,n=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=NS(this.degree,this.knots,this.controlPoints,n,1);return t.copy(i[1]).normalize(),t}}let DS,HS,BS;class kS extends fh{constructor(e){super(e)}load(e,t,n,i){const s=this,r=""===s.path?Fh.extractUrlBase(e):s.path,a=new yh(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,(function(n){try{t(s.parse(n,r))}catch(t){i?i(t):console.error(t),s.manager.itemError(e)}}),n,i)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===aT(e,0,t.length)}(e))DS=(new KS).parse(e);else{const t=aT(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function i(t){const i=e[t-1];return e=e.slice(n+t),n++,i}for(let e=0;e<t.length;++e){if(i(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(QS(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+QS(t));DS=(new YS).parse(t)}const n=new Sh(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new FS(n,this.manager).parse(DS)}}class FS{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){HS=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),s=(new US).parse(i);return this.parseScene(i,s,n),BS}parseConnections(){const e=new Map;if("Connections"in DS){DS.Connections.connections.forEach((function(t){const n=t[0],i=t[1],s=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const r={ID:i,relationship:s};e.get(n).parents.push(r),e.has(i)||e.set(i,{parents:[],children:[]});const a={ID:n,relationship:s};e.get(i).children.push(a)}))}return e}parseImages(){const e={},t={};if("Video"in DS.Objects){const n=DS.Objects.Video;for(const i in n){const s=n[i];if(e[parseInt(i)]=s.RelativeFilename||s.Filename,"Content"in s){const e=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,r="string"==typeof s.Content&&""!==s.Content;if(e||r){const e=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=e}}}}for(const n in e){const i=e[n];void 0!==t[i]?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+i+'" is not supported.')}if("string"==typeof t)return"data:"+s+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in DS.Objects){const n=DS.Objects.Texture;for(const i in n){const s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,r=void 0!==i?i.value:0,a=void 0!==s?s.value:0;if(n.wrapS=0===r?1e3:1001,n.wrapT=0===a?1e3:1001,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,s=HS.get(e.id).children;let r;void 0!==s&&s.length>0&&void 0!==t[s[0].ID]&&(n=t[s[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const a=e.FileName.slice(-3).toLowerCase();if("tga"===a){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),r=new Jn):(t.setPath(this.textureLoader.path),r=t.load(n))}else"psd"===a?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),r=new Jn):r=this.textureLoader.load(n);return this.textureLoader.setPath(i),r}parseMaterials(e){const t=new Map;if("Material"in DS.Objects){const n=DS.Objects.Material;for(const i in n){const s=this.parseMaterial(n[i],e);null!==s&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let s=e.ShadingModel;if("object"==typeof s&&(s=s.value),!HS.has(n))return null;const r=this.parseParameters(e,t,n);let a;switch(s.toLowerCase()){case"phong":a=new Ud;break;case"lambert":a=new Kd;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new Ud}return a.setValues(r),a.name=i,a}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new Fn).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(i.color=(new Fn).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new Fn).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(i.emissive=(new Fn).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new Fn).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new Fn).fromArray(e.SpecularColor.value));const s=this;return HS.get(n).children.forEach((function(e){const n=e.relationship;switch(n){case"Bump":i.bumpMap=s.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,e.ID),void 0!==i.map&&(i.map.encoding=3001);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=303,i.envMap.encoding=3001);break;case"SpecularColor":i.specularMap=s.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,e.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),i}getTexture(e,t){return"LayeredTexture"in DS.Objects&&t in DS.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=HS.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in DS.Objects){const n=DS.Objects.Deformer;for(const i in n){const s=n[i],r=HS.get(parseInt(i));if("Skin"===s.attrType){const t=this.parseSkeleton(r,n);t.ID=i,r.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=r.parents[0].ID,e[i]=t}else if("BlendShape"===s.attrType){const e={id:i};e.rawTargets=this.parseMorphTargets(r,n),e.id=i,r.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach((function(e){const i=t[e.ID];if("Cluster"!==i.attrType)return;const s={ID:e.ID,indices:[],weights:[],transformLink:(new Wi).fromArray(i.TransformLink.a)};"Indexes"in i&&(s.indices=i.Indexes.a,s.weights=i.Weights.a),n.push(s)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],r=t[s.ID],a={name:r.attrName,initialWeight:r.DeformPercent,id:r.id,fullWeights:r.FullWeights.a};if("BlendShapeChannel"!==r.attrType)return;a.geoID=HS.get(parseInt(s.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(a)}return n}parseScene(e,t,n){BS=new qo;const i=this.parseModels(e.skeletons,t,n),s=DS.Objects.Model,r=this;i.forEach((function(e){const t=s[e.ID];r.setLookAtProperties(e,t);HS.get(e.ID).parents.forEach((function(t){const n=i.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&BS.add(e)})),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),BS.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=iT(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const a=(new OS).parse();1===BS.children.length&&BS.children[0].isGroup&&(BS.children[0].animations=a,BS=BS.children[0]),BS.animations=a}parseModels(e,t,n){const i=new Map,s=DS.Objects.Model;for(const r in s){const a=parseInt(r),o=s[r],l=HS.get(a);let c=this.buildSkeleton(l,e,a,o.attrName);if(!c){switch(o.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,n);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new Nl;break;case"Null":default:c=new qo}c.name=o.attrName?Lu.sanitizeNodeName(o.attrName):"",c.ID=a}this.getTransformData(c,o),i.set(a,c)}return i}buildSkeleton(e,t,n,i){let s=null;return e.parents.forEach((function(e){for(const r in t){const a=t[r];a.rawBones.forEach((function(t,r){if(t.ID===e.ID){const e=s;s=new Nl,s.matrixWorld.copy(t.transformLink),s.name=i?Lu.sanitizeNodeName(i):"",s.ID=n,a.bones[r]=s,null!==e&&s.add(e)}}))}})),s}createCamera(e){let t,n;if(e.children.forEach((function(e){const t=DS.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new os;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let i=1;void 0!==n.NearPlane&&(i=n.NearPlane.value/1e3);let s=1e3;void 0!==n.FarPlane&&(s=n.FarPlane.value/1e3);let r=window.innerWidth,a=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(r=n.AspectWidth.value,a=n.AspectHeight.value);const o=r/a;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new mr(l,o,i,s),null!==c&&t.setFocalLength(c);break;case 1:t=new Zr(-r/2,r/2,a/2,-a/2,i,s);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new os}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){const t=DS.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new os;else{let e;e=void 0===n.LightType?0:n.LightType.value;let i=16777215;void 0!==n.Color&&(i=(new Fn).fromArray(n.Color.value));let s=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(s=0);let r=0;void 0!==n.FarAttenuationEnd&&(r=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const a=1;switch(e){case 0:t=new Wh(i,s,r,a);break;case 1:t=new Nh(i,s);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=Gn.degToRad(n.InnerAngle.value));let o=0;void 0!==n.OuterAngle&&(o=Gn.degToRad(n.OuterAngle.value),o=Math.max(o,1)),t=new Ih(i,s,r,e,o,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Wh(i,s)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,s=null,r=null;const a=[];return e.children.forEach((function(e){t.has(e.ID)&&(s=t.get(e.ID)),n.has(e.ID)&&a.push(n.get(e.ID))})),a.length>1?r=a:a.length>0?r=a[0]:(r=new Ud({color:13421772}),a.push(r)),"color"in s.attributes&&a.forEach((function(e){e.vertexColors=!0})),s.FBX_Deformer?(i=new Zl(s,r),i.normalizeSkinWeights()):i=new ar(s,r),i}createCurve(e,t){const n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),i=new jl({color:3342591,linewidth:1});return new tc(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?sT(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){if("LookAtProperty"in t){HS.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const n=DS.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),BS.add(e.target)):e.lookAt((new ri).fromArray(t))}}}))}}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const r=e[s];HS.get(parseInt(r.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;HS.get(t).parents.forEach((function(e){if(n.has(e.ID)){n.get(e.ID).bind(new Bl(r.bones),i[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in DS.Objects){const t=DS.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new Wi).fromArray(t.Matrix.a)})):e[i.Node]=(new Wi).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in DS&&"AmbientColor"in DS.GlobalSettings){const e=DS.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){const e=new Fn(t,n,i);BS.add(new Vh(e,1))}}}}class US{parse(e){const t=new Map;if("Geometry"in DS.Objects){const n=DS.Objects.Geometry;for(const i in n){const s=HS.get(parseInt(i)),r=this.parseGeometry(s,n[i],e);t.set(parseInt(i),r)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,s=[],r=e.parents.map((function(e){return DS.Objects.Model[e.ID]}));if(0===r.length)return;const a=e.children.reduce((function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&s.push(n.morphTargets[e.ID])}));const o=r[0],l={};"RotationOrder"in o&&(l.eulerOrder=sT(o.RotationOrder.value)),"InheritType"in o&&(l.inheritType=parseInt(o.InheritType.value)),"GeometricTranslation"in o&&(l.translation=o.GeometricTranslation.value),"GeometricRotation"in o&&(l.rotation=o.GeometricRotation.value),"GeometricScaling"in o&&(l.scale=o.GeometricScaling.value);const c=iT(l);return this.genGeometry(t,a,s,c)}genGeometry(e,t,n,i){const s=new Bs;e.attrName&&(s.name=e.attrName);const r=this.parseGeoNode(e,t),a=this.genBuffers(r),o=new Es(a.vertex,3);if(o.applyMatrix4(i),s.setAttribute("position",o),a.colors.length>0&&s.setAttribute("color",new Es(a.colors,3)),t&&(s.setAttribute("skinIndex",new _s(a.weightsIndices,4)),s.setAttribute("skinWeight",new Es(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){const e=(new _n).getNormalMatrix(i),t=new Es(a.normal,3);t.applyNormalMatrix(e),s.setAttribute("normal",t)}if(a.uvs.forEach((function(e,t){let n="uv"+(t+1).toString();0===t&&(n="uv"),s.setAttribute(n,new Es(a.uvs[t],2))})),r.material&&"AllSame"!==r.material.mappingType){let e=a.materialIndex[0],t=0;if(a.materialIndex.forEach((function(n,i){n!==e&&(s.addGroup(t,i-t,e),e=n,t=i)})),s.groups.length>0){const t=s.groups[s.groups.length-1],n=t.start+t.count;n!==a.materialIndex.length&&s.addGroup(n,a.materialIndex.length-n,e)}0===s.groups.length&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,s){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[s]})}))}))),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,s=!1,r=[],a=[],o=[],l=[],c=[],d=[];const h=this;return e.vertexIndices.forEach((function(u,p){let m,f=!1;u<0&&(u^=-1,f=!0);let g=[],y=[];if(r.push(3*u,3*u+1,3*u+2),e.color){const t=eT(p,n,u,e.color);o.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[u]&&e.weightTable[u].forEach((function(e){y.push(e.weight),g.push(e.id)})),y.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const e=[0,0,0,0],t=[0,0,0,0];y.forEach((function(n,i){let s=n,r=g[i];t.forEach((function(t,n,i){if(s>t){i[n]=s,s=t;const a=e[n];e[n]=r,r=a}}))})),g=e,y=t}for(;y.length<4;)y.push(0),g.push(0);for(let e=0;e<4;++e)c.push(y[e]),d.push(g[e])}if(e.normal){const t=eT(p,n,u,e.normal);a.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(m=eT(p,n,u,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){const i=eT(p,n,u,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,f&&(h.genFace(t,e,r,m,a,o,l,c,d,i),n++,i=0,r=[],a=[],o=[],l=[],c=[],d=[])})),t}genFace(e,t,n,i,s,r,a,o,l,c){for(let d=2;d<c;d++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(d-1)]]),e.vertex.push(t.vertexPositions[n[3*(d-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(d-1)+2]]),e.vertex.push(t.vertexPositions[n[3*d]]),e.vertex.push(t.vertexPositions[n[3*d+1]]),e.vertex.push(t.vertexPositions[n[3*d+2]]),t.skeleton&&(e.vertexWeights.push(o[0]),e.vertexWeights.push(o[1]),e.vertexWeights.push(o[2]),e.vertexWeights.push(o[3]),e.vertexWeights.push(o[4*(d-1)]),e.vertexWeights.push(o[4*(d-1)+1]),e.vertexWeights.push(o[4*(d-1)+2]),e.vertexWeights.push(o[4*(d-1)+3]),e.vertexWeights.push(o[4*d]),e.vertexWeights.push(o[4*d+1]),e.vertexWeights.push(o[4*d+2]),e.vertexWeights.push(o[4*d+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(d-1)]),e.weightsIndices.push(l[4*(d-1)+1]),e.weightsIndices.push(l[4*(d-1)+2]),e.weightsIndices.push(l[4*(d-1)+3]),e.weightsIndices.push(l[4*d]),e.weightsIndices.push(l[4*d+1]),e.weightsIndices.push(l[4*d+2]),e.weightsIndices.push(l[4*d+3])),t.color&&(e.colors.push(r[0]),e.colors.push(r[1]),e.colors.push(r[2]),e.colors.push(r[3*(d-1)]),e.colors.push(r[3*(d-1)+1]),e.colors.push(r[3*(d-1)+2]),e.colors.push(r[3*d]),e.colors.push(r[3*d+1]),e.colors.push(r[3*d+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(s[0]),e.normal.push(s[1]),e.normal.push(s[2]),e.normal.push(s[3*(d-1)]),e.normal.push(s[3*(d-1)+1]),e.normal.push(s[3*(d-1)+2]),e.normal.push(s[3*d]),e.normal.push(s[3*d+1]),e.normal.push(s[3*d+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(a[n][0]),e.uvs[n].push(a[n][1]),e.uvs[n].push(a[n][2*(d-1)]),e.uvs[n].push(a[n][2*(d-1)+1]),e.uvs[n].push(a[n][2*d]),e.uvs[n].push(a[n][2*d+1])}))}addMorphTargets(e,t,n,i){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const r=DS.Objects.Geometry[n.geoID];void 0!==r&&s.genMorphGeometry(e,t,r,i,n.name)}))}))}genMorphGeometry(e,t,n,i,s){const r=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],a=void 0!==n.Vertices?n.Vertices.a:[],o=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,c=new Float32Array(l);for(let e=0;e<o.length;e++){const t=3*o[e];c[t]=a[3*e],c[t+1]=a[3*e+1],c[t+2]=a[3*e+2]}const d={vertexIndices:r,vertexPositions:c},h=this.genBuffers(d),u=new Es(h.vertex,3);u.name=s||n.attrName,u.applyMatrix4(i),e.morphAttributes.position.push(u)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let s=[];return"IndexToDirect"===n&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:s,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let s=[];return"IndexToDirect"===n&&(s=e.UVIndex.a),{dataSize:2,buffer:i,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let s=[];return"IndexToDirect"===n&&(s=e.ColorIndex.a),{dataSize:4,buffer:i,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,s=[];for(let e=0;e<i.length;++e)s.push(e);return{dataSize:1,buffer:i,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(void 0===VS)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new Bs;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Bs;const n=t-1,i=e.KnotVector.a,s=[],r=e.Points.a;for(let e=0,t=r.length;e<t;e+=4)s.push((new Qn).fromArray(r,e));let a,o;if("Closed"===e.Form)s.push(s[0]);else if("Periodic"===e.Form){a=n,o=i.length-1-a;for(let e=0;e<n;++e)s.push(s[e])}const l=new VS(n,i,s,a,o).getPoints(12*s.length);return(new Bs).setFromPoints(l)}}class OS{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const i=t[n],s=this.addClip(i);e.push(s)}return e}parseClips(){if(void 0===DS.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=DS.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(null!==i.attrName.match(/S|R|T|DeformPercent/)){const e={id:i.id,attr:i.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=DS.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(qS),values:t[n].KeyValueFloat.a},s=HS.get(i.id);if(void 0!==s){const t=s.parents[0].ID,n=s.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=i:n.match(/Y/)?e.get(t).curves.y=i:n.match(/Z/)?e.get(t).curves.z=i:n.match(/d|DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=i)}}}parseAnimationLayers(e){const t=DS.Objects.AnimationLayer,n=new Map;for(const i in t){const t=[],s=HS.get(parseInt(i));if(void 0!==s){s.children.forEach((function(n,i){if(e.has(n.ID)){const s=e.get(n.ID);if(void 0!==s.curves.x||void 0!==s.curves.y||void 0!==s.curves.z){if(void 0===t[i]){const e=HS.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const s=DS.Objects.Model[e.toString()];if(void 0===s)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const r={modelName:s.attrName?Lu.sanitizeNodeName(s.attrName):"",ID:s.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};BS.traverse((function(e){e.ID===s.id&&(r.transform=e.matrix,e.userData.transformData&&(r.eulerOrder=e.userData.transformData.eulerOrder))})),r.transform||(r.transform=new Wi),"PreRotation"in s&&(r.preRotation=s.PreRotation.value),"PostRotation"in s&&(r.postRotation=s.PostRotation.value),t[i]=r}}t[i]&&(t[i][s.attr]=s)}else if(void 0!==s.curves.morph){if(void 0===t[i]){const e=HS.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,s=HS.get(e).parents[0].ID,r=HS.get(s).parents[0].ID,a=HS.get(r).parents[0].ID,o=DS.Objects.Model[a],l={modelName:o.attrName?Lu.sanitizeNodeName(o.attrName):"",morphName:DS.Objects.Deformer[e].attrName};t[i]=l}t[i][s.attr]=s}}})),n.set(parseInt(i),t)}}return n}parseAnimStacks(e){const t=DS.Objects.AnimationStack,n={};for(const i in t){const s=HS.get(parseInt(i)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const r=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:r}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new dh(e.name,-1,t)}generateTracks(e){const t=[];let n=new ri,i=new si,s=new ri;if(e.transform&&e.transform.decompose(n,i,s),n=n.toArray(),i=(new Oi).setFromQuaternion(i,e.eulerOrder).toArray(),s=s.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==i&&t.push(i)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,i){const s=this.getTimesForAllAxes(t),r=this.getKeyframeTrackValues(s,t,n);return new ch(e+"."+i,s,r)}generateRotationTrack(e,t,n,i,s,r){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Gn.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Gn.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Gn.degToRad));const a=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(a,t,n);void 0!==i&&((i=i.map(Gn.degToRad)).push(r),i=(new Oi).fromArray(i),i=(new si).setFromEuler(i)),void 0!==s&&((s=s.map(Gn.degToRad)).push(r),s=(new Oi).fromArray(s),s=(new si).setFromEuler(s).invert());const l=new si,c=new Oi,d=[];for(let e=0;e<o.length;e+=3)c.set(o[e],o[e+1],o[e+2],r),l.setFromEuler(c),void 0!==i&&l.premultiply(i),void 0!==s&&l.multiply(s),l.toArray(d,e/3*4);return new oh(e+".quaternion",a,d)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),i=BS.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new rh(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let i=1;i<t.length;i++){const s=t[i];s!==n&&(t[e]=s,n=s,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const i=n,s=[];let r=-1,a=-1,o=-1;return e.forEach((function(e){if(t.x&&(r=t.x.times.indexOf(e)),t.y&&(a=t.y.times.indexOf(e)),t.z&&(o=t.z.times.indexOf(e)),-1!==r){const e=t.x.values[r];s.push(e),i[0]=e}else s.push(i[0]);if(-1!==a){const e=t.y.values[a];s.push(e),i[1]=e}else s.push(i[1]);if(-1!==o){const e=t.z.values[o];s.push(e),i[2]=e}else s.push(i[2])})),s}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],i=e.values[t]-n,s=Math.abs(i);if(s>=180){const r=s/180,a=i/r;let o=n+a;const l=e.times[t-1],c=(e.times[t]-l)/r;let d=l+c;const h=[],u=[];for(;d<e.times[t];)h.push(d),d+=c,u.push(o),o+=a;e.times=oT(e.times,t,h),e.values=oT(e.values,t,u)}}}}class YS{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new JS,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,i){const s=e.match(/^[\s\t]*;/),r=e.match(/^[\s\t]*$/);if(s||r)return;const a=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),o=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(e,a):o?t.parseNodeProperty(e,o,n[++i]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),s={name:n},r=this.parseNodeAttr(i),a=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,s):n in a?("PoseNode"===n?a.PoseNode.push(s):void 0!==a[n].id&&(a[n]={},a[n][a[n].id]=a[n]),""!==r.id&&(a[n][r.id]=s)):"number"==typeof r.id?(a[n]={},a[n][r.id]=s):"Properties70"!==n&&(a[n]="PoseNode"===n?[s]:s),"number"==typeof r.id&&(s.id=r.id),""!==r.name&&(s.attrName=r.name),""!==r.type&&(s.attrType=r.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===s&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const r=this.getCurrentNode();if("Properties70"!==r.name){if("C"===i){const e=s.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let a=s.split(",").slice(3);a=a.map((function(e){return e.trim().replace(/^"/,"")})),i="connections",s=[t,n],function(e,t){for(let n=0,i=e.length,s=t.length;n<s;n++,i++)e[i]=t[n]}(s,a),void 0===r[i]&&(r[i]=[])}"Node"===i&&(r.id=s),i in r&&Array.isArray(r[i])?r[i].push(s):"a"!==i?r[i]=s:r.a=s,this.setCurrentProp(r,i),"a"===i&&","!==s.slice(-1)&&(r.a=rT(s))}else this.parseNodeSpecialProperty(e,i,s)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=rT(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),s=i[0],r=i[1],a=i[2],o=i[3];let l=i[4];switch(r){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=rT(l)}this.getPrevNode()[s]={type:r,type2:a,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),s)}}class KS{parse(e){const t=new jS(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new JS;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&i.add(e.name,e)}return i}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const r=e.getUint8(),a=e.getString(r);if(0===i)return null;const o=[];for(let t=0;t<s;t++)o.push(this.parseProperty(e));const l=o.length>0?o[0]:"",c=o.length>1?o[1]:"",d=o.length>2?o[2]:"";for(n.singleProperty=1===s&&e.getOffset()===i;i>e.getOffset();){const i=this.parseNode(e,t);null!==i&&this.parseSubNode(a,n,i)}return n.propertyList=o,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==d&&(n.attrType=d),""!==a&&(n.name=a),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach((function(e){t[e]=n[e]}))}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],i=n.propertyList[1];const s=n.propertyList[2],r=n.propertyList[3];let a;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),a="Color"===i||"ColorRGB"===i||"Vector"===i||"Vector3D"===i||0===i.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:i,type2:s,flag:r,value:a}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),r=e.getUint32();if(0===s)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}void 0===PS&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=lS(new Uint8Array(e.getArrayBuffer(r))),o=new jS(a.buffer);switch(t){case"b":case"c":return o.getBooleanArray(i);case"d":return o.getFloat64Array(i);case"f":return o.getFloat32Array(i);case"i":return o.getInt32Array(i);case"l":return o.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class jS{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let n=0;n<e;n++)t[n]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),Fh.decodeText(new Uint8Array(t))}}class JS{add(e,t){this[e]=t}}function QS(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function qS(e){return e/46186158e3}const $S=[];function eT(e,t,n,i){let s;switch(i.mappingType){case"ByPolygonVertex":s=e;break;case"ByPolygon":s=t;break;case"ByVertice":s=n;break;case"AllSame":s=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(s=i.indices[s]);const r=s*i.dataSize,a=r+i.dataSize;return function(e,t,n,i){for(let s=n,r=0;s<i;s++,r++)e[r]=t[s];return e}($S,i.buffer,r,a)}const tT=new Oi,nT=new ri;function iT(e){const t=new Wi,n=new Wi,i=new Wi,s=new Wi,r=new Wi,a=new Wi,o=new Wi,l=new Wi,c=new Wi,d=new Wi,h=new Wi,u=new Wi,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(nT.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(Gn.degToRad);t.push(e.eulerOrder),n.makeRotationFromEuler(tT.fromArray(t))}if(e.rotation){const t=e.rotation.map(Gn.degToRad);t.push(e.eulerOrder),i.makeRotationFromEuler(tT.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(Gn.degToRad);t.push(e.eulerOrder),s.makeRotationFromEuler(tT.fromArray(t)),s.invert()}e.scale&&r.scale(nT.fromArray(e.scale)),e.scalingOffset&&o.setPosition(nT.fromArray(e.scalingOffset)),e.scalingPivot&&a.setPosition(nT.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(nT.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(nT.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(h.copy(e.parentMatrix),d.copy(e.parentMatrixWorld));const m=n.clone().multiply(i).multiply(s),f=new Wi;f.extractRotation(d);const g=new Wi;g.copyPosition(d);const y=g.clone().invert().multiply(d),b=f.clone().invert().multiply(y),v=r,x=new Wi;if(0===p)x.copy(f).multiply(m).multiply(b).multiply(v);else if(1===p)x.copy(f).multiply(b).multiply(m).multiply(v);else{const e=(new Wi).scale((new ri).setFromMatrixScale(h)).clone().invert(),t=b.clone().multiply(e);x.copy(f).multiply(m).multiply(t).multiply(v)}const w=c.clone().invert(),M=a.clone().invert();let S=t.clone().multiply(l).multiply(c).multiply(n).multiply(i).multiply(s).multiply(w).multiply(o).multiply(a).multiply(r).multiply(M);const T=(new Wi).copyPosition(S),C=d.clone().multiply(T);return u.copyPosition(C),S=u.clone().multiply(x),S.premultiply(d.invert()),S}function sT(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function rT(e){return e.split(",").map((function(e){return parseFloat(e)}))}function aT(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),Fh.decodeText(new Uint8Array(e,t,n))}function oT(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}class lT extends Mh{constructor(e){super(e)}parse(e){const t=0,n=1,i=2,s=3,r=9,a=10,o=11,l=48,c=4,d=0,h=1,u=2,p=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let m=0;const f=new Uint8Array(e),g={id_length:f[m++],colormap_type:f[m++],image_type:f[m++],colormap_index:f[m++]|f[m++]<<8,colormap_length:f[m++]|f[m++]<<8,colormap_size:f[m++],origin:[f[m++]|f[m++]<<8,f[m++]|f[m++]<<8],width:f[m++]|f[m++]<<8,height:f[m++]|f[m++]<<8,pixel_size:f[m++],flags:f[m++]};!function(e){switch(e.image_type){case n:case r:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case i:case s:case a:case o:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(g),g.id_length+m>e.length&&console.error("THREE.TGALoader: No data."),m+=g.id_length;let y=!1,b=!1,v=!1;switch(g.image_type){case r:y=!0,b=!0;break;case n:b=!0;break;case a:y=!0;break;case i:break;case o:y=!0,v=!0;break;case s:v=!0}const x=new Uint8Array(g.width*g.height*4),w=function(e,t,n,i,s){let r,a;const o=n.pixel_size>>3,l=n.width*n.height*o;if(t&&(a=s.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;r=new Uint8Array(l);let a=0;const c=new Uint8Array(o);for(;a<l;)if(e=s[i++],t=1+(127&e),128&e){for(n=0;n<o;++n)c[n]=s[i++];for(n=0;n<t;++n)r.set(c,a+n*o);a+=o*t}else{for(t*=o,n=0;n<t;++n)r[a+n]=s[i++];a+=t}}else r=s.subarray(i,i+=t?n.width*n.height:l);return{pixel_data:r,palettes:a}}(y,b,g,m,f);return function(e,t,n,i,s){let r,a,o,m,f,y;switch((g.flags&l)>>c){default:case u:r=0,o=1,f=t,a=0,m=1,y=n;break;case d:r=0,o=1,f=t,a=n-1,m=-1,y=-1;break;case p:r=t-1,o=-1,f=-1,a=0,m=1,y=n;break;case h:r=t-1,o=-1,f=-1,a=n-1,m=-1,y=-1}if(v)switch(g.pixel_size){case 8:!function(e,t,n,i,s,r,a,o){let l,c,d,h=0;const u=g.width;for(d=t;d!==i;d+=n)for(c=s;c!==a;c+=r,h++)l=o[h],e[4*(c+u*d)+0]=l,e[4*(c+u*d)+1]=l,e[4*(c+u*d)+2]=l,e[4*(c+u*d)+3]=255}(e,a,m,y,r,o,f,i);break;case 16:!function(e,t,n,i,s,r,a,o){let l,c,d=0;const h=g.width;for(c=t;c!==i;c+=n)for(l=s;l!==a;l+=r,d+=2)e[4*(l+h*c)+0]=o[d+0],e[4*(l+h*c)+1]=o[d+0],e[4*(l+h*c)+2]=o[d+0],e[4*(l+h*c)+3]=o[d+1]}(e,a,m,y,r,o,f,i);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(e,t,n,i,s,r,a,o,l){const c=l;let d,h,u,p=0;const m=g.width;for(u=t;u!==i;u+=n)for(h=s;h!==a;h+=r,p++)d=o[p],e[4*(h+m*u)+3]=255,e[4*(h+m*u)+2]=c[3*d+0],e[4*(h+m*u)+1]=c[3*d+1],e[4*(h+m*u)+0]=c[3*d+2]}(e,a,m,y,r,o,f,i,s);break;case 16:!function(e,t,n,i,s,r,a,o){let l,c,d,h=0;const u=g.width;for(d=t;d!==i;d+=n)for(c=s;c!==a;c+=r,h+=2)l=o[h+0]+(o[h+1]<<8),e[4*(c+u*d)+0]=(31744&l)>>7,e[4*(c+u*d)+1]=(992&l)>>2,e[4*(c+u*d)+2]=(31&l)<<3,e[4*(c+u*d)+3]=32768&l?0:255}(e,a,m,y,r,o,f,i);break;case 24:!function(e,t,n,i,s,r,a,o){let l,c,d=0;const h=g.width;for(c=t;c!==i;c+=n)for(l=s;l!==a;l+=r,d+=3)e[4*(l+h*c)+3]=255,e[4*(l+h*c)+2]=o[d+0],e[4*(l+h*c)+1]=o[d+1],e[4*(l+h*c)+0]=o[d+2]}(e,a,m,y,r,o,f,i);break;case 32:!function(e,t,n,i,s,r,a,o){let l,c,d=0;const h=g.width;for(c=t;c!==i;c+=n)for(l=s;l!==a;l+=r,d+=4)e[4*(l+h*c)+2]=o[d+0],e[4*(l+h*c)+1]=o[d+1],e[4*(l+h*c)+0]=o[d+2],e[4*(l+h*c)+3]=o[d+3]}(e,a,m,y,r,o,f,i);break;default:console.error("THREE.TGALoader: Format not supported.")}}(x,g.width,g.height,w.pixel_data,w.palettes),{data:x,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:1008}}}class cT extends fh{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new fT(e)})),this.register((function(e){return new MT(e)})),this.register((function(e){return new ST(e)})),this.register((function(e){return new yT(e)})),this.register((function(e){return new bT(e)})),this.register((function(e){return new vT(e)})),this.register((function(e){return new xT(e)})),this.register((function(e){return new mT(e)})),this.register((function(e){return new wT(e)})),this.register((function(e){return new gT(e)})),this.register((function(e){return new uT(e)})),this.register((function(e){return new TT(e)}))}load(e,t,n,i){const s=this;let r;r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Fh.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){i?i(t):console.error(t),s.manager.itemError(e),s.manager.itemEnd(e)},o=new yh(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{s.parse(n,r,(function(n){t(n),s.manager.itemEnd(e)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s;const r={},a={};if("string"==typeof e)s=e;else{if(Fh.decodeText(new Uint8Array(e,0,4))===CT){try{r[hT.KHR_BINARY_GLTF]=new RT(e)}catch(e){return void(i&&i(e))}s=r[hT.KHR_BINARY_GLTF].content}else s=Fh.decodeText(new Uint8Array(e))}const o=JSON.parse(s);if(void 0===o.asset||o.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new oC(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);a[t.name]=t,r[t.name]=!0}if(o.extensionsUsed)for(let e=0;e<o.extensionsUsed.length;++e){const t=o.extensionsUsed[e],n=o.extensionsRequired||[];switch(t){case hT.KHR_MATERIALS_UNLIT:r[t]=new pT;break;case hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:r[t]=new XT;break;case hT.KHR_DRACO_MESH_COMPRESSION:r[t]=new _T(o,this.dracoLoader);break;case hT.KHR_TEXTURE_TRANSFORM:r[t]=new AT;break;case hT.KHR_MESH_QUANTIZATION:r[t]=new ET;break;default:n.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(r),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,s){n.parse(e,t,i,s)}))}}function dT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const hT={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class uT{constructor(e){this.parser=e,this.name=hT.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,r=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let a;const o=new Fn(16777215);void 0!==r.color&&o.fromArray(r.color);const l=void 0!==r.range?r.range:0;switch(r.type){case"directional":a=new Nh(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Wh(o),a.distance=l;break;case"spot":a=new Ih(o),a.distance=l,r.spot=r.spot||{},r.spot.innerConeAngle=void 0!==r.spot.innerConeAngle?r.spot.innerConeAngle:0,r.spot.outerConeAngle=void 0!==r.spot.outerConeAngle?r.spot.outerConeAngle:Math.PI/4,a.angle=r.spot.outerConeAngle,a.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return a.position.set(0,0,0),a.decay=2,void 0!==r.intensity&&(a.intensity=r.intensity),a.name=t.createUniqueName(r.name||"light_"+e),i=Promise.resolve(a),t.cache.add(n,i),i}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],s=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===s?null:this._loadLight(s).then((function(e){return n._getNodeRef(t.cache,s,e)}))}}class pT{constructor(){this.name=hT.KHR_MATERIALS_UNLIT}getMaterialType(){return ws}extendParams(e,t,n){const i=[];e.color=new Fn(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const t=s.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==s.baseColorTexture&&i.push(n.assignTexture(e,"map",s.baseColorTexture,3001))}return Promise.all(i)}}class mT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class fT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];if(void 0!==r.clearcoatFactor&&(t.clearcoat=r.clearcoatFactor),void 0!==r.clearcoatTexture&&s.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),void 0!==r.clearcoatRoughnessFactor&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),void 0!==r.clearcoatRoughnessTexture&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),void 0!==r.clearcoatNormalTexture&&(s.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),void 0!==r.clearcoatNormalTexture.scale)){const e=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Rn(e,e)}return Promise.all(s)}}class gT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return void 0!==r.iridescenceFactor&&(t.iridescence=r.iridescenceFactor),void 0!==r.iridescenceTexture&&s.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),void 0!==r.iridescenceIor&&(t.iridescenceIOR=r.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==r.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),void 0!==r.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),void 0!==r.iridescenceThicknessTexture&&s.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(s)}}class yT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new Fn(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];return void 0!==r.sheenColorFactor&&t.sheenColor.fromArray(r.sheenColorFactor),void 0!==r.sheenRoughnessFactor&&(t.sheenRoughness=r.sheenRoughnessFactor),void 0!==r.sheenColorTexture&&s.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,3001)),void 0!==r.sheenRoughnessTexture&&s.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(s)}}class bT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return void 0!==r.transmissionFactor&&(t.transmission=r.transmissionFactor),void 0!==r.transmissionTexture&&s.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(s)}}class vT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.thickness=void 0!==r.thicknessFactor?r.thicknessFactor:0,void 0!==r.thicknessTexture&&s.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new Fn(a[0],a[1],a[2]),Promise.all(s)}}class xT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class wT{constructor(e){this.parser=e,this.name=hT.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Fd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.specularIntensity=void 0!==r.specularFactor?r.specularFactor:1,void 0!==r.specularTexture&&s.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new Fn(a[0],a[1],a[2]),void 0!==r.specularColorTexture&&s.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,3001)),Promise.all(s)}}class MT{constructor(e){this.parser=e,this.name=hT.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}}class ST{constructor(e){this.parser=e,this.name=hT.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],a=i.images[r.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(s){if(s)return n.loadTextureImage(e,r.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class TT{constructor(e){this.name=hT.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,s.ready]).then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,r=e.count,a=e.byteStride,o=new ArrayBuffer(r*a),l=new Uint8Array(t[0],n,i);return s.decodeGltfBuffer(new Uint8Array(o),r,a,l,e.mode,e.filter),o}))}return null}}const CT="glTF",LT=1313821514,GT=5130562;class RT{constructor(e){this.name=hT.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:Fh.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==CT)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,i=new DataView(e,12);let s=0;for(;s<n;){const t=i.getUint32(s,!0);s+=4;const n=i.getUint32(s,!0);if(s+=4,n===LT){const n=new Uint8Array(e,12+s,t);this.content=Fh.decodeText(n)}else if(n===GT){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class _T{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=hT.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},o={},l={};for(const e in r){const t=KT[e]||e.toLowerCase();a[t]=r[e]}for(const t in e.attributes){const i=KT[t]||t.toLowerCase();if(void 0!==r[t]){const s=n.accessors[e.attributes[t]],r=FT[s.componentType];l[i]=r,o[i]=!0===s.normalized}}return t.getDependency("bufferView",s).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=o[t];void 0!==i&&(n.normalized=i)}t(e)}),a,l)}))}))}}class AT{constructor(){this.name=hT.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class IT extends kd{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),i=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),s=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),r=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new Fn).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(const t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",s).replace("#include <lights_physical_fragment>",r)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class XT{constructor(){this.name=hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return IT}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new Fn(1,1,1),e.opacity=1;const s=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&s.push(n.assignTexture(e,"map",i.diffuseTexture,3001)),e.emissive=new Fn(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Fn(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;s.push(n.assignTexture(e,"glossinessMap",t)),s.push(n.assignTexture(e,"specularMap",t,3001))}return Promise.all(s)}createMaterial(e){const t=new IT(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=void 0===e.emissiveIntensity?1:e.emissiveIntensity,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=0,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class ET{constructor(){this.name=hT.KHR_MESH_QUANTIZATION}}class zT extends qd{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[s+e];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,c=i-t,d=(n-t)/c,h=d*d,u=h*d,p=e*l,m=p-l,f=-2*u+3*h,g=u-h,y=1-f,b=g-h+d;for(let e=0;e!==a;e++){const t=r[m+e+a],n=r[m+e+o]*c,i=r[p+e+a],l=r[p+e]*c;s[e]=y*t+b*n+f*i+g*l}return s}}const PT=new si;class WT extends zT{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return PT.fromArray(s).normalize().toArray(s),s}}const ZT=0,NT=1,VT=2,DT=3,HT=4,BT=5,kT=6,FT={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},UT={9728:1003,9729:1006,9984:1004,9985:1007,9986:1005,9987:1008},OT={33071:1001,33648:1002,10497:1e3},YT={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},KT={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},jT={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},JT={CUBICSPLINE:void 0,LINEAR:2301,STEP:2300},QT="OPAQUE",qT="MASK",$T="BLEND";function eC(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new kd({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function tC(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function nC(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function iC(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function sC(e){const t=e.extensions&&e.extensions[hT.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+rC(t.attributes):e.indices+":"+rC(e.attributes)+":"+e.mode,n}function rC(e){let t="";const n=Object.keys(e).sort();for(let i=0,s=n.length;i<s;i++)t+=n[i]+":"+e[n[i]]+";";return t}function aC(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class oC{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new dT,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1;"undefined"==typeof createImageBitmap||n||i&&s<98?this.textureLoader=new Sh(this.options.manager):this.textureLoader=new Qh(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new yh(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const r={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};tC(s,r,i),nC(r,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(r)}))).then((function(){e(r)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())s(i,t.children[n])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[hT.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,s){n.load(Fh.resolveURL(t.uri,i.path),e,void 0,(function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);const s=[];return void 0!==i.bufferView?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),void 0!==i.sparse&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then((function(e){const s=e[0],r=YT[i.type],a=FT[i.componentType],o=a.BYTES_PER_ELEMENT,l=o*r,c=i.byteOffset||0,d=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,h=!0===i.normalized;let u,p;if(d&&d!==l){const e=Math.floor(c/d),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(u=new a(s,e*d,i.count*d/o),l=new dl(u,d/o),t.cache.add(n,l)),p=new ul(l,r,c%d/o,h)}else u=null===s?new a(i.count*r):new a(s,c,i.count*r),p=new Ts(u,r,h);if(void 0!==i.sparse){const t=YT.SCALAR,n=FT[i.sparse.indices.componentType],o=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],o,i.sparse.count*t),d=new a(e[2],l,i.sparse.count*r);null!==s&&(p=new Ts(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,d[e*r]),r>=2&&p.setY(t,d[e*r+1]),r>=3&&p.setZ(t,d[e*r+2]),r>=4&&p.setW(t,d[e*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,s=t.images[i];let r=this.textureLoader;if(s.uri){const e=n.manager.getHandler(s.uri);null!==e&&(r=e)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],a=s.images[t],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,r.name&&(t.name=r.name);const n=(s.samplers||{})[r.sampler]||{};return t.magFilter=UT[n.magFilter]||1006,t.minFilter=UT[n.minFilter]||1008,t.wrapS=OT[n.wrapS]||1e3,t.wrapT=OT[n.wrapT]||1e3,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const r=i.images[e],a=self.URL||self.webkitURL;let o=r.uri||"",l=!1;if(void 0!==r.bufferView)o=n.getDependency("bufferView",r.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:r.mimeType});return o=a.createObjectURL(t),o}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(o).then((function(e){return new Promise((function(n,i){let r=n;!0===t.isImageBitmapLoader&&(r=function(e){const t=new Jn(e);t.needsUpdate=!0,n(t)}),t.load(Fh.resolveURL(e,s.path),r,void 0,i)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(o),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then((function(r){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),s.extensions[hT.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[hT.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=s.associations.get(r);r=s.extensions[hT.KHR_TEXTURE_TRANSFORM].extendTexture(r,e),s.associations.set(r,t)}}return void 0!==i&&(r.encoding=i),e[t]=r,r}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,r=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ac,xs.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new jl,xs.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(i||s||r){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),r&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),r&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return kd}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const a={},o=s.extensions||{},l=[];if(o[hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];r=e.getMaterialType(),l.push(e.extendParams(a,s,t))}else if(o[hT.KHR_MATERIALS_UNLIT]){const e=i[hT.KHR_MATERIALS_UNLIT];r=e.getMaterialType(),l.push(e.extendParams(a,s,t))}else{const n=s.pbrMetallicRoughness||{};if(a.color=new Fn(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(a,"map",n.baseColorTexture,3001)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),r=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===s.doubleSided&&(a.side=2);const c=s.alphaMode||QT;if(c===$T?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===qT&&(a.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&r!==ws&&(l.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Rn(1,1),void 0!==s.normalTexture.scale)){const e=s.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==s.occlusionTexture&&r!==ws&&(l.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(a.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&r!==ws&&(a.emissive=(new Fn).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&r!==ws&&l.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,3001)),Promise.all(l).then((function(){let n;return n=r===IT?i[hT.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new r(a),s.name&&(n.name=s.name),nC(n,s),t.associations.set(n,{materials:e}),s.extensions&&tC(i,n,s),n}))}createUniqueName(e){const t=Lu.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(e){return n[hT.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return cC(n,e,t)}))}const r=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],o=sC(a),l=i[o];if(l)r.push(l.promise);else{let e;e=a.extensions&&a.extensions[hT.KHR_DRACO_MESH_COMPRESSION]?s(a):cC(new Bs,a,t),i[o]={primitive:a,promise:e},r.push(e)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],r=s.primitives,a=[];for(let e=0,t=r.length;e<t;e++){const t=void 0===r[e].material?eC(this.cache):this.getDependency("material",r[e].material);a.push(t)}return a.push(t.loadGeometries(r)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,c=o.length;n<c;n++){const c=o[n],d=r[n];let h;const u=a[n];if(d.mode===HT||d.mode===BT||d.mode===kT||void 0===d.mode)h=!0===s.isSkinnedMesh?new Zl(c,u):new ar(c,u),!0!==h.isSkinnedMesh||h.geometry.attributes.skinWeight.normalized||h.normalizeSkinWeights(),d.mode===BT?h.geometry=dC(h.geometry,1):d.mode===kT&&(h.geometry=dC(h.geometry,2));else if(d.mode===NT)h=new sc(c,u);else if(d.mode===DT)h=new tc(c,u);else if(d.mode===VT)h=new rc(c,u);else{if(d.mode!==ZT)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);h=new hc(c,u)}Object.keys(h.geometry.morphAttributes).length>0&&iC(h,s),h.name=t.createUniqueName(s.name||"mesh_"+e),nC(h,s),d.extensions&&tC(i,h,d),t.assignFinalMaterial(h),l.push(h)}for(let n=0,i=l.length;n<i;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new qo;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new mr(Gn.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new Zr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),nC(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return n.inverseBindMatrices=e,n}))}loadAnimation(e){const t=this.json.animations[e],n=[],i=[],s=[],r=[],a=[];for(let e=0,o=t.channels.length;e<o;e++){const o=t.channels[e],l=t.samplers[o.sampler],c=o.target,d=void 0!==c.node?c.node:c.id,h=void 0!==t.parameters?t.parameters[l.input]:l.input,u=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",d)),i.push(this.getDependency("accessor",h)),s.push(this.getDependency("accessor",u)),r.push(l),a.push(c)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(s),Promise.all(r),Promise.all(a)]).then((function(n){const i=n[0],s=n[1],r=n[2],a=n[3],o=n[4],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],n=s[e],c=r[e],d=a[e],h=o[e];if(void 0===t)continue;let u;switch(t.updateMatrix(),t.matrixAutoUpdate=!0,jT[h.path]){case jT.weights:u=rh;break;case jT.rotation:u=oh;break;case jT.position:case jT.scale:default:u=ch}const p=t.name?t.name:t.uuid,m=void 0!==d.interpolation?JT[d.interpolation]:2301,f=[];jT[h.path]===jT.weights?t.traverse((function(e){e.morphTargetInfluences&&f.push(e.name?e.name:e.uuid)})):f.push(p);let g=c.array;if(c.normalized){const e=aC(g.constructor),t=new Float32Array(g.length);for(let n=0,i=g.length;n<i;n++)t[n]=g[n]*e;g=t}for(let e=0,t=f.length;e<t;e++){const t=new u(f[e]+"."+jT[h.path],n.array,g,m);"CUBICSPLINE"===d.interpolation&&(t.createInterpolant=function(e){return new(this instanceof oh?WT:zT)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new dh(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,i=this,s=t.nodes[e],r=s.name?i.createUniqueName(s.name):"";return function(){const t=[],n=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==s.camera&&t.push(i.getDependency("camera",s.camera).then((function(e){return i._getNodeRef(i.cameraCache,s.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let a;if(a=!0===s.isBone?new Nl:t.length>1?new qo:1===t.length?t[0]:new os,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(s.name&&(a.userData.name=s.name,a.name=r),nC(a,s),s.extensions&&tC(n,a,s),void 0!==s.matrix){const e=new Wi;e.fromArray(s.matrix),a.applyMatrix4(e)}else void 0!==s.translation&&a.position.fromArray(s.translation),void 0!==s.rotation&&a.quaternion.fromArray(s.rotation),void 0!==s.scale&&a.scale.fromArray(s.scale);return i.associations.has(a)||i.associations.set(a,{}),i.associations.get(a).nodes=e,a}))}loadScene(e){const t=this.json,n=this.extensions,i=this.json.scenes[e],s=this,r=new qo;i.name&&(r.name=s.createUniqueName(i.name)),nC(r,i),i.extensions&&tC(n,r,i);const a=i.nodes||[],o=[];for(let e=0,n=a.length;e<n;e++)o.push(lC(a[e],r,t,s));return Promise.all(o).then((function(){return s.associations=(e=>{const t=new Map;for(const[e,n]of s.associations)(e instanceof xs||e instanceof Jn)&&t.set(e,n);return e.traverse((e=>{const n=s.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}}function lC(e,t,n,i){const s=n.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===s.skin)return e;let t;return i.getDependency("skin",s.skin).then((function(e){t=e;const n=[];for(let e=0,s=t.joints.length;e<s;e++)n.push(i.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const i=[],s=[];for(let e=0,r=n.length;e<r;e++){const r=n[e];if(r){i.push(r);const n=new Wi;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),s.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new Bl(i,s),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const r=[];if(s.children){const t=s.children;for(let s=0,a=t.length;s<a;s++){const a=t[s];r.push(lC(a,e,n,i))}}return Promise.all(r)}))}function cC(e,t,n){const i=t.attributes,s=[];function r(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=KT[t]||t.toLowerCase();n in e.attributes||s.push(r(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));s.push(i)}return nC(e,t),function(e,t,n){const i=t.attributes,s=new li;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.POSITION],t=e.min,r=e.max;if(void 0===t||void 0===r)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(s.set(new ri(t[0],t[1],t[2]),new ri(r[0],r[1],r[2])),e.normalized){const t=aC(FT[e.componentType]);s.min.multiplyScalar(t),s.max.multiplyScalar(t)}}const r=t.targets;if(void 0!==r){const e=new ri,t=new ri;for(let i=0,s=r.length;i<s;i++){const s=r[i];if(void 0!==s.POSITION){const i=n.json.accessors[s.POSITION],r=i.min,a=i.max;if(void 0!==r&&void 0!==a){if(t.setX(Math.max(Math.abs(r[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(r[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(r[2]),Math.abs(a[2]))),i.normalized){const e=aC(FT[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(e)}e.boundingBox=s;const a=new Gi;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(s).then((function(){return void 0!==t.targets?function(e,t,n){let i=!1,s=!1,r=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(s=!0),void 0!==n.COLOR_0&&(r=!0),i&&s&&r)break}if(!i&&!s&&!r)return Promise.resolve(e);const a=[],o=[],l=[];for(let c=0,d=t.length;c<d;c++){const d=t[c];if(i){const t=void 0!==d.POSITION?n.getDependency("accessor",d.POSITION):e.attributes.position;a.push(t)}if(s){const t=void 0!==d.NORMAL?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(t)}if(r){const t=void 0!==d.COLOR_0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],o=t[2];return i&&(e.morphAttributes.position=n),s&&(e.morphAttributes.normal=a),r&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function dC(e,t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,s=[];if(2===t)for(let e=1;e<=i;e++)s.push(n.getX(0)),s.push(n.getX(e)),s.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(s.push(n.getX(e)),s.push(n.getX(e+1)),s.push(n.getX(e+2))):(s.push(n.getX(e+2)),s.push(n.getX(e+1)),s.push(n.getX(e)));s.length/3!==i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=e.clone();return r.setIndex(s),r}const hC=new WeakMap;class uC extends fh{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new yh(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(i)}),n,i)}decodeDracoFile(e,t,n,i){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const n=t.attributeTypes[e];void 0!==n.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=n.name)}const n=JSON.stringify(t);if(hC.has(e)){const t=hC.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(s,r).then((n=>(i=n,new Promise(((n,r)=>{i._callbacks[s]={resolve:n,reject:r},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return a.catch((()=>!0)).then((()=>{i&&s&&this._releaseTask(i,s)})),hC.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new Bs;e.index&&t.setIndex(new Ts(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],s=i.name,r=i.array,a=i.itemSize;t.setAttribute(s,new Ts(r,a))}return t}_loadLibrary(e,t){const n=new yh(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=pC.toString(),s=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([s]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function pC(){let e,t;function n(e,t,n,i,s,r){const a=r.num_components(),o=n.num_points()*a,l=o*s.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,s),d=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,r,c,l,d);const h=new s(e.HEAPF32.buffer,d,o).slice();return e._free(d),{name:i,array:h,itemSize:a}}onmessage=function(i){const s=i.data;switch(s.type){case"init":e=s.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=s.buffer,r=s.taskConfig;t.then((e=>{const t=e.draco,a=new t.Decoder,o=new t.DecoderBuffer;o.Init(new Int8Array(i),i.byteLength);try{const e=function(e,t,i,s){const r=s.attributeIDs,a=s.attributeTypes;let o,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeBufferToMesh(i,o);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const d={index:null,attributes:[]};for(const i in r){const l=self[a[i]];let c,h;if(s.useUniqueIDs)h=r[i],c=t.GetAttributeByUniqueId(o,h);else{if(h=t.GetAttributeId(o,e[r[i]]),-1===h)continue;c=t.GetAttribute(o,h)}d.attributes.push(n(e,t,o,i,l,c))}c===e.TRIANGULAR_MESH&&(d.index=function(e,t,n){const i=3*n.num_faces(),s=4*i,r=e._malloc(s);t.GetTrianglesUInt32Array(n,s,r);const a=new Uint32Array(e.HEAPF32.buffer,r,i).slice();return e._free(r),{array:a,itemSize:1}}(e,t,o));return e.destroy(o),d}(t,a,o,r),i=e.attributes.map((e=>e.array.buffer));e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}finally{t.destroy(o),t.destroy(a)}}))}}}
33
33
  /*!
34
34
  localForage -- Offline Storage, Improved
35
35
  Version 1.9.0
36
36
  https://localforage.github.io/localForage
37
37
  (c) 2013-2017 Mozilla, Apache License 2.0
38
- */var mC,fC=(function(e,t){e.exports=function e(t,n,i){function s(a,o){if(!n[a]){if(!t[a]){if(!o&&Jy)return Jy(a);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};t[a][0].call(c.exports,(function(e){var n=t[a][1][e];return s(n||e)}),c,c.exports,e,t,n,i)}return n[a].exports}for(var r=Jy,a=0;a<i.length;a++)s(i[a]);return s}({1:[function(e,t,n){(function(e){var n,i,s=e.MutationObserver||e.WebKitMutationObserver;if(s){var r=0,a=new s(d),o=e.document.createTextNode("");a.observe(o,{characterData:!0}),n=function(){o.data=r=++r%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){d(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(d,0)};else{var l=new e.MessageChannel;l.port1.onmessage=d,n=function(){l.port2.postMessage(0)}}var c=[];function d(){var e,t;i=!0;for(var n=c.length;n;){for(t=c,c=[],e=-1;++e<n;)t[e]();n=c.length}i=!1}function h(e){1!==c.push(e)||i||n()}t.exports=h}).call(this,void 0!==Ky?Ky:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){var i=e(1);function s(){}var r={},a=["REJECTED"],o=["FULFILLED"],l=["PENDING"];function c(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==s&&p(this,e)}function d(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function h(e,t,n){i((function(){var i;try{i=t(n)}catch(t){return r.reject(e,t)}i===e?r.reject(e,new TypeError("Cannot resolve promise with itself")):r.resolve(e,i)}))}function u(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function p(e,t){var n=!1;function i(t){n||(n=!0,r.reject(e,t))}function s(t){n||(n=!0,r.resolve(e,t))}function a(){t(s,i)}var o=m(a);"error"===o.status&&i(o.value)}function m(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function f(e){return e instanceof this?e:r.resolve(new this(s),e)}function g(e){var t=new this(s);return r.reject(t,e)}function y(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var a=new Array(n),o=0,l=-1,c=new this(s);++l<n;)d(e[l],l);return c;function d(e,s){function l(e){a[s]=e,++o!==n||i||(i=!0,r.resolve(c,a))}t.resolve(e).then(l,(function(e){i||(i=!0,r.reject(c,e))}))}}function b(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var a=-1,o=new this(s);++a<n;)l(e[a]);return o;function l(e){t.resolve(e).then((function(e){i||(i=!0,r.resolve(o,e))}),(function(e){i||(i=!0,r.reject(o,e))}))}}t.exports=c,c.prototype.catch=function(e){return this.then(null,e)},c.prototype.then=function(e,t){if("function"!=typeof e&&this.state===o||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(s);return this.state!==l?h(n,this.state===o?e:t,this.outcome):this.queue.push(new d(n,e,t)),n},d.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},d.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},d.prototype.callRejected=function(e){r.reject(this.promise,e)},d.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},r.resolve=function(e,t){var n=m(u,t);if("error"===n.status)return r.reject(e,n.value);var i=n.value;if(i)p(e,i);else{e.state=o,e.outcome=t;for(var s=-1,a=e.queue.length;++s<a;)e.queue[s].callFulfilled(t)}return e},r.reject=function(e,t){e.state=a,e.outcome=t;for(var n=-1,i=e.queue.length;++n<i;)e.queue[n].callRejected(t);return e},c.resolve=f,c.reject=g,c.all=y,c.race=b},{1:1}],3:[function(e,t,n){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==Ky?Ky:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var a=r();function o(){try{if(!a||!a.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function l(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(s){if("TypeError"!==s.name)throw s;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),i=0;i<e.length;i+=1)n.append(e[i]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var c=Promise;function d(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function h(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function u(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function p(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var m="local-forage-detect-blob-support",f=void 0,g={},y=Object.prototype.toString,b="readonly",v="readwrite";function x(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=0;s<t;s++)i[s]=e.charCodeAt(s);return n}function w(e){return new c((function(t){var n=e.transaction(m,v),i=l([""]);n.objectStore(m).put(i,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function M(e){return"boolean"==typeof f?c.resolve(f):w(e).then((function(e){return f=e}))}function S(e){var t=g[e.name],n={};n.promise=new c((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function T(e){var t=g[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function C(e,t){var n=g[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function L(e,t){return new c((function(n,i){if(g[e.name]=g[e.name]||W(),e.db){if(!t)return n(e.db);S(e),e.db.close()}var s=[e.name];t&&s.push(e.version);var r=a.open.apply(a,s);t&&(r.onupgradeneeded=function(t){var n=r.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(m)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),r.onerror=function(e){e.preventDefault(),i(r.error)},r.onsuccess=function(){n(r.result),T(e)}}))}function G(e){return L(e,!1)}function R(e){return L(e,!0)}function _(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),i=e.version<e.db.version,s=e.version>e.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),s||n){if(n){var r=e.db.version+1;r>e.version&&(e.version=r)}return!0}return!1}function A(e){return new c((function(t,n){var i=new FileReader;i.onerror=n,i.onloadend=function(n){var i=btoa(n.target.result||"");t({__local_forage_encoded_blob:!0,data:i,type:e.type})},i.readAsBinaryString(e)}))}function I(e){return l([x(atob(e.data))],{type:e.type})}function X(e){return e&&e.__local_forage_encoded_blob}function E(e){var t=this,n=t._initReady().then((function(){var e=g[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return h(n,e,e),n}function z(e){S(e);for(var t=g[e.name],n=t.forages,i=0;i<n.length;i++){var s=n[i];s._dbInfo.db&&(s._dbInfo.db.close(),s._dbInfo.db=null)}return e.db=null,G(e).then((function(t){return e.db=t,_(e)?R(e):t})).then((function(i){e.db=t.db=i;for(var s=0;s<n.length;s++)n[s]._dbInfo.db=i})).catch((function(t){throw C(e,t),t}))}function P(e,t,n,i){void 0===i&&(i=1);try{var s=e.db.transaction(e.storeName,t);n(null,s)}catch(s){if(i>0&&(!e.db||"InvalidStateError"===s.name||"NotFoundError"===s.name))return c.resolve().then((function(){if(!e.db||"NotFoundError"===s.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),R(e)})).then((function(){return z(e).then((function(){P(e,t,n,i-1)}))})).catch(n);n(s)}}function W(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Z(e){var t=this,n={db:null};if(e)for(var i in e)n[i]=e[i];var s=g[n.name];s||(s=W(),g[n.name]=s),s.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=E);var r=[];function a(){return c.resolve()}for(var o=0;o<s.forages.length;o++){var l=s.forages[o];l!==t&&r.push(l._initReady().catch(a))}var d=s.forages.slice(0);return c.all(r).then((function(){return n.db=s.db,G(n)})).then((function(e){return n.db=e,_(n,t._defaultConfig.version)?R(n):e})).then((function(e){n.db=s.db=e,t._dbInfo=n;for(var i=0;i<d.length;i++){var r=d[i];r!==t&&(r._dbInfo.db=n.db,r._dbInfo.version=n.version)}}))}function N(e,t){var n=this;e=u(e);var i=new c((function(t,i){n.ready().then((function(){P(n._dbInfo,b,(function(s,r){if(s)return i(s);try{var a=r.objectStore(n._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),X(e)&&(e=I(e)),t(e)},a.onerror=function(){i(a.error)}}catch(e){i(e)}}))})).catch(i)}));return d(i,t),i}function V(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){P(n._dbInfo,b,(function(s,r){if(s)return i(s);try{var a=r.objectStore(n._dbInfo.storeName).openCursor(),o=1;a.onsuccess=function(){var n=a.result;if(n){var i=n.value;X(i)&&(i=I(i));var s=e(i,n.key,o++);void 0!==s?t(s):n.continue()}else t()},a.onerror=function(){i(a.error)}}catch(e){i(e)}}))})).catch(i)}));return d(i,t),i}function D(e,t,n){var i=this;e=u(e);var s=new c((function(n,s){var r;i.ready().then((function(){return r=i._dbInfo,"[object Blob]"===y.call(t)?M(r.db).then((function(e){return e?t:A(t)})):t})).then((function(t){P(i._dbInfo,v,(function(r,a){if(r)return s(r);try{var o=a.objectStore(i._dbInfo.storeName);null===t&&(t=void 0);var l=o.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=l.error?l.error:l.transaction.error;s(e)}}catch(e){s(e)}}))})).catch(s)}));return d(s,n),s}function H(e,t){var n=this;e=u(e);var i=new c((function(t,i){n.ready().then((function(){P(n._dbInfo,v,(function(s,r){if(s)return i(s);try{var a=r.objectStore(n._dbInfo.storeName).delete(e);r.oncomplete=function(){t()},r.onerror=function(){i(a.error)},r.onabort=function(){var e=a.error?a.error:a.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return d(i,t),i}function B(e){var t=this,n=new c((function(e,n){t.ready().then((function(){P(t._dbInfo,v,(function(i,s){if(i)return n(i);try{var r=s.objectStore(t._dbInfo.storeName).clear();s.oncomplete=function(){e()},s.onabort=s.onerror=function(){var e=r.error?r.error:r.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return d(n,e),n}function k(e){var t=this,n=new c((function(e,n){t.ready().then((function(){P(t._dbInfo,b,(function(i,s){if(i)return n(i);try{var r=s.objectStore(t._dbInfo.storeName).count();r.onsuccess=function(){e(r.result)},r.onerror=function(){n(r.error)}}catch(e){n(e)}}))})).catch(n)}));return d(n,e),n}function F(e,t){var n=this,i=new c((function(t,i){e<0?t(null):n.ready().then((function(){P(n._dbInfo,b,(function(s,r){if(s)return i(s);try{var a=r.objectStore(n._dbInfo.storeName),o=!1,l=a.openKeyCursor();l.onsuccess=function(){var n=l.result;n?0===e||o?t(n.key):(o=!0,n.advance(e)):t(null)},l.onerror=function(){i(l.error)}}catch(e){i(e)}}))})).catch(i)}));return d(i,t),i}function U(e){var t=this,n=new c((function(e,n){t.ready().then((function(){P(t._dbInfo,b,(function(i,s){if(i)return n(i);try{var r=s.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];r.onsuccess=function(){var t=r.result;t?(a.push(t.key),t.continue()):e(a)},r.onerror=function(){n(r.error)}}catch(e){n(e)}}))})).catch(n)}));return d(n,e),n}function O(e,t){t=p.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var i,s=this;if(e.name){var r=e.name===n.name&&s._dbInfo.db?c.resolve(s._dbInfo.db):G(e).then((function(t){var n=g[e.name],i=n.forages;n.db=t;for(var s=0;s<i.length;s++)i[s]._dbInfo.db=t;return t}));i=e.storeName?r.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;S(e);var i=g[e.name],s=i.forages;t.close();for(var r=0;r<s.length;r++){var o=s[r];o._dbInfo.db=null,o._dbInfo.version=n}return new c((function(t,i){var s=a.open(e.name,n);s.onerror=function(e){s.result.close(),i(e)},s.onupgradeneeded=function(){s.result.deleteObjectStore(e.storeName)},s.onsuccess=function(){var e=s.result;e.close(),t(e)}})).then((function(e){i.db=e;for(var t=0;t<s.length;t++){var n=s[t];n._dbInfo.db=e,T(n._dbInfo)}})).catch((function(t){throw(C(e,t)||c.resolve()).catch((function(){})),t}))}})):r.then((function(t){S(e);var n=g[e.name],i=n.forages;t.close();for(var s=0;s<i.length;s++)i[s]._dbInfo.db=null;return new c((function(t,n){var i=a.deleteDatabase(e.name);i.onerror=i.onblocked=function(e){var t=i.result;t&&t.close(),n(e)},i.onsuccess=function(){var e=i.result;e&&e.close(),t(e)}})).then((function(e){n.db=e;for(var t=0;t<i.length;t++)T(i[t]._dbInfo)})).catch((function(t){throw(C(e,t)||c.resolve()).catch((function(){})),t}))}))}else i=c.reject("Invalid arguments");return d(i,t),i}var Y={_driver:"asyncStorage",_initStorage:Z,_support:o(),iterate:V,getItem:N,setItem:D,removeItem:H,clear:B,length:k,key:F,keys:U,dropInstance:O};function K(){return"function"==typeof openDatabase}var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J="~~local_forage_type~",Q=/^~~local_forage_type~([^~]+)~/,q="__lfsc__:",$=q.length,ee="arbf",te="blob",ne="si08",ie="ui08",se="uic8",re="si16",ae="si32",oe="ur16",le="ui32",ce="fl32",de="fl64",he=$+ee.length,ue=Object.prototype.toString;function pe(e){var t,n,i,s,r,a=.75*e.length,o=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var c=new ArrayBuffer(a),d=new Uint8Array(c);for(t=0;t<o;t+=4)n=j.indexOf(e[t]),i=j.indexOf(e[t+1]),s=j.indexOf(e[t+2]),r=j.indexOf(e[t+3]),d[l++]=n<<2|i>>4,d[l++]=(15&i)<<4|s>>2,d[l++]=(3&s)<<6|63&r;return c}function me(e){var t,n=new Uint8Array(e),i="";for(t=0;t<n.length;t+=3)i+=j[n[t]>>2],i+=j[(3&n[t])<<4|n[t+1]>>4],i+=j[(15&n[t+1])<<2|n[t+2]>>6],i+=j[63&n[t+2]];return n.length%3==2?i=i.substring(0,i.length-1)+"=":n.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}function fe(e,t){var n="";if(e&&(n=ue.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===ue.call(e.buffer))){var i,s=q;e instanceof ArrayBuffer?(i=e,s+=ee):(i=e.buffer,"[object Int8Array]"===n?s+=ne:"[object Uint8Array]"===n?s+=ie:"[object Uint8ClampedArray]"===n?s+=se:"[object Int16Array]"===n?s+=re:"[object Uint16Array]"===n?s+=oe:"[object Int32Array]"===n?s+=ae:"[object Uint32Array]"===n?s+=le:"[object Float32Array]"===n?s+=ce:"[object Float64Array]"===n?s+=de:t(new Error("Failed to get type for BinaryArray"))),t(s+me(i))}else if("[object Blob]"===n){var r=new FileReader;r.onload=function(){var n=J+e.type+"~"+me(this.result);t(q+te+n)},r.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}}function ge(e){if(e.substring(0,$)!==q)return JSON.parse(e);var t,n=e.substring(he),i=e.substring($,he);if(i===te&&Q.test(n)){var s=n.match(Q);t=s[1],n=n.substring(s[0].length)}var r=pe(n);switch(i){case ee:return r;case te:return l([r],{type:t});case ne:return new Int8Array(r);case ie:return new Uint8Array(r);case se:return new Uint8ClampedArray(r);case re:return new Int16Array(r);case oe:return new Uint16Array(r);case ae:return new Int32Array(r);case le:return new Uint32Array(r);case ce:return new Float32Array(r);case de:return new Float64Array(r);default:throw new Error("Unkown type: "+i)}}var ye={serialize:fe,deserialize:ge,stringToBuffer:pe,bufferToString:me};function be(e,t,n,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,i)}function ve(e){var t=this,n={db:null};if(e)for(var i in e)n[i]="string"!=typeof e[i]?e[i].toString():e[i];var s=new c((function(e,i){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return i(e)}n.db.transaction((function(s){be(s,n,(function(){t._dbInfo=n,e()}),(function(e,t){i(t)}))}),i)}));return n.serializer=ye,s}function xe(e,t,n,i,s,r){e.executeSql(n,i,s,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,o){o.rows.length?r(e,a):be(e,t,(function(){e.executeSql(n,i,s,r)}),r)}),r):r(e,a)}),r)}function we(e,t){var n=this;e=u(e);var i=new c((function(t,i){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){xe(n,s,"SELECT * FROM "+s.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var i=n.rows.length?n.rows.item(0).value:null;i&&(i=s.serializer.deserialize(i)),t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return d(i,t),i}function Me(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){xe(n,s,"SELECT * FROM "+s.storeName,[],(function(n,i){for(var r=i.rows,a=r.length,o=0;o<a;o++){var l=r.item(o),c=l.value;if(c&&(c=s.serializer.deserialize(c)),void 0!==(c=e(c,l.key,o+1)))return void t(c)}t()}),(function(e,t){i(t)}))}))})).catch(i)}));return d(i,t),i}function Se(e,t,n,i){var s=this;e=u(e);var r=new c((function(r,a){s.ready().then((function(){void 0===t&&(t=null);var o=t,l=s._dbInfo;l.serializer.serialize(t,(function(t,c){c?a(c):l.db.transaction((function(n){xe(n,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){r(o)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void r(Se.apply(s,[e,o,n,i-1]));a(t)}}))}))})).catch(a)}));return d(r,n),r}function Te(e,t,n){return Se.apply(this,[e,t,n,1])}function Ce(e,t){var n=this;e=u(e);var i=new c((function(t,i){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){xe(n,s,"DELETE FROM "+s.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){i(t)}))}))})).catch(i)}));return d(i,t),i}function Le(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){xe(t,i,"DELETE FROM "+i.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return d(n,e),n}function Ge(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){xe(t,i,"SELECT COUNT(key) as c FROM "+i.storeName,[],(function(t,n){var i=n.rows.item(0).c;e(i)}),(function(e,t){n(t)}))}))})).catch(n)}));return d(n,e),n}function Re(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){xe(n,s,"SELECT key FROM "+s.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var i=n.rows.length?n.rows.item(0).key:null;t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return d(i,t),i}function _e(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){xe(t,i,"SELECT key FROM "+i.storeName,[],(function(t,n){for(var i=[],s=0;s<n.rows.length;s++)i.push(n.rows.item(s).key);e(i)}),(function(e,t){n(t)}))}))})).catch(n)}));return d(n,e),n}function Ae(e){return new c((function(t,n){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,i){for(var s=[],r=0;r<i.rows.length;r++)s.push(i.rows.item(r).name);t({db:e,storeNames:s})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}function Ie(e,t){t=p.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var i,s=this;return d(i=e.name?new c((function(t){var i;i=e.name===n.name?s._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:i,storeNames:[e.storeName]}):t(Ae(i))})).then((function(e){return new c((function(t,n){e.db.transaction((function(i){function s(e){return new c((function(t,n){i.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var r=[],a=0,o=e.storeNames.length;a<o;a++)r.push(s(e.storeNames[a]));c.all(r).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):c.reject("Invalid arguments"),t),i}var Xe={_driver:"webSQLStorage",_initStorage:ve,_support:K(),iterate:Me,getItem:we,setItem:Te,removeItem:Ce,clear:Le,length:Ge,key:Re,keys:_e,dropInstance:Ie};function Ee(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function ze(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function Pe(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function We(){return!Pe()||localStorage.length>0}function Ze(e){var t=this,n={};if(e)for(var i in e)n[i]=e[i];return n.keyPrefix=ze(e,t._defaultConfig),We()?(t._dbInfo=n,n.serializer=ye,c.resolve()):c.reject()}function Ne(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var i=localStorage.key(n);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return d(n,e),n}function Ve(e,t){var n=this;e=u(e);var i=n.ready().then((function(){var t=n._dbInfo,i=localStorage.getItem(t.keyPrefix+e);return i&&(i=t.serializer.deserialize(i)),i}));return d(i,t),i}function De(e,t){var n=this,i=n.ready().then((function(){for(var t=n._dbInfo,i=t.keyPrefix,s=i.length,r=localStorage.length,a=1,o=0;o<r;o++){var l=localStorage.key(o);if(0===l.indexOf(i)){var c=localStorage.getItem(l);if(c&&(c=t.serializer.deserialize(c)),void 0!==(c=e(c,l.substring(s),a++)))return c}}}));return d(i,t),i}function He(e,t){var n=this,i=n.ready().then((function(){var t,i=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return d(i,t),i}function Be(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,i=[],s=0;s<n;s++){var r=localStorage.key(s);0===r.indexOf(e.keyPrefix)&&i.push(r.substring(e.keyPrefix.length))}return i}));return d(n,e),n}function ke(e){var t=this.keys().then((function(e){return e.length}));return d(t,e),t}function Fe(e,t){var n=this;e=u(e);var i=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return d(i,t),i}function Ue(e,t,n){var i=this;e=u(e);var s=i.ready().then((function(){void 0===t&&(t=null);var n=t;return new c((function(s,r){var a=i._dbInfo;a.serializer.serialize(t,(function(t,i){if(i)r(i);else try{localStorage.setItem(a.keyPrefix+e,t),s(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||r(e),r(e)}}))}))}));return d(s,n),s}function Oe(e,t){if(t=p.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var i,s=this;return d(i=e.name?new c((function(t){e.storeName?t(ze(e,s._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):c.reject("Invalid arguments"),t),i}var Ye={_driver:"localStorageWrapper",_initStorage:Ze,_support:Ee(),iterate:De,getItem:Ve,setItem:Ue,removeItem:Fe,clear:Ne,length:ke,key:He,keys:Be,dropInstance:Oe},Ke=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},je=function(e,t){for(var n=e.length,i=0;i<n;){if(Ke(e[i],t))return!0;i++}return!1},Je=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Qe={},qe={},$e={INDEXEDDB:Y,WEBSQL:Xe,LOCALSTORAGE:Ye},et=[$e.INDEXEDDB._driver,$e.WEBSQL._driver,$e.LOCALSTORAGE._driver],tt=["dropInstance"],nt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),it={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function st(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function rt(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(Je(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var at=new(function(){function e(t){for(var n in s(this,e),$e)if($e.hasOwnProperty(n)){var i=$e[n],r=i._driver;this[n]=r,Qe[r]||this.defineDriver(i)}this._defaultConfig=rt({},it),this._config=rt({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":i(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var i=new c((function(t,n){try{var i=e._driver,s=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(s);for(var r=nt.concat("_initStorage"),a=0,o=r.length;a<o;a++){var l=r[a];if((!je(tt,l)||e[l])&&"function"!=typeof e[l])return void n(s)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=c.reject(t);return d(n,arguments[arguments.length-1]),n}},n=0,i=tt.length;n<i;n++){var s=tt[n];e[s]||(e[s]=t(s))}}();var h=function(n){Qe[i]&&console.info("Redefining LocalForage driver: "+i),Qe[i]=e,qe[i]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(h,n):h(!!e._support):h(!0)}catch(e){n(e)}}));return h(i,t,n),i},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var i=Qe[e]?c.resolve(Qe[e]):c.reject(new Error("Driver not found."));return h(i,t,n),i},e.prototype.getSerializer=function(e){var t=c.resolve(ye);return h(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return h(n,e,e),n},e.prototype.setDriver=function(e,t,n){var i=this;Je(e)||(e=[e]);var s=this._getSupportedDrivers(e);function r(){i._config.driver=i.driver()}function a(e){return i._extend(e),r(),i._ready=i._initStorage(i._config),i._ready}function o(e){return function(){var t=0;function n(){for(;t<e.length;){var s=e[t];return t++,i._dbInfo=null,i._ready=null,i.getDriver(s).then(a).catch(n)}r();var o=new Error("No available storage method found.");return i._driverSet=c.reject(o),i._driverSet}return n()}}var l=null!==this._driverSet?this._driverSet.catch((function(){return c.resolve()})):c.resolve();return this._driverSet=l.then((function(){var e=s[0];return i._dbInfo=null,i._ready=null,i.getDriver(e).then((function(e){i._driver=e._driver,r(),i._wrapLibraryMethodsWithReady(),i._initDriver=o(s)}))})).catch((function(){r();var e=new Error("No available storage method found.");return i._driverSet=c.reject(e),i._driverSet})),h(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!qe[e]},e.prototype._extend=function(e){rt(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,i=e.length;n<i;n++){var s=e[n];this.supports(s)&&t.push(s)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=nt.length;e<t;e++)st(this,nt[e])},e.prototype.createInstance=function(t){return new e(t)},e}());t.exports=at},{3:3}]},{},[4])(4)}(mC={exports:{}},mC.exports),mC.exports);class gC{constructor(e){this.name="EXT_mesh_gpu_instancing",this.parser=e}createNodeMesh(e){const t=this.parser.json.nodes[e];if(!t.extensions||!t.extensions[this.name]||void 0===t.mesh)return null;const n=t.extensions[this.name].attributes,i=[],s={};for(const e in n)i.push(this.parser.getDependency("accessor",n[e]).then((t=>(s[e]=t,s[e]))));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=e.matrix.clone(),n=e.position.clone().set(0,0,0),a=e.quaternion.clone().set(0,0,0,1),o=e.scale.clone().set(1,1,1),l=new Kl(e.geometry,e.material,i);for(let e=0;e<i;e++)s.TRANSLATION&&n.fromBufferAttribute(s.TRANSLATION,e),s.ROTATION&&a.fromBufferAttribute(s.ROTATION,e),s.SCALE&&o.fromBufferAttribute(s.SCALE,e),l.setMatrixAt(e,t.compose(n,a,o));for(const t in s)"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,s[t]);os.prototype.copy.call(l,e),l.frustumCulled=!1,this.parser.assignFinalMaterial(l),r.push(l)}if(t.isGroup){for(;t.children.length>0;)t.remove(t.children[0]);for(const e of r)t.add(e);return t}return r[0]})))}}const yC=()=>{self.noCompressWorker=function(e,t){const[n]=new Uint32Array(e,t,1),i={byteOffset:t+=4,length:3*n},s={byteOffset:t+=3*n*4,length:2*n},r={byteOffset:t+=2*n*4,length:4*n},a={byteOffset:t+=4*n*1,length:3*n};t+=3*n*1;let o=(r.length+a.length)%4;o>0&&(o=4-o,t+=o);const l=new Uint32Array(e,t,1);t+=4;const[c]=l,d={byteOffset:t,length:c};t+=4*c;const h=new Uint32Array(e,t,1);t+=4;const[u]=h,p=[];if(u>0)for(let n=0;n<u;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const a=new Uint8Array(e,t,r);t+=r;const o=(new TextDecoder).decode(a);p.push({start:n,count:i,uuid:o,alphaMode:s})}return{buffer:e,position:i,normal:a,color:r,texcoord:s,indice:d,sub_mesh:p}}},bC=()=>{self.gzipCompressWorker=function(e){const t=new Uint8Array(e,4,e.byteLength-4),n=new pako.Inflate;n.push(t,!0);const{result:i}=n;if(i instanceof Uint8Array){const{buffer:e}=i;let t=0;const[n]=new Uint32Array(e,t,1);t+=4;const s={byteOffset:t,length:3*n};t+=3*n*4;const r={byteOffset:t,length:2*n};t+=2*n*4;const a={byteOffset:t,length:4*n};t+=4*n*1;const o={byteOffset:t,length:3*n};t+=3*n*1;let l=(a.length+o.length)%4;l>0&&(l=4-l,t+=l);const c=new Uint32Array(e,t,1);t+=4;const[d]=c,h={byteOffset:t,length:d};t+=4*d;const u=new Uint32Array(e,t,1);t+=4;const[p]=u,m=[];if(p>0)for(let n=0;n<p;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const a=new Uint8Array(e,t,r);t+=r;const o=(new TextDecoder).decode(a);m.push({start:n,count:i,uuid:o,alphaMode:s})}return{buffer:e,position:s,normal:o,color:a,texcoord:r,indice:h,sub_mesh:m}}}},vC=()=>{self.parseChunkWorker=function(e){let t=0;const n=new Int8Array(e,t,128);t+=128,(new TextDecoder).decode(n.slice(0,4));const[i]=n.slice(4,8);if(0===i)return self.noCompressWorker(e,t);if(1===i){const t=e.slice(128);return self.gzipCompressWorker(t)}throw new Error("unknown compress mode [ .sbmx model ]")}},xC="\n onmessage = function ( e ) {\n \n const message = e.data\n\n switch ( message.type ) {\n\n case 'decode': {\n\n const chunkInfo = self.parseChunkWorker( message.data )\n\n if ( chunkInfo ) { \n\n self.postMessage( \n { type: 'decode', data: chunkInfo, }, \n [ chunkInfo.buffer ]\n )\n\n } else {\n\n self.postMessage( { type: 'decode', data: {}, } )\n\n }\n\n break\n \n }\n \n }\n\n }\n\n";class wC extends fh{constructor(e){super(),this.store=e,this.loadedTextures=new Map,this.loadedMaterialsMap=new Map,this.defaultMaterial=new kd({name:"defaultDatMaterial",color:0}),this.loadedMaterials=[this.defaultMaterial],this.dracoDecoderPath=null,this.workerPool=new zy(4),this.workerSourceURL="";const t=this._initWorkerCreator();this.workerPool.setWorkerCreator(t)}parseAsync(e,t){return tf(this,void 0,void 0,(function*(){const[n]=yield Promise.allSettled([this._decodeBuffer(e,t),this._createMaterial(t)]);if("fulfilled"===n.status&&n.value){const e=jm(t),i=this._createMesh(n.value,e),s=new qo;return s.add(i),s}}))}_decodeBuffer(e,t){return tf(this,void 0,void 0,(function*(){const n=yield this.store.getItem(`${t}_object`);if(n)return n;const[{data:i}]=yield Promise.all([this.workerPool.postMessage({type:"decode",data:e},[e])]);if(i){const{type:e,data:n}=null!=i?i:{};if("decode"===e&&n){const{buffer:{byteLength:e}}=n;return Jf(e)&&e/1024/1024<=500&&df((()=>{this.store.setItem(`${t}_object`,n)})),n}}}))}_initWorkerCreator(){if(!this.workerSourceURL){const e=yC.toString(),t=bC.toString(),n=vC.toString(),i=["/* dat decoder */",["/* pako */","\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pako = {}));\n}(this, (function (exports) { 'use strict';\n\n // Note: adler32 takes 12% for level 0 and 2% for level 6.\n // It isn't worth it to make additional optimizations as in original.\n // Small size is preferable.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express ofr implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const adler32 = (adler, buf, len, pos) => {\n let s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n };\n\n\n var adler32_1 = adler32;\n\n // Note: we can't get significant speed boost here.\n // So write code to minimize size - no pregenerated tables\n // and array tools dependencies.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // Use ordinary array, since untyped makes no boost here\n const makeTable = () => {\n let c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n };\n\n // Create table on load. Just 255 signed longs. Not a problem.\n const crcTable = new Uint32Array(makeTable());\n\n\n const crc32 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n\n crc ^= -1;\n\n for (let i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n };\n\n\n var crc32_1 = crc32;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // See state defs from inflate.js\n const BAD$1 = 30; /* got a data error -- remain here until reset */\n const TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n /*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n var inffast = function inflate_fast(strm, start) {\n let _in; /* local strm.input */\n let last; /* have enough input while in < last */\n let _out; /* local strm.output */\n let beg; /* inflate()'s initial strm.output */\n let end; /* while out < end, enough space available */\n //#ifdef INFLATE_STRICT\n let dmax; /* maximum distance from zlib header */\n //#endif\n let wsize; /* window size or zero if not using window */\n let whave; /* valid bytes in the window */\n let wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n let s_window; /* allocated sliding window, if wsize != 0 */\n let hold; /* local strm.hold */\n let bits; /* local strm.bits */\n let lcode; /* local strm.lencode */\n let dcode; /* local strm.distcode */\n let lmask; /* mask for first level of length codes */\n let dmask; /* mask for first level of distance codes */\n let here; /* retrieved table entry */\n let op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n let len; /* match length, unused bytes */\n let dist; /* match distance */\n let from; /* where to copy match from */\n let from_source;\n\n\n let input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n const state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n //#ifdef INFLATE_STRICT\n dmax = state.dmax;\n //#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n //#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n //#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // if (len <= op - whave) {\n // do {\n // output[_out++] = 0;\n // } while (--len);\n // continue top;\n // }\n // len -= op - whave;\n // do {\n // output[_out++] = 0;\n // } while (--op > whave);\n // if (op === 0) {\n // from = _out - dist;\n // do {\n // output[_out++] = output[from++];\n // } while (--len);\n // continue top;\n // }\n //#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const MAXBITS = 15;\n const ENOUGH_LENS$1 = 852;\n const ENOUGH_DISTS$1 = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const CODES$1 = 0;\n const LENS$1 = 1;\n const DISTS$1 = 2;\n\n const lbase = new Uint16Array([ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n ]);\n\n const lext = new Uint8Array([ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n ]);\n\n const dbase = new Uint16Array([ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n ]);\n\n const dext = new Uint8Array([ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n ]);\n\n const inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) =>\n {\n const bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n let len = 0; /* a code's length in bits */\n let sym = 0; /* index of code symbols */\n let min = 0, max = 0; /* minimum and maximum code lengths */\n let root = 0; /* number of index bits for root table */\n let curr = 0; /* number of index bits for current table */\n let drop = 0; /* code bits to drop for sub-table */\n let left = 0; /* number of prefix codes available */\n let used = 0; /* code entries in table used */\n let huff = 0; /* Huffman code */\n let incr; /* for incrementing code, index */\n let fill; /* index for replicating entries */\n let low; /* low bits for current root entry */\n let mask; /* mask for low root bits */\n let next; /* next available space in table */\n let base = null; /* base value table to use */\n let base_index = 0;\n // let shoextra; /* extra bits table to use */\n let end; /* use base and extra for symbol > end */\n const count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n const offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n let extra = null;\n let extra_index = 0;\n\n let here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n };\n\n\n var inftrees = inflate_table;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var constants$1 = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n\n\n\n\n\n const CODES = 0;\n const LENS = 1;\n const DISTS = 2;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_FINISH: Z_FINISH$1, Z_BLOCK, Z_TREES,\n Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR,\n Z_DEFLATED\n } = constants$1;\n\n\n /* STATES ====================================================================*/\n /* ===========================================================================*/\n\n\n const HEAD = 1; /* i: waiting for magic header */\n const FLAGS = 2; /* i: waiting for method and flags (gzip) */\n const TIME = 3; /* i: waiting for modification time (gzip) */\n const OS = 4; /* i: waiting for extra flags and operating system (gzip) */\n const EXLEN = 5; /* i: waiting for extra length (gzip) */\n const EXTRA = 6; /* i: waiting for extra bytes (gzip) */\n const NAME = 7; /* i: waiting for end of file name (gzip) */\n const COMMENT = 8; /* i: waiting for end of comment (gzip) */\n const HCRC = 9; /* i: waiting for header crc (gzip) */\n const DICTID = 10; /* i: waiting for dictionary check value */\n const DICT = 11; /* waiting for inflateSetDictionary() call */\n const TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n const TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\n const STORED = 14; /* i: waiting for stored size (length and complement) */\n const COPY_ = 15; /* i/o: same as COPY below, but only first time in */\n const COPY = 16; /* i/o: waiting for input or output to copy stored block */\n const TABLE = 17; /* i: waiting for dynamic block table lengths */\n const LENLENS = 18; /* i: waiting for code length code lengths */\n const CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\n const LEN_ = 20; /* i: same as LEN below, but only first time in */\n const LEN = 21; /* i: waiting for length/lit/eob code */\n const LENEXT = 22; /* i: waiting for length extra bits */\n const DIST = 23; /* i: waiting for distance code */\n const DISTEXT = 24; /* i: waiting for distance extra bits */\n const MATCH = 25; /* o: waiting for output space to copy string */\n const LIT = 26; /* o: waiting for output space to write literal */\n const CHECK = 27; /* i: waiting for 32-bit check value */\n const LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\n const DONE = 29; /* finished check, done -- remain here until reset */\n const BAD = 30; /* got a data error -- remain here until reset */\n const MEM = 31; /* got an inflate() memory error -- remain here until reset */\n const SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n /* ===========================================================================*/\n\n\n\n const ENOUGH_LENS = 852;\n const ENOUGH_DISTS = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const MAX_WBITS = 15;\n /* 32K LZ77 window */\n const DEF_WBITS = MAX_WBITS;\n\n\n const zswap32 = (q) => {\n\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n };\n\n\n function InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Int32Array(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n }\n\n\n const inflateResetKeep = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\"));\n return Z_OK$1;\n };\n\n\n const inflateReset = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n };\n\n\n const inflateReset2 = (strm, windowBits) => {\n let wrap;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n };\n\n\n const inflateInit2 = (strm, windowBits) => {\n\n if (!strm) { return Z_STREAM_ERROR$1; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n const state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n };\n\n\n const inflateInit = (strm) => {\n\n return inflateInit2(strm, DEF_WBITS);\n };\n\n\n /*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\n let virgin = true;\n\n let lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\n\n const fixedtables = (state) => {\n\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n let sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inftrees(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inftrees(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n };\n\n\n /*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\n const updatewindow = (strm, src, end, copy) => {\n\n let dist;\n const state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n };\n\n\n const inflate$1 = (strm, flush) => {\n\n let state;\n let input, output; // input/output buffers\n let next; /* next input INDEX */\n let put; /* next output INDEX */\n let have, left; /* available input and output */\n let hold; /* bit buffer */\n let bits; /* bits in bit buffer */\n let _in, _out; /* save starting available input and output */\n let copy; /* number of stored or match bytes to copy */\n let from; /* where to copy match bytes from */\n let from_source;\n let here = 0; /* current decoding table entry */\n let here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //let last; /* parent table entry */\n let last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n let len; /* length to copy for repeats, bits to drop */\n let ret; /* return code */\n const hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n let opts;\n\n let n; // temporary variable for NEED_BITS\n\n const order = /* permutation of code lengths */\n new Uint8Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]);\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR$1;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK$1;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n\n // !!! pako patch. Force use `options.windowBits` if passed.\n // Required to always use max window size by default.\n state.dmax = 1 << state.wbits;\n //state.dmax = 1 << len;\n\n //Tracev((stderr, \"inflate: zlib header ok\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32_1(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n output.set(input.subarray(next, next + copy), put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n //#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracev((stderr, \"inflate: table sizes ok\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inftrees(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inftrees(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inffast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracevv((stderr, \"inflate: distance %u\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // Trace((stderr, \"inflate.c too far\"));\n // copy -= state.whave;\n // if (copy > state.length) { copy = state.length; }\n // if (copy > left) { copy = left; }\n // left -= copy;\n // state.length -= copy;\n // do {\n // output[put++] = 0;\n // } while (--copy);\n // if (state.length === 0) { state.mode = LEN; }\n // break;\n //#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, put - _out) : adler32_1(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH$1))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n };\n\n\n const inflateEnd = (strm) => {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR$1;\n }\n\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n };\n\n\n const inflateGetHeader = (strm, head) => {\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR$1; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK$1;\n };\n\n\n const inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n\n let state;\n let dictid;\n let ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR$1; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32_1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\"));\n return Z_OK$1;\n };\n\n\n var inflateReset_1 = inflateReset;\n var inflateReset2_1 = inflateReset2;\n var inflateResetKeep_1 = inflateResetKeep;\n var inflateInit_1 = inflateInit;\n var inflateInit2_1 = inflateInit2;\n var inflate_2$1 = inflate$1;\n var inflateEnd_1 = inflateEnd;\n var inflateGetHeader_1 = inflateGetHeader;\n var inflateSetDictionary_1 = inflateSetDictionary;\n var inflateInfo = 'pako inflate (from Nodeca project)';\n\n /* Not implemented\n module.exports.inflateCopy = inflateCopy;\n module.exports.inflateGetDictionary = inflateGetDictionary;\n module.exports.inflateMark = inflateMark;\n module.exports.inflatePrime = inflatePrime;\n module.exports.inflateSync = inflateSync;\n module.exports.inflateSyncPoint = inflateSyncPoint;\n module.exports.inflateUndermine = inflateUndermine;\n */\n\n var inflate_1$1 = {\n \tinflateReset: inflateReset_1,\n \tinflateReset2: inflateReset2_1,\n \tinflateResetKeep: inflateResetKeep_1,\n \tinflateInit: inflateInit_1,\n \tinflateInit2: inflateInit2_1,\n \tinflate: inflate_2$1,\n \tinflateEnd: inflateEnd_1,\n \tinflateGetHeader: inflateGetHeader_1,\n \tinflateSetDictionary: inflateSetDictionary_1,\n \tinflateInfo: inflateInfo\n };\n\n const _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n\n var assign = function (obj /*from1, from2, from3, ...*/) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n };\n\n\n // Join array of chunks to single array.\n var flattenChunks = (chunks) => {\n // calculate data length\n let len = 0;\n\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n const result = new Uint8Array(len);\n\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n };\n\n var common = {\n \tassign: assign,\n \tflattenChunks: flattenChunks\n };\n\n // String encode/decode helpers\n\n\n // Quick check if we can use fast array to bin string conversion\n //\n // - apply(Array) can fail on Android 2.2\n // - apply(Uint8Array) can fail on iOS 5.1 Safari\n //\n let STR_APPLY_UIA_OK = true;\n\n try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n // Table with utf8 lengths (calculated by first byte of sequence)\n // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n // because max possible codepoint is 0x10ffff\n const _utf8len = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n }\n _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n // convert string to array (typed, when possible)\n var string2buf = (str) => {\n if (typeof TextEncoder === 'function' && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n };\n\n // Helper\n const buf2binstring = (buf, len) => {\n // On Chrome, the arguments in a function call that are allowed is `65534`.\n // If the length of the buffer is smaller than that, we can use this optimization,\n // otherwise we will take a slower path.\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n\n let result = '';\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n\n\n // convert array to string\n var buf2string = (buf, max) => {\n const len = max || buf.length;\n\n if (typeof TextDecoder === 'function' && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n\n let i, out;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n const utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n let c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n let c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n };\n\n\n // Calculate max possible position in utf8 buffer,\n // that will not break sequence. If that's not possible\n // - (very small limits) return max size as is.\n //\n // buf[] - utf8 bytes array\n // max - length limit (mandatory);\n var utf8border = (buf, max) => {\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n };\n\n var strings = {\n \tstring2buf: string2buf,\n \tbuf2string: buf2string,\n \tutf8border: utf8border\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n }\n\n var zstream = ZStream;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n }\n\n var gzheader = GZheader;\n\n const toString = Object.prototype.toString;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_NO_FLUSH, Z_FINISH,\n Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR\n } = constants$1;\n\n /* ===========================================================================*/\n\n\n /**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n /* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n /**\n * Inflate.result -> Uint8Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param).\n **/\n\n /**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n /**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n /**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako')\n * const chunk1 = new Uint8Array([1,2,3,4,5,6,7,8,9])\n * const chunk2 = new Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * const inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\n function Inflate(options) {\n this.options = common.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ''\n }, options || {});\n\n const opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new zstream();\n this.strm.avail_out = 0;\n\n let status = inflate_1$1.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n\n this.header = new gzheader();\n\n inflate_1$1.inflateGetHeader(this.strm, this.header);\n\n // Setup dictionary\n if (opt.dictionary) {\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n opt.dictionary = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) { //In raw mode we need to set the dictionary early\n status = inflate_1$1.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n }\n }\n }\n\n /**\n * Inflate#push(data[, flush_mode]) -> Boolean\n * - data (Uint8Array|ArrayBuffer): input data\n * - flush_mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE\n * flush modes. See constants. Skipped or `false` means Z_NO_FLUSH,\n * `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. If end of stream detected,\n * [[Inflate#onEnd]] will be called.\n *\n * `flush_mode` is not needed for normal operation, because end of stream\n * detected automatically. You may try to use it for advanced things, but\n * this functionality was not tested.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\n Inflate.prototype.push = function (data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n\n if (this.ended) return false;\n\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n\n // Convert data if needed\n if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n for (;;) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate_1$1.inflate(strm, _flush_mode);\n\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$1.inflateSetDictionary(strm, dictionary);\n\n if (status === Z_OK) {\n status = inflate_1$1.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n // Replace code with more verbose\n status = Z_NEED_DICT;\n }\n }\n\n // Skip snyc markers if more data follows and not raw mode\n while (strm.avail_in > 0 &&\n status === Z_STREAM_END &&\n strm.state.wrap > 0 &&\n data[strm.next_in] !== 0)\n {\n inflate_1$1.inflateReset(strm);\n status = inflate_1$1.inflate(strm, _flush_mode);\n }\n\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n // Remember real `avail_out` value, because we may patch out buffer content\n // to align utf8 strings boundaries.\n last_avail_out = strm.avail_out;\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n\n if (this.options.to === 'string') {\n\n let next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail & realign counters\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n\n this.onData(utf8str);\n\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n\n // Must repeat iteration if out buffer is full\n if (status === Z_OK && last_avail_out === 0) continue;\n\n // Finalize if end of stream reached.\n if (status === Z_STREAM_END) {\n status = inflate_1$1.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n\n if (strm.avail_in === 0) break;\n }\n\n return true;\n };\n\n\n /**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|String): output data. When string output requested,\n * each chunk will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\n Inflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n };\n\n\n /**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH). By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\n Inflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = common.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n\n\n /**\n * inflate(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako');\n * const input = pako.deflate(new Uint8Array([1,2,3,4,5,6,7,8,9]));\n * let output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err) {\n * console.log(err);\n * }\n * ```\n **/\n function inflate(input, options) {\n const inflator = new Inflate(options);\n\n inflator.push(input);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) throw inflator.msg || messages[inflator.err];\n\n return inflator.result;\n }\n\n\n /**\n * inflateRaw(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n }\n\n\n /**\n * ungzip(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\n var Inflate_1 = Inflate;\n var inflate_2 = inflate;\n var inflateRaw_1 = inflateRaw;\n var ungzip = inflate;\n var constants = constants$1;\n\n var inflate_1 = {\n \tInflate: Inflate_1,\n \tinflate: inflate_2,\n \tinflateRaw: inflateRaw_1,\n \tungzip: ungzip,\n \tconstants: constants\n };\n\n exports.Inflate = Inflate_1;\n exports.constants = constants;\n exports['default'] = inflate_1;\n exports.inflate = inflate_2;\n exports.inflateRaw = inflateRaw_1;\n exports.ungzip = ungzip;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n\n","/* noCompress */",e.substring(e.indexOf("{")+1,e.lastIndexOf("}")),"/* gzipCompress */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),"/* parseChunk */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n"),"","/* worker */",xC].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}return()=>new Worker(this.workerSourceURL)}_createMesh(e,t){const{buffer:n,position:i,normal:s,texcoord:r,indice:a,sub_mesh:o}=e,l=new Uint32Array(n,a.byteOffset,a.length),c=new Float32Array(n,i.byteOffset,i.length),d=new Int8Array(n,s.byteOffset,s.length),h=new Float32Array(n,r.byteOffset,r.length),u=new Bs;u.setIndex(new Ts(l,1)),u.setAttribute("position",new Ts(c,3)),u.setAttribute("normal",new Ts(d,3,!0)),u.setAttribute("uv",new Ts(h,2));for(let e=0;e<o.length;e++){const{uuid:n,start:i,count:s}=o[e],r=this.loadedMaterialsMap.get(n);if(r){const{materialIndex:e}=r;u.addGroup(i,s,e)}else u.addGroup(i,s,0),console.warn(`sbmx material: not found uuid: ${n} in file: ${t+"textureIndex.json"}`)}Hy.generate(u).then((e=>{u.boundsTree=e}));const p=new ar(u,this.loadedMaterials);return p.castShadow=!0,p.receiveShadow=!0,p}_createMaterial(e){return tf(this,void 0,void 0,(function*(){const t=jm(e),n=t+"textureIndex.json",i=this.loadedTextures.get(n);if(i)return i;const s=yield this.store.getItem(`${e}_texture`);let r;if(s)r=s,this.loadedTextures.set(n,Promise.resolve(r));else{const t=this.loadedTextures.get(n);if(t)return t;const i=cf(n).then((e=>e.json()));this.loadedTextures.set(n,i),r=yield i,df((()=>{this.store.setItem(`${e}_texture`,r)}))}Object.entries(r).forEach((([e,n])=>{if(this.loadedMaterialsMap.has(e))return;const{name:i,base_map:s,nor_map:r,alphamode:a,color:o={r:1,g:1,b:1,a:1},metallic:l=.5,roughness:c=.5}=n,{r:d,g:h,b:u,a:p}=o,m=0!==a,f=new kd({name:i,color:new Fn(d,h,u),side:0,metalness:l,roughness:c,opacity:p,transparent:m,depthWrite:!m});if(s){const e=t+s;(new Sh).load(e,(e=>{e.flipY=!0,e.encoding=3001,e.wrapS=1e3,e.wrapT=1e3,e.minFilter=1008,e.magFilter=1006,e.needsUpdate=!0,f.map=e,f.needsUpdate=!0,Yx.needsUpdate=!0}))}if(r){const e=t+r;(new Sh).load(e,(e=>{e.flipY=!0,e.encoding=3001,e.wrapS=1e3,e.wrapT=1e3,e.needsUpdate=!0,f.normalMap=e,f.needsUpdate=!0,Yx.needsUpdate=!0}))}const g=this.loadedMaterials.push(f)-1;this.loadedMaterialsMap.set(e,{material:f,materialIndex:g})}))}))}dispose(){this.workerPool.dispose(),URL.revokeObjectURL(this.workerSourceURL)}}const MC=new Map,SC=e=>{if(MC.has(e))return MC.get(e);const t=new Jn;return MC.set(e,t),(new xh).load(e,(e=>{t.image=e,t.needsUpdate=!0,Yx.needsUpdate=!0})),t.encoding=3001,t.wrapS=1e3,t.wrapT=1e3,t.flipY=!1,t.anisotropy=16,t.mipmaps=[],t.generateMipmaps=!0,t},TC=(e,t,n)=>{const[i,s,r,a,o]=t,l=a<1;return new kd({name:e,color:new Fn(i,s,r),opacity:a,transparent:l,depthWrite:!l,alphaTest:.01,map:n,side:o})};class CC extends DataView{constructor(e,t){super(e),this.isLE=!0,this.appKeys=t}byteRevers(e,t){const n=t%this.appKeys.length;return e^this.appKeys[n]}getSoonUint8(e){return this.byteRevers(this.getUint8(e),e)}getSoonUint16(e){const t=new DataView(new Uint8Array(2).buffer);for(let n=0;n<2;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getUint16(0,this.isLE)}getSoonUint32(e){const t=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getUint32(0,this.isLE)}getSoonFloat32(e){const t=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getFloat32(0,this.isLE)}}class LC{constructor(){this.materials=new Map}parseObject(e,t){const n=new iw(Object.assign(Object.assign({},t),{format:"sbm"})),i=new ew({id:ng()});n.add(i);const{materialsCache:s,meshsCache:r}=e;for(const[e,t]of Object.entries(s)){if(this.materials.has(e))continue;const{textureUrl:n,materialInfo:i}=t;let s=null;n&&(s=SC(n));const r=TC(e,i,s);this.materials.set(e,r)}for(const[e,t]of Object.entries(r)){const{materialId:n,position:s,uv:r}=t,a=this.materials.get(n.toString());if(a){const t=new Bs,n=new Float32Array(s),o=new Float32Array(r);n.length>0&&t.setAttribute("position",new Ts(n,3)),o.length>0&&t.setAttribute("uv",new Ts(o,2)),t.computeVertexNormals(),Hy.generate(t).then((e=>{t.boundsTree=e}));const l=new Qx(t,a,{id:`${e}_${ng()}`,name:e});i.add(l)}}return n}}var GC=class{constructor(){this.materials=new Map,this.sbmInfo=null}parseBuffer(e,t,n){return tf(this,void 0,void 0,(function*(){this.sbmInfo=t;const i=new DataView(e);let s=0;const r=[];for(let e=0;e<8;e++)r.push(i.getUint8(s)),s+=1;if("SBK-----"!==String.fromCharCode(...r))return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})格式或数据错误!`);const a=[],o=[],l=[];for(let e=0;e<32;e++)a.push(i.getUint8(s)),s+=1;const c=i.getUint8(s);s+=1;const d=i.getUint8(s);s+=1;for(let e=0;e<32;e++)o.push(i.getUint8(s)),s+=1;for(let e=0;e<64;e++)l.push(i.getUint8(s)),s+=1;const h=[...o,...l,...a],u=[];for(let e=0;e<h.length;e++)(e<=7||e>23&&e<=31||e>39&&e<=55||e>63&&e<=87||e>95&&e<=103)&&u.push(h[e]);if(64!==u.length)return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url} 数据错误!`);if(1===c){const e=i.buffer.slice(s,i.buffer.byteLength),t=new CC(e,u);return 1===d||2===d?this._parseV2(t,n):3===d?this._parseV3(t,n):Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})版本错误!`)}return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})key 错误!`)}))}_parseV2(e,t){let n=0;const i=performance.now();n+=66;const s={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const r=new iw(Object.assign(Object.assign({},this.sbmInfo),{format:"sbm"})),a=new ew({id:ng()});r.add(a);const o=e.getSoonUint16(n);n+=2;const l=e.getSoonUint16(n);n+=2,s.total=l;const c={};for(let t=0;t<o;++t){const t=e.getSoonUint16(n).toString();n+=2,c[t]={materialInfo:[]},n+=4,n+=4,n+=4,n+=4;const i=e.getSoonFloat32(n);n+=4;const s=e.getSoonFloat32(n);n+=4;const r=e.getSoonFloat32(n);n+=4;const a=e.getSoonFloat32(n);n+=4,n+=4,n+=4,n+=4,n+=4;let o=e.getSoonUint8(n);n+=1,0===o?o=0:1===o?o=1:2===o&&(o=2);const l=e.getSoonUint16(n);n+=2;let d=null;if(l>0){let i="",s="";for(let t=0;t<l;t++){const t=e.getSoonUint8(n);t>127?s=s+"%"+t.toString(16).toUpperCase():s.length>0?(i+=decodeURIComponent(s)+String.fromCharCode(t),s=""):i+=String.fromCharCode(t),n+=1}i=i.replace("\\","/");const{url:r,isPlatform:a}=this.sbmInfo,o=this.getTextureUrl(r,i,a);c[t].textureUrl=o,d=SC(o)}if(!this.materials.has(t)){const e=[i,s,r,a,o],n=TC(t,e,d);this.materials.set(t,n),c[t].materialInfo=e}}const d={};for(let r=0;r<l;++r){const r=e.getSoonUint16(n);n+=2;const o=e.getSoonUint16(n).toString();n+=2,d[r]={materialId:o,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const l=[],c=[],h=[],u=[],p=e.getSoonUint16(n);if(n+=2,p>0)for(let t=0;t<p;t++){const t=new ri;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,t.setZ(e.getSoonFloat32(n)),n+=4,l.push(t)}const m=e.getSoonUint16(n);if(n+=2,m>0)for(let t=0;t<m;t++){const t=new ri;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,t.setZ(e.getSoonFloat32(n)),n+=4}const f=e.getSoonUint16(n);if(n+=2,f>0)for(let t=0;t<f;t++){const t=new Rn;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,c.push(t)}const g=e.getSoonUint16(n);if(n+=2,g>0)for(let t=0;t<g;t++){const t=e.getSoonUint16(n);n+=2;const i=e.getSoonUint16(n);n+=2;const s=e.getSoonUint16(n);n+=2;const r=[t,i,s];h.push(r),c.length>0&&u.push([c[r[0]],c[r[1]],c[r[2]]])}const y=[],b=[];for(let e=0;e<h.length;e++){const t=h[e],n=l[t[0]],i=l[t[1]],s=l[t[2]];y.push(...n.toArray(),...i.toArray(),...s.toArray());let r=new Rn,a=new Rn,o=new Rn;const c=u[e];void 0!==c&&(r=c[0],a=c[1],o=c[2]),b.push(...r.toArray(),...a.toArray(),...o.toArray())}const v=new Float32Array(y),x=new Float32Array(b);d[r].position=v.buffer,d[r].uv=x.buffer;const w=new Bs;v.length>0&&w.setAttribute("position",new Ts(v,3)),x.length>0&&w.setAttribute("uv",new Ts(x,2)),w.computeVertexNormals(),Hy.generate(w).then((e=>{w.boundsTree=e}));const M=this.materials.get(o);if(M){const e=new Qx(w,M,{id:`${r}_${ng()}`,name:r.toString()});a.add(e)}s.loaded++,s.timeStamp=performance.now()-i,null==t||t(s)}const h={materialsCache:c,meshsCache:d};return Promise.resolve({model:r,caches:h})}_parseV3(e,t){let n=0;n+=66;const i=performance.now(),s={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const r=new iw(Object.assign(Object.assign({},this.sbmInfo),{format:"sbm"})),a=new ew({id:ng()});r.add(a);const o=e.getSoonUint16(n);n+=2;const l=e.getSoonUint16(n);n+=2,s.total=l;const c={};for(let t=0;t<o;++t){const t=e.getSoonUint16(n).toString();n+=2,c[t]={materialInfo:[]},n+=4,n+=4,n+=4,n+=4;const i=e.getSoonFloat32(n);n+=4;const s=e.getSoonFloat32(n);n+=4;const r=e.getSoonFloat32(n);n+=4;const a=e.getSoonFloat32(n);n+=4,n+=4,n+=4,n+=4,n+=4;let o=e.getSoonUint8(n);n+=1,0===o?o=0:1===o?o=1:2===o&&(o=2);const l=e.getSoonUint16(n);n+=2;let d=null;if(l>0){let i="",s="";for(let t=0;t<l;t++){const t=e.getSoonUint8(n);t>127?s=s+"%"+t.toString(16).toUpperCase():s.length>0?(i+=decodeURIComponent(s)+String.fromCharCode(t),s=""):i+=String.fromCharCode(t),n+=1}i=i.replace("\\","/");const{url:r,isPlatform:a}=this.sbmInfo,o=this.getTextureUrl(r,i,a);c[t].textureUrl=o,d=SC(o)}if(!this.materials.has(t)){const e=[i,s,r,a,o],n=TC(t,e,d);this.materials.set(t,n),c[t].materialInfo=e}}const d={};for(let r=0;r<l;++r){const r=e.getSoonUint16(n).toString();n+=2;const o=e.getSoonUint16(n);n+=2;let l="";if(o>0){let t="";for(let i=0;i<o;i++){const i=e.getUint8(n);i>127?t=t+"%"+i.toString(16).toUpperCase():t.length>0?(l+=decodeURIComponent(t)+String.fromCharCode(i),t=""):l+=String.fromCharCode(i),n+=1}}const c=e.getSoonUint16(n).toString();n+=2,d[r]={materialId:c,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const h=[],u=[],p=[],m=[],f=e.getSoonUint32(n);if(n+=4,f>0)for(let t=0;t<f;t++){const t=new ri;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,t.setZ(e.getSoonFloat32(n)),n+=4,h.push(t)}const g=e.getSoonUint32(n);if(n+=4,g>0)for(let t=0;t<g;t++){const t=new ri;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,t.setZ(e.getSoonFloat32(n)),n+=4}const y=e.getSoonUint32(n);if(n+=4,y>0)for(let t=0;t<y;t++){const t=new Rn;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,u.push(t)}const b=e.getSoonUint32(n);if(n+=4,b>0)for(let t=0;t<b;t++){const t=e.getSoonUint32(n);n+=4;const i=e.getSoonUint32(n);n+=4;const s=e.getSoonUint32(n);n+=4;const r=[t,i,s];p.push(r),u.length>0&&m.push([u[r[0]],u[r[1]],u[r[2]]])}const v=[],x=[];for(let e=0;e<p.length;e++){const t=p[e],n=h[t[0]],i=h[t[1]],s=h[t[2]];v.push(...n.toArray(),...i.toArray(),...s.toArray());let r=new Rn,a=new Rn,o=new Rn;const l=m[e];void 0!==l&&(r=l[0],a=l[1],o=l[2]),x.push(...r.toArray(),...a.toArray(),...o.toArray())}const w=new Float32Array(v),M=new Float32Array(x);d[r].position=w.buffer,d[r].uv=M.buffer;const S=new Bs;if(w.length>0&&S.setAttribute("position",new Ts(w,3)),M.length>0&&S.setAttribute("uv",new Ts(M,2)),S.computeVertexNormals(),Hy.generate(S).then((e=>{S.boundsTree=e})),this.materials.has(c)){const e=new Qx(S,this.materials.get(c),{id:`${r}_${ng()}`,name:l});a.add(e)}s.loaded++,s.timeStamp=performance.now()-i,null==t||t(s)}const h={materialsCache:c,meshsCache:d};return Promise.resolve({model:r,caches:h})}getTextureUrl(e,t,n){let i="",s=t;const r=s.lastIndexOf("/");if(-1!==r&&(s=s.substring(r+1)),i=e,n){const e=i.split("/");e.length>1&&(e.splice(e.length-3,e.length),i=e.join("/")+"/Maps/"+s)}else{const e=i.lastIndexOf("/");-1!==e&&(i=i.substring(0,e+1)+"Maps/"+s)}return i}};class RC extends vw{constructor(e,t){super("Model",e,t),this.viewport=e,this.isDisposed=!1,this.modelsPromiseMap=new Map,this.modelsMap=new Map,this.store=fC.createInstance({name:"soonspace",storeName:"modelData"}),this.cacheStore=fC.createInstance({name:"soonspace",storeName:"modelCache"}),this.loadingManager=new ph,this.datLoader=new wC(this.cacheStore),this.gltfLoader=new cT(this.loadingManager),this.fbxLoader=new kS(this.loadingManager),this.dracoDecoderPath=null,this.gltfLoader.register((e=>new gC(e))),this._initLoadingManager(this.loadingManager)}setDracoDecoderPath(e){this.dracoDecoderPath=e;const t=new uC;t.setDecoderPath(e),this.gltfLoader.setDRACOLoader(t),this.datLoader.dracoDecoderPath=e}load(e,t=this.scene){return tf(this,void 0,void 0,(function*(){const{url:n}=e,i=this.modelsPromiseMap.get(n);if(i){if(yield i,this.isDisposed)return this.dispose(),null;const s=this.modelsMap.get(n);return s?this.clone(s,e,t):null}const s=this._innerLoad(e,t);return this.modelsPromiseMap.set(n,s),s}))}parse(e){return tf(this,void 0,void 0,(function*(){const{url:t,id:n}=e;if(!t)return Wm(`id: ${n} url: ${t} is empty`),null;switch(t.slice(t.lastIndexOf(".")+1).toLocaleUpperCase()){case"SBM":return this._parseSbm(e);case"SBMX":return this._parseSbmx(e);case"DAT":return this._parseDat(e);case"GLB":case"GLTF":return this._parseGltf(e);case"FBX":return this._parseFbx(e);default:return Wm(`模型资源( id: ${n}, url: ${t} )格式错误,当前格式支持 sbm、sbmx、fbx、gltf、glb !`),null}}))}clone(e,t,n){return new Promise(((i,s)=>{var r;"Model"!==e.stype&&s("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:a,name:o,level:l,visible:c,position:d,rotation:h,scale:u,onClick:p,onDblClick:m,onRightClick:f,onLoad:g,userData:y}=t;function b(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)b(e.children[i],t.children[i],n)}const v=function(e){const t=new Map,n=new Map,i=e.sClone();return b(e,i,(function(e,i){t.set(i,e),n.set(e,i)})),i.traverse((function(e){if(e instanceof Zl){const i=e,s=t.get(e),r=s.skeleton.bones;i.skeleton=s.skeleton.clone(),i.bindMatrix.copy(s.bindMatrix),i.skeleton.bones=r.map((function(e){return n.get(e)})),i.bind(i.skeleton,i.bindMatrix)}})),i}(e);v.animations=v.animations.map((e=>e.clone())),a&&(v.sid=a),o&&(v.name=o),l&&(v.level=l),!1===c&&v.hide(),d&&v.position.set(d.x,d.y,d.z),h&&v.rotation.set(h.x,h.y,h.z),u&&v.scale.set(u.x,u.y,u.z),v.onClick=p?p.bind(v):null,v.onDblClick=m?m.bind(v):null,v.onRightClick=f?f.bind(v):null,v.onLoad=g?g.bind(v):null,null===(r=v.onLoad)||void 0===r||r.call(v,v),y&&(v.userData=y),null!==n&&this.viewport.scener.addObject(v,n||this.scene||e.parent),i(v)}))}loadToGroup(e,t){return tf(this,void 0,void 0,(function*(){const n=this.createGroup(e,null);return yield Promise.allSettled(t.map((e=>this.load(e,null).then((e=>e&&n.add(e))).catch(console.error)))),this.viewport.scener.addObject(n,this.scene),n}))}addForGroup(e,t){return tf(this,void 0,void 0,(function*(){return e&&(yield Promise.allSettled(t.map((t=>tf(this,void 0,void 0,(function*(){return this.load(t,null).then((t=>t&&this.viewport.scener.addObject(t,e))).catch(console.error)})))))),e}))}clearIdb(){return tf(this,void 0,void 0,(function*(){yield this.store.clear(),yield this.cacheStore.clear()}))}dispose(){var e;this.isDisposed=!0,this.modelsPromiseMap.clear(),this.modelsMap.clear(),null===(e=this.gltfLoader.dracoLoader)||void 0===e||e.dispose(),this.datLoader.dispose()}_initLoadingManager(e){e.addHandler(/\.tga$/i,new lT)}_setModelsMap(e,t){this.modelsMap.has(e)||this.modelsMap.set(e,t)}_parseSbm(e){return tf(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options,{url:n}=e,i=t=>tf(this,void 0,void 0,(function*(){const i=yield(new GC).parseBuffer(t,e),{model:s,caches:r}=i;return r&&df((()=>{this.cacheStore.setItem(n,r)})),s})),s=e=>{var t;null===(t=e.onLoad)||void 0===t||t.call(e,e)};if(t){const t=yield this.cacheStore.getItem(n);if(t){const n=(new LC).parseObject(t,e);return s(n),n}{const e=(yield this.store.getItem(n))||(yield this._fetchBuffer(n)),t=yield i(e);return s(t),t}}{const e=yield this._fetchBuffer(n),t=yield i(e);return s(t),t}}))}_parseSbmx(e){return tf(this,void 0,void 0,(function*(){const{url:t}=e,n=yield this._getBuffer(t),i=tg(n,0,8),s=new DataView(n.slice(8));switch(i){case"SBMG----":for(let e=0;e<s.byteLength;e++){const t=s.getUint8(e),n=(t>>4&15)+(t<<4&240);s.setUint8(e,n)}return this._parseGltf(e,s.buffer);case"SBMD----":return this._parseDat(e,s.buffer);default:return this._parseGltf(e,s.buffer)}}))}_parseDat(e,t){return tf(this,void 0,void 0,(function*(){const{url:n}=e,i=t||(yield this._getBuffer(n)),s=new iw(Object.assign(Object.assign({},e),{format:"dat"})),r=yield this.datLoader.parseAsync(i,n);return r&&s.add(r),s}))}_parseGltf(e,t){return tf(this,void 0,void 0,(function*(){const{url:n}=e,i=jm(n),s=t||(yield this._getBuffer(n)),r=new iw(Object.assign(Object.assign({},e),{format:"gltf"})),a=yield this.gltfLoader.parseAsync(s,i),{animations:o}=a;return o&&o.length>0&&(r.animations=o),a.scene.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0,e instanceof ar&&Hy.generate(e.geometry).then((t=>{e.geometry.boundsTree=t}))})),r.add(a.scene),r}))}_parseFbx(e){return tf(this,void 0,void 0,(function*(){const{url:t}=e,n=jm(t),i=yield this._getBuffer(t),s=new iw(Object.assign(Object.assign({},e),{format:"gltf"})),r=this.fbxLoader.parse(i,n),{animations:a}=r;return a&&a.length>0&&(s.animations=a),r.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0,e instanceof ar&&Hy.generate(e.geometry).then((t=>{e.geometry.boundsTree=t}))})),s.add(r),s}))}_innerLoad(e,t=this.scene){var n;return tf(this,void 0,void 0,(function*(){const{url:i}=e,s=yield this.parse(e);return s?(null===(n=s.onLoad)||void 0===n||n.call(s,s),this._setModelsMap(i,s),null!==t&&this.viewport.scener.addObject(s,t),s):null}))}_fetchBuffer(e){return tf(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options,n=yield cf(e),i=yield n.arrayBuffer();return t&&this.store.setItem(e,i),i}))}_getBuffer(e){return tf(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options;if(t){const t=yield this.store.getItem(e);return t||this._fetchBuffer(e)}return this._fetchBuffer(e)}))}}class _C extends vw{constructor(e,t){super("Poi",e,t),this.materials=new Map}create(e){const t=this._createMaterial(e.url),n=new aw(t,e);return this.viewport.scener.addObject(n,this.scene),n}clone(e,t,n){"Poi"!==e.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:i,name:s,level:r,visible:a,position:o,rotation:l,scale:c,onClick:d,onDblClick:h,onRightClick:u,userData:p}=t,m=e.sClone(!1);return this._copyMaterial(m),i&&(m.sid=i),s&&(m.name=s),r&&(m.level=r),jf(a)&&(m.visible=a),o&&m.position.set(o.x,o.y,o.z),l&&m.rotation.set(l.x,l.y,l.z),c&&m.scale.set(c.x,c.y,c.z),m.onClick=d?d.bind(m):null,m.onDblClick=h?h.bind(m):null,m.onRightClick=u?u.bind(m):null,p&&(m.userData=p),null!==n&&this.viewport.scener.addObject(m,n||this.scene||e.parent),m}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this._createMaterial(e.url),i=new aw(t,e);n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{const n=this._createMaterial(t.url),i=new aw(n,t);e.add(i)})),this.viewport.scener.addObject(e,this.scene)),e}_createMaterial(e){const t=this.materials.get(e);if(!t){const t=(new Sh).load(e);t.flipY=!0;const n=new pl({map:t,color:16777215});return this.materials.set(e,n),n}return t}_copyMaterial(e){e.traverse((e=>{(e instanceof ar||e instanceof Gl)&&(Qf(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof xs&&(e.material=e.material.clone()))}))}}class AC extends vw{constructor(e,t){super("PoiNode",e,t)}create(e){this._openEnableRenderCss(e);const t=new nw(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{this._openEnableRenderCss(e);const t=new nw(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{this._openEnableRenderCss(t);const n=new nw(t);e.add(n)})),this.viewport.scener.addObject(e,this.scene)),e}_openEnableRenderCss(e){switch(e.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class IC extends vw{constructor(e,t){super("Canvas3D",e,t)}create(e){const t=new gw(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=new gw(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{const n=new gw(t);e.add(n)})),this.viewport.scener.addObject(e,this.scene)),e}}var XC=function(){function e(){}return e.prototype.toJson=function(e,t){var n=this.xmlStringToXmlDom(e),i=this.xmlToJson(n);return t?(t.removeLineBreaks&&this.removeLineBreaks(i),t.removeComments&&this.removeCommentProperties(i),t.transformTextOnly&&this.transformTextOnly(i),i):i},e.prototype.xmlStringToXmlDom=function(e){return(new DOMParser).parseFromString(e,"text/xml")},e.prototype.removeLineBreaks=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#text"===n&&Array.isArray(e[n])&&delete e[n],"object"==typeof e[n]&&t.removeLineBreaks(e[n])}))},e.prototype.removeCommentProperties=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#comment"===n&&delete e[n],"object"==typeof e[n]&&t.removeCommentProperties(e[n])}))},e.prototype.transformTextOnly=function(e){var t=this;Object.keys(e).forEach((function(n,i){var s=Object.keys(e[n]).length>1,r=Object.keys(e[n])[0];s||"object"==typeof e[n][r]?t.transformTextOnly(e[n]):"object"==typeof e[n]&&e[n]["#text"]&&(e[n]=e[n]["#text"])}))},e.prototype.xmlToJson=function(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t._attributes={};for(var n=0;n<e.attributes.length;n++){var i=e.attributes.item(n);t._attributes[i.nodeName]=i.nodeValue}}}else 3==e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(var s=0;s<e.childNodes.length;s++){var r=e.childNodes.item(s),a=r.nodeName;if(void 0===t[a])t[a]=this.xmlToJson(r);else{if(void 0===t[a].push){var o=t[a];t[a]=[],t[a].push(o)}t[a].push(this.xmlToJson(r))}}return t},e}();function EC(e){return cf(e).then((e=>e.text())).then((e=>Promise.resolve(function(e){return(new XC).toJson(e,{transformTextOnly:!0,removeComments:!0,removeLineBreaks:!0})}(e))))}class zC{constructor(){this.graph=new Map,this.queue=null,this.previous=new Map}setGraph(e){if(!(e.length<1))for(const t of e){const[e,n]=t;this.graph.set(e,new Map);for(const t of n){const[n,i]=t,s=this.graph.get(e);null==s||s.set(n,i)}}}getPath(e,t){var n;if(e===t)return[];const i=this.queue=new Om;i.add(e,0),this.previous.set(e,null);let s=null;for(;s=i.shift();){if(s===t){const e=[];for(;null!==s&&null!==this.previous.get(s);)e.unshift(s),s=null!==(n=this.previous.get(s))&&void 0!==n?n:null;return e}const e=i.getDistance(s);if(e===1/0)return[];const r=this.graph.get(s);r&&r.forEach(((t,n)=>{const r=i.getDistance(n),a=e+t;a<r&&(i.update(n,a),this.previous.set(n,s))}))}return[]}}class PC extends vw{constructor(e,t){super("Topology",e,t),this.dijkstra=new zC}createFromGml(e){return tf(this,void 0,void 0,(function*(){const{url:t,linkWidth:n=20,linkColor:i=65280,renderNode:s=!0,nodeColor:r=255}=e;return EC(t).then((t=>{if(!t||!t.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const a=[],o=new Map;let l=[],c=[];const d=t.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;Qf(d)?d.forEach((e=>{l=[...l,...e.state],c=[...c,...e.transition]})):(l=[...l,...d.state],c=[...c,...d.transition]),l.forEach(((e,t)=>{const n=e.State._attributes["gml:id"],i=e.State.topoNode["gml:Node"].node_name;a.push({id:Kf(n)?n:"",name:Kf(i)?i:"",position:{x:Number(e.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(e.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(e.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),o.set(n,t)})),c.forEach((e=>{const t=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],i=e.Transition.topoEdge["gml:Edge"].restrict["#text"],s=e.Transition.topoEdge["gml:Edge"].passable["#text"],r=o.get(t),l=o.get(n),c=e.Transition._attributes["gml:id"],d=e.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==r&&void 0!==l&&("2"!==s&&"3"!==s&&a[r].graphs.push({targetNodeId:n,linkInfo:{id:c,name:d},enable:!0,restrict:parseInt(i),passable:parseInt(s)}),"1"!==s&&"3"!==s&&a[l].graphs.push({targetNodeId:t,linkInfo:{id:c,name:d},enable:!0,restrict:parseInt(i),passable:parseInt(s)}))}));const h=new hw(Object.assign(Object.assign({},e),{type:"network",nodes:a,linkWidth:n,renderLink:!0,linkColor:i,renderNode:s,nodeColor:r}));return this.setDijkstraGraph(h.nodes),this.viewport.scener.addObject(h,this.scene),Promise.resolve(h)}))}))}create(e){const t=this.generateLineTopologyInfoNodeGraphs(e),n=new hw(t);return this.setDijkstraGraph(n.nodes),this.viewport.scener.addObject(n,this.scene),n}resetNodes(e,t){const n=this.generateLineTopologyInfoNodeGraphs(Object.assign(Object.assign({},e.info),{nodes:t}));return e.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),e}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e),i=new hw(t);this.setDijkstraGraph(i.nodes),n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&t.forEach((t=>{const n=this.generateLineTopologyInfoNodeGraphs(t),i=new hw(n);this.setDijkstraGraph(i.nodes),e.add(i)})),e}getShortestPath(e,t){const n=Jm(e.info.nodes),i=Zm(t.start),s=Zm(t.end);let r=null,a=1/0,o=null,l=1/0;for(let t=0;t<n.length;t++){const c=n[t];if(0===c.graphs.length)continue;const d=e.nodes.find((e=>e.sid===c.id));if(!d)continue;const h=d.getWorldPosition(new ri),u=h.distanceTo(i),p=h.distanceTo(s);u<a&&(a=u,r=c),p<l&&(l=p,o=c)}if(!r||!o||r.id===o.id)return null;const c=r.id,d=o.id,h=this.dijkstra.getPath(c,d);if(0===h.length)return null;h.unshift(r.id);const u=[];for(let e=0;e<h.length;e++){const t=n.find((t=>t.id==h[e]));t&&(t.id+=ng(),t.position.y+=.01,u.push(t))}const p=Object.assign(Object.assign(Object.assign({},t),{type:"line",nodes:u}),e.getSpaceAttribute(!0));this.generateLineTopologyInfoNodeGraphs(p);const m=new hw(p);return this.viewport.scener.addObject(m,this.scene),m}getShortestPathByMultipleStartPoints(e,t){const{nodes:n}=e.info,i=[];t.start.forEach((e=>{const s=Zm(e),r=Zm(t.end);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Zm(e.position),n=t.distanceTo(s),i=t.distanceTo(r);n<o&&(o=n,a=e.id),i<c&&(c=i,l=e.id)}})),a&&l){let e=0;const t=this.dijkstra.getPath(a,l);if(t.length>0){const a=[{id:"startPoint",position:s,graphs:[]}];t.forEach(((t,i)=>{const r=n.find((e=>e.id==t));r&&(e+=0===i?Zm(r.position).distanceTo(s):Zm(r.position).distanceTo(Zm(a[a.length-1].position)),a.push(r))})),a.push({id:"endPoint",position:r,graphs:[]}),e+=r.distanceTo(Zm(a[a.length-1].position)),i.push({nodeInfo:a,pathLength:e})}}}));let s=[],r=1/0;if(i.forEach((({nodeInfo:e,pathLength:t})=>{t<r&&(r=t,s=e)})),s.length){for(let e=0;e<s.length;e++)s[e].position.y+=.01;const n=Object.assign(Object.assign({},t),{type:"line",nodes:s,position:e.getWorldPosition(new ri),rotation:(new Oi).setFromQuaternion(e.getWorldQuaternion(new si)),scale:e.getWorldScale(new ri)});this.generateLineTopologyInfoNodeGraphs(n);const i=new hw(n);return this.viewport.scener.addObject(i,this.scene),i}return null}getShortestPathByMultipleEndPoints(e,t){const{nodes:n}=e.info,i=[];t.end.forEach((e=>{const s=Zm(t.start),r=Zm(e);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Zm(e.position),n=t.distanceTo(s),i=t.distanceTo(r);n<o&&(o=n,a=e.id),i<c&&(c=i,l=e.id)}})),a&&l){let e=0;const t=this.dijkstra.getPath(a,l);if(t.length>0){const a=[{id:"startPoint",position:s,graphs:[]}];t.forEach(((t,i)=>{const r=n.find((e=>e.id==t));r&&(e+=0===i?Zm(r.position).distanceTo(s):Zm(r.position).distanceTo(Zm(a[a.length-1].position)),a.push(r))})),a.push({id:"endPoint",position:r,graphs:[]}),e+=r.distanceTo(Zm(a[a.length-1].position)),i.push({nodeInfo:a,pathLength:e})}}}));let s=[],r=1/0;if(i.forEach((({nodeInfo:e,pathLength:t})=>{t<r&&(r=t,s=e)})),s.length){for(let e=0;e<s.length;e++)s[e].position.y+=.01;const n=Object.assign(Object.assign({},t),{type:"line",nodes:s,position:e.getWorldPosition(new ri),rotation:(new Oi).setFromQuaternion(e.getWorldQuaternion(new si)),scale:e.getWorldScale(new ri)});this.generateLineTopologyInfoNodeGraphs(n);const i=new hw(n);return this.viewport.scener.addObject(i,this.scene),i}return null}setDijkstraGraph(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];if(0===i.graphs.length)continue;const s=[];for(let t=0;t<i.graphs.length;t++){const n=i.graphs[t],r=e.find((e=>e.sid===n.targetNodeId));if(!r)continue;const a=i.getWorldPosition(new ri),o=r.getWorldPosition(new ri);s.push([n.targetNodeId,a.distanceTo(o)])}t.push([i.sid,s])}t.length>0&&this.dijkstra.setGraph(t)}generateLineTopologyInfoNodeGraphs(e){const{type:t,nodes:n}=e;if("line"===t)for(let t=0;t<n.length;t++)if(t===n.length-1)n[t].graphs=[];else{const i=e.nodes[t],s=e.nodes[t+1];n[t].graphs=[{targetNodeId:s.id,linkInfo:{id:`${i.id}_to_${s.id}`,name:`${i.name||i.id}_to_${s.name||s.id}`},enable:!0,restrict:0,passable:0}]}return Object.assign(Object.assign({},e),{nodes:n})}}class WC extends tc{constructor(e,t){const n=new Bs;n.setAttribute("position",new Es([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere();super(n,new jl({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new Bs;i.setAttribute("position",new Es([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new ar(i,new ws({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class ZC extends vw{constructor(e,t){super("Helper",e,t)}addGridHelper(e){const{id:t,size:n=1e3,divisions:i=20,color:s="#fff",position:r={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:o={x:1,y:1,z:1}}=e,l=new np(n,i,s,s);return l.position.set(r.x,r.y,r.z),l.rotation.set(a.x,a.y,a.z),l.scale.set(o.x,o.y,o.z),l.userData.sid=t,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(e){const{id:t,axesLength:n=1e3}=e,i=new xp(n);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addBoxHelper(e){const{id:t,box:n,color:i="#00ff00"}=e,s=new mp(n,new Fn(i));return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addPlaneHelper(e){const{id:t,width:n=500,height:i=500,color:s="#00ff00",opacity:r=.2,position:a={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=e,c=new Qx(new Gr(n,i),new ws({color:s,opacity:r,transparent:r<1,side:2}),{id:t,position:a,rotation:o,scale:l});return c.userData.sid=t,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(e){const{imgUrl:t,id:n,width:i=500,height:s=500,opacity:r=1,position:a={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=e,d=(new Sh).load(t),h=new Gr(i,s);h.computeBoundingBox();const u=new kd({side:2,map:d,transparent:r<1,opacity:r,roughness:.8});u.map&&(u.map.repeat.set(c.x,c.x),u.map.wrapS=1e3,u.map.wrapT=1e3,u.map.version++),o.x-=Math.PI/2,u.version++;const p=new yw(h,u,{id:n,position:a,rotation:o,scale:l});return p.userData.sid=n,p.userData.stype="Helper",this.viewport.scener.addObject(p,this.scene),p}addDirectionalLightHelper(e){const{id:t,light:n,color:i,size:s=50}=e,r=new op(n,s,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addHemisphereLightHelper(e){const{id:t,light:n,color:i,size:s=20}=e,r=new tp(n,s,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addSpotLightHelper(e){const{id:t,light:n,color:i}=e,s=new Uu(n,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addPointLightHelper(e){const{id:t,light:n,color:i,size:s=20}=e,r=new Qu(n,s,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addRectAreaLightHelper(e){const{id:t,light:n,color:i}=e,s=new WC(n,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}}class NC extends vw{constructor(e,t){super("PluginObject",e,t)}createObject(e,t){const n=new tw(e);return t&&n.add(t),this.viewport.scener.addObject(n,this.scene),n}addToObject(e,t){return e?(this.viewport.scener.addObject(t,e),e):null}}class VC extends vw{constructor(e,t){super("Group",e,t)}}class DC{constructor(e){this.viewport=e,this.cache={objects:new Map},this.scene=e.scene,this.store={groupManager:new VC(e,this.scene),lightManager:new xw(e,this.scene),modelManager:new RC(e,this.scene),poiManager:new _C(e,this.scene),poiNodeManager:new AC(e,this.scene),canvas3DManager:new IC(e,this.scene),topologyManager:new PC(e,this.scene),helperManager:new ZC(e,this.scene),pluginObjectManager:new NC(e,this.scene)},e.postUpdate.set("ManagerRender",this.update.bind(this)),e.signals.objectAdded.add(this.setObjectCache.bind(this)),e.signals.objectRemoved.add(this.deleteObjectCache.bind(this))}levelUpdate(){if(!this.viewport.options.levelEnabled)return;const e=(e,t)=>{e.visible!==t&&(e instanceof nw&&e._setElementDisplay(t),e.visible=t,e.matrixAutoUpdate=t,e.autoUpdate=!0)},t=t=>{const{level:n,handleHide:i,autoUpdate:s}=t,{max:r=null,min:a=null}=n;if(s)t.autoUpdate=!1,this.viewport.signals.objectChanged.dispatch();else if(!i&&(r||a)){const n=this.viewport.camera.position.distanceTo(t.position);e(t,!(r&&n>r)&&!(a&&n<a))}};this.scene.traverse((e=>{(e instanceof $x||e instanceof Qx)&&t(e)}))}update(){if(0===this.scene.children.length)return;const e=performance.now();this.levelUpdate(),this.viewport.signals.loadRendered.dispatch(performance.now()-e)}isObjectInScene(e){let t=!1;return e.traverseAncestors((e=>{e===this.scene&&(t=!0)})),t}getObjectById(e){const t=this.getObjectCache(e);if(t){if(this.isObjectInScene(t))return t}return null}getObjectByName(e){return this._getObjectByProps("name",e)}getObjectByUserDataProperty(e,t){const n=[];return this.cache.objects.forEach((i=>{this.isObjectInScene(i)&&qf(i)&&(i instanceof $x||i instanceof Qx||i.userData.stype)&&($f(e)&&e(i.userData)||Kf(e)&&i.userData[e]===t)&&n.push(i)})),n}removeObjectById(e){const t=this.getObjectById(e);return!!t&&(this.viewport.scener.removeObject(t),!0)}_getObjectByProps(e,t){const n=[];return this.cache.objects.forEach((i=>{this.isObjectInScene(i)&&((i instanceof $x||i instanceof Qx)&&qf(i)&&i[e]===t||qf(i)&&i.userData.stype&&("name"===e&&i.name===t||"sid"===e&&i.userData.sid===t))&&n.push(i)})),n}getObjectCache(e){return this.cache.objects.get(e)}setObjectCache(e){const t=(e,t)=>{const n=this.cache.objects.get(t);n&&n!==e&&console.warn(`object id ${t} already exists in scene`)};null==e||e.traverse((n=>{if(n instanceof $x||n instanceof Qx){if("string"==typeof n.sid&&n.sid.startsWith("[soonspacejs]: "))return;t(n,n.sid),this.cache.objects.set(n.sid,n)}else n.userData.sid&&e.userData.stype&&(t(n,n.userData.sid),this.cache.objects.set(n.userData.sid,n))}))}deleteObjectCache(e){null==e||e.traverse((t=>{t instanceof $x||t instanceof Qx?this.cache.objects.delete(t.sid):t.userData.sid&&e.userData.stype&&this.cache.objects.delete(t.userData.sid)}))}clearObject(){this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.lightManager.clear()}dispose(){this.store.modelManager.dispose(),this.cache.objects.clear(),this.clear()}}function HC(e){const t=BC(e),n=new Wi;n.setFromMatrix3(t);const i=e[0],s=n.clone();s.setPosition(i);const r=s.clone().invert(),a=e.map((e=>{const t=e.clone().applyMatrix4(r);return new Rn(t.x,t.y)})),o=new Qc(a),l=new Xd(o),c=new Du;c.setFromPoints(a);const d=kC(c);return l.getAttribute("uv").applyMatrix3(d),l.applyMatrix4(n),{geometry:l,polygonBox:c,modelMatrix:n,planeMatrix:s,projectionMatrix:r,position:i}}function BC(e){const[t,n,i]=e,s=new wr;s.setFromCoplanarPoints(n,t,i);const r=s.normal,a=r.clone().cross(new ri(0,0,1));a.equals(new ri)&&a.set(1,0,0);const o=r.clone().cross(a);a.normalize(),o.normalize(),r.normalize();const l=new _n;return l.elements=[a.x,a.y,a.z,o.x,o.y,o.z,r.x,r.y,r.z],l}function kC(e){const t=e.min,n=e.getSize(new Rn),i=new _n;return i.elements=[n.x,0,0,0,n.y,0,t.x,t.y,1],i.invert()}function FC(e,t){const n=UC(t);return e.intersectsBox(n)}function UC(e){const t=new li,n=t.min.clone(),i=t.max.clone();if(t.setFromObject(e),t.min.equals(n)&&t.max.equals(i)){const n=new ri;e.getWorldPosition(n),t.min.copy(n),t.max.copy(n)}if(e.isInstancedMesh){const{count:n,matrixWorld:i,geometry:s}=e;let r=s.boundingBox;if(r||(s.computeBoundingBox(),r=s.boundingBox),r){const s=i.clone();for(let i=0;i<n;i++){const n=new Wi;e.getMatrixAt(i,n),n.premultiply(s);const a=r.clone();a.applyMatrix4(s),t.union(a)}}}return t}function OC(e,t,n){if("string"==typeof e){let i=t?null==n?void 0:n.get(e):null;if(!i){i=(new Sh).load(e),null==n||n.set(e,i)}return i}return e instanceof HTMLImageElement?new Jn(e):e instanceof HTMLCanvasElement?new gc(e):new pc(e)}function YC(e,t,n,i){const s=e.map,r=OC(t,n,i);if(!s)return e.map=s,s;const a=r.source;return r.copy(s),r.source=a,e.map=r,r}self.THREE=Vp;class KC{constructor(e){this.THREE=Vp,this.TWEEN=zm,this.utils=ig,this.THREE_PLUGINS={TransformControls:jp,Reflector:bm},this.version=t,this.animation=rg,this.library=bw,this.plugins={},this.textureCache=new Map;const{el:n,options:i={},events:s={}}=e;if(this.domElement=document.querySelector(n),this.options=Object.assign(Object.assign({},{showInfo:!1,showStats:!1,showViewHelper:!1,showGrid:!1,background:{color:11459572,alpha:!1},fog:!1,controls:{type:"free"},hoverEnabled:!1,levelEnabled:!1,closeInfoLog:!1,closeWarnLog:!1,useIndexedDB:!0,logarithmicDepthBuffer:!0}),i),this.viewport=new Jx(this.options),this.signals=this.viewport.signals,this.manager=new DC(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(s),this._initDefaultSettings()}_init(){const{showGrid:t,background:n,fog:i,controls:s,closeInfoLog:r,closeWarnLog:a,useIndexedDB:o}=this.options;if(!r){Pm(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),Pm(e,{color:"#3eaf7c","font-size":"24px"}),Pm(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),Pm("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),Pm("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),Pm("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}t&&this.addGridHelper(!0===t?{id:"defaultGridHelper"}:t),(null==n?void 0:n.skyBox)?Kf(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):qf(null==n?void 0:n.skyBox)&&this.setSkyBackground(n.skyBox.dirPath,n.skyBox.fileNames):(null==n?void 0:n.img)?this.setBackgroundImage(n.img):(null==n?void 0:n.color)&&this.setBackgroundColor(n.color),i&&this.openSceneFog(!0===i?void 0:i),s&&this.setControlsOptions(s),a&&(window.console.warn=function(){}),o&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(e){const{modelHover:t,modelUnHover:n,modelClick:i,modelRightClick:s,modelDblClick:r,poiHover:a,poiUnHover:o,poiClick:l,poiRightClick:c,poiDblClick:d,selectPosition:h,sceneClick:u,resize:p}=e;t&&this.signals.modelHover.add(t),n&&this.signals.modelUnHover.add(n),i&&this.signals.modelClick.add(i),s&&this.signals.modelRightClick.add(s),r&&this.signals.modelDblClick.add(r),a&&this.signals.poiHover.add(a),o&&this.signals.poiUnHover.add(o),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),d&&this.signals.poiDblClick.add(d),h&&this.signals.selectPosition.add(h),u&&this.signals.sceneClick.add(u),p&&this.signals.windowResize.add(p),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultSettings(){this.setEnvironment(),this.setColorSpace("sRGB"),this.setToneMapping({type:"Linear",exposure:.8})}registerPlugin(e,t){const n=new e(this);return this.plugins[t]=n,n}getPlugin(e){return this.plugins[e]?this.plugins[e]:null}createPluginObject(e,t){return this.manager.store.pluginObjectManager.createObject(e,t)}addToPluginObject(e,t){const n=this.getObjectById(e);return this.manager.store.pluginObjectManager.addToObject(n,t)}getPluginObjectById(e){return Wm("getPluginObjectById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPluginObjectByName(e){return Wm("getPluginObjectByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}removePluginObjectById(e){return Wm("removePluginObjectById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}setSSR(e){this.viewport.setSSR(e)}setBloom(e){this.viewport.setBloom(e)}setSSAO(e){this.viewport.setSSAO(e)}setColorSpace(e){this.viewport.setColorSpace(e)}setToneMapping(e){this.viewport.setToneMapping(e)}setHoverEnabled(e){this.viewport.setHoverEnabled(e)}setBackgroundColor(e){this.viewport.setBackgroundColor(e)}setBackgroundImage(e){this.viewport.setBackgroundImage(e)}setSphereSkyBackground(e){this.viewport.setSphereSkyBackground(e)}setSkyBackground(e,t){this.viewport.setSkyBackground(e,t)}setEnvironment(){return this.viewport.setEnvironment()}playModelAnimation(e,t){return this.viewport.playModelAnimation(e,t)}stopModelAnimation(e,t){this.viewport.stopModelAnimation(e,t)}getOffsetByPosition(e){return this.viewport.getOffsetByPosition(e)}getPositionByOffset(e,t){return this.viewport.getPositionByOffset(e,t)}render(e){return this.viewport.render(e)}clearSignals(){this.viewport.clearSignals()}dispose(){this.manager.dispose(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(e){this.viewport.cameraManager.setCameraViewpoint(e)}getCameraTargetView(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraTargetView(e){this.viewport.cameraManager.setCameraViewpoint(e)}flyTo(e,t="frontTop",n){return"orbit"===this.viewport.controls.options.type&&this.utils.warn("flyTo 方法不适用于 orbit 控制器"),this.viewport.cameraManager.flyTo(e,t,n)}flyToBoundingBox(e,t="frontTop",n){return this.viewport.cameraManager.flyToBoundingBox(e,t,n)}flyToObj(e,t="frontTop",n){return this.viewport.cameraManager.flyToObj(e,t,n)}flyMainViewpoint(e="frontTop",t){return this.flyToObj(this.manager.scene,e,t)}surroundOnTarget(e,t){return this.viewport.cameraManager.surroundOnTarget(e,t)}surroundOnObject(e,t){return this.viewport.cameraManager.surroundOnObject(e,t)}getObjectLabelPos(e,t="frontTop",n){return this.viewport.cameraManager.getObjectLabelPos(e,t,n)}setControlsOptions(e){return this.viewport.controls.setOptions(e)}addObject(e,t){this.viewport.scener.addObject(e,t)}removeObject(e){this.viewport.scener.removeObject(e)}openSceneFog(e){this.viewport.scener.openSceneFog(e)}closeSceneFog(){this.viewport.scener.closeSceneFog()}setSky(e){return this.viewport.setSky(e)}getScreenshot(){return this.screenshot()}screenshot(){return this.viewport.screenshot()}edgeShow(e,t){return this.viewport.scener.edgeShow(e,t)}unEdgeShow(e){return this.viewport.scener.unEdgeShow(e)}strokeShow(e,t){return this.viewport.scener.strokeShow(e,t)}unStrokeShow(e){return this.viewport.scener.unStrokeShow(e)}opacityShow(e,t){return this.viewport.scener.opacityShow(e,t)}unOpacityShow(e){return this.viewport.scener.unOpacityShow(e)}highlightShow(e,t){return this.viewport.scener.highlightShow(e,t)}unHighlightShow(e){return this.viewport.scener.unHighlightShow(e)}emissiveShow(e,t){return this.viewport.scener.emissiveShow(e,t)}unEmissiveShow(e){return this.viewport.scener.unEmissiveShow(e)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(e){return this.manager.store.lightManager.createAmbientLight(e)}setAmbientLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setAmbientLight(t,e)}createDirectionalLight(e){return this.manager.store.lightManager.createDirectionalLight(e)}setDirectionalLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setDirectionalLight(t,e)}createHemisphereLight(e){return this.manager.store.lightManager.createHemisphereLight(e)}setHemisphereLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setHemisphereLight(t,e)}createSpotLight(e){return this.manager.store.lightManager.createSpotLight(e)}setSpotLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setSpotLight(t,e)}createPointLight(e){return this.manager.store.lightManager.createPointLight(e)}setPointLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setPointLight(t,e)}createRectAreaLight(e){return this.manager.store.lightManager.createRectAreaLight(e)}setRectAreaLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setRectAreaLight(t,e)}getLightById(e){return Wm("getLightById is deprecated, use getObjectById instead"),this.getObjectById(e)}removeLightById(e){return Wm("removeLightById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}getAllLight(){return this.manager.store.lightManager.getAll()}clearLight(){return this.manager.store.lightManager.clear()}showAllLight(){return this.manager.store.lightManager.showAll()}hideAllLight(){return this.manager.store.lightManager.hideAll()}updateAllShadow(){return this.manager.store.lightManager.updateAllShadow()}getObjectById(e){return this.manager.getObjectById(e)}getObjectByName(e){return this.manager.getObjectByName(e)}getObjectByUserDataProperty(e,t){return this.manager.getObjectByUserDataProperty(e,t)}removeObjectById(e){return this.manager.removeObjectById(e)}createGroup(e){return this.manager.store.groupManager.createGroup(e)}getGroupById(e){return Wm("getGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getGroupByName(e){return Wm("getGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllGroup(){return this.manager.store.groupManager.getAll()}showAllGroup(){return this.manager.store.groupManager.showAll()}hideAllGroup(){return this.manager.store.groupManager.hideAll()}removeGroupById(e){return Wm("removeGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}loadSbm(e){return Wm("loadSbm is deprecated, use loadModel instead"),this.loadModel(e)}parseSbm(){Wm("parseSbm is deprecated!")}cloneSbm(e,t,n){return Wm("cloneSbm is deprecated, use cloneModel instead"),this.cloneModel(e,t,n)}getSbmById(e){return Wm("getSbmById is deprecated, use getObjectById instead"),this.getObjectById(e)}getSbmByName(e){return Wm("getSbmByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getSbmByUserDataProperty(e,t){return Wm("getSbmByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeSbmById(e){return Wm("removeSbmById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForSbm(e){return Wm("createGroupForSbm is deprecated, use createGroup instead"),this.createGroup(e)}loadSbmToGroup(e,t){return Wm("loadSbmToGroup is deprecated, use loadModelToGroup instead"),this.loadModelToGroup(e,t)}addSbmForGroup(e,t){return Wm("addSbmForGroup is deprecated, use addModelForGroup instead"),this.addModelForGroup(e,t)}createSbmGroupFromXml(){Wm("createGroupForSbm is deprecated!")}getSbmGroupById(e){return Wm("getSbmGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getSbmGroupByName(e){return Wm("getSbmGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllSbmGroup(){return Wm("getAllSbmGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeSbmGroupById(e){return Wm("removeSbmGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearSbm(){return Wm("clearSbm is deprecated, use clearModel instead"),this.clearModel()}getAllSbm(){return Wm("getAllSbm is deprecated, use getAllModel instead"),this.getAllModel()}showAllSbm(){return Wm("showAllSbm is deprecated, use showAllModel instead"),this.showAllModel()}hideAllSbm(){return Wm("hideAllSbm is deprecated, use hideAllModel instead"),this.hideAllModel()}getSbmModelMaps(){return Wm("getSbmModelMaps is deprecated, use getModelsMap instead"),this.getModelsMap()}setSbmModelMaps(e){return Wm("setSbmModelMaps is deprecated, use setModelsMap instead"),this.setModelsMap(e)}setModelDracoDecoderPath(e){return this.manager.store.modelManager.setDracoDecoderPath(e)}loadModel(e){return this.manager.store.modelManager.load(e)}cloneModel(e,t,n){return this.manager.store.modelManager.clone(e,t,n)}getModelById(e){return Wm("getModelById is deprecated, use getObjectById instead"),this.getObjectById(e)}getModelByName(e){return Wm("getModelByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getModelByUserDataProperty(e,t){return Wm("getModelByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeModelById(e){return Wm("removeModelById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForModel(e){return Wm("createGroupForModel is deprecated, use createGroup instead"),this.createGroup(e)}loadModelToGroup(e,t){return this.manager.store.modelManager.loadToGroup(e,t)}addModelForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.modelManager.addForGroup(n,t)}getModelGroupById(e){return Wm("getModelGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getModelGroupByName(e){return Wm("getModelGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllModelGroup(){return Wm("getAllModelGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeModelGroupById(e){return Wm("removeModelGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}clearIdb(){return this.manager.store.modelManager.clearIdb()}getModelsMap(){return this.manager.store.modelManager.modelsMap}setModelsMap(e){this.manager.store.modelManager.modelsMap=e}createPoi(e){return this.manager.store.poiManager.create(e)}clonePoi(e,t,n){return this.manager.store.poiManager.clone(e,t,n)}getPoiById(e){return Wm("getPoiById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiByName(e){return Wm("getPoiByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getPoiByUserDataProperty(e,t){return Wm("getPoiByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removePoiById(e){return Wm("removePoiById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForPoi(e){return Wm("createGroupForPoi is deprecated, use createGroup instead"),this.createGroup(e)}createPoiToGroup(e,t){return this.manager.store.poiManager.createToGroup(e,t)}addPoiForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.poiManager.addForGroup(n,t)}getPoiGroupById(e){return Wm("getPoiGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiGroupByName(e){return Wm("getPoiGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllPoiGroup(){return Wm("getAllPoiGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiGroupById(e){return Wm("removePoiGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(e){return this.manager.store.poiNodeManager.create(e)}getPoiNodeById(e){return Wm("getPoiNodeById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiNodeByName(e){return Wm("getPoiNodeByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getPoiNodeByUserDataProperty(e,t){return Wm("getPoiNodeByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removePoiNodeById(e){return Wm("removePoiNodeById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForPoiNode(e){return Wm("createGroupForPoiNode is deprecated, use createGroup instead"),this.createGroup(e)}createPoiNodeToGroup(e,t){return this.manager.store.poiNodeManager.createToGroup(e,t)}addPoiNodeForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.poiNodeManager.addForGroup(n,t)}getPoiNodeGroupById(e){return Wm("getPoiNodeGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiNodeGroupByName(e){return Wm("getPoiNodeGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllPoiNodeGroup(){return Wm("getAllPoiNodeGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiNodeGroupById(e){return Wm("removePoiNodeGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createPoiMesh(e){const t=function(e,t){const{image:n,color:i,width:s,height:r,position:a,rotation:o,needLight:l,id:c,name:d,userData:h,level:u,visible:p,cache:m}=e,f=ef(e,["image","color","width","height","position","rotation","needLight","id","name","userData","level","visible","cache"]),g=new Gr(s,r),y=n?Object.assign(Object.assign({},f),{map:OC(n,null==m||m,t)}):f,b=l?new Ud(y):new ws(y),v=new Qx(g,b,{id:c,name:d,userData:h,level:u,visible:p});return a&&v.position.copy(a),o&&v.rotation.copy(o),v}(e,this.textureCache);return this.addObject(t),t}createPolygonPoiMesh(e){const t=function(e,t){const{points:n,image:i,color:s,needLight:r,id:a,name:o,userData:l,level:c,visible:d,cache:h}=e,u=ef(e,["points","image","color","needLight","id","name","userData","level","visible","cache"]),p=n.map((e=>new ri(e.x,e.y,e.z))),m=i?Object.assign(Object.assign({},u),{map:OC(i,null==h||h,t)}):u,f=r?new Ud(m):new ws(m),{geometry:g,position:y}=HC(p),b=new Qx(g,f,{id:a,name:o,userData:l,level:c,visible:d});return b.position.copy(y),b}(e,this.textureCache);return this.addObject(t),t}setTexture(e,t,n){const{cache:i=!0,independ:s}=n||{};let r=e.material;s&&(r=r.clone(),e.material=r);return YC(r,t,i,this.textureCache)}createCanvas3D(e){return this.manager.store.canvas3DManager.create(e)}getCanvas3DById(e){return Wm("getCanvas3DById is deprecated, use getObjectById instead"),this.getObjectById(e)}getCanvas3DByName(e){return Wm("getCanvas3DByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getCanvas3DByUserDataProperty(e,t){return Wm("getCanvas3DByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeCanvas3DById(e){return Wm("removeCanvas3DById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForCanvas3D(e){return Wm("createGroupForCanvas3D is deprecated, use createGroup instead"),this.createGroup(e)}createCanvas3DToGroup(e,t){return this.manager.store.canvas3DManager.createToGroup(e,t)}addCanvas3DForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.canvas3DManager.addForGroup(n,t)}getCanvas3DGroupById(e){return Wm("getCanvas3DGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getCanvas3DGroupByName(e){return Wm("getCanvas3DGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllCanvas3DGroup(){return Wm("getAllCanvas3DGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeCanvas3DGroupById(e){return Wm("removeCanvas3DGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(e,t){return this.manager.store.topologyManager.getShortestPath(e,t)}getShortestPathByMultipleStartPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(e,t)}getShortestPathByMultipleEndPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(e,t)}createTopologyFromGml(e){return this.manager.store.topologyManager.createFromGml(e)}createTopology(e){return this.manager.store.topologyManager.create(e)}resetTopologyNodes(e,t){return this.manager.store.topologyManager.resetNodes(e,t)}getTopologyById(e){return Wm("getTopologyById is deprecated, use getObjectById instead"),this.getObjectById(e)}getTopologyByName(e){return Wm("getTopologyByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getTopologyByUserDataProperty(e,t){return Wm("getTopologyByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeTopologyById(e){return Wm("removeTopologyById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForTopology(e){return Wm("createGroupForTopology is deprecated, use createGroup instead"),this.createGroup(e)}createTopologyToGroup(e,t){return this.manager.store.topologyManager.createToGroup(e,t)}addTopologyForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.topologyManager.addForGroup(n,t)}getTopologyGroupById(e){return Wm("getTopologyGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getTopologyGroupByName(e){return Wm("getTopologyGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllTopologyGroup(){return Wm("getAllTopologyGroup is deprecated, use getAllGroups instead"),this.getAllGroup()}removeTopologyGroupById(e){return Wm("removeTopologyGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(e){return this.manager.store.helperManager.addGridHelper(e)}addAxesHelper(e){return this.manager.store.helperManager.addAxesHelper(e)}addBoxHelper(e){return this.manager.store.helperManager.addBoxHelper(e)}addPlaneHelper(e){return this.manager.store.helperManager.addPlaneHelper(e)}createGround(e){return Wm("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(e)}addGroundHelper(e){return this.manager.store.helperManager.addGroundHelper(e)}addDirectionalLightHelper(e){return this.manager.store.helperManager.addDirectionalLightHelper(e)}addHemisphereLightHelper(e){return this.manager.store.helperManager.addHemisphereLightHelper(e)}addSpotLightHelper(e){return this.manager.store.helperManager.addSpotLightHelper(e)}addPointLightHelper(e){return this.manager.store.helperManager.addPointLightHelper(e)}addRectAreaLightHelper(e){return this.manager.store.helperManager.addRectAreaLightHelper(e)}getHelperById(e){return Wm("getHelperById is deprecated, use getObjectById instead"),this.getObjectById(e)}removeHelperById(e){return Wm("removeHelperById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}createFindObjectsInBoxNearPosition(e,t){return function(e,t){const{top:n,left:i,bottom:s,right:r,front:a,back:o}=e,l=new ri(r,n,a),c=new ri(i,s,o),d=new li;return function(e){return d.max.addVectors(e,l),d.min.subVectors(e,c),t.filter((e=>FC(d,e)))}}(e,t)}createFindObjectsInSphereNearPosition(e,t){return function(e,t){const n=new Gi(new ri,e);return function(e){return n.center.copy(e),t.filter((e=>FC(n,e)))}}(e,t)}createFindObjectsNearPath(e,t){return function(e,t){const n=e.length-1,i=[];for(let t=0;t<n;t++){const n=e[t],s=e[t+1],r=new ku(n,s);i.push(r)}const s=new Gi(new ri,t);return function(e){return e.filter((e=>{const t=UC(e),n=new ri;t.getCenter(n);const r=i.filter((e=>{const t=e.closestPointToPointParameter(n);return 0<=t||t>=1}));if(0===r.length)return!1;let a=1/0,o=n;for(const e of r){const t=e.closestPointToPoint(n,!0,new ri),i=n.distanceToSquared(t);i<a&&(a=i,o=t)}return s.center.copy(o),s.intersectsBox(t)}))}}(e,t)}}KC.THREE=Vp,KC.TWEEN=zm,KC.utils=ig;export{te as ACESFilmicToneMapping,T as AddEquation,J as AddOperation,Gt as AdditiveAnimationBlendMode,x as AdditiveBlending,Ee as AlphaFormat,H as AlwaysDepth,tn as AlwaysStencilFunc,Vh as AmbientLight,nu as AmbientLightProbe,dh as AnimationClip,bh as AnimationLoader,Au as AnimationMixer,Gu as AnimationObjectGroup,Qd as AnimationUtils,vc as ArcCurve,Qo as ArrayCamera,vp as ArrowHelper,mu as Audio,xu as AudioAnalyser,$h as AudioContext,pu as AudioListener,eu as AudioLoader,xp as AxesHelper,m as BackSide,Et as BasicDepthPacking,c as BasicShadowMap,Nl as Bone,ih as BooleanKeyframeTrack,Du as Box2,li as Box3,mp as Box3Helper,lr as BoxBufferGeometry,lr as BoxGeometry,pp as BoxHelper,Ts as BufferAttribute,Bs as BufferGeometry,Oh as BufferGeometryLoader,Se as ByteType,uh as Cache,pr as Camera,dp as CameraHelper,gc as CanvasTexture,Dc as CapsuleBufferGeometry,Dc as CapsuleGeometry,Cc as CatmullRomCurve3,ee as CineonToneMapping,Hc as CircleBufferGeometry,Hc as CircleGeometry,de as ClampToEdgeWrapping,ou as Clock,Fn as Color,sh as ColorKeyframeTrack,Zn as ColorManagement,fc as CompressedTexture,vh as CompressedTextureLoader,kc as ConeBufferGeometry,kc as ConeGeometry,fr as CubeCamera,se as CubeReflectionMapping,re as CubeRefractionMapping,gr as CubeTexture,wh as CubeTextureLoader,le as CubeUVReflectionMapping,_c as CubicBezierCurve,Ac as CubicBezierCurve3,$d as CubicInterpolant,a as CullFaceBack,o as CullFaceFront,l as CullFaceFrontBack,r as CullFaceNone,yc as Curve,Zc as CurvePath,S as CustomBlending,ne as CustomToneMapping,Bc as CylinderBufferGeometry,Bc as CylinderGeometry,Nu as Cylindrical,ti as Data3DTexture,$n as DataArrayTexture,Vl as DataTexture,Zp as DataTexture2DArray,Np as DataTexture3D,Mh as DataTextureLoader,Ap as DataUtils,Ft as DecrementStencilOp,Ot as DecrementWrapStencilOp,mh as DefaultLoadingManager,Ne as DepthFormat,Ve as DepthStencilFormat,tl as DepthTexture,Nh as DirectionalLight,op as DirectionalLightHelper,th as DiscreteInterpolant,Uc as DodecahedronBufferGeometry,Uc as DodecahedronGeometry,f as DoubleSide,P as DstAlphaFactor,Z as DstColorFactor,dn as DynamicCopyUsage,sn as DynamicDrawUsage,on as DynamicReadUsage,Jc as EdgesGeometry,bc as EllipseCurve,F as EqualDepth,Jt as EqualStencilFunc,ae as EquirectangularReflectionMapping,oe as EquirectangularRefractionMapping,Oi as Euler,fn as EventDispatcher,Gd as ExtrudeBufferGeometry,Gd as ExtrudeGeometry,yh as FileLoader,g as FlatShading,Xs as Float16BufferAttribute,Es as Float32BufferAttribute,zs as Float64BufferAttribute,Re as FloatType,ll as Fog,ol as FogExp2,zp as Font,Ep as FontLoader,mc as FramebufferTexture,p as FrontSide,Tr as Frustum,Eu as GLBufferAttribute,un as GLSL1,pn as GLSL3,O as GreaterDepth,U as GreaterEqualDepth,en as GreaterEqualStencilFunc,qt as GreaterStencilFunc,np as GridHelper,qo as Group,_e as HalfFloatType,Ch as HemisphereLight,tp as HemisphereLightHelper,tu as HemisphereLightProbe,_d as IcosahedronBufferGeometry,_d as IcosahedronGeometry,Qh as ImageBitmapLoader,xh as ImageLoader,On as ImageUtils,Pp as ImmediateRenderObject,kt as IncrementStencilOp,Ut as IncrementWrapStencilOp,kl as InstancedBufferAttribute,Uh as InstancedBufferGeometry,Xu as InstancedInterleavedBuffer,Kl as InstancedMesh,Rs as Int16BufferAttribute,As as Int32BufferAttribute,Cs as Int8BufferAttribute,Le as IntType,dl as InterleavedBuffer,ul as InterleavedBufferAttribute,qd as Interpolant,xt as InterpolateDiscrete,wt as InterpolateLinear,Mt as InterpolateSmooth,Yt as InvertStencilOp,Ht as KeepStencilOp,nh as KeyframeTrack,Il as LOD,Vc as LatheBufferGeometry,Vc as LatheGeometry,Yi as Layers,B as LessDepth,k as LessEqualDepth,Qt as LessEqualStencilFunc,jt as LessStencilFunc,Th as Light,Bh as LightProbe,tc as Line,ku as Line3,jl as LineBasicMaterial,Ic as LineCurve,Xc as LineCurve3,Jd as LineDashedMaterial,rc as LineLoop,sc as LineSegments,It as LinearEncoding,ye as LinearFilter,eh as LinearInterpolant,we as LinearMipMapLinearFilter,ve as LinearMipMapNearestFilter,xe as LinearMipmapLinearFilter,be as LinearMipmapNearestFilter,Vt as LinearSRGBColorSpace,q as LinearToneMapping,fh as Loader,Fh as LoaderUtils,ph as LoadingManager,yt as LoopOnce,vt as LoopPingPong,bt as LoopRepeat,Ze as LuminanceAlphaFormat,We as LuminanceFormat,i as MOUSE,xs as Material,kh as MaterialLoader,Gn as MathUtils,_n as Matrix3,Wi as Matrix4,R as MaxEquation,ar as Mesh,ws as MeshBasicMaterial,Uo as MeshDepthMaterial,Oo as MeshDistanceMaterial,Kd as MeshLambertMaterial,jd as MeshMatcapMaterial,Yd as MeshNormalMaterial,Ud as MeshPhongMaterial,Fd as MeshPhysicalMaterial,kd as MeshStandardMaterial,Od as MeshToonMaterial,G as MinEquation,he as MirroredRepeatWrapping,j as MixOperation,M as MultiplyBlending,K as MultiplyOperation,ue as NearestFilter,ge as NearestMipMapLinearFilter,me as NearestMipMapNearestFilter,fe as NearestMipmapLinearFilter,pe as NearestMipmapNearestFilter,D as NeverDepth,Kt as NeverStencilFunc,b as NoBlending,Zt as NoColorSpace,Q as NoToneMapping,Lt as NormalAnimationBlendMode,v as NormalBlending,Y as NotEqualDepth,$t as NotEqualStencilFunc,rh as NumberKeyframeTrack,os as Object3D,Yh as ObjectLoader,Wt as ObjectSpaceNormalMap,Ad as OctahedronBufferGeometry,Ad as OctahedronGeometry,A as OneFactor,W as OneMinusDstAlphaFactor,N as OneMinusDstColorFactor,z as OneMinusSrcAlphaFactor,X as OneMinusSrcColorFactor,Zr as OrthographicCamera,d as PCFShadowMap,h as PCFSoftShadowMap,Ur as PMREMGenerator,Ip as ParametricGeometry,Nc as Path,mr as PerspectiveCamera,wr as Plane,Gr as PlaneBufferGeometry,Gr as PlaneGeometry,fp as PlaneHelper,Wh as PointLight,Qu as PointLightHelper,hc as Points,ac as PointsMaterial,ip as PolarGridHelper,Fc as PolyhedronBufferGeometry,Fc as PolyhedronGeometry,vu as PositionalAudio,Lu as PropertyBinding,wu as PropertyMixer,Ec as QuadraticBezierCurve,zc as QuadraticBezierCurve3,si as Quaternion,oh as QuaternionKeyframeTrack,ah as QuaternionLinearInterpolant,n as REVISION,zt as RGBADepthPacking,Pe as RGBAFormat,Fe as RGBAIntegerFormat,pt as RGBA_ASTC_10x10_Format,dt as RGBA_ASTC_10x5_Format,ht as RGBA_ASTC_10x6_Format,ut as RGBA_ASTC_10x8_Format,mt as RGBA_ASTC_12x10_Format,ft as RGBA_ASTC_12x12_Format,nt as RGBA_ASTC_4x4_Format,it as RGBA_ASTC_5x4_Format,st as RGBA_ASTC_5x5_Format,rt as RGBA_ASTC_6x5_Format,at as RGBA_ASTC_6x6_Format,ot as RGBA_ASTC_8x5_Format,lt as RGBA_ASTC_8x6_Format,ct as RGBA_ASTC_8x8_Format,gt as RGBA_BPTC_Format,tt as RGBA_ETC2_EAC_Format,qe as RGBA_PVRTC_2BPPV1_Format,Qe as RGBA_PVRTC_4BPPV1_Format,Oe as RGBA_S3TC_DXT1_Format,Ye as RGBA_S3TC_DXT3_Format,Ke as RGBA_S3TC_DXT5_Format,ze as RGBFormat,$e as RGB_ETC1_Format,et as RGB_ETC2_Format,Je as RGB_PVRTC_2BPPV1_Format,je as RGB_PVRTC_4BPPV1_Format,Ue as RGB_S3TC_DXT1_Format,Be as RGFormat,ke as RGIntegerFormat,Bd as RawShaderMaterial,Pi as Ray,zu as Raycaster,Dh as RectAreaLight,De as RedFormat,He as RedIntegerFormat,$ as ReinhardToneMapping,ce as RepeatWrapping,Bt as ReplaceStencilOp,L as ReverseSubtractEquation,Id as RingBufferGeometry,Id as RingGeometry,Nt as SRGBColorSpace,cl as Scene,Rr as ShaderChunk,Ar as ShaderLib,ur as ShaderMaterial,Hd as ShadowMaterial,Qc as Shape,Xd as ShapeBufferGeometry,Xd as ShapeGeometry,wp as ShapePath,Td as ShapeUtils,Te as ShortType,Bl as Skeleton,ju as SkeletonHelper,Zl as SkinnedMesh,y as SmoothShading,KC as SoonSpace,Yn as Source,Gi as Sphere,Ed as SphereBufferGeometry,Ed as SphereGeometry,Zu as Spherical,Hh as SphericalHarmonics3,Pc as SplineCurve,Ih as SpotLight,Uu as SpotLightHelper,Gl as Sprite,pl as SpriteMaterial,E as SrcAlphaFactor,V as SrcAlphaSaturateFactor,I as SrcColorFactor,cn as StaticCopyUsage,nn as StaticDrawUsage,an as StaticReadUsage,au as StereoCamera,hn as StreamCopyUsage,rn as StreamDrawUsage,ln as StreamReadUsage,lh as StringKeyframeTrack,C as SubtractEquation,w as SubtractiveBlending,s as TOUCH,Pt as TangentSpaceNormalMap,zd as TetrahedronBufferGeometry,zd as TetrahedronGeometry,Xp as TextGeometry,Jn as Texture,Sh as TextureLoader,Pd as TorusBufferGeometry,Pd as TorusGeometry,Wd as TorusKnotBufferGeometry,Wd as TorusKnotGeometry,bs as Triangle,At as TriangleFanDrawMode,_t as TriangleStripDrawMode,Rt as TrianglesDrawMode,Zd as TubeBufferGeometry,Zd as TubeGeometry,ie as UVMapping,_s as Uint16BufferAttribute,Is as Uint32BufferAttribute,Ls as Uint8BufferAttribute,Gs as Uint8ClampedBufferAttribute,Iu as Uniform,_r as UniformsLib,hr as UniformsUtils,Me as UnsignedByteType,Xe as UnsignedInt248Type,Ge as UnsignedIntType,Ae as UnsignedShort4444Type,Ie as UnsignedShort5551Type,Ce as UnsignedShortType,u as VSMShadowMap,Rn as Vector2,ri as Vector3,Qn as Vector4,ch as VectorKeyframeTrack,pc as VideoTexture,al as WebGL1Renderer,ni as WebGL3DRenderTarget,ei as WebGLArrayRenderTarget,yr as WebGLCubeRenderTarget,ii as WebGLMultipleRenderTargets,Wp as WebGLMultisampleRenderTarget,qn as WebGLRenderTarget,rl as WebGLRenderer,Jo as WebGLUtils,Nd as WireframeGeometry,Ct as WrapAroundEnding,St as ZeroCurvatureEnding,_ as ZeroFactor,Tt as ZeroSlopeEnding,Dt as ZeroStencilOp,mn as _SRGBAFormat,FC as boundingIsIntersected,BC as createPlaneMatrix,OC as createTexture,kC as createUVMatrix,KC as default,UC as getBoundingBox,HC as getPolygonGeometryInfo,Xt as sRGBEncoding,YC as setTexture};
38
+ */var mC,fC=(function(e,t){e.exports=function e(t,n,i){function s(a,o){if(!n[a]){if(!t[a]){if(!o&&Jy)return Jy(a);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};t[a][0].call(c.exports,(function(e){var n=t[a][1][e];return s(n||e)}),c,c.exports,e,t,n,i)}return n[a].exports}for(var r=Jy,a=0;a<i.length;a++)s(i[a]);return s}({1:[function(e,t,n){(function(e){var n,i,s=e.MutationObserver||e.WebKitMutationObserver;if(s){var r=0,a=new s(d),o=e.document.createTextNode("");a.observe(o,{characterData:!0}),n=function(){o.data=r=++r%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){d(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(d,0)};else{var l=new e.MessageChannel;l.port1.onmessage=d,n=function(){l.port2.postMessage(0)}}var c=[];function d(){var e,t;i=!0;for(var n=c.length;n;){for(t=c,c=[],e=-1;++e<n;)t[e]();n=c.length}i=!1}function h(e){1!==c.push(e)||i||n()}t.exports=h}).call(this,void 0!==Ky?Ky:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){var i=e(1);function s(){}var r={},a=["REJECTED"],o=["FULFILLED"],l=["PENDING"];function c(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==s&&p(this,e)}function d(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function h(e,t,n){i((function(){var i;try{i=t(n)}catch(t){return r.reject(e,t)}i===e?r.reject(e,new TypeError("Cannot resolve promise with itself")):r.resolve(e,i)}))}function u(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function p(e,t){var n=!1;function i(t){n||(n=!0,r.reject(e,t))}function s(t){n||(n=!0,r.resolve(e,t))}function a(){t(s,i)}var o=m(a);"error"===o.status&&i(o.value)}function m(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function f(e){return e instanceof this?e:r.resolve(new this(s),e)}function g(e){var t=new this(s);return r.reject(t,e)}function y(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var a=new Array(n),o=0,l=-1,c=new this(s);++l<n;)d(e[l],l);return c;function d(e,s){function l(e){a[s]=e,++o!==n||i||(i=!0,r.resolve(c,a))}t.resolve(e).then(l,(function(e){i||(i=!0,r.reject(c,e))}))}}function b(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var a=-1,o=new this(s);++a<n;)l(e[a]);return o;function l(e){t.resolve(e).then((function(e){i||(i=!0,r.resolve(o,e))}),(function(e){i||(i=!0,r.reject(o,e))}))}}t.exports=c,c.prototype.catch=function(e){return this.then(null,e)},c.prototype.then=function(e,t){if("function"!=typeof e&&this.state===o||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(s);return this.state!==l?h(n,this.state===o?e:t,this.outcome):this.queue.push(new d(n,e,t)),n},d.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},d.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},d.prototype.callRejected=function(e){r.reject(this.promise,e)},d.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},r.resolve=function(e,t){var n=m(u,t);if("error"===n.status)return r.reject(e,n.value);var i=n.value;if(i)p(e,i);else{e.state=o,e.outcome=t;for(var s=-1,a=e.queue.length;++s<a;)e.queue[s].callFulfilled(t)}return e},r.reject=function(e,t){e.state=a,e.outcome=t;for(var n=-1,i=e.queue.length;++n<i;)e.queue[n].callRejected(t);return e},c.resolve=f,c.reject=g,c.all=y,c.race=b},{1:1}],3:[function(e,t,n){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==Ky?Ky:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var a=r();function o(){try{if(!a||!a.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function l(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(s){if("TypeError"!==s.name)throw s;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),i=0;i<e.length;i+=1)n.append(e[i]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var c=Promise;function d(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function h(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function u(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function p(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var m="local-forage-detect-blob-support",f=void 0,g={},y=Object.prototype.toString,b="readonly",v="readwrite";function x(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=0;s<t;s++)i[s]=e.charCodeAt(s);return n}function w(e){return new c((function(t){var n=e.transaction(m,v),i=l([""]);n.objectStore(m).put(i,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function M(e){return"boolean"==typeof f?c.resolve(f):w(e).then((function(e){return f=e}))}function S(e){var t=g[e.name],n={};n.promise=new c((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function T(e){var t=g[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function C(e,t){var n=g[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function L(e,t){return new c((function(n,i){if(g[e.name]=g[e.name]||W(),e.db){if(!t)return n(e.db);S(e),e.db.close()}var s=[e.name];t&&s.push(e.version);var r=a.open.apply(a,s);t&&(r.onupgradeneeded=function(t){var n=r.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(m)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),r.onerror=function(e){e.preventDefault(),i(r.error)},r.onsuccess=function(){n(r.result),T(e)}}))}function G(e){return L(e,!1)}function R(e){return L(e,!0)}function _(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),i=e.version<e.db.version,s=e.version>e.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),s||n){if(n){var r=e.db.version+1;r>e.version&&(e.version=r)}return!0}return!1}function A(e){return new c((function(t,n){var i=new FileReader;i.onerror=n,i.onloadend=function(n){var i=btoa(n.target.result||"");t({__local_forage_encoded_blob:!0,data:i,type:e.type})},i.readAsBinaryString(e)}))}function I(e){return l([x(atob(e.data))],{type:e.type})}function X(e){return e&&e.__local_forage_encoded_blob}function E(e){var t=this,n=t._initReady().then((function(){var e=g[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return h(n,e,e),n}function z(e){S(e);for(var t=g[e.name],n=t.forages,i=0;i<n.length;i++){var s=n[i];s._dbInfo.db&&(s._dbInfo.db.close(),s._dbInfo.db=null)}return e.db=null,G(e).then((function(t){return e.db=t,_(e)?R(e):t})).then((function(i){e.db=t.db=i;for(var s=0;s<n.length;s++)n[s]._dbInfo.db=i})).catch((function(t){throw C(e,t),t}))}function P(e,t,n,i){void 0===i&&(i=1);try{var s=e.db.transaction(e.storeName,t);n(null,s)}catch(s){if(i>0&&(!e.db||"InvalidStateError"===s.name||"NotFoundError"===s.name))return c.resolve().then((function(){if(!e.db||"NotFoundError"===s.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),R(e)})).then((function(){return z(e).then((function(){P(e,t,n,i-1)}))})).catch(n);n(s)}}function W(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Z(e){var t=this,n={db:null};if(e)for(var i in e)n[i]=e[i];var s=g[n.name];s||(s=W(),g[n.name]=s),s.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=E);var r=[];function a(){return c.resolve()}for(var o=0;o<s.forages.length;o++){var l=s.forages[o];l!==t&&r.push(l._initReady().catch(a))}var d=s.forages.slice(0);return c.all(r).then((function(){return n.db=s.db,G(n)})).then((function(e){return n.db=e,_(n,t._defaultConfig.version)?R(n):e})).then((function(e){n.db=s.db=e,t._dbInfo=n;for(var i=0;i<d.length;i++){var r=d[i];r!==t&&(r._dbInfo.db=n.db,r._dbInfo.version=n.version)}}))}function N(e,t){var n=this;e=u(e);var i=new c((function(t,i){n.ready().then((function(){P(n._dbInfo,b,(function(s,r){if(s)return i(s);try{var a=r.objectStore(n._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),X(e)&&(e=I(e)),t(e)},a.onerror=function(){i(a.error)}}catch(e){i(e)}}))})).catch(i)}));return d(i,t),i}function V(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){P(n._dbInfo,b,(function(s,r){if(s)return i(s);try{var a=r.objectStore(n._dbInfo.storeName).openCursor(),o=1;a.onsuccess=function(){var n=a.result;if(n){var i=n.value;X(i)&&(i=I(i));var s=e(i,n.key,o++);void 0!==s?t(s):n.continue()}else t()},a.onerror=function(){i(a.error)}}catch(e){i(e)}}))})).catch(i)}));return d(i,t),i}function D(e,t,n){var i=this;e=u(e);var s=new c((function(n,s){var r;i.ready().then((function(){return r=i._dbInfo,"[object Blob]"===y.call(t)?M(r.db).then((function(e){return e?t:A(t)})):t})).then((function(t){P(i._dbInfo,v,(function(r,a){if(r)return s(r);try{var o=a.objectStore(i._dbInfo.storeName);null===t&&(t=void 0);var l=o.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=l.error?l.error:l.transaction.error;s(e)}}catch(e){s(e)}}))})).catch(s)}));return d(s,n),s}function H(e,t){var n=this;e=u(e);var i=new c((function(t,i){n.ready().then((function(){P(n._dbInfo,v,(function(s,r){if(s)return i(s);try{var a=r.objectStore(n._dbInfo.storeName).delete(e);r.oncomplete=function(){t()},r.onerror=function(){i(a.error)},r.onabort=function(){var e=a.error?a.error:a.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return d(i,t),i}function B(e){var t=this,n=new c((function(e,n){t.ready().then((function(){P(t._dbInfo,v,(function(i,s){if(i)return n(i);try{var r=s.objectStore(t._dbInfo.storeName).clear();s.oncomplete=function(){e()},s.onabort=s.onerror=function(){var e=r.error?r.error:r.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return d(n,e),n}function k(e){var t=this,n=new c((function(e,n){t.ready().then((function(){P(t._dbInfo,b,(function(i,s){if(i)return n(i);try{var r=s.objectStore(t._dbInfo.storeName).count();r.onsuccess=function(){e(r.result)},r.onerror=function(){n(r.error)}}catch(e){n(e)}}))})).catch(n)}));return d(n,e),n}function F(e,t){var n=this,i=new c((function(t,i){e<0?t(null):n.ready().then((function(){P(n._dbInfo,b,(function(s,r){if(s)return i(s);try{var a=r.objectStore(n._dbInfo.storeName),o=!1,l=a.openKeyCursor();l.onsuccess=function(){var n=l.result;n?0===e||o?t(n.key):(o=!0,n.advance(e)):t(null)},l.onerror=function(){i(l.error)}}catch(e){i(e)}}))})).catch(i)}));return d(i,t),i}function U(e){var t=this,n=new c((function(e,n){t.ready().then((function(){P(t._dbInfo,b,(function(i,s){if(i)return n(i);try{var r=s.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];r.onsuccess=function(){var t=r.result;t?(a.push(t.key),t.continue()):e(a)},r.onerror=function(){n(r.error)}}catch(e){n(e)}}))})).catch(n)}));return d(n,e),n}function O(e,t){t=p.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var i,s=this;if(e.name){var r=e.name===n.name&&s._dbInfo.db?c.resolve(s._dbInfo.db):G(e).then((function(t){var n=g[e.name],i=n.forages;n.db=t;for(var s=0;s<i.length;s++)i[s]._dbInfo.db=t;return t}));i=e.storeName?r.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;S(e);var i=g[e.name],s=i.forages;t.close();for(var r=0;r<s.length;r++){var o=s[r];o._dbInfo.db=null,o._dbInfo.version=n}return new c((function(t,i){var s=a.open(e.name,n);s.onerror=function(e){s.result.close(),i(e)},s.onupgradeneeded=function(){s.result.deleteObjectStore(e.storeName)},s.onsuccess=function(){var e=s.result;e.close(),t(e)}})).then((function(e){i.db=e;for(var t=0;t<s.length;t++){var n=s[t];n._dbInfo.db=e,T(n._dbInfo)}})).catch((function(t){throw(C(e,t)||c.resolve()).catch((function(){})),t}))}})):r.then((function(t){S(e);var n=g[e.name],i=n.forages;t.close();for(var s=0;s<i.length;s++)i[s]._dbInfo.db=null;return new c((function(t,n){var i=a.deleteDatabase(e.name);i.onerror=i.onblocked=function(e){var t=i.result;t&&t.close(),n(e)},i.onsuccess=function(){var e=i.result;e&&e.close(),t(e)}})).then((function(e){n.db=e;for(var t=0;t<i.length;t++)T(i[t]._dbInfo)})).catch((function(t){throw(C(e,t)||c.resolve()).catch((function(){})),t}))}))}else i=c.reject("Invalid arguments");return d(i,t),i}var Y={_driver:"asyncStorage",_initStorage:Z,_support:o(),iterate:V,getItem:N,setItem:D,removeItem:H,clear:B,length:k,key:F,keys:U,dropInstance:O};function K(){return"function"==typeof openDatabase}var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J="~~local_forage_type~",Q=/^~~local_forage_type~([^~]+)~/,q="__lfsc__:",$=q.length,ee="arbf",te="blob",ne="si08",ie="ui08",se="uic8",re="si16",ae="si32",oe="ur16",le="ui32",ce="fl32",de="fl64",he=$+ee.length,ue=Object.prototype.toString;function pe(e){var t,n,i,s,r,a=.75*e.length,o=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var c=new ArrayBuffer(a),d=new Uint8Array(c);for(t=0;t<o;t+=4)n=j.indexOf(e[t]),i=j.indexOf(e[t+1]),s=j.indexOf(e[t+2]),r=j.indexOf(e[t+3]),d[l++]=n<<2|i>>4,d[l++]=(15&i)<<4|s>>2,d[l++]=(3&s)<<6|63&r;return c}function me(e){var t,n=new Uint8Array(e),i="";for(t=0;t<n.length;t+=3)i+=j[n[t]>>2],i+=j[(3&n[t])<<4|n[t+1]>>4],i+=j[(15&n[t+1])<<2|n[t+2]>>6],i+=j[63&n[t+2]];return n.length%3==2?i=i.substring(0,i.length-1)+"=":n.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}function fe(e,t){var n="";if(e&&(n=ue.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===ue.call(e.buffer))){var i,s=q;e instanceof ArrayBuffer?(i=e,s+=ee):(i=e.buffer,"[object Int8Array]"===n?s+=ne:"[object Uint8Array]"===n?s+=ie:"[object Uint8ClampedArray]"===n?s+=se:"[object Int16Array]"===n?s+=re:"[object Uint16Array]"===n?s+=oe:"[object Int32Array]"===n?s+=ae:"[object Uint32Array]"===n?s+=le:"[object Float32Array]"===n?s+=ce:"[object Float64Array]"===n?s+=de:t(new Error("Failed to get type for BinaryArray"))),t(s+me(i))}else if("[object Blob]"===n){var r=new FileReader;r.onload=function(){var n=J+e.type+"~"+me(this.result);t(q+te+n)},r.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}}function ge(e){if(e.substring(0,$)!==q)return JSON.parse(e);var t,n=e.substring(he),i=e.substring($,he);if(i===te&&Q.test(n)){var s=n.match(Q);t=s[1],n=n.substring(s[0].length)}var r=pe(n);switch(i){case ee:return r;case te:return l([r],{type:t});case ne:return new Int8Array(r);case ie:return new Uint8Array(r);case se:return new Uint8ClampedArray(r);case re:return new Int16Array(r);case oe:return new Uint16Array(r);case ae:return new Int32Array(r);case le:return new Uint32Array(r);case ce:return new Float32Array(r);case de:return new Float64Array(r);default:throw new Error("Unkown type: "+i)}}var ye={serialize:fe,deserialize:ge,stringToBuffer:pe,bufferToString:me};function be(e,t,n,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,i)}function ve(e){var t=this,n={db:null};if(e)for(var i in e)n[i]="string"!=typeof e[i]?e[i].toString():e[i];var s=new c((function(e,i){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return i(e)}n.db.transaction((function(s){be(s,n,(function(){t._dbInfo=n,e()}),(function(e,t){i(t)}))}),i)}));return n.serializer=ye,s}function xe(e,t,n,i,s,r){e.executeSql(n,i,s,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,o){o.rows.length?r(e,a):be(e,t,(function(){e.executeSql(n,i,s,r)}),r)}),r):r(e,a)}),r)}function we(e,t){var n=this;e=u(e);var i=new c((function(t,i){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){xe(n,s,"SELECT * FROM "+s.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var i=n.rows.length?n.rows.item(0).value:null;i&&(i=s.serializer.deserialize(i)),t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return d(i,t),i}function Me(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){xe(n,s,"SELECT * FROM "+s.storeName,[],(function(n,i){for(var r=i.rows,a=r.length,o=0;o<a;o++){var l=r.item(o),c=l.value;if(c&&(c=s.serializer.deserialize(c)),void 0!==(c=e(c,l.key,o+1)))return void t(c)}t()}),(function(e,t){i(t)}))}))})).catch(i)}));return d(i,t),i}function Se(e,t,n,i){var s=this;e=u(e);var r=new c((function(r,a){s.ready().then((function(){void 0===t&&(t=null);var o=t,l=s._dbInfo;l.serializer.serialize(t,(function(t,c){c?a(c):l.db.transaction((function(n){xe(n,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){r(o)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void r(Se.apply(s,[e,o,n,i-1]));a(t)}}))}))})).catch(a)}));return d(r,n),r}function Te(e,t,n){return Se.apply(this,[e,t,n,1])}function Ce(e,t){var n=this;e=u(e);var i=new c((function(t,i){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){xe(n,s,"DELETE FROM "+s.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){i(t)}))}))})).catch(i)}));return d(i,t),i}function Le(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){xe(t,i,"DELETE FROM "+i.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return d(n,e),n}function Ge(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){xe(t,i,"SELECT COUNT(key) as c FROM "+i.storeName,[],(function(t,n){var i=n.rows.item(0).c;e(i)}),(function(e,t){n(t)}))}))})).catch(n)}));return d(n,e),n}function Re(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){xe(n,s,"SELECT key FROM "+s.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var i=n.rows.length?n.rows.item(0).key:null;t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return d(i,t),i}function _e(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){xe(t,i,"SELECT key FROM "+i.storeName,[],(function(t,n){for(var i=[],s=0;s<n.rows.length;s++)i.push(n.rows.item(s).key);e(i)}),(function(e,t){n(t)}))}))})).catch(n)}));return d(n,e),n}function Ae(e){return new c((function(t,n){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,i){for(var s=[],r=0;r<i.rows.length;r++)s.push(i.rows.item(r).name);t({db:e,storeNames:s})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}function Ie(e,t){t=p.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var i,s=this;return d(i=e.name?new c((function(t){var i;i=e.name===n.name?s._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:i,storeNames:[e.storeName]}):t(Ae(i))})).then((function(e){return new c((function(t,n){e.db.transaction((function(i){function s(e){return new c((function(t,n){i.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var r=[],a=0,o=e.storeNames.length;a<o;a++)r.push(s(e.storeNames[a]));c.all(r).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):c.reject("Invalid arguments"),t),i}var Xe={_driver:"webSQLStorage",_initStorage:ve,_support:K(),iterate:Me,getItem:we,setItem:Te,removeItem:Ce,clear:Le,length:Ge,key:Re,keys:_e,dropInstance:Ie};function Ee(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function ze(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function Pe(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function We(){return!Pe()||localStorage.length>0}function Ze(e){var t=this,n={};if(e)for(var i in e)n[i]=e[i];return n.keyPrefix=ze(e,t._defaultConfig),We()?(t._dbInfo=n,n.serializer=ye,c.resolve()):c.reject()}function Ne(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var i=localStorage.key(n);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return d(n,e),n}function Ve(e,t){var n=this;e=u(e);var i=n.ready().then((function(){var t=n._dbInfo,i=localStorage.getItem(t.keyPrefix+e);return i&&(i=t.serializer.deserialize(i)),i}));return d(i,t),i}function De(e,t){var n=this,i=n.ready().then((function(){for(var t=n._dbInfo,i=t.keyPrefix,s=i.length,r=localStorage.length,a=1,o=0;o<r;o++){var l=localStorage.key(o);if(0===l.indexOf(i)){var c=localStorage.getItem(l);if(c&&(c=t.serializer.deserialize(c)),void 0!==(c=e(c,l.substring(s),a++)))return c}}}));return d(i,t),i}function He(e,t){var n=this,i=n.ready().then((function(){var t,i=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return d(i,t),i}function Be(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,i=[],s=0;s<n;s++){var r=localStorage.key(s);0===r.indexOf(e.keyPrefix)&&i.push(r.substring(e.keyPrefix.length))}return i}));return d(n,e),n}function ke(e){var t=this.keys().then((function(e){return e.length}));return d(t,e),t}function Fe(e,t){var n=this;e=u(e);var i=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return d(i,t),i}function Ue(e,t,n){var i=this;e=u(e);var s=i.ready().then((function(){void 0===t&&(t=null);var n=t;return new c((function(s,r){var a=i._dbInfo;a.serializer.serialize(t,(function(t,i){if(i)r(i);else try{localStorage.setItem(a.keyPrefix+e,t),s(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||r(e),r(e)}}))}))}));return d(s,n),s}function Oe(e,t){if(t=p.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var i,s=this;return d(i=e.name?new c((function(t){e.storeName?t(ze(e,s._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):c.reject("Invalid arguments"),t),i}var Ye={_driver:"localStorageWrapper",_initStorage:Ze,_support:Ee(),iterate:De,getItem:Ve,setItem:Ue,removeItem:Fe,clear:Ne,length:ke,key:He,keys:Be,dropInstance:Oe},Ke=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},je=function(e,t){for(var n=e.length,i=0;i<n;){if(Ke(e[i],t))return!0;i++}return!1},Je=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Qe={},qe={},$e={INDEXEDDB:Y,WEBSQL:Xe,LOCALSTORAGE:Ye},et=[$e.INDEXEDDB._driver,$e.WEBSQL._driver,$e.LOCALSTORAGE._driver],tt=["dropInstance"],nt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),it={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function st(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function rt(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(Je(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var at=new(function(){function e(t){for(var n in s(this,e),$e)if($e.hasOwnProperty(n)){var i=$e[n],r=i._driver;this[n]=r,Qe[r]||this.defineDriver(i)}this._defaultConfig=rt({},it),this._config=rt({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":i(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var i=new c((function(t,n){try{var i=e._driver,s=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(s);for(var r=nt.concat("_initStorage"),a=0,o=r.length;a<o;a++){var l=r[a];if((!je(tt,l)||e[l])&&"function"!=typeof e[l])return void n(s)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=c.reject(t);return d(n,arguments[arguments.length-1]),n}},n=0,i=tt.length;n<i;n++){var s=tt[n];e[s]||(e[s]=t(s))}}();var h=function(n){Qe[i]&&console.info("Redefining LocalForage driver: "+i),Qe[i]=e,qe[i]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(h,n):h(!!e._support):h(!0)}catch(e){n(e)}}));return h(i,t,n),i},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var i=Qe[e]?c.resolve(Qe[e]):c.reject(new Error("Driver not found."));return h(i,t,n),i},e.prototype.getSerializer=function(e){var t=c.resolve(ye);return h(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return h(n,e,e),n},e.prototype.setDriver=function(e,t,n){var i=this;Je(e)||(e=[e]);var s=this._getSupportedDrivers(e);function r(){i._config.driver=i.driver()}function a(e){return i._extend(e),r(),i._ready=i._initStorage(i._config),i._ready}function o(e){return function(){var t=0;function n(){for(;t<e.length;){var s=e[t];return t++,i._dbInfo=null,i._ready=null,i.getDriver(s).then(a).catch(n)}r();var o=new Error("No available storage method found.");return i._driverSet=c.reject(o),i._driverSet}return n()}}var l=null!==this._driverSet?this._driverSet.catch((function(){return c.resolve()})):c.resolve();return this._driverSet=l.then((function(){var e=s[0];return i._dbInfo=null,i._ready=null,i.getDriver(e).then((function(e){i._driver=e._driver,r(),i._wrapLibraryMethodsWithReady(),i._initDriver=o(s)}))})).catch((function(){r();var e=new Error("No available storage method found.");return i._driverSet=c.reject(e),i._driverSet})),h(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!qe[e]},e.prototype._extend=function(e){rt(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,i=e.length;n<i;n++){var s=e[n];this.supports(s)&&t.push(s)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=nt.length;e<t;e++)st(this,nt[e])},e.prototype.createInstance=function(t){return new e(t)},e}());t.exports=at},{3:3}]},{},[4])(4)}(mC={exports:{}},mC.exports),mC.exports);class gC{constructor(e){this.name="EXT_mesh_gpu_instancing",this.parser=e}createNodeMesh(e){const t=this.parser.json.nodes[e];if(!t.extensions||!t.extensions[this.name]||void 0===t.mesh)return null;const n=t.extensions[this.name].attributes,i=[],s={};for(const e in n)i.push(this.parser.getDependency("accessor",n[e]).then((t=>(s[e]=t,s[e]))));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=e.matrix.clone(),n=e.position.clone().set(0,0,0),a=e.quaternion.clone().set(0,0,0,1),o=e.scale.clone().set(1,1,1),l=new Kl(e.geometry,e.material,i);for(let e=0;e<i;e++)s.TRANSLATION&&n.fromBufferAttribute(s.TRANSLATION,e),s.ROTATION&&a.fromBufferAttribute(s.ROTATION,e),s.SCALE&&o.fromBufferAttribute(s.SCALE,e),l.setMatrixAt(e,t.compose(n,a,o));for(const t in s)"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,s[t]);os.prototype.copy.call(l,e),l.frustumCulled=!1,this.parser.assignFinalMaterial(l),r.push(l)}if(t.isGroup){for(;t.children.length>0;)t.remove(t.children[0]);for(const e of r)t.add(e);return t}return r[0]})))}}const yC=()=>{self.noCompressWorker=function(e,t){const[n]=new Uint32Array(e,t,1),i={byteOffset:t+=4,length:3*n},s={byteOffset:t+=3*n*4,length:2*n},r={byteOffset:t+=2*n*4,length:4*n},a={byteOffset:t+=4*n*1,length:3*n};t+=3*n*1;let o=(r.length+a.length)%4;o>0&&(o=4-o,t+=o);const l=new Uint32Array(e,t,1);t+=4;const[c]=l,d={byteOffset:t,length:c};t+=4*c;const h=new Uint32Array(e,t,1);t+=4;const[u]=h,p=[];if(u>0)for(let n=0;n<u;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const a=new Uint8Array(e,t,r);t+=r;const o=(new TextDecoder).decode(a);p.push({start:n,count:i,uuid:o,alphaMode:s})}return{buffer:e,position:i,normal:a,color:r,texcoord:s,indice:d,sub_mesh:p}}},bC=()=>{self.gzipCompressWorker=function(e){const t=new Uint8Array(e,4,e.byteLength-4),n=new pako.Inflate;n.push(t,!0);const{result:i}=n;if(i instanceof Uint8Array){const{buffer:e}=i;let t=0;const[n]=new Uint32Array(e,t,1);t+=4;const s={byteOffset:t,length:3*n};t+=3*n*4;const r={byteOffset:t,length:2*n};t+=2*n*4;const a={byteOffset:t,length:4*n};t+=4*n*1;const o={byteOffset:t,length:3*n};t+=3*n*1;let l=(a.length+o.length)%4;l>0&&(l=4-l,t+=l);const c=new Uint32Array(e,t,1);t+=4;const[d]=c,h={byteOffset:t,length:d};t+=4*d;const u=new Uint32Array(e,t,1);t+=4;const[p]=u,m=[];if(p>0)for(let n=0;n<p;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const a=new Uint8Array(e,t,r);t+=r;const o=(new TextDecoder).decode(a);m.push({start:n,count:i,uuid:o,alphaMode:s})}return{buffer:e,position:s,normal:o,color:a,texcoord:r,indice:h,sub_mesh:m}}}},vC=()=>{self.parseChunkWorker=function(e){let t=0;const n=new Int8Array(e,t,128);t+=128,(new TextDecoder).decode(n.slice(0,4));const[i]=n.slice(4,8);if(0===i)return self.noCompressWorker(e,t);if(1===i){const t=e.slice(128);return self.gzipCompressWorker(t)}throw new Error("unknown compress mode [ .sbmx model ]")}},xC="\n onmessage = function ( e ) {\n \n const message = e.data\n\n switch ( message.type ) {\n\n case 'decode': {\n\n const chunkInfo = self.parseChunkWorker( message.data )\n\n if ( chunkInfo ) { \n\n self.postMessage( \n { type: 'decode', data: chunkInfo, }, \n [ chunkInfo.buffer ]\n )\n\n } else {\n\n self.postMessage( { type: 'decode', data: {}, } )\n\n }\n\n break\n \n }\n \n }\n\n }\n\n";class wC extends fh{constructor(e){super(),this.store=e,this.loadedTextures=new Map,this.loadedMaterialsMap=new Map,this.defaultMaterial=new kd({name:"defaultDatMaterial",color:0}),this.loadedMaterials=[this.defaultMaterial],this.dracoDecoderPath=null,this.workerPool=new zy(4),this.workerSourceURL="";const t=this._initWorkerCreator();this.workerPool.setWorkerCreator(t)}parseAsync(e,t){return tf(this,void 0,void 0,(function*(){const[n]=yield Promise.allSettled([this._decodeBuffer(e,t),this._createMaterial(t)]);if("fulfilled"===n.status&&n.value){const e=jm(t),i=this._createMesh(n.value,e),s=new qo;return s.add(i),s}}))}_decodeBuffer(e,t){return tf(this,void 0,void 0,(function*(){const n=yield this.store.getItem(`${t}_object`);if(n)return n;const[{data:i}]=yield Promise.all([this.workerPool.postMessage({type:"decode",data:e},[e])]);if(i){const{type:e,data:n}=null!=i?i:{};if("decode"===e&&n){const{buffer:{byteLength:e}}=n;return Jf(e)&&e/1024/1024<=500&&df((()=>{this.store.setItem(`${t}_object`,n)})),n}}}))}_initWorkerCreator(){if(!this.workerSourceURL){const e=yC.toString(),t=bC.toString(),n=vC.toString(),i=["/* dat decoder */",["/* pako */","\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pako = {}));\n}(this, (function (exports) { 'use strict';\n\n // Note: adler32 takes 12% for level 0 and 2% for level 6.\n // It isn't worth it to make additional optimizations as in original.\n // Small size is preferable.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express ofr implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const adler32 = (adler, buf, len, pos) => {\n let s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n };\n\n\n var adler32_1 = adler32;\n\n // Note: we can't get significant speed boost here.\n // So write code to minimize size - no pregenerated tables\n // and array tools dependencies.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // Use ordinary array, since untyped makes no boost here\n const makeTable = () => {\n let c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n };\n\n // Create table on load. Just 255 signed longs. Not a problem.\n const crcTable = new Uint32Array(makeTable());\n\n\n const crc32 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n\n crc ^= -1;\n\n for (let i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n };\n\n\n var crc32_1 = crc32;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // See state defs from inflate.js\n const BAD$1 = 30; /* got a data error -- remain here until reset */\n const TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n /*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n var inffast = function inflate_fast(strm, start) {\n let _in; /* local strm.input */\n let last; /* have enough input while in < last */\n let _out; /* local strm.output */\n let beg; /* inflate()'s initial strm.output */\n let end; /* while out < end, enough space available */\n //#ifdef INFLATE_STRICT\n let dmax; /* maximum distance from zlib header */\n //#endif\n let wsize; /* window size or zero if not using window */\n let whave; /* valid bytes in the window */\n let wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n let s_window; /* allocated sliding window, if wsize != 0 */\n let hold; /* local strm.hold */\n let bits; /* local strm.bits */\n let lcode; /* local strm.lencode */\n let dcode; /* local strm.distcode */\n let lmask; /* mask for first level of length codes */\n let dmask; /* mask for first level of distance codes */\n let here; /* retrieved table entry */\n let op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n let len; /* match length, unused bytes */\n let dist; /* match distance */\n let from; /* where to copy match from */\n let from_source;\n\n\n let input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n const state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n //#ifdef INFLATE_STRICT\n dmax = state.dmax;\n //#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n //#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n //#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // if (len <= op - whave) {\n // do {\n // output[_out++] = 0;\n // } while (--len);\n // continue top;\n // }\n // len -= op - whave;\n // do {\n // output[_out++] = 0;\n // } while (--op > whave);\n // if (op === 0) {\n // from = _out - dist;\n // do {\n // output[_out++] = output[from++];\n // } while (--len);\n // continue top;\n // }\n //#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const MAXBITS = 15;\n const ENOUGH_LENS$1 = 852;\n const ENOUGH_DISTS$1 = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const CODES$1 = 0;\n const LENS$1 = 1;\n const DISTS$1 = 2;\n\n const lbase = new Uint16Array([ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n ]);\n\n const lext = new Uint8Array([ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n ]);\n\n const dbase = new Uint16Array([ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n ]);\n\n const dext = new Uint8Array([ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n ]);\n\n const inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) =>\n {\n const bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n let len = 0; /* a code's length in bits */\n let sym = 0; /* index of code symbols */\n let min = 0, max = 0; /* minimum and maximum code lengths */\n let root = 0; /* number of index bits for root table */\n let curr = 0; /* number of index bits for current table */\n let drop = 0; /* code bits to drop for sub-table */\n let left = 0; /* number of prefix codes available */\n let used = 0; /* code entries in table used */\n let huff = 0; /* Huffman code */\n let incr; /* for incrementing code, index */\n let fill; /* index for replicating entries */\n let low; /* low bits for current root entry */\n let mask; /* mask for low root bits */\n let next; /* next available space in table */\n let base = null; /* base value table to use */\n let base_index = 0;\n // let shoextra; /* extra bits table to use */\n let end; /* use base and extra for symbol > end */\n const count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n const offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n let extra = null;\n let extra_index = 0;\n\n let here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n };\n\n\n var inftrees = inflate_table;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var constants$1 = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n\n\n\n\n\n const CODES = 0;\n const LENS = 1;\n const DISTS = 2;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_FINISH: Z_FINISH$1, Z_BLOCK, Z_TREES,\n Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR,\n Z_DEFLATED\n } = constants$1;\n\n\n /* STATES ====================================================================*/\n /* ===========================================================================*/\n\n\n const HEAD = 1; /* i: waiting for magic header */\n const FLAGS = 2; /* i: waiting for method and flags (gzip) */\n const TIME = 3; /* i: waiting for modification time (gzip) */\n const OS = 4; /* i: waiting for extra flags and operating system (gzip) */\n const EXLEN = 5; /* i: waiting for extra length (gzip) */\n const EXTRA = 6; /* i: waiting for extra bytes (gzip) */\n const NAME = 7; /* i: waiting for end of file name (gzip) */\n const COMMENT = 8; /* i: waiting for end of comment (gzip) */\n const HCRC = 9; /* i: waiting for header crc (gzip) */\n const DICTID = 10; /* i: waiting for dictionary check value */\n const DICT = 11; /* waiting for inflateSetDictionary() call */\n const TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n const TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\n const STORED = 14; /* i: waiting for stored size (length and complement) */\n const COPY_ = 15; /* i/o: same as COPY below, but only first time in */\n const COPY = 16; /* i/o: waiting for input or output to copy stored block */\n const TABLE = 17; /* i: waiting for dynamic block table lengths */\n const LENLENS = 18; /* i: waiting for code length code lengths */\n const CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\n const LEN_ = 20; /* i: same as LEN below, but only first time in */\n const LEN = 21; /* i: waiting for length/lit/eob code */\n const LENEXT = 22; /* i: waiting for length extra bits */\n const DIST = 23; /* i: waiting for distance code */\n const DISTEXT = 24; /* i: waiting for distance extra bits */\n const MATCH = 25; /* o: waiting for output space to copy string */\n const LIT = 26; /* o: waiting for output space to write literal */\n const CHECK = 27; /* i: waiting for 32-bit check value */\n const LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\n const DONE = 29; /* finished check, done -- remain here until reset */\n const BAD = 30; /* got a data error -- remain here until reset */\n const MEM = 31; /* got an inflate() memory error -- remain here until reset */\n const SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n /* ===========================================================================*/\n\n\n\n const ENOUGH_LENS = 852;\n const ENOUGH_DISTS = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const MAX_WBITS = 15;\n /* 32K LZ77 window */\n const DEF_WBITS = MAX_WBITS;\n\n\n const zswap32 = (q) => {\n\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n };\n\n\n function InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Int32Array(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n }\n\n\n const inflateResetKeep = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\"));\n return Z_OK$1;\n };\n\n\n const inflateReset = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n };\n\n\n const inflateReset2 = (strm, windowBits) => {\n let wrap;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n };\n\n\n const inflateInit2 = (strm, windowBits) => {\n\n if (!strm) { return Z_STREAM_ERROR$1; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n const state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n };\n\n\n const inflateInit = (strm) => {\n\n return inflateInit2(strm, DEF_WBITS);\n };\n\n\n /*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\n let virgin = true;\n\n let lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\n\n const fixedtables = (state) => {\n\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n let sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inftrees(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inftrees(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n };\n\n\n /*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\n const updatewindow = (strm, src, end, copy) => {\n\n let dist;\n const state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n };\n\n\n const inflate$1 = (strm, flush) => {\n\n let state;\n let input, output; // input/output buffers\n let next; /* next input INDEX */\n let put; /* next output INDEX */\n let have, left; /* available input and output */\n let hold; /* bit buffer */\n let bits; /* bits in bit buffer */\n let _in, _out; /* save starting available input and output */\n let copy; /* number of stored or match bytes to copy */\n let from; /* where to copy match bytes from */\n let from_source;\n let here = 0; /* current decoding table entry */\n let here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //let last; /* parent table entry */\n let last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n let len; /* length to copy for repeats, bits to drop */\n let ret; /* return code */\n const hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n let opts;\n\n let n; // temporary variable for NEED_BITS\n\n const order = /* permutation of code lengths */\n new Uint8Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]);\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR$1;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK$1;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n\n // !!! pako patch. Force use `options.windowBits` if passed.\n // Required to always use max window size by default.\n state.dmax = 1 << state.wbits;\n //state.dmax = 1 << len;\n\n //Tracev((stderr, \"inflate: zlib header ok\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32_1(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n output.set(input.subarray(next, next + copy), put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n //#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracev((stderr, \"inflate: table sizes ok\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inftrees(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inftrees(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inffast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracevv((stderr, \"inflate: distance %u\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // Trace((stderr, \"inflate.c too far\"));\n // copy -= state.whave;\n // if (copy > state.length) { copy = state.length; }\n // if (copy > left) { copy = left; }\n // left -= copy;\n // state.length -= copy;\n // do {\n // output[put++] = 0;\n // } while (--copy);\n // if (state.length === 0) { state.mode = LEN; }\n // break;\n //#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, put - _out) : adler32_1(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH$1))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n };\n\n\n const inflateEnd = (strm) => {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR$1;\n }\n\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n };\n\n\n const inflateGetHeader = (strm, head) => {\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR$1; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK$1;\n };\n\n\n const inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n\n let state;\n let dictid;\n let ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR$1; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32_1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\"));\n return Z_OK$1;\n };\n\n\n var inflateReset_1 = inflateReset;\n var inflateReset2_1 = inflateReset2;\n var inflateResetKeep_1 = inflateResetKeep;\n var inflateInit_1 = inflateInit;\n var inflateInit2_1 = inflateInit2;\n var inflate_2$1 = inflate$1;\n var inflateEnd_1 = inflateEnd;\n var inflateGetHeader_1 = inflateGetHeader;\n var inflateSetDictionary_1 = inflateSetDictionary;\n var inflateInfo = 'pako inflate (from Nodeca project)';\n\n /* Not implemented\n module.exports.inflateCopy = inflateCopy;\n module.exports.inflateGetDictionary = inflateGetDictionary;\n module.exports.inflateMark = inflateMark;\n module.exports.inflatePrime = inflatePrime;\n module.exports.inflateSync = inflateSync;\n module.exports.inflateSyncPoint = inflateSyncPoint;\n module.exports.inflateUndermine = inflateUndermine;\n */\n\n var inflate_1$1 = {\n \tinflateReset: inflateReset_1,\n \tinflateReset2: inflateReset2_1,\n \tinflateResetKeep: inflateResetKeep_1,\n \tinflateInit: inflateInit_1,\n \tinflateInit2: inflateInit2_1,\n \tinflate: inflate_2$1,\n \tinflateEnd: inflateEnd_1,\n \tinflateGetHeader: inflateGetHeader_1,\n \tinflateSetDictionary: inflateSetDictionary_1,\n \tinflateInfo: inflateInfo\n };\n\n const _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n\n var assign = function (obj /*from1, from2, from3, ...*/) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n };\n\n\n // Join array of chunks to single array.\n var flattenChunks = (chunks) => {\n // calculate data length\n let len = 0;\n\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n const result = new Uint8Array(len);\n\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n };\n\n var common = {\n \tassign: assign,\n \tflattenChunks: flattenChunks\n };\n\n // String encode/decode helpers\n\n\n // Quick check if we can use fast array to bin string conversion\n //\n // - apply(Array) can fail on Android 2.2\n // - apply(Uint8Array) can fail on iOS 5.1 Safari\n //\n let STR_APPLY_UIA_OK = true;\n\n try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n // Table with utf8 lengths (calculated by first byte of sequence)\n // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n // because max possible codepoint is 0x10ffff\n const _utf8len = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n }\n _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n // convert string to array (typed, when possible)\n var string2buf = (str) => {\n if (typeof TextEncoder === 'function' && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n };\n\n // Helper\n const buf2binstring = (buf, len) => {\n // On Chrome, the arguments in a function call that are allowed is `65534`.\n // If the length of the buffer is smaller than that, we can use this optimization,\n // otherwise we will take a slower path.\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n\n let result = '';\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n\n\n // convert array to string\n var buf2string = (buf, max) => {\n const len = max || buf.length;\n\n if (typeof TextDecoder === 'function' && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n\n let i, out;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n const utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n let c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n let c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n };\n\n\n // Calculate max possible position in utf8 buffer,\n // that will not break sequence. If that's not possible\n // - (very small limits) return max size as is.\n //\n // buf[] - utf8 bytes array\n // max - length limit (mandatory);\n var utf8border = (buf, max) => {\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n };\n\n var strings = {\n \tstring2buf: string2buf,\n \tbuf2string: buf2string,\n \tutf8border: utf8border\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n }\n\n var zstream = ZStream;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n }\n\n var gzheader = GZheader;\n\n const toString = Object.prototype.toString;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_NO_FLUSH, Z_FINISH,\n Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR\n } = constants$1;\n\n /* ===========================================================================*/\n\n\n /**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n /* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n /**\n * Inflate.result -> Uint8Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param).\n **/\n\n /**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n /**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n /**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako')\n * const chunk1 = new Uint8Array([1,2,3,4,5,6,7,8,9])\n * const chunk2 = new Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * const inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\n function Inflate(options) {\n this.options = common.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ''\n }, options || {});\n\n const opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new zstream();\n this.strm.avail_out = 0;\n\n let status = inflate_1$1.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n\n this.header = new gzheader();\n\n inflate_1$1.inflateGetHeader(this.strm, this.header);\n\n // Setup dictionary\n if (opt.dictionary) {\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n opt.dictionary = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) { //In raw mode we need to set the dictionary early\n status = inflate_1$1.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n }\n }\n }\n\n /**\n * Inflate#push(data[, flush_mode]) -> Boolean\n * - data (Uint8Array|ArrayBuffer): input data\n * - flush_mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE\n * flush modes. See constants. Skipped or `false` means Z_NO_FLUSH,\n * `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. If end of stream detected,\n * [[Inflate#onEnd]] will be called.\n *\n * `flush_mode` is not needed for normal operation, because end of stream\n * detected automatically. You may try to use it for advanced things, but\n * this functionality was not tested.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\n Inflate.prototype.push = function (data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n\n if (this.ended) return false;\n\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n\n // Convert data if needed\n if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n for (;;) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate_1$1.inflate(strm, _flush_mode);\n\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$1.inflateSetDictionary(strm, dictionary);\n\n if (status === Z_OK) {\n status = inflate_1$1.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n // Replace code with more verbose\n status = Z_NEED_DICT;\n }\n }\n\n // Skip snyc markers if more data follows and not raw mode\n while (strm.avail_in > 0 &&\n status === Z_STREAM_END &&\n strm.state.wrap > 0 &&\n data[strm.next_in] !== 0)\n {\n inflate_1$1.inflateReset(strm);\n status = inflate_1$1.inflate(strm, _flush_mode);\n }\n\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n // Remember real `avail_out` value, because we may patch out buffer content\n // to align utf8 strings boundaries.\n last_avail_out = strm.avail_out;\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n\n if (this.options.to === 'string') {\n\n let next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail & realign counters\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n\n this.onData(utf8str);\n\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n\n // Must repeat iteration if out buffer is full\n if (status === Z_OK && last_avail_out === 0) continue;\n\n // Finalize if end of stream reached.\n if (status === Z_STREAM_END) {\n status = inflate_1$1.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n\n if (strm.avail_in === 0) break;\n }\n\n return true;\n };\n\n\n /**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|String): output data. When string output requested,\n * each chunk will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\n Inflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n };\n\n\n /**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH). By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\n Inflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = common.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n\n\n /**\n * inflate(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako');\n * const input = pako.deflate(new Uint8Array([1,2,3,4,5,6,7,8,9]));\n * let output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err) {\n * console.log(err);\n * }\n * ```\n **/\n function inflate(input, options) {\n const inflator = new Inflate(options);\n\n inflator.push(input);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) throw inflator.msg || messages[inflator.err];\n\n return inflator.result;\n }\n\n\n /**\n * inflateRaw(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n }\n\n\n /**\n * ungzip(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\n var Inflate_1 = Inflate;\n var inflate_2 = inflate;\n var inflateRaw_1 = inflateRaw;\n var ungzip = inflate;\n var constants = constants$1;\n\n var inflate_1 = {\n \tInflate: Inflate_1,\n \tinflate: inflate_2,\n \tinflateRaw: inflateRaw_1,\n \tungzip: ungzip,\n \tconstants: constants\n };\n\n exports.Inflate = Inflate_1;\n exports.constants = constants;\n exports['default'] = inflate_1;\n exports.inflate = inflate_2;\n exports.inflateRaw = inflateRaw_1;\n exports.ungzip = ungzip;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n\n","/* noCompress */",e.substring(e.indexOf("{")+1,e.lastIndexOf("}")),"/* gzipCompress */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),"/* parseChunk */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n"),"","/* worker */",xC].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}return()=>new Worker(this.workerSourceURL)}_createMesh(e,t){const{buffer:n,position:i,normal:s,texcoord:r,indice:a,sub_mesh:o}=e,l=new Uint32Array(n,a.byteOffset,a.length),c=new Float32Array(n,i.byteOffset,i.length),d=new Int8Array(n,s.byteOffset,s.length),h=new Float32Array(n,r.byteOffset,r.length),u=new Bs;u.setIndex(new Ts(l,1)),u.setAttribute("position",new Ts(c,3)),u.setAttribute("normal",new Ts(d,3,!0)),u.setAttribute("uv",new Ts(h,2));for(let e=0;e<o.length;e++){const{uuid:n,start:i,count:s}=o[e],r=this.loadedMaterialsMap.get(n);if(r){const{materialIndex:e}=r;u.addGroup(i,s,e)}else u.addGroup(i,s,0),console.warn(`sbmx material: not found uuid: ${n} in file: ${t+"textureIndex.json"}`)}Hy.generate(u).then((e=>{u.boundsTree=e}));const p=new ar(u,this.loadedMaterials);return p.castShadow=!0,p.receiveShadow=!0,p}_createMaterial(e){return tf(this,void 0,void 0,(function*(){const t=jm(e),n=t+"textureIndex.json",i=this.loadedTextures.get(n);if(i)return i;const s=yield this.store.getItem(`${e}_texture`);let r;if(s)r=s,this.loadedTextures.set(n,Promise.resolve(r));else{const t=this.loadedTextures.get(n);if(t)return t;const i=cf(n).then((e=>e.json()));this.loadedTextures.set(n,i),r=yield i,df((()=>{this.store.setItem(`${e}_texture`,r)}))}Object.entries(r).forEach((([e,n])=>{if(this.loadedMaterialsMap.has(e))return;const{name:i,base_map:s,nor_map:r,alphamode:a,color:o={r:1,g:1,b:1,a:1},metallic:l=.5,roughness:c=.5}=n,{r:d,g:h,b:u,a:p}=o,m=0!==a,f=new kd({name:i,color:new Fn(d,h,u),side:0,metalness:l,roughness:c,opacity:p,transparent:m,depthWrite:!m});if(s){const e=t+s;(new Sh).load(e,(e=>{e.flipY=!0,e.encoding=3001,e.wrapS=1e3,e.wrapT=1e3,e.minFilter=1008,e.magFilter=1006,e.needsUpdate=!0,f.map=e,f.needsUpdate=!0,Yx.needsUpdate=!0}))}if(r){const e=t+r;(new Sh).load(e,(e=>{e.flipY=!0,e.encoding=3001,e.wrapS=1e3,e.wrapT=1e3,e.needsUpdate=!0,f.normalMap=e,f.needsUpdate=!0,Yx.needsUpdate=!0}))}const g=this.loadedMaterials.push(f)-1;this.loadedMaterialsMap.set(e,{material:f,materialIndex:g})}))}))}dispose(){this.workerPool.dispose(),URL.revokeObjectURL(this.workerSourceURL)}}const MC=new Map,SC=e=>{if(MC.has(e))return MC.get(e);const t=new Jn;return MC.set(e,t),(new xh).load(e,(e=>{t.image=e,t.needsUpdate=!0,Yx.needsUpdate=!0})),t.encoding=3001,t.wrapS=1e3,t.wrapT=1e3,t.flipY=!1,t.anisotropy=16,t.mipmaps=[],t.generateMipmaps=!0,t},TC=(e,t,n)=>{const[i,s,r,a,o]=t,l=a<1;return new kd({name:e,color:new Fn(i,s,r),opacity:a,transparent:l,depthWrite:!l,alphaTest:.01,map:n,side:o})};class CC extends DataView{constructor(e,t){super(e),this.isLE=!0,this.appKeys=t}byteRevers(e,t){const n=t%this.appKeys.length;return e^this.appKeys[n]}getSoonUint8(e){return this.byteRevers(this.getUint8(e),e)}getSoonUint16(e){const t=new DataView(new Uint8Array(2).buffer);for(let n=0;n<2;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getUint16(0,this.isLE)}getSoonUint32(e){const t=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getUint32(0,this.isLE)}getSoonFloat32(e){const t=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getFloat32(0,this.isLE)}}const LC=new TextDecoder;new TextDecoder;class GC{constructor(){this.materials=new Map}parseObject(e,t){const n=new iw(Object.assign(Object.assign({},t),{format:"sbm"})),i=new ew({id:ng()});n.add(i);const{materialsCache:s,meshsCache:r}=e;for(const[e,t]of Object.entries(s)){if(this.materials.has(e))continue;const{textureUrl:n,materialInfo:i}=t;let s=null;n&&(s=SC(n));const r=TC(e,i,s);this.materials.set(e,r)}for(const[e,t]of Object.entries(r)){const{meshName:n,materialId:s,position:r,uv:a}=t,o=this.materials.get(s.toString());if(o){const t=new Bs,s=new Float32Array(r),l=new Float32Array(a);s.length>0&&t.setAttribute("position",new Ts(s,3)),l.length>0&&t.setAttribute("uv",new Ts(l,2)),t.computeVertexNormals(),Hy.generate(t).then((e=>{t.boundsTree=e}));const c=new Qx(t,o,{id:`${e}_${ng()}`,name:n||e});i.add(c)}}return n}}var RC=class{constructor(){this.materials=new Map,this.sbmInfo=null}parseBuffer(e,t,n){return tf(this,void 0,void 0,(function*(){this.sbmInfo=t;const i=new DataView(e);let s=0;const r=[];for(let e=0;e<8;e++)r.push(i.getUint8(s)),s+=1;if("SBK-----"!==String.fromCharCode(...r))return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})格式或数据错误!`);const a=[],o=[],l=[];for(let e=0;e<32;e++)a.push(i.getUint8(s)),s+=1;const c=i.getUint8(s);s+=1;const d=i.getUint8(s);s+=1;for(let e=0;e<32;e++)o.push(i.getUint8(s)),s+=1;for(let e=0;e<64;e++)l.push(i.getUint8(s)),s+=1;const h=[...o,...l,...a],u=[];for(let e=0;e<h.length;e++)(e<=7||e>23&&e<=31||e>39&&e<=55||e>63&&e<=87||e>95&&e<=103)&&u.push(h[e]);if(64!==u.length)return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url} 数据错误!`);if(1===c){const e=i.buffer.slice(s,i.buffer.byteLength),t=new CC(e,u);return 1===d||2===d?this._parseV2(t,n):3===d?this._parseV3(t,n):Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})版本错误!`)}return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})key 错误!`)}))}_parseV2(e,t){let n=0;const i=performance.now();n+=66;const s={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const r=new iw(Object.assign(Object.assign({},this.sbmInfo),{format:"sbm"})),a=new ew({id:ng()});r.add(a);const o=e.getSoonUint16(n);n+=2;const l=e.getSoonUint16(n);n+=2,s.total=l;const c={};for(let t=0;t<o;++t){const t=e.getSoonUint16(n).toString();n+=2,c[t]={materialInfo:[]},n+=4,n+=4,n+=4,n+=4;const i=e.getSoonFloat32(n);n+=4;const s=e.getSoonFloat32(n);n+=4;const r=e.getSoonFloat32(n);n+=4;const a=e.getSoonFloat32(n);n+=4,n+=4,n+=4,n+=4,n+=4;let o=e.getSoonUint8(n);n+=1,0===o?o=0:1===o?o=1:2===o&&(o=2);const l=e.getSoonUint16(n);n+=2;let d=null;if(l>0){let i="",s="";for(let t=0;t<l;t++){const t=e.getSoonUint8(n);t>127?s=s+"%"+t.toString(16).toUpperCase():s.length>0?(i+=decodeURIComponent(s)+String.fromCharCode(t),s=""):i+=String.fromCharCode(t),n+=1}i=i.replace("\\","/");const{url:r,isPlatform:a}=this.sbmInfo,o=this.getTextureUrl(r,i,a);c[t].textureUrl=o,d=SC(o)}if(!this.materials.has(t)){const e=[i,s,r,a,o],n=TC(t,e,d);this.materials.set(t,n),c[t].materialInfo=e}}const d={};for(let r=0;r<l;++r){const r=e.getSoonUint16(n);n+=2;const o=e.getSoonUint16(n).toString();n+=2,d[r]={materialId:o,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const l=[],c=[],h=[],u=[],p=e.getSoonUint16(n);if(n+=2,p>0)for(let t=0;t<p;t++){const t=new ri;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,t.setZ(e.getSoonFloat32(n)),n+=4,l.push(t)}const m=e.getSoonUint16(n);if(n+=2,m>0)for(let t=0;t<m;t++){const t=new ri;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,t.setZ(e.getSoonFloat32(n)),n+=4}const f=e.getSoonUint16(n);if(n+=2,f>0)for(let t=0;t<f;t++){const t=new Rn;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,c.push(t)}const g=e.getSoonUint16(n);if(n+=2,g>0)for(let t=0;t<g;t++){const t=e.getSoonUint16(n);n+=2;const i=e.getSoonUint16(n);n+=2;const s=e.getSoonUint16(n);n+=2;const r=[t,i,s];h.push(r),c.length>0&&u.push([c[r[0]],c[r[1]],c[r[2]]])}const y=[],b=[];for(let e=0;e<h.length;e++){const t=h[e],n=l[t[0]],i=l[t[1]],s=l[t[2]];y.push(...n.toArray(),...i.toArray(),...s.toArray());let r=new Rn,a=new Rn,o=new Rn;const c=u[e];void 0!==c&&(r=c[0],a=c[1],o=c[2]),b.push(...r.toArray(),...a.toArray(),...o.toArray())}const v=new Float32Array(y),x=new Float32Array(b);d[r].position=v.buffer,d[r].uv=x.buffer;const w=new Bs;v.length>0&&w.setAttribute("position",new Ts(v,3)),x.length>0&&w.setAttribute("uv",new Ts(x,2)),w.computeVertexNormals(),Hy.generate(w).then((e=>{w.boundsTree=e}));const M=this.materials.get(o);if(M){const e=new Qx(w,M,{id:`${r}_${ng()}`,name:r.toString()});a.add(e)}s.loaded++,s.timeStamp=performance.now()-i,null==t||t(s)}const h={materialsCache:c,meshsCache:d};return Promise.resolve({model:r,caches:h})}_parseV3(e,t){let n=0;n+=66;const i=performance.now(),s={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const r=new iw(Object.assign(Object.assign({},this.sbmInfo),{format:"sbm"})),a=new ew({id:ng()});r.add(a);const o=e.getSoonUint16(n);n+=2;const l=e.getSoonUint16(n);n+=2,s.total=l;const c={};for(let t=0;t<o;++t){const t=e.getSoonUint16(n).toString();n+=2,c[t]={materialInfo:[]},n+=4,n+=4,n+=4,n+=4;const i=e.getSoonFloat32(n);n+=4;const s=e.getSoonFloat32(n);n+=4;const r=e.getSoonFloat32(n);n+=4;const a=e.getSoonFloat32(n);n+=4,n+=4,n+=4,n+=4,n+=4;let o=e.getSoonUint8(n);n+=1,0===o?o=0:1===o?o=1:2===o&&(o=2);const l=e.getSoonUint16(n);n+=2;let d=null;if(l>0){let i="",s="";for(let t=0;t<l;t++){const t=e.getSoonUint8(n);t>127?s=s+"%"+t.toString(16).toUpperCase():s.length>0?(i+=decodeURIComponent(s)+String.fromCharCode(t),s=""):i+=String.fromCharCode(t),n+=1}i=i.replace("\\","/");const{url:r,isPlatform:a}=this.sbmInfo,o=this.getTextureUrl(r,i,a);c[t].textureUrl=o,d=SC(o)}if(!this.materials.has(t)){const e=[i,s,r,a,o],n=TC(t,e,d);this.materials.set(t,n),c[t].materialInfo=e}}const d={};for(let r=0;r<l;++r){const r=e.getSoonUint16(n).toString();n+=2;const o=e.getSoonUint16(n);n+=2;let l="";if(o>0){const t=[];for(let i=0;i<o;i++){const i=e.getSoonUint8(n);t.push(i),n+=1}const i=new Uint8Array(t);l=LC.decode(i)}const c=e.getSoonUint16(n).toString();n+=2,d[r]={meshName:l,materialId:c,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const h=[],u=[],p=[],m=[],f=e.getSoonUint32(n);if(n+=4,f>0)for(let t=0;t<f;t++){const t=new ri;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,t.setZ(e.getSoonFloat32(n)),n+=4,h.push(t)}const g=e.getSoonUint32(n);if(n+=4,g>0)for(let t=0;t<g;t++){const t=new ri;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,t.setZ(e.getSoonFloat32(n)),n+=4}const y=e.getSoonUint32(n);if(n+=4,y>0)for(let t=0;t<y;t++){const t=new Rn;t.setX(e.getSoonFloat32(n)),n+=4,t.setY(e.getSoonFloat32(n)),n+=4,u.push(t)}const b=e.getSoonUint32(n);if(n+=4,b>0)for(let t=0;t<b;t++){const t=e.getSoonUint32(n);n+=4;const i=e.getSoonUint32(n);n+=4;const s=e.getSoonUint32(n);n+=4;const r=[t,i,s];p.push(r),u.length>0&&m.push([u[r[0]],u[r[1]],u[r[2]]])}const v=[],x=[];for(let e=0;e<p.length;e++){const t=p[e],n=h[t[0]],i=h[t[1]],s=h[t[2]];v.push(...n.toArray(),...i.toArray(),...s.toArray());let r=new Rn,a=new Rn,o=new Rn;const l=m[e];void 0!==l&&(r=l[0],a=l[1],o=l[2]),x.push(...r.toArray(),...a.toArray(),...o.toArray())}const w=new Float32Array(v),M=new Float32Array(x);d[r].position=w.buffer,d[r].uv=M.buffer;const S=new Bs;if(w.length>0&&S.setAttribute("position",new Ts(w,3)),M.length>0&&S.setAttribute("uv",new Ts(M,2)),S.computeVertexNormals(),Hy.generate(S).then((e=>{S.boundsTree=e})),this.materials.has(c)){const e=new Qx(S,this.materials.get(c),{id:`${r}_${ng()}`,name:l});a.add(e)}s.loaded++,s.timeStamp=performance.now()-i,null==t||t(s)}const h={materialsCache:c,meshsCache:d};return Promise.resolve({model:r,caches:h})}getTextureUrl(e,t,n){let i="",s=t;const r=s.lastIndexOf("/");if(-1!==r&&(s=s.substring(r+1)),i=e,n){const e=i.split("/");e.length>1&&(e.splice(e.length-3,e.length),i=e.join("/")+"/Maps/"+s)}else{const e=i.lastIndexOf("/");-1!==e&&(i=i.substring(0,e+1)+"Maps/"+s)}return i}};class _C extends vw{constructor(e,t){super("Model",e,t),this.viewport=e,this.isDisposed=!1,this.modelsPromiseMap=new Map,this.modelsMap=new Map,this.store=fC.createInstance({name:"soonspace",storeName:"modelData"}),this.cacheStore=fC.createInstance({name:"soonspace",storeName:"modelCache"}),this.loadingManager=new ph,this.datLoader=new wC(this.cacheStore),this.gltfLoader=new cT(this.loadingManager),this.fbxLoader=new kS(this.loadingManager),this.dracoDecoderPath=null,this.gltfLoader.register((e=>new gC(e))),this._initLoadingManager(this.loadingManager)}setDracoDecoderPath(e){this.dracoDecoderPath=e;const t=new uC;t.setDecoderPath(e),this.gltfLoader.setDRACOLoader(t),this.datLoader.dracoDecoderPath=e}load(e,t=this.scene){return tf(this,void 0,void 0,(function*(){const{url:n}=e,i=this.modelsPromiseMap.get(n);if(i){if(yield i,this.isDisposed)return this.dispose(),null;const s=this.modelsMap.get(n);return s?this.clone(s,e,t):null}const s=this._innerLoad(e,t);return this.modelsPromiseMap.set(n,s),s}))}parse(e){return tf(this,void 0,void 0,(function*(){const{url:t,id:n}=e;if(!t)return Wm(`id: ${n} url: ${t} is empty`),null;switch(t.slice(t.lastIndexOf(".")+1).toLocaleUpperCase()){case"SBM":return this._parseSbm(e);case"SBMX":return this._parseSbmx(e);case"DAT":return this._parseDat(e);case"GLB":case"GLTF":return this._parseGltf(e);case"FBX":return this._parseFbx(e);default:return Wm(`模型资源( id: ${n}, url: ${t} )格式错误,当前格式支持 sbm、sbmx、fbx、gltf、glb !`),null}}))}clone(e,t,n){return new Promise(((i,s)=>{var r;"Model"!==e.stype&&s("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:a,name:o,level:l,visible:c,position:d,rotation:h,scale:u,onClick:p,onDblClick:m,onRightClick:f,onLoad:g,userData:y}=t;function b(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)b(e.children[i],t.children[i],n)}const v=function(e){const t=new Map,n=new Map,i=e.sClone();return b(e,i,(function(e,i){t.set(i,e),n.set(e,i)})),i.traverse((function(e){if(e instanceof Zl){const i=e,s=t.get(e),r=s.skeleton.bones;i.skeleton=s.skeleton.clone(),i.bindMatrix.copy(s.bindMatrix),i.skeleton.bones=r.map((function(e){return n.get(e)})),i.bind(i.skeleton,i.bindMatrix)}})),i}(e);v.animations=v.animations.map((e=>e.clone())),a&&(v.sid=a),o&&(v.name=o),l&&(v.level=l),!1===c&&v.hide(),d&&v.position.set(d.x,d.y,d.z),h&&v.rotation.set(h.x,h.y,h.z),u&&v.scale.set(u.x,u.y,u.z),v.onClick=p?p.bind(v):null,v.onDblClick=m?m.bind(v):null,v.onRightClick=f?f.bind(v):null,v.onLoad=g?g.bind(v):null,null===(r=v.onLoad)||void 0===r||r.call(v,v),y&&(v.userData=y),null!==n&&this.viewport.scener.addObject(v,n||this.scene||e.parent),i(v)}))}loadToGroup(e,t){return tf(this,void 0,void 0,(function*(){const n=this.createGroup(e,null);return yield Promise.allSettled(t.map((e=>this.load(e,null).then((e=>e&&n.add(e))).catch(console.error)))),this.viewport.scener.addObject(n,this.scene),n}))}addForGroup(e,t){return tf(this,void 0,void 0,(function*(){return e&&(yield Promise.allSettled(t.map((t=>tf(this,void 0,void 0,(function*(){return this.load(t,null).then((t=>t&&this.viewport.scener.addObject(t,e))).catch(console.error)})))))),e}))}clearIdb(){return tf(this,void 0,void 0,(function*(){yield this.store.clear(),yield this.cacheStore.clear()}))}dispose(){var e;this.isDisposed=!0,this.modelsPromiseMap.clear(),this.modelsMap.clear(),null===(e=this.gltfLoader.dracoLoader)||void 0===e||e.dispose(),this.datLoader.dispose()}_initLoadingManager(e){e.addHandler(/\.tga$/i,new lT)}_setModelsMap(e,t){this.modelsMap.has(e)||this.modelsMap.set(e,t)}_parseSbm(e){return tf(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options,{url:n}=e,i=t=>tf(this,void 0,void 0,(function*(){const i=yield(new RC).parseBuffer(t,e),{model:s,caches:r}=i;return r&&df((()=>{this.cacheStore.setItem(n,r)})),s})),s=e=>{var t;null===(t=e.onLoad)||void 0===t||t.call(e,e)};if(t){const t=yield this.cacheStore.getItem(n);if(t){const n=(new GC).parseObject(t,e);return s(n),n}{const e=(yield this.store.getItem(n))||(yield this._fetchBuffer(n)),t=yield i(e);return s(t),t}}{const e=yield this._fetchBuffer(n),t=yield i(e);return s(t),t}}))}_parseSbmx(e){return tf(this,void 0,void 0,(function*(){const{url:t}=e,n=yield this._getBuffer(t),i=tg(n,0,8),s=new DataView(n.slice(8));switch(i){case"SBMG----":for(let e=0;e<s.byteLength;e++){const t=s.getUint8(e),n=(t>>4&15)+(t<<4&240);s.setUint8(e,n)}return this._parseGltf(e,s.buffer);case"SBMD----":return this._parseDat(e,s.buffer);default:return this._parseGltf(e,s.buffer)}}))}_parseDat(e,t){return tf(this,void 0,void 0,(function*(){const{url:n}=e,i=t||(yield this._getBuffer(n)),s=new iw(Object.assign(Object.assign({},e),{format:"dat"})),r=yield this.datLoader.parseAsync(i,n);return r&&s.add(r),s}))}_parseGltf(e,t){return tf(this,void 0,void 0,(function*(){const{url:n}=e,i=jm(n),s=t||(yield this._getBuffer(n)),r=new iw(Object.assign(Object.assign({},e),{format:"gltf"})),a=yield this.gltfLoader.parseAsync(s,i),{animations:o}=a;return o&&o.length>0&&(r.animations=o),a.scene.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0,e instanceof ar&&Hy.generate(e.geometry).then((t=>{e.geometry.boundsTree=t}))})),r.add(a.scene),r}))}_parseFbx(e){return tf(this,void 0,void 0,(function*(){const{url:t}=e,n=jm(t),i=yield this._getBuffer(t),s=new iw(Object.assign(Object.assign({},e),{format:"gltf"})),r=this.fbxLoader.parse(i,n),{animations:a}=r;return a&&a.length>0&&(s.animations=a),r.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0,e instanceof ar&&Hy.generate(e.geometry).then((t=>{e.geometry.boundsTree=t}))})),s.add(r),s}))}_innerLoad(e,t=this.scene){var n;return tf(this,void 0,void 0,(function*(){const{url:i}=e,s=yield this.parse(e);return s?(null===(n=s.onLoad)||void 0===n||n.call(s,s),this._setModelsMap(i,s),null!==t&&this.viewport.scener.addObject(s,t),s):null}))}_fetchBuffer(e){return tf(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options,n=yield cf(e),i=yield n.arrayBuffer();return t&&this.store.setItem(e,i),i}))}_getBuffer(e){return tf(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options;if(t){const t=yield this.store.getItem(e);return t||this._fetchBuffer(e)}return this._fetchBuffer(e)}))}}class AC extends vw{constructor(e,t){super("Poi",e,t),this.materials=new Map}create(e){const t=this._createMaterial(e.url),n=new aw(t,e);return this.viewport.scener.addObject(n,this.scene),n}clone(e,t,n){"Poi"!==e.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:i,name:s,level:r,visible:a,position:o,rotation:l,scale:c,onClick:d,onDblClick:h,onRightClick:u,userData:p}=t,m=e.sClone(!1);return this._copyMaterial(m),i&&(m.sid=i),s&&(m.name=s),r&&(m.level=r),jf(a)&&(m.visible=a),o&&m.position.set(o.x,o.y,o.z),l&&m.rotation.set(l.x,l.y,l.z),c&&m.scale.set(c.x,c.y,c.z),m.onClick=d?d.bind(m):null,m.onDblClick=h?h.bind(m):null,m.onRightClick=u?u.bind(m):null,p&&(m.userData=p),null!==n&&this.viewport.scener.addObject(m,n||this.scene||e.parent),m}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this._createMaterial(e.url),i=new aw(t,e);n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{const n=this._createMaterial(t.url),i=new aw(n,t);e.add(i)})),this.viewport.scener.addObject(e,this.scene)),e}_createMaterial(e){const t=this.materials.get(e);if(!t){const t=(new Sh).load(e);t.flipY=!0;const n=new pl({map:t,color:16777215});return this.materials.set(e,n),n}return t}_copyMaterial(e){e.traverse((e=>{(e instanceof ar||e instanceof Gl)&&(Qf(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof xs&&(e.material=e.material.clone()))}))}}class IC extends vw{constructor(e,t){super("PoiNode",e,t)}create(e){this._openEnableRenderCss(e);const t=new nw(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{this._openEnableRenderCss(e);const t=new nw(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{this._openEnableRenderCss(t);const n=new nw(t);e.add(n)})),this.viewport.scener.addObject(e,this.scene)),e}_openEnableRenderCss(e){switch(e.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class XC extends vw{constructor(e,t){super("Canvas3D",e,t)}create(e){const t=new gw(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=new gw(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{const n=new gw(t);e.add(n)})),this.viewport.scener.addObject(e,this.scene)),e}}var EC=function(){function e(){}return e.prototype.toJson=function(e,t){var n=this.xmlStringToXmlDom(e),i=this.xmlToJson(n);return t?(t.removeLineBreaks&&this.removeLineBreaks(i),t.removeComments&&this.removeCommentProperties(i),t.transformTextOnly&&this.transformTextOnly(i),i):i},e.prototype.xmlStringToXmlDom=function(e){return(new DOMParser).parseFromString(e,"text/xml")},e.prototype.removeLineBreaks=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#text"===n&&Array.isArray(e[n])&&delete e[n],"object"==typeof e[n]&&t.removeLineBreaks(e[n])}))},e.prototype.removeCommentProperties=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#comment"===n&&delete e[n],"object"==typeof e[n]&&t.removeCommentProperties(e[n])}))},e.prototype.transformTextOnly=function(e){var t=this;Object.keys(e).forEach((function(n,i){var s=Object.keys(e[n]).length>1,r=Object.keys(e[n])[0];s||"object"==typeof e[n][r]?t.transformTextOnly(e[n]):"object"==typeof e[n]&&e[n]["#text"]&&(e[n]=e[n]["#text"])}))},e.prototype.xmlToJson=function(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t._attributes={};for(var n=0;n<e.attributes.length;n++){var i=e.attributes.item(n);t._attributes[i.nodeName]=i.nodeValue}}}else 3==e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(var s=0;s<e.childNodes.length;s++){var r=e.childNodes.item(s),a=r.nodeName;if(void 0===t[a])t[a]=this.xmlToJson(r);else{if(void 0===t[a].push){var o=t[a];t[a]=[],t[a].push(o)}t[a].push(this.xmlToJson(r))}}return t},e}();function zC(e){return cf(e).then((e=>e.text())).then((e=>Promise.resolve(function(e){return(new EC).toJson(e,{transformTextOnly:!0,removeComments:!0,removeLineBreaks:!0})}(e))))}class PC{constructor(){this.graph=new Map,this.queue=null,this.previous=new Map}setGraph(e){if(!(e.length<1))for(const t of e){const[e,n]=t;this.graph.set(e,new Map);for(const t of n){const[n,i]=t,s=this.graph.get(e);null==s||s.set(n,i)}}}getPath(e,t){var n;if(e===t)return[];const i=this.queue=new Om;i.add(e,0),this.previous.set(e,null);let s=null;for(;s=i.shift();){if(s===t){const e=[];for(;null!==s&&null!==this.previous.get(s);)e.unshift(s),s=null!==(n=this.previous.get(s))&&void 0!==n?n:null;return e}const e=i.getDistance(s);if(e===1/0)return[];const r=this.graph.get(s);r&&r.forEach(((t,n)=>{const r=i.getDistance(n),a=e+t;a<r&&(i.update(n,a),this.previous.set(n,s))}))}return[]}}class WC extends vw{constructor(e,t){super("Topology",e,t),this.dijkstra=new PC}createFromGml(e){return tf(this,void 0,void 0,(function*(){const{url:t,linkWidth:n=20,linkColor:i=65280,renderNode:s=!0,nodeColor:r=255}=e;return zC(t).then((t=>{if(!t||!t.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const a=[],o=new Map;let l=[],c=[];const d=t.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;Qf(d)?d.forEach((e=>{l=[...l,...e.state],c=[...c,...e.transition]})):(l=[...l,...d.state],c=[...c,...d.transition]),l.forEach(((e,t)=>{const n=e.State._attributes["gml:id"],i=e.State.topoNode["gml:Node"].node_name;a.push({id:Kf(n)?n:"",name:Kf(i)?i:"",position:{x:Number(e.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(e.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(e.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),o.set(n,t)})),c.forEach((e=>{const t=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],i=e.Transition.topoEdge["gml:Edge"].restrict["#text"],s=e.Transition.topoEdge["gml:Edge"].passable["#text"],r=o.get(t),l=o.get(n),c=e.Transition._attributes["gml:id"],d=e.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==r&&void 0!==l&&("2"!==s&&"3"!==s&&a[r].graphs.push({targetNodeId:n,linkInfo:{id:c,name:d},enable:!0,restrict:parseInt(i),passable:parseInt(s)}),"1"!==s&&"3"!==s&&a[l].graphs.push({targetNodeId:t,linkInfo:{id:c,name:d},enable:!0,restrict:parseInt(i),passable:parseInt(s)}))}));const h=new hw(Object.assign(Object.assign({},e),{type:"network",nodes:a,linkWidth:n,renderLink:!0,linkColor:i,renderNode:s,nodeColor:r}));return this.setDijkstraGraph(h.nodes),this.viewport.scener.addObject(h,this.scene),Promise.resolve(h)}))}))}create(e){const t=this.generateLineTopologyInfoNodeGraphs(e),n=new hw(t);return this.setDijkstraGraph(n.nodes),this.viewport.scener.addObject(n,this.scene),n}resetNodes(e,t){const n=this.generateLineTopologyInfoNodeGraphs(Object.assign(Object.assign({},e.info),{nodes:t}));return e.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),e}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e),i=new hw(t);this.setDijkstraGraph(i.nodes),n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&t.forEach((t=>{const n=this.generateLineTopologyInfoNodeGraphs(t),i=new hw(n);this.setDijkstraGraph(i.nodes),e.add(i)})),e}getShortestPath(e,t){const n=Jm(e.info.nodes),i=Zm(t.start),s=Zm(t.end);let r=null,a=1/0,o=null,l=1/0;for(let t=0;t<n.length;t++){const c=n[t];if(0===c.graphs.length)continue;const d=e.nodes.find((e=>e.sid===c.id));if(!d)continue;const h=d.getWorldPosition(new ri),u=h.distanceTo(i),p=h.distanceTo(s);u<a&&(a=u,r=c),p<l&&(l=p,o=c)}if(!r||!o||r.id===o.id)return null;const c=r.id,d=o.id,h=this.dijkstra.getPath(c,d);if(0===h.length)return null;h.unshift(r.id);const u=[];for(let e=0;e<h.length;e++){const t=n.find((t=>t.id==h[e]));t&&(t.id+=ng(),t.position.y+=.01,u.push(t))}const p=Object.assign(Object.assign(Object.assign({},t),{type:"line",nodes:u}),e.getSpaceAttribute(!0));this.generateLineTopologyInfoNodeGraphs(p);const m=new hw(p);return this.viewport.scener.addObject(m,this.scene),m}getShortestPathByMultipleStartPoints(e,t){const{nodes:n}=e.info,i=[];t.start.forEach((e=>{const s=Zm(e),r=Zm(t.end);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Zm(e.position),n=t.distanceTo(s),i=t.distanceTo(r);n<o&&(o=n,a=e.id),i<c&&(c=i,l=e.id)}})),a&&l){let e=0;const t=this.dijkstra.getPath(a,l);if(t.length>0){const a=[{id:"startPoint",position:s,graphs:[]}];t.forEach(((t,i)=>{const r=n.find((e=>e.id==t));r&&(e+=0===i?Zm(r.position).distanceTo(s):Zm(r.position).distanceTo(Zm(a[a.length-1].position)),a.push(r))})),a.push({id:"endPoint",position:r,graphs:[]}),e+=r.distanceTo(Zm(a[a.length-1].position)),i.push({nodeInfo:a,pathLength:e})}}}));let s=[],r=1/0;if(i.forEach((({nodeInfo:e,pathLength:t})=>{t<r&&(r=t,s=e)})),s.length){for(let e=0;e<s.length;e++)s[e].position.y+=.01;const n=Object.assign(Object.assign({},t),{type:"line",nodes:s,position:e.getWorldPosition(new ri),rotation:(new Oi).setFromQuaternion(e.getWorldQuaternion(new si)),scale:e.getWorldScale(new ri)});this.generateLineTopologyInfoNodeGraphs(n);const i=new hw(n);return this.viewport.scener.addObject(i,this.scene),i}return null}getShortestPathByMultipleEndPoints(e,t){const{nodes:n}=e.info,i=[];t.end.forEach((e=>{const s=Zm(t.start),r=Zm(e);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Zm(e.position),n=t.distanceTo(s),i=t.distanceTo(r);n<o&&(o=n,a=e.id),i<c&&(c=i,l=e.id)}})),a&&l){let e=0;const t=this.dijkstra.getPath(a,l);if(t.length>0){const a=[{id:"startPoint",position:s,graphs:[]}];t.forEach(((t,i)=>{const r=n.find((e=>e.id==t));r&&(e+=0===i?Zm(r.position).distanceTo(s):Zm(r.position).distanceTo(Zm(a[a.length-1].position)),a.push(r))})),a.push({id:"endPoint",position:r,graphs:[]}),e+=r.distanceTo(Zm(a[a.length-1].position)),i.push({nodeInfo:a,pathLength:e})}}}));let s=[],r=1/0;if(i.forEach((({nodeInfo:e,pathLength:t})=>{t<r&&(r=t,s=e)})),s.length){for(let e=0;e<s.length;e++)s[e].position.y+=.01;const n=Object.assign(Object.assign({},t),{type:"line",nodes:s,position:e.getWorldPosition(new ri),rotation:(new Oi).setFromQuaternion(e.getWorldQuaternion(new si)),scale:e.getWorldScale(new ri)});this.generateLineTopologyInfoNodeGraphs(n);const i=new hw(n);return this.viewport.scener.addObject(i,this.scene),i}return null}setDijkstraGraph(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];if(0===i.graphs.length)continue;const s=[];for(let t=0;t<i.graphs.length;t++){const n=i.graphs[t],r=e.find((e=>e.sid===n.targetNodeId));if(!r)continue;const a=i.getWorldPosition(new ri),o=r.getWorldPosition(new ri);s.push([n.targetNodeId,a.distanceTo(o)])}t.push([i.sid,s])}t.length>0&&this.dijkstra.setGraph(t)}generateLineTopologyInfoNodeGraphs(e){const{type:t,nodes:n}=e;if("line"===t)for(let t=0;t<n.length;t++)if(t===n.length-1)n[t].graphs=[];else{const i=e.nodes[t],s=e.nodes[t+1];n[t].graphs=[{targetNodeId:s.id,linkInfo:{id:`${i.id}_to_${s.id}`,name:`${i.name||i.id}_to_${s.name||s.id}`},enable:!0,restrict:0,passable:0}]}return Object.assign(Object.assign({},e),{nodes:n})}}class ZC extends tc{constructor(e,t){const n=new Bs;n.setAttribute("position",new Es([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere();super(n,new jl({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new Bs;i.setAttribute("position",new Es([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new ar(i,new ws({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class NC extends vw{constructor(e,t){super("Helper",e,t)}addGridHelper(e){const{id:t,size:n=1e3,divisions:i=20,color:s="#fff",position:r={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:o={x:1,y:1,z:1}}=e,l=new np(n,i,s,s);return l.position.set(r.x,r.y,r.z),l.rotation.set(a.x,a.y,a.z),l.scale.set(o.x,o.y,o.z),l.userData.sid=t,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(e){const{id:t,axesLength:n=1e3}=e,i=new xp(n);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addBoxHelper(e){const{id:t,box:n,color:i="#00ff00"}=e,s=new mp(n,new Fn(i));return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addPlaneHelper(e){const{id:t,width:n=500,height:i=500,color:s="#00ff00",opacity:r=.2,position:a={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=e,c=new Qx(new Gr(n,i),new ws({color:s,opacity:r,transparent:r<1,side:2}),{id:t,position:a,rotation:o,scale:l});return c.userData.sid=t,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(e){const{imgUrl:t,id:n,width:i=500,height:s=500,opacity:r=1,position:a={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=e,d=(new Sh).load(t),h=new Gr(i,s);h.computeBoundingBox();const u=new kd({side:2,map:d,transparent:r<1,opacity:r,roughness:.8});u.map&&(u.map.repeat.set(c.x,c.x),u.map.wrapS=1e3,u.map.wrapT=1e3,u.map.version++),o.x-=Math.PI/2,u.version++;const p=new yw(h,u,{id:n,position:a,rotation:o,scale:l});return p.userData.sid=n,p.userData.stype="Helper",this.viewport.scener.addObject(p,this.scene),p}addDirectionalLightHelper(e){const{id:t,light:n,color:i,size:s=50}=e,r=new op(n,s,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addHemisphereLightHelper(e){const{id:t,light:n,color:i,size:s=20}=e,r=new tp(n,s,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addSpotLightHelper(e){const{id:t,light:n,color:i}=e,s=new Uu(n,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addPointLightHelper(e){const{id:t,light:n,color:i,size:s=20}=e,r=new Qu(n,s,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addRectAreaLightHelper(e){const{id:t,light:n,color:i}=e,s=new ZC(n,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}}class VC extends vw{constructor(e,t){super("PluginObject",e,t)}createObject(e,t){const n=new tw(e);return t&&n.add(t),this.viewport.scener.addObject(n,this.scene),n}addToObject(e,t){return e?(this.viewport.scener.addObject(t,e),e):null}}class DC extends vw{constructor(e,t){super("Group",e,t)}}class HC{constructor(e){this.viewport=e,this.cache={objects:new Map},this.scene=e.scene,this.store={groupManager:new DC(e,this.scene),lightManager:new xw(e,this.scene),modelManager:new _C(e,this.scene),poiManager:new AC(e,this.scene),poiNodeManager:new IC(e,this.scene),canvas3DManager:new XC(e,this.scene),topologyManager:new WC(e,this.scene),helperManager:new NC(e,this.scene),pluginObjectManager:new VC(e,this.scene)},e.postUpdate.set("ManagerRender",this.update.bind(this)),e.signals.objectAdded.add(this.setObjectCache.bind(this)),e.signals.objectRemoved.add(this.deleteObjectCache.bind(this))}levelUpdate(){if(!this.viewport.options.levelEnabled)return;const e=(e,t)=>{e.visible!==t&&(e instanceof nw&&e._setElementDisplay(t),e.visible=t,e.matrixAutoUpdate=t,e.autoUpdate=!0)},t=t=>{const{level:n,handleHide:i,autoUpdate:s}=t,{max:r=null,min:a=null}=n;if(s)t.autoUpdate=!1,this.viewport.signals.objectChanged.dispatch();else if(!i&&(r||a)){const n=this.viewport.camera.position.distanceTo(t.position);e(t,!(r&&n>r)&&!(a&&n<a))}};this.scene.traverse((e=>{(e instanceof $x||e instanceof Qx)&&t(e)}))}update(){if(0===this.scene.children.length)return;const e=performance.now();this.levelUpdate(),this.viewport.signals.loadRendered.dispatch(performance.now()-e)}isObjectInScene(e){let t=!1;return e.traverseAncestors((e=>{e===this.scene&&(t=!0)})),t}getObjectById(e){const t=this.getObjectCache(e);if(t){if(this.isObjectInScene(t))return t}return null}getObjectByName(e){return this._getObjectByProps("name",e)}getObjectByUserDataProperty(e,t){const n=[];return this.cache.objects.forEach((i=>{this.isObjectInScene(i)&&qf(i)&&(i instanceof $x||i instanceof Qx||i.userData.stype)&&($f(e)&&e(i.userData)||Kf(e)&&i.userData[e]===t)&&n.push(i)})),n}removeObjectById(e){const t=this.getObjectById(e);return!!t&&(this.viewport.scener.removeObject(t),!0)}_getObjectByProps(e,t){const n=[];return this.cache.objects.forEach((i=>{this.isObjectInScene(i)&&((i instanceof $x||i instanceof Qx)&&qf(i)&&i[e]===t||qf(i)&&i.userData.stype&&("name"===e&&i.name===t||"sid"===e&&i.userData.sid===t))&&n.push(i)})),n}getObjectCache(e){return this.cache.objects.get(e)}setObjectCache(e){const t=(e,t)=>{const n=this.cache.objects.get(t);n&&n!==e&&console.warn(`object id ${t} already exists in scene`)};null==e||e.traverse((n=>{if(n instanceof $x||n instanceof Qx){if("string"==typeof n.sid&&n.sid.startsWith("[soonspacejs]: "))return;t(n,n.sid),this.cache.objects.set(n.sid,n)}else n.userData.sid&&e.userData.stype&&(t(n,n.userData.sid),this.cache.objects.set(n.userData.sid,n))}))}deleteObjectCache(e){null==e||e.traverse((t=>{t instanceof $x||t instanceof Qx?this.cache.objects.delete(t.sid):t.userData.sid&&e.userData.stype&&this.cache.objects.delete(t.userData.sid)}))}clearObject(){this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.lightManager.clear()}dispose(){this.store.modelManager.dispose(),this.cache.objects.clear(),this.clear()}}function BC(e){const t=kC(e),n=new Wi;n.setFromMatrix3(t);const i=e[0],s=n.clone();s.setPosition(i);const r=s.clone().invert(),a=e.map((e=>{const t=e.clone().applyMatrix4(r);return new Rn(t.x,t.y)})),o=new Qc(a),l=new Xd(o),c=new Du;c.setFromPoints(a);const d=FC(c);return l.getAttribute("uv").applyMatrix3(d),l.applyMatrix4(n),{geometry:l,polygonBox:c,modelMatrix:n,planeMatrix:s,projectionMatrix:r,position:i}}function kC(e){const[t,n,i]=e,s=new wr;s.setFromCoplanarPoints(n,t,i);const r=s.normal,a=r.clone().cross(new ri(0,0,1));a.equals(new ri)&&a.set(1,0,0);const o=r.clone().cross(a);a.normalize(),o.normalize(),r.normalize();const l=new _n;return l.elements=[a.x,a.y,a.z,o.x,o.y,o.z,r.x,r.y,r.z],l}function FC(e){const t=e.min,n=e.getSize(new Rn),i=new _n;return i.elements=[n.x,0,0,0,n.y,0,t.x,t.y,1],i.invert()}function UC(e,t){const n=OC(t);return e.intersectsBox(n)}function OC(e){const t=new li,n=t.min.clone(),i=t.max.clone();if(t.setFromObject(e),t.min.equals(n)&&t.max.equals(i)){const n=new ri;e.getWorldPosition(n),t.min.copy(n),t.max.copy(n)}if(e.isInstancedMesh){const{count:n,matrixWorld:i,geometry:s}=e;let r=s.boundingBox;if(r||(s.computeBoundingBox(),r=s.boundingBox),r){const s=i.clone();for(let i=0;i<n;i++){const n=new Wi;e.getMatrixAt(i,n),n.premultiply(s);const a=r.clone();a.applyMatrix4(s),t.union(a)}}}return t}function YC(e,t,n){if("string"==typeof e){let i=t?null==n?void 0:n.get(e):null;if(!i){i=(new Sh).load(e),null==n||n.set(e,i)}return i}return e instanceof HTMLImageElement?new Jn(e):e instanceof HTMLCanvasElement?new gc(e):new pc(e)}function KC(e,t,n,i){const s=e.map,r=YC(t,n,i);if(!s)return e.map=s,s;const a=r.source;return r.copy(s),r.source=a,e.map=r,r}self.THREE=Vp;class jC{constructor(e){this.THREE=Vp,this.TWEEN=zm,this.utils=ig,this.THREE_PLUGINS={TransformControls:jp,Reflector:bm},this.version=t,this.animation=rg,this.library=bw,this.plugins={},this.textureCache=new Map;const{el:n,options:i={},events:s={}}=e;if(this.domElement=document.querySelector(n),this.options=Object.assign(Object.assign({},{showInfo:!1,showStats:!1,showViewHelper:!1,showGrid:!1,background:{color:11459572,alpha:!1},fog:!1,controls:{type:"free"},hoverEnabled:!1,levelEnabled:!1,closeInfoLog:!1,closeWarnLog:!1,useIndexedDB:!0,logarithmicDepthBuffer:!0}),i),this.viewport=new Jx(this.options),this.signals=this.viewport.signals,this.manager=new HC(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(s),this._initDefaultSettings()}_init(){const{showGrid:t,background:n,fog:i,controls:s,closeInfoLog:r,closeWarnLog:a,useIndexedDB:o}=this.options;if(!r){Pm(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),Pm(e,{color:"#3eaf7c","font-size":"24px"}),Pm(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),Pm("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),Pm("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),Pm("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}t&&this.addGridHelper(!0===t?{id:"defaultGridHelper"}:t),(null==n?void 0:n.skyBox)?Kf(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):qf(null==n?void 0:n.skyBox)&&this.setSkyBackground(n.skyBox.dirPath,n.skyBox.fileNames):(null==n?void 0:n.img)?this.setBackgroundImage(n.img):(null==n?void 0:n.color)&&this.setBackgroundColor(n.color),i&&this.openSceneFog(!0===i?void 0:i),s&&this.setControlsOptions(s),a&&(window.console.warn=function(){}),o&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(e){const{modelHover:t,modelUnHover:n,modelClick:i,modelRightClick:s,modelDblClick:r,poiHover:a,poiUnHover:o,poiClick:l,poiRightClick:c,poiDblClick:d,selectPosition:h,sceneClick:u,resize:p}=e;t&&this.signals.modelHover.add(t),n&&this.signals.modelUnHover.add(n),i&&this.signals.modelClick.add(i),s&&this.signals.modelRightClick.add(s),r&&this.signals.modelDblClick.add(r),a&&this.signals.poiHover.add(a),o&&this.signals.poiUnHover.add(o),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),d&&this.signals.poiDblClick.add(d),h&&this.signals.selectPosition.add(h),u&&this.signals.sceneClick.add(u),p&&this.signals.windowResize.add(p),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultSettings(){this.setEnvironment(),this.setColorSpace("sRGB"),this.setToneMapping({type:"Linear",exposure:.8})}registerPlugin(e,t){const n=new e(this);return this.plugins[t]=n,n}getPlugin(e){return this.plugins[e]?this.plugins[e]:null}createPluginObject(e,t){return this.manager.store.pluginObjectManager.createObject(e,t)}addToPluginObject(e,t){const n=this.getObjectById(e);return this.manager.store.pluginObjectManager.addToObject(n,t)}getPluginObjectById(e){return Wm("getPluginObjectById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPluginObjectByName(e){return Wm("getPluginObjectByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}removePluginObjectById(e){return Wm("removePluginObjectById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}setSSR(e){this.viewport.setSSR(e)}setBloom(e){this.viewport.setBloom(e)}setSSAO(e){this.viewport.setSSAO(e)}setColorSpace(e){this.viewport.setColorSpace(e)}setToneMapping(e){this.viewport.setToneMapping(e)}setHoverEnabled(e){this.viewport.setHoverEnabled(e)}setBackgroundColor(e){this.viewport.setBackgroundColor(e)}setBackgroundImage(e){this.viewport.setBackgroundImage(e)}setSphereSkyBackground(e){this.viewport.setSphereSkyBackground(e)}setSkyBackground(e,t){this.viewport.setSkyBackground(e,t)}setEnvironment(){return this.viewport.setEnvironment()}playModelAnimation(e,t){return this.viewport.playModelAnimation(e,t)}stopModelAnimation(e,t){this.viewport.stopModelAnimation(e,t)}getOffsetByPosition(e){return this.viewport.getOffsetByPosition(e)}getPositionByOffset(e,t){return this.viewport.getPositionByOffset(e,t)}render(e){return this.viewport.render(e)}clearSignals(){this.viewport.clearSignals()}dispose(){this.manager.dispose(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(e){this.viewport.cameraManager.setCameraViewpoint(e)}getCameraTargetView(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraTargetView(e){this.viewport.cameraManager.setCameraViewpoint(e)}flyTo(e,t="frontTop",n){return"orbit"===this.viewport.controls.options.type&&this.utils.warn("flyTo 方法不适用于 orbit 控制器"),this.viewport.cameraManager.flyTo(e,t,n)}flyToBoundingBox(e,t="frontTop",n){return this.viewport.cameraManager.flyToBoundingBox(e,t,n)}flyToObj(e,t="frontTop",n){return this.viewport.cameraManager.flyToObj(e,t,n)}flyMainViewpoint(e="frontTop",t){return this.flyToObj(this.manager.scene,e,t)}surroundOnTarget(e,t){return this.viewport.cameraManager.surroundOnTarget(e,t)}surroundOnObject(e,t){return this.viewport.cameraManager.surroundOnObject(e,t)}getObjectLabelPos(e,t="frontTop",n){return this.viewport.cameraManager.getObjectLabelPos(e,t,n)}setControlsOptions(e){return this.viewport.controls.setOptions(e)}addObject(e,t){this.viewport.scener.addObject(e,t)}removeObject(e){this.viewport.scener.removeObject(e)}openSceneFog(e){this.viewport.scener.openSceneFog(e)}closeSceneFog(){this.viewport.scener.closeSceneFog()}setSky(e){return this.viewport.setSky(e)}getScreenshot(){return this.screenshot()}screenshot(){return this.viewport.screenshot()}edgeShow(e,t){return this.viewport.scener.edgeShow(e,t)}unEdgeShow(e){return this.viewport.scener.unEdgeShow(e)}strokeShow(e,t){return this.viewport.scener.strokeShow(e,t)}unStrokeShow(e){return this.viewport.scener.unStrokeShow(e)}opacityShow(e,t){return this.viewport.scener.opacityShow(e,t)}unOpacityShow(e){return this.viewport.scener.unOpacityShow(e)}highlightShow(e,t){return this.viewport.scener.highlightShow(e,t)}unHighlightShow(e){return this.viewport.scener.unHighlightShow(e)}emissiveShow(e,t){return this.viewport.scener.emissiveShow(e,t)}unEmissiveShow(e){return this.viewport.scener.unEmissiveShow(e)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(e){return this.manager.store.lightManager.createAmbientLight(e)}setAmbientLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setAmbientLight(t,e)}createDirectionalLight(e){return this.manager.store.lightManager.createDirectionalLight(e)}setDirectionalLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setDirectionalLight(t,e)}createHemisphereLight(e){return this.manager.store.lightManager.createHemisphereLight(e)}setHemisphereLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setHemisphereLight(t,e)}createSpotLight(e){return this.manager.store.lightManager.createSpotLight(e)}setSpotLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setSpotLight(t,e)}createPointLight(e){return this.manager.store.lightManager.createPointLight(e)}setPointLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setPointLight(t,e)}createRectAreaLight(e){return this.manager.store.lightManager.createRectAreaLight(e)}setRectAreaLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setRectAreaLight(t,e)}getLightById(e){return Wm("getLightById is deprecated, use getObjectById instead"),this.getObjectById(e)}removeLightById(e){return Wm("removeLightById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}getAllLight(){return this.manager.store.lightManager.getAll()}clearLight(){return this.manager.store.lightManager.clear()}showAllLight(){return this.manager.store.lightManager.showAll()}hideAllLight(){return this.manager.store.lightManager.hideAll()}updateAllShadow(){return this.manager.store.lightManager.updateAllShadow()}getObjectById(e){return this.manager.getObjectById(e)}getObjectByName(e){return this.manager.getObjectByName(e)}getObjectByUserDataProperty(e,t){return this.manager.getObjectByUserDataProperty(e,t)}removeObjectById(e){return this.manager.removeObjectById(e)}createGroup(e){return this.manager.store.groupManager.createGroup(e)}getGroupById(e){return Wm("getGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getGroupByName(e){return Wm("getGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllGroup(){return this.manager.store.groupManager.getAll()}showAllGroup(){return this.manager.store.groupManager.showAll()}hideAllGroup(){return this.manager.store.groupManager.hideAll()}removeGroupById(e){return Wm("removeGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}loadSbm(e){return Wm("loadSbm is deprecated, use loadModel instead"),this.loadModel(e)}parseSbm(){Wm("parseSbm is deprecated!")}cloneSbm(e,t,n){return Wm("cloneSbm is deprecated, use cloneModel instead"),this.cloneModel(e,t,n)}getSbmById(e){return Wm("getSbmById is deprecated, use getObjectById instead"),this.getObjectById(e)}getSbmByName(e){return Wm("getSbmByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getSbmByUserDataProperty(e,t){return Wm("getSbmByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeSbmById(e){return Wm("removeSbmById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForSbm(e){return Wm("createGroupForSbm is deprecated, use createGroup instead"),this.createGroup(e)}loadSbmToGroup(e,t){return Wm("loadSbmToGroup is deprecated, use loadModelToGroup instead"),this.loadModelToGroup(e,t)}addSbmForGroup(e,t){return Wm("addSbmForGroup is deprecated, use addModelForGroup instead"),this.addModelForGroup(e,t)}createSbmGroupFromXml(){Wm("createGroupForSbm is deprecated!")}getSbmGroupById(e){return Wm("getSbmGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getSbmGroupByName(e){return Wm("getSbmGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllSbmGroup(){return Wm("getAllSbmGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeSbmGroupById(e){return Wm("removeSbmGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearSbm(){return Wm("clearSbm is deprecated, use clearModel instead"),this.clearModel()}getAllSbm(){return Wm("getAllSbm is deprecated, use getAllModel instead"),this.getAllModel()}showAllSbm(){return Wm("showAllSbm is deprecated, use showAllModel instead"),this.showAllModel()}hideAllSbm(){return Wm("hideAllSbm is deprecated, use hideAllModel instead"),this.hideAllModel()}getSbmModelMaps(){return Wm("getSbmModelMaps is deprecated, use getModelsMap instead"),this.getModelsMap()}setSbmModelMaps(e){return Wm("setSbmModelMaps is deprecated, use setModelsMap instead"),this.setModelsMap(e)}setModelDracoDecoderPath(e){return this.manager.store.modelManager.setDracoDecoderPath(e)}loadModel(e){return this.manager.store.modelManager.load(e)}cloneModel(e,t,n){return this.manager.store.modelManager.clone(e,t,n)}getModelById(e){return Wm("getModelById is deprecated, use getObjectById instead"),this.getObjectById(e)}getModelByName(e){return Wm("getModelByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getModelByUserDataProperty(e,t){return Wm("getModelByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeModelById(e){return Wm("removeModelById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForModel(e){return Wm("createGroupForModel is deprecated, use createGroup instead"),this.createGroup(e)}loadModelToGroup(e,t){return this.manager.store.modelManager.loadToGroup(e,t)}addModelForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.modelManager.addForGroup(n,t)}getModelGroupById(e){return Wm("getModelGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getModelGroupByName(e){return Wm("getModelGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllModelGroup(){return Wm("getAllModelGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeModelGroupById(e){return Wm("removeModelGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}clearIdb(){return this.manager.store.modelManager.clearIdb()}getModelsMap(){return this.manager.store.modelManager.modelsMap}setModelsMap(e){this.manager.store.modelManager.modelsMap=e}createPoi(e){return this.manager.store.poiManager.create(e)}clonePoi(e,t,n){return this.manager.store.poiManager.clone(e,t,n)}getPoiById(e){return Wm("getPoiById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiByName(e){return Wm("getPoiByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getPoiByUserDataProperty(e,t){return Wm("getPoiByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removePoiById(e){return Wm("removePoiById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForPoi(e){return Wm("createGroupForPoi is deprecated, use createGroup instead"),this.createGroup(e)}createPoiToGroup(e,t){return this.manager.store.poiManager.createToGroup(e,t)}addPoiForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.poiManager.addForGroup(n,t)}getPoiGroupById(e){return Wm("getPoiGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiGroupByName(e){return Wm("getPoiGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllPoiGroup(){return Wm("getAllPoiGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiGroupById(e){return Wm("removePoiGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(e){return this.manager.store.poiNodeManager.create(e)}getPoiNodeById(e){return Wm("getPoiNodeById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiNodeByName(e){return Wm("getPoiNodeByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getPoiNodeByUserDataProperty(e,t){return Wm("getPoiNodeByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removePoiNodeById(e){return Wm("removePoiNodeById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForPoiNode(e){return Wm("createGroupForPoiNode is deprecated, use createGroup instead"),this.createGroup(e)}createPoiNodeToGroup(e,t){return this.manager.store.poiNodeManager.createToGroup(e,t)}addPoiNodeForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.poiNodeManager.addForGroup(n,t)}getPoiNodeGroupById(e){return Wm("getPoiNodeGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiNodeGroupByName(e){return Wm("getPoiNodeGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllPoiNodeGroup(){return Wm("getAllPoiNodeGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiNodeGroupById(e){return Wm("removePoiNodeGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createPoiMesh(e){const t=function(e,t){const{image:n,color:i,width:s,height:r,position:a,rotation:o,needLight:l,id:c,name:d,userData:h,level:u,visible:p,cache:m}=e,f=ef(e,["image","color","width","height","position","rotation","needLight","id","name","userData","level","visible","cache"]),g=new Gr(s,r),y=n?Object.assign(Object.assign({},f),{map:YC(n,null==m||m,t)}):f,b=l?new Ud(y):new ws(y),v=new Qx(g,b,{id:c,name:d,userData:h,level:u,visible:p});return a&&v.position.copy(a),o&&v.rotation.copy(o),v}(e,this.textureCache);return this.addObject(t),t}createPolygonPoiMesh(e){const t=function(e,t){const{points:n,image:i,color:s,needLight:r,id:a,name:o,userData:l,level:c,visible:d,cache:h}=e,u=ef(e,["points","image","color","needLight","id","name","userData","level","visible","cache"]),p=n.map((e=>new ri(e.x,e.y,e.z))),m=i?Object.assign(Object.assign({},u),{map:YC(i,null==h||h,t)}):u,f=r?new Ud(m):new ws(m),{geometry:g,position:y}=BC(p),b=new Qx(g,f,{id:a,name:o,userData:l,level:c,visible:d});return b.position.copy(y),b}(e,this.textureCache);return this.addObject(t),t}setTexture(e,t,n){const{cache:i=!0,independ:s}=n||{};let r=e.material;s&&(r=r.clone(),e.material=r);return KC(r,t,i,this.textureCache)}createCanvas3D(e){return this.manager.store.canvas3DManager.create(e)}getCanvas3DById(e){return Wm("getCanvas3DById is deprecated, use getObjectById instead"),this.getObjectById(e)}getCanvas3DByName(e){return Wm("getCanvas3DByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getCanvas3DByUserDataProperty(e,t){return Wm("getCanvas3DByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeCanvas3DById(e){return Wm("removeCanvas3DById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForCanvas3D(e){return Wm("createGroupForCanvas3D is deprecated, use createGroup instead"),this.createGroup(e)}createCanvas3DToGroup(e,t){return this.manager.store.canvas3DManager.createToGroup(e,t)}addCanvas3DForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.canvas3DManager.addForGroup(n,t)}getCanvas3DGroupById(e){return Wm("getCanvas3DGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getCanvas3DGroupByName(e){return Wm("getCanvas3DGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllCanvas3DGroup(){return Wm("getAllCanvas3DGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeCanvas3DGroupById(e){return Wm("removeCanvas3DGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(e,t){return this.manager.store.topologyManager.getShortestPath(e,t)}getShortestPathByMultipleStartPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(e,t)}getShortestPathByMultipleEndPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(e,t)}createTopologyFromGml(e){return this.manager.store.topologyManager.createFromGml(e)}createTopology(e){return this.manager.store.topologyManager.create(e)}resetTopologyNodes(e,t){return this.manager.store.topologyManager.resetNodes(e,t)}getTopologyById(e){return Wm("getTopologyById is deprecated, use getObjectById instead"),this.getObjectById(e)}getTopologyByName(e){return Wm("getTopologyByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getTopologyByUserDataProperty(e,t){return Wm("getTopologyByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeTopologyById(e){return Wm("removeTopologyById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForTopology(e){return Wm("createGroupForTopology is deprecated, use createGroup instead"),this.createGroup(e)}createTopologyToGroup(e,t){return this.manager.store.topologyManager.createToGroup(e,t)}addTopologyForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.topologyManager.addForGroup(n,t)}getTopologyGroupById(e){return Wm("getTopologyGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getTopologyGroupByName(e){return Wm("getTopologyGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllTopologyGroup(){return Wm("getAllTopologyGroup is deprecated, use getAllGroups instead"),this.getAllGroup()}removeTopologyGroupById(e){return Wm("removeTopologyGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(e){return this.manager.store.helperManager.addGridHelper(e)}addAxesHelper(e){return this.manager.store.helperManager.addAxesHelper(e)}addBoxHelper(e){return this.manager.store.helperManager.addBoxHelper(e)}addPlaneHelper(e){return this.manager.store.helperManager.addPlaneHelper(e)}createGround(e){return Wm("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(e)}addGroundHelper(e){return this.manager.store.helperManager.addGroundHelper(e)}addDirectionalLightHelper(e){return this.manager.store.helperManager.addDirectionalLightHelper(e)}addHemisphereLightHelper(e){return this.manager.store.helperManager.addHemisphereLightHelper(e)}addSpotLightHelper(e){return this.manager.store.helperManager.addSpotLightHelper(e)}addPointLightHelper(e){return this.manager.store.helperManager.addPointLightHelper(e)}addRectAreaLightHelper(e){return this.manager.store.helperManager.addRectAreaLightHelper(e)}getHelperById(e){return Wm("getHelperById is deprecated, use getObjectById instead"),this.getObjectById(e)}removeHelperById(e){return Wm("removeHelperById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}createFindObjectsInBoxNearPosition(e,t){return function(e,t){const{top:n,left:i,bottom:s,right:r,front:a,back:o}=e,l=new ri(r,n,a),c=new ri(i,s,o),d=new li;return function(e){return d.max.addVectors(e,l),d.min.subVectors(e,c),t.filter((e=>UC(d,e)))}}(e,t)}createFindObjectsInSphereNearPosition(e,t){return function(e,t){const n=new Gi(new ri,e);return function(e){return n.center.copy(e),t.filter((e=>UC(n,e)))}}(e,t)}createFindObjectsNearPath(e,t){return function(e,t){const n=e.length-1,i=[];for(let t=0;t<n;t++){const n=e[t],s=e[t+1],r=new ku(n,s);i.push(r)}const s=new Gi(new ri,t);return function(e){return e.filter((e=>{const t=OC(e),n=new ri;t.getCenter(n);const r=i.filter((e=>{const t=e.closestPointToPointParameter(n);return 0<=t||t>=1}));if(0===r.length)return!1;let a=1/0,o=n;for(const e of r){const t=e.closestPointToPoint(n,!0,new ri),i=n.distanceToSquared(t);i<a&&(a=i,o=t)}return s.center.copy(o),s.intersectsBox(t)}))}}(e,t)}}jC.THREE=Vp,jC.TWEEN=zm,jC.utils=ig;export{te as ACESFilmicToneMapping,T as AddEquation,J as AddOperation,Gt as AdditiveAnimationBlendMode,x as AdditiveBlending,Ee as AlphaFormat,H as AlwaysDepth,tn as AlwaysStencilFunc,Vh as AmbientLight,nu as AmbientLightProbe,dh as AnimationClip,bh as AnimationLoader,Au as AnimationMixer,Gu as AnimationObjectGroup,Qd as AnimationUtils,vc as ArcCurve,Qo as ArrayCamera,vp as ArrowHelper,mu as Audio,xu as AudioAnalyser,$h as AudioContext,pu as AudioListener,eu as AudioLoader,xp as AxesHelper,m as BackSide,Et as BasicDepthPacking,c as BasicShadowMap,Nl as Bone,ih as BooleanKeyframeTrack,Du as Box2,li as Box3,mp as Box3Helper,lr as BoxBufferGeometry,lr as BoxGeometry,pp as BoxHelper,Ts as BufferAttribute,Bs as BufferGeometry,Oh as BufferGeometryLoader,Se as ByteType,uh as Cache,pr as Camera,dp as CameraHelper,gc as CanvasTexture,Dc as CapsuleBufferGeometry,Dc as CapsuleGeometry,Cc as CatmullRomCurve3,ee as CineonToneMapping,Hc as CircleBufferGeometry,Hc as CircleGeometry,de as ClampToEdgeWrapping,ou as Clock,Fn as Color,sh as ColorKeyframeTrack,Zn as ColorManagement,fc as CompressedTexture,vh as CompressedTextureLoader,kc as ConeBufferGeometry,kc as ConeGeometry,fr as CubeCamera,se as CubeReflectionMapping,re as CubeRefractionMapping,gr as CubeTexture,wh as CubeTextureLoader,le as CubeUVReflectionMapping,_c as CubicBezierCurve,Ac as CubicBezierCurve3,$d as CubicInterpolant,a as CullFaceBack,o as CullFaceFront,l as CullFaceFrontBack,r as CullFaceNone,yc as Curve,Zc as CurvePath,S as CustomBlending,ne as CustomToneMapping,Bc as CylinderBufferGeometry,Bc as CylinderGeometry,Nu as Cylindrical,ti as Data3DTexture,$n as DataArrayTexture,Vl as DataTexture,Zp as DataTexture2DArray,Np as DataTexture3D,Mh as DataTextureLoader,Ap as DataUtils,Ft as DecrementStencilOp,Ot as DecrementWrapStencilOp,mh as DefaultLoadingManager,Ne as DepthFormat,Ve as DepthStencilFormat,tl as DepthTexture,Nh as DirectionalLight,op as DirectionalLightHelper,th as DiscreteInterpolant,Uc as DodecahedronBufferGeometry,Uc as DodecahedronGeometry,f as DoubleSide,P as DstAlphaFactor,Z as DstColorFactor,dn as DynamicCopyUsage,sn as DynamicDrawUsage,on as DynamicReadUsage,Jc as EdgesGeometry,bc as EllipseCurve,F as EqualDepth,Jt as EqualStencilFunc,ae as EquirectangularReflectionMapping,oe as EquirectangularRefractionMapping,Oi as Euler,fn as EventDispatcher,Gd as ExtrudeBufferGeometry,Gd as ExtrudeGeometry,yh as FileLoader,g as FlatShading,Xs as Float16BufferAttribute,Es as Float32BufferAttribute,zs as Float64BufferAttribute,Re as FloatType,ll as Fog,ol as FogExp2,zp as Font,Ep as FontLoader,mc as FramebufferTexture,p as FrontSide,Tr as Frustum,Eu as GLBufferAttribute,un as GLSL1,pn as GLSL3,O as GreaterDepth,U as GreaterEqualDepth,en as GreaterEqualStencilFunc,qt as GreaterStencilFunc,np as GridHelper,qo as Group,_e as HalfFloatType,Ch as HemisphereLight,tp as HemisphereLightHelper,tu as HemisphereLightProbe,_d as IcosahedronBufferGeometry,_d as IcosahedronGeometry,Qh as ImageBitmapLoader,xh as ImageLoader,On as ImageUtils,Pp as ImmediateRenderObject,kt as IncrementStencilOp,Ut as IncrementWrapStencilOp,kl as InstancedBufferAttribute,Uh as InstancedBufferGeometry,Xu as InstancedInterleavedBuffer,Kl as InstancedMesh,Rs as Int16BufferAttribute,As as Int32BufferAttribute,Cs as Int8BufferAttribute,Le as IntType,dl as InterleavedBuffer,ul as InterleavedBufferAttribute,qd as Interpolant,xt as InterpolateDiscrete,wt as InterpolateLinear,Mt as InterpolateSmooth,Yt as InvertStencilOp,Ht as KeepStencilOp,nh as KeyframeTrack,Il as LOD,Vc as LatheBufferGeometry,Vc as LatheGeometry,Yi as Layers,B as LessDepth,k as LessEqualDepth,Qt as LessEqualStencilFunc,jt as LessStencilFunc,Th as Light,Bh as LightProbe,tc as Line,ku as Line3,jl as LineBasicMaterial,Ic as LineCurve,Xc as LineCurve3,Jd as LineDashedMaterial,rc as LineLoop,sc as LineSegments,It as LinearEncoding,ye as LinearFilter,eh as LinearInterpolant,we as LinearMipMapLinearFilter,ve as LinearMipMapNearestFilter,xe as LinearMipmapLinearFilter,be as LinearMipmapNearestFilter,Vt as LinearSRGBColorSpace,q as LinearToneMapping,fh as Loader,Fh as LoaderUtils,ph as LoadingManager,yt as LoopOnce,vt as LoopPingPong,bt as LoopRepeat,Ze as LuminanceAlphaFormat,We as LuminanceFormat,i as MOUSE,xs as Material,kh as MaterialLoader,Gn as MathUtils,_n as Matrix3,Wi as Matrix4,R as MaxEquation,ar as Mesh,ws as MeshBasicMaterial,Uo as MeshDepthMaterial,Oo as MeshDistanceMaterial,Kd as MeshLambertMaterial,jd as MeshMatcapMaterial,Yd as MeshNormalMaterial,Ud as MeshPhongMaterial,Fd as MeshPhysicalMaterial,kd as MeshStandardMaterial,Od as MeshToonMaterial,G as MinEquation,he as MirroredRepeatWrapping,j as MixOperation,M as MultiplyBlending,K as MultiplyOperation,ue as NearestFilter,ge as NearestMipMapLinearFilter,me as NearestMipMapNearestFilter,fe as NearestMipmapLinearFilter,pe as NearestMipmapNearestFilter,D as NeverDepth,Kt as NeverStencilFunc,b as NoBlending,Zt as NoColorSpace,Q as NoToneMapping,Lt as NormalAnimationBlendMode,v as NormalBlending,Y as NotEqualDepth,$t as NotEqualStencilFunc,rh as NumberKeyframeTrack,os as Object3D,Yh as ObjectLoader,Wt as ObjectSpaceNormalMap,Ad as OctahedronBufferGeometry,Ad as OctahedronGeometry,A as OneFactor,W as OneMinusDstAlphaFactor,N as OneMinusDstColorFactor,z as OneMinusSrcAlphaFactor,X as OneMinusSrcColorFactor,Zr as OrthographicCamera,d as PCFShadowMap,h as PCFSoftShadowMap,Ur as PMREMGenerator,Ip as ParametricGeometry,Nc as Path,mr as PerspectiveCamera,wr as Plane,Gr as PlaneBufferGeometry,Gr as PlaneGeometry,fp as PlaneHelper,Wh as PointLight,Qu as PointLightHelper,hc as Points,ac as PointsMaterial,ip as PolarGridHelper,Fc as PolyhedronBufferGeometry,Fc as PolyhedronGeometry,vu as PositionalAudio,Lu as PropertyBinding,wu as PropertyMixer,Ec as QuadraticBezierCurve,zc as QuadraticBezierCurve3,si as Quaternion,oh as QuaternionKeyframeTrack,ah as QuaternionLinearInterpolant,n as REVISION,zt as RGBADepthPacking,Pe as RGBAFormat,Fe as RGBAIntegerFormat,pt as RGBA_ASTC_10x10_Format,dt as RGBA_ASTC_10x5_Format,ht as RGBA_ASTC_10x6_Format,ut as RGBA_ASTC_10x8_Format,mt as RGBA_ASTC_12x10_Format,ft as RGBA_ASTC_12x12_Format,nt as RGBA_ASTC_4x4_Format,it as RGBA_ASTC_5x4_Format,st as RGBA_ASTC_5x5_Format,rt as RGBA_ASTC_6x5_Format,at as RGBA_ASTC_6x6_Format,ot as RGBA_ASTC_8x5_Format,lt as RGBA_ASTC_8x6_Format,ct as RGBA_ASTC_8x8_Format,gt as RGBA_BPTC_Format,tt as RGBA_ETC2_EAC_Format,qe as RGBA_PVRTC_2BPPV1_Format,Qe as RGBA_PVRTC_4BPPV1_Format,Oe as RGBA_S3TC_DXT1_Format,Ye as RGBA_S3TC_DXT3_Format,Ke as RGBA_S3TC_DXT5_Format,ze as RGBFormat,$e as RGB_ETC1_Format,et as RGB_ETC2_Format,Je as RGB_PVRTC_2BPPV1_Format,je as RGB_PVRTC_4BPPV1_Format,Ue as RGB_S3TC_DXT1_Format,Be as RGFormat,ke as RGIntegerFormat,Bd as RawShaderMaterial,Pi as Ray,zu as Raycaster,Dh as RectAreaLight,De as RedFormat,He as RedIntegerFormat,$ as ReinhardToneMapping,ce as RepeatWrapping,Bt as ReplaceStencilOp,L as ReverseSubtractEquation,Id as RingBufferGeometry,Id as RingGeometry,Nt as SRGBColorSpace,cl as Scene,Rr as ShaderChunk,Ar as ShaderLib,ur as ShaderMaterial,Hd as ShadowMaterial,Qc as Shape,Xd as ShapeBufferGeometry,Xd as ShapeGeometry,wp as ShapePath,Td as ShapeUtils,Te as ShortType,Bl as Skeleton,ju as SkeletonHelper,Zl as SkinnedMesh,y as SmoothShading,jC as SoonSpace,Yn as Source,Gi as Sphere,Ed as SphereBufferGeometry,Ed as SphereGeometry,Zu as Spherical,Hh as SphericalHarmonics3,Pc as SplineCurve,Ih as SpotLight,Uu as SpotLightHelper,Gl as Sprite,pl as SpriteMaterial,E as SrcAlphaFactor,V as SrcAlphaSaturateFactor,I as SrcColorFactor,cn as StaticCopyUsage,nn as StaticDrawUsage,an as StaticReadUsage,au as StereoCamera,hn as StreamCopyUsage,rn as StreamDrawUsage,ln as StreamReadUsage,lh as StringKeyframeTrack,C as SubtractEquation,w as SubtractiveBlending,s as TOUCH,Pt as TangentSpaceNormalMap,zd as TetrahedronBufferGeometry,zd as TetrahedronGeometry,Xp as TextGeometry,Jn as Texture,Sh as TextureLoader,Pd as TorusBufferGeometry,Pd as TorusGeometry,Wd as TorusKnotBufferGeometry,Wd as TorusKnotGeometry,bs as Triangle,At as TriangleFanDrawMode,_t as TriangleStripDrawMode,Rt as TrianglesDrawMode,Zd as TubeBufferGeometry,Zd as TubeGeometry,ie as UVMapping,_s as Uint16BufferAttribute,Is as Uint32BufferAttribute,Ls as Uint8BufferAttribute,Gs as Uint8ClampedBufferAttribute,Iu as Uniform,_r as UniformsLib,hr as UniformsUtils,Me as UnsignedByteType,Xe as UnsignedInt248Type,Ge as UnsignedIntType,Ae as UnsignedShort4444Type,Ie as UnsignedShort5551Type,Ce as UnsignedShortType,u as VSMShadowMap,Rn as Vector2,ri as Vector3,Qn as Vector4,ch as VectorKeyframeTrack,pc as VideoTexture,al as WebGL1Renderer,ni as WebGL3DRenderTarget,ei as WebGLArrayRenderTarget,yr as WebGLCubeRenderTarget,ii as WebGLMultipleRenderTargets,Wp as WebGLMultisampleRenderTarget,qn as WebGLRenderTarget,rl as WebGLRenderer,Jo as WebGLUtils,Nd as WireframeGeometry,Ct as WrapAroundEnding,St as ZeroCurvatureEnding,_ as ZeroFactor,Tt as ZeroSlopeEnding,Dt as ZeroStencilOp,mn as _SRGBAFormat,UC as boundingIsIntersected,kC as createPlaneMatrix,YC as createTexture,FC as createUVMatrix,jC as default,OC as getBoundingBox,BC as getPolygonGeometryInfo,Xt as sRGBEncoding,KC as setTexture};