diff --git a/assets/howler-2601a619.js b/assets/howler-fa9e008d.js similarity index 99% rename from assets/howler-2601a619.js rename to assets/howler-fa9e008d.js index 5b6eef50..eae58984 100644 --- a/assets/howler-2601a619.js +++ b/assets/howler-fa9e008d.js @@ -1,4 +1,4 @@ -import{g as L,c as S}from"./index-58594c95.js";function D(b,g){for(var r=0;ru[i]})}}}return Object.freeze(Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}))}var O={};/*! +import{g as L,c as S}from"./index-f020dae5.js";function D(b,g){for(var r=0;ru[i]})}}}return Object.freeze(Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}))}var O={};/*! * howler.js v2.2.3 * howlerjs.com * diff --git a/assets/index-58594c95.js b/assets/index-f020dae5.js similarity index 97% rename from assets/index-58594c95.js rename to assets/index-f020dae5.js index beea1b39..43984d3c 100644 --- a/assets/index-58594c95.js +++ b/assets/index-f020dae5.js @@ -14,14 +14,14 @@ var mz=Object.defineProperty;var vz=(n,e,t)=>e in n?mz(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Nz=me,Dz=Symbol.for("react.element"),kz=Symbol.for("react.fragment"),Vz=Object.prototype.hasOwnProperty,Lz=Nz.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Pz={key:!0,ref:!0,__self:!0,__source:!0};function N3(n,e,t){var r,i={},s=null,o=null;t!==void 0&&(s=""+t),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)Vz.call(e,r)&&!Pz.hasOwnProperty(r)&&(i[r]=e[r]);if(n&&n.defaultProps)for(r in e=n.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:Dz,type:n,key:s,ref:o,props:i,_owner:Lz.current}}mC.Fragment=kz;mC.jsx=N3;mC.jsxs=N3;F3.exports=mC;var P=F3.exports,JU={exports:{}};const Wz={},Oz=Object.freeze(Object.defineProperty({__proto__:null,default:Wz},Symbol.toStringTag,{value:"Module"})),Gz=yz(Oz);JU.exports;(function(n){(function(e,t){function r(_,B){if(!_)throw new Error(B||"Assertion failed")}function i(_,B){_.super_=B;var F=function(){};F.prototype=B.prototype,_.prototype=new F,_.prototype.constructor=_}function s(_,B,F){if(s.isBN(_))return _;this.negative=0,this.words=null,this.length=0,this.red=null,_!==null&&((B==="le"||B==="be")&&(F=B,B=10),this._init(_||0,B||10,F||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Gz.Buffer}catch{}s.isBN=function(B){return B instanceof s?!0:B!==null&&typeof B=="object"&&B.constructor.wordSize===s.wordSize&&Array.isArray(B.words)},s.max=function(B,F){return B.cmp(F)>0?B:F},s.min=function(B,F){return B.cmp(F)<0?B:F},s.prototype._init=function(B,F,R){if(typeof B=="number")return this._initNumber(B,F,R);if(typeof B=="object")return this._initArray(B,F,R);F==="hex"&&(F=16),r(F===(F|0)&&F>=2&&F<=36),B=B.toString().replace(/\s+/g,"");var k=0;B[0]==="-"&&(k++,this.negative=1),k=0;k-=3)V=B[k]|B[k-1]<<8|B[k-2]<<16,this.words[T]|=V<>>26-O&67108863,O+=24,O>=26&&(O-=26,T++);else if(R==="le")for(k=0,T=0;k>>26-O&67108863,O+=24,O>=26&&(O-=26,T++);return this._strip()};function a(_,B){var F=_.charCodeAt(B);if(F>=48&&F<=57)return F-48;if(F>=65&&F<=70)return F-55;if(F>=97&&F<=102)return F-87;r(!1,"Invalid character in "+_)}function l(_,B,F){var R=a(_,F);return F-1>=B&&(R|=a(_,F-1)<<4),R}s.prototype._parseHex=function(B,F,R){this.length=Math.ceil((B.length-F)/6),this.words=new Array(this.length);for(var k=0;k=F;k-=2)O=l(B,F,k)<=18?(T-=18,V+=1,this.words[V]|=O>>>26):T+=8;else{var L=B.length-F;for(k=L%2===0?F+1:F;k=18?(T-=18,V+=1,this.words[V]|=O>>>26):T+=8}this._strip()};function A(_,B,F,R){for(var k=0,T=0,V=Math.min(_.length,F),O=B;O=49?T=L-49+10:L>=17?T=L-17+10:T=L,r(L>=0&&T1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=u}catch{s.prototype.inspect=u}else s.prototype.inspect=u;function u(){return(this.red?""}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(B,F){B=B||10,F=F|0||1;var R;if(B===16||B==="hex"){R="";for(var k=0,T=0,V=0;V>>24-k&16777215,k+=2,k>=26&&(k-=26,V--),T!==0||V!==this.length-1?R=f[6-L.length]+L+R:R=L+R}for(T!==0&&(R=T.toString(16)+R);R.length%F!==0;)R="0"+R;return this.negative!==0&&(R="-"+R),R}if(B===(B|0)&&B>=2&&B<=36){var U=d[B],H=h[B];R="";var Ae=this.clone();for(Ae.negative=0;!Ae.isZero();){var N=Ae.modrn(H).toString(B);Ae=Ae.idivn(H),Ae.isZero()?R=N+R:R=f[U-N.length]+N+R}for(this.isZero()&&(R="0"+R);R.length%F!==0;)R="0"+R;return this.negative!==0&&(R="-"+R),R}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var B=this.words[0];return this.length===2?B+=this.words[1]*67108864:this.length===3&&this.words[2]===1?B+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-B:B},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(B,F){return this.toArrayLike(o,B,F)}),s.prototype.toArray=function(B,F){return this.toArrayLike(Array,B,F)};var p=function(B,F){return B.allocUnsafe?B.allocUnsafe(F):new B(F)};s.prototype.toArrayLike=function(B,F,R){this._strip();var k=this.byteLength(),T=R||Math.max(1,k);r(k<=T,"byte array longer than desired length"),r(T>0,"Requested array length <= 0");var V=p(B,T),O=F==="le"?"LE":"BE";return this["_toArrayLike"+O](V,k),V},s.prototype._toArrayLikeLE=function(B,F){for(var R=0,k=0,T=0,V=0;T>8&255),R>16&255),V===6?(R>24&255),k=0,V=0):(k=O>>>24,V+=2)}if(R=0&&(B[R--]=O>>8&255),R>=0&&(B[R--]=O>>16&255),V===6?(R>=0&&(B[R--]=O>>24&255),k=0,V=0):(k=O>>>24,V+=2)}if(R>=0)for(B[R--]=k;R>=0;)B[R--]=0},Math.clz32?s.prototype._countBits=function(B){return 32-Math.clz32(B)}:s.prototype._countBits=function(B){var F=B,R=0;return F>=4096&&(R+=13,F>>>=13),F>=64&&(R+=7,F>>>=7),F>=8&&(R+=4,F>>>=4),F>=2&&(R+=2,F>>>=2),R+F},s.prototype._zeroBits=function(B){if(B===0)return 26;var F=B,R=0;return F&8191||(R+=13,F>>>=13),F&127||(R+=7,F>>>=7),F&15||(R+=4,F>>>=4),F&3||(R+=2,F>>>=2),F&1||R++,R},s.prototype.bitLength=function(){var B=this.words[this.length-1],F=this._countBits(B);return(this.length-1)*26+F};function m(_){for(var B=new Array(_.bitLength()),F=0;F>>k&1}return B}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var B=0,F=0;FB.length?this.clone().ior(B):B.clone().ior(this)},s.prototype.uor=function(B){return this.length>B.length?this.clone().iuor(B):B.clone().iuor(this)},s.prototype.iuand=function(B){var F;this.length>B.length?F=B:F=this;for(var R=0;RB.length?this.clone().iand(B):B.clone().iand(this)},s.prototype.uand=function(B){return this.length>B.length?this.clone().iuand(B):B.clone().iuand(this)},s.prototype.iuxor=function(B){var F,R;this.length>B.length?(F=this,R=B):(F=B,R=this);for(var k=0;kB.length?this.clone().ixor(B):B.clone().ixor(this)},s.prototype.uxor=function(B){return this.length>B.length?this.clone().iuxor(B):B.clone().iuxor(this)},s.prototype.inotn=function(B){r(typeof B=="number"&&B>=0);var F=Math.ceil(B/26)|0,R=B%26;this._expand(F),R>0&&F--;for(var k=0;k0&&(this.words[k]=~this.words[k]&67108863>>26-R),this._strip()},s.prototype.notn=function(B){return this.clone().inotn(B)},s.prototype.setn=function(B,F){r(typeof B=="number"&&B>=0);var R=B/26|0,k=B%26;return this._expand(R+1),F?this.words[R]=this.words[R]|1<B.length?(R=this,k=B):(R=B,k=this);for(var T=0,V=0;V>>26;for(;T!==0&&V>>26;if(this.length=R.length,T!==0)this.words[this.length]=T,this.length++;else if(R!==this)for(;VB.length?this.clone().iadd(B):B.clone().iadd(this)},s.prototype.isub=function(B){if(B.negative!==0){B.negative=0;var F=this.iadd(B);return B.negative=1,F._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(B),this.negative=1,this._normSign();var R=this.cmp(B);if(R===0)return this.negative=0,this.length=1,this.words[0]=0,this;var k,T;R>0?(k=this,T=B):(k=B,T=this);for(var V=0,O=0;O>26,this.words[O]=F&67108863;for(;V!==0&&O>26,this.words[O]=F&67108863;if(V===0&&O>>26,Ae=L&67108863,N=Math.min(U,B.length-1),j=Math.max(0,U-_.length+1);j<=N;j++){var oe=U-j|0;k=_.words[oe]|0,T=B.words[j]|0,V=k*T+Ae,H+=V/67108864|0,Ae=V&67108863}F.words[U]=Ae|0,L=H|0}return L!==0?F.words[U]=L|0:F.length--,F._strip()}var v=function(B,F,R){var k=B.words,T=F.words,V=R.words,O=0,L,U,H,Ae=k[0]|0,N=Ae&8191,j=Ae>>>13,oe=k[1]|0,ie=oe&8191,de=oe>>>13,X=k[2]|0,ne=X&8191,ae=X>>>13,Be=k[3]|0,pe=Be&8191,Fe=Be>>>13,rt=k[4]|0,Oe=rt&8191,ke=rt>>>13,Qe=k[5]|0,Ge=Qe&8191,Xe=Qe>>>13,G=k[6]|0,J=G&8191,se=G>>>13,fe=k[7]|0,ve=fe&8191,W=fe>>>13,Q=k[8]|0,I=Q&8191,D=Q>>>13,$=k[9]|0,ee=$&8191,te=$>>>13,we=T[0]|0,Ce=we&8191,Ee=we>>>13,Ve=T[1]|0,_e=Ve&8191,re=Ve>>>13,ye=T[2]|0,be=ye&8191,Ue=ye>>>13,Je=T[3]|0,qe=Je&8191,ct=Je>>>13,An=T[4]|0,xt=An&8191,st=An>>>13,or=T[5]|0,mt=or&8191,qt=or>>>13,co=T[6]|0,Xt=co&8191,en=co>>>13,q=T[7]|0,le=q&8191,he=q>>>13,ue=T[8]|0,ge=ue&8191,Ne=ue>>>13,at=T[9]|0,Ye=at&8191,He=at>>>13;R.negative=B.negative^F.negative,R.length=19,L=Math.imul(N,Ce),U=Math.imul(N,Ee),U=U+Math.imul(j,Ce)|0,H=Math.imul(j,Ee);var vt=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(vt>>>26)|0,vt&=67108863,L=Math.imul(ie,Ce),U=Math.imul(ie,Ee),U=U+Math.imul(de,Ce)|0,H=Math.imul(de,Ee),L=L+Math.imul(N,_e)|0,U=U+Math.imul(N,re)|0,U=U+Math.imul(j,_e)|0,H=H+Math.imul(j,re)|0;var ft=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(ft>>>26)|0,ft&=67108863,L=Math.imul(ne,Ce),U=Math.imul(ne,Ee),U=U+Math.imul(ae,Ce)|0,H=Math.imul(ae,Ee),L=L+Math.imul(ie,_e)|0,U=U+Math.imul(ie,re)|0,U=U+Math.imul(de,_e)|0,H=H+Math.imul(de,re)|0,L=L+Math.imul(N,be)|0,U=U+Math.imul(N,Ue)|0,U=U+Math.imul(j,be)|0,H=H+Math.imul(j,Ue)|0;var gt=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(gt>>>26)|0,gt&=67108863,L=Math.imul(pe,Ce),U=Math.imul(pe,Ee),U=U+Math.imul(Fe,Ce)|0,H=Math.imul(Fe,Ee),L=L+Math.imul(ne,_e)|0,U=U+Math.imul(ne,re)|0,U=U+Math.imul(ae,_e)|0,H=H+Math.imul(ae,re)|0,L=L+Math.imul(ie,be)|0,U=U+Math.imul(ie,Ue)|0,U=U+Math.imul(de,be)|0,H=H+Math.imul(de,Ue)|0,L=L+Math.imul(N,qe)|0,U=U+Math.imul(N,ct)|0,U=U+Math.imul(j,qe)|0,H=H+Math.imul(j,ct)|0;var zt=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(zt>>>26)|0,zt&=67108863,L=Math.imul(Oe,Ce),U=Math.imul(Oe,Ee),U=U+Math.imul(ke,Ce)|0,H=Math.imul(ke,Ee),L=L+Math.imul(pe,_e)|0,U=U+Math.imul(pe,re)|0,U=U+Math.imul(Fe,_e)|0,H=H+Math.imul(Fe,re)|0,L=L+Math.imul(ne,be)|0,U=U+Math.imul(ne,Ue)|0,U=U+Math.imul(ae,be)|0,H=H+Math.imul(ae,Ue)|0,L=L+Math.imul(ie,qe)|0,U=U+Math.imul(ie,ct)|0,U=U+Math.imul(de,qe)|0,H=H+Math.imul(de,ct)|0,L=L+Math.imul(N,xt)|0,U=U+Math.imul(N,st)|0,U=U+Math.imul(j,xt)|0,H=H+Math.imul(j,st)|0;var Pr=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,L=Math.imul(Ge,Ce),U=Math.imul(Ge,Ee),U=U+Math.imul(Xe,Ce)|0,H=Math.imul(Xe,Ee),L=L+Math.imul(Oe,_e)|0,U=U+Math.imul(Oe,re)|0,U=U+Math.imul(ke,_e)|0,H=H+Math.imul(ke,re)|0,L=L+Math.imul(pe,be)|0,U=U+Math.imul(pe,Ue)|0,U=U+Math.imul(Fe,be)|0,H=H+Math.imul(Fe,Ue)|0,L=L+Math.imul(ne,qe)|0,U=U+Math.imul(ne,ct)|0,U=U+Math.imul(ae,qe)|0,H=H+Math.imul(ae,ct)|0,L=L+Math.imul(ie,xt)|0,U=U+Math.imul(ie,st)|0,U=U+Math.imul(de,xt)|0,H=H+Math.imul(de,st)|0,L=L+Math.imul(N,mt)|0,U=U+Math.imul(N,qt)|0,U=U+Math.imul(j,mt)|0,H=H+Math.imul(j,qt)|0;var Oo=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Oo>>>26)|0,Oo&=67108863,L=Math.imul(J,Ce),U=Math.imul(J,Ee),U=U+Math.imul(se,Ce)|0,H=Math.imul(se,Ee),L=L+Math.imul(Ge,_e)|0,U=U+Math.imul(Ge,re)|0,U=U+Math.imul(Xe,_e)|0,H=H+Math.imul(Xe,re)|0,L=L+Math.imul(Oe,be)|0,U=U+Math.imul(Oe,Ue)|0,U=U+Math.imul(ke,be)|0,H=H+Math.imul(ke,Ue)|0,L=L+Math.imul(pe,qe)|0,U=U+Math.imul(pe,ct)|0,U=U+Math.imul(Fe,qe)|0,H=H+Math.imul(Fe,ct)|0,L=L+Math.imul(ne,xt)|0,U=U+Math.imul(ne,st)|0,U=U+Math.imul(ae,xt)|0,H=H+Math.imul(ae,st)|0,L=L+Math.imul(ie,mt)|0,U=U+Math.imul(ie,qt)|0,U=U+Math.imul(de,mt)|0,H=H+Math.imul(de,qt)|0,L=L+Math.imul(N,Xt)|0,U=U+Math.imul(N,en)|0,U=U+Math.imul(j,Xt)|0,H=H+Math.imul(j,en)|0;var Go=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Go>>>26)|0,Go&=67108863,L=Math.imul(ve,Ce),U=Math.imul(ve,Ee),U=U+Math.imul(W,Ce)|0,H=Math.imul(W,Ee),L=L+Math.imul(J,_e)|0,U=U+Math.imul(J,re)|0,U=U+Math.imul(se,_e)|0,H=H+Math.imul(se,re)|0,L=L+Math.imul(Ge,be)|0,U=U+Math.imul(Ge,Ue)|0,U=U+Math.imul(Xe,be)|0,H=H+Math.imul(Xe,Ue)|0,L=L+Math.imul(Oe,qe)|0,U=U+Math.imul(Oe,ct)|0,U=U+Math.imul(ke,qe)|0,H=H+Math.imul(ke,ct)|0,L=L+Math.imul(pe,xt)|0,U=U+Math.imul(pe,st)|0,U=U+Math.imul(Fe,xt)|0,H=H+Math.imul(Fe,st)|0,L=L+Math.imul(ne,mt)|0,U=U+Math.imul(ne,qt)|0,U=U+Math.imul(ae,mt)|0,H=H+Math.imul(ae,qt)|0,L=L+Math.imul(ie,Xt)|0,U=U+Math.imul(ie,en)|0,U=U+Math.imul(de,Xt)|0,H=H+Math.imul(de,en)|0,L=L+Math.imul(N,le)|0,U=U+Math.imul(N,he)|0,U=U+Math.imul(j,le)|0,H=H+Math.imul(j,he)|0;var wi=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(wi>>>26)|0,wi&=67108863,L=Math.imul(I,Ce),U=Math.imul(I,Ee),U=U+Math.imul(D,Ce)|0,H=Math.imul(D,Ee),L=L+Math.imul(ve,_e)|0,U=U+Math.imul(ve,re)|0,U=U+Math.imul(W,_e)|0,H=H+Math.imul(W,re)|0,L=L+Math.imul(J,be)|0,U=U+Math.imul(J,Ue)|0,U=U+Math.imul(se,be)|0,H=H+Math.imul(se,Ue)|0,L=L+Math.imul(Ge,qe)|0,U=U+Math.imul(Ge,ct)|0,U=U+Math.imul(Xe,qe)|0,H=H+Math.imul(Xe,ct)|0,L=L+Math.imul(Oe,xt)|0,U=U+Math.imul(Oe,st)|0,U=U+Math.imul(ke,xt)|0,H=H+Math.imul(ke,st)|0,L=L+Math.imul(pe,mt)|0,U=U+Math.imul(pe,qt)|0,U=U+Math.imul(Fe,mt)|0,H=H+Math.imul(Fe,qt)|0,L=L+Math.imul(ne,Xt)|0,U=U+Math.imul(ne,en)|0,U=U+Math.imul(ae,Xt)|0,H=H+Math.imul(ae,en)|0,L=L+Math.imul(ie,le)|0,U=U+Math.imul(ie,he)|0,U=U+Math.imul(de,le)|0,H=H+Math.imul(de,he)|0,L=L+Math.imul(N,ge)|0,U=U+Math.imul(N,Ne)|0,U=U+Math.imul(j,ge)|0,H=H+Math.imul(j,Ne)|0;var Vt=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,L=Math.imul(ee,Ce),U=Math.imul(ee,Ee),U=U+Math.imul(te,Ce)|0,H=Math.imul(te,Ee),L=L+Math.imul(I,_e)|0,U=U+Math.imul(I,re)|0,U=U+Math.imul(D,_e)|0,H=H+Math.imul(D,re)|0,L=L+Math.imul(ve,be)|0,U=U+Math.imul(ve,Ue)|0,U=U+Math.imul(W,be)|0,H=H+Math.imul(W,Ue)|0,L=L+Math.imul(J,qe)|0,U=U+Math.imul(J,ct)|0,U=U+Math.imul(se,qe)|0,H=H+Math.imul(se,ct)|0,L=L+Math.imul(Ge,xt)|0,U=U+Math.imul(Ge,st)|0,U=U+Math.imul(Xe,xt)|0,H=H+Math.imul(Xe,st)|0,L=L+Math.imul(Oe,mt)|0,U=U+Math.imul(Oe,qt)|0,U=U+Math.imul(ke,mt)|0,H=H+Math.imul(ke,qt)|0,L=L+Math.imul(pe,Xt)|0,U=U+Math.imul(pe,en)|0,U=U+Math.imul(Fe,Xt)|0,H=H+Math.imul(Fe,en)|0,L=L+Math.imul(ne,le)|0,U=U+Math.imul(ne,he)|0,U=U+Math.imul(ae,le)|0,H=H+Math.imul(ae,he)|0,L=L+Math.imul(ie,ge)|0,U=U+Math.imul(ie,Ne)|0,U=U+Math.imul(de,ge)|0,H=H+Math.imul(de,Ne)|0,L=L+Math.imul(N,Ye)|0,U=U+Math.imul(N,He)|0,U=U+Math.imul(j,Ye)|0,H=H+Math.imul(j,He)|0;var Zo=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Zo>>>26)|0,Zo&=67108863,L=Math.imul(ee,_e),U=Math.imul(ee,re),U=U+Math.imul(te,_e)|0,H=Math.imul(te,re),L=L+Math.imul(I,be)|0,U=U+Math.imul(I,Ue)|0,U=U+Math.imul(D,be)|0,H=H+Math.imul(D,Ue)|0,L=L+Math.imul(ve,qe)|0,U=U+Math.imul(ve,ct)|0,U=U+Math.imul(W,qe)|0,H=H+Math.imul(W,ct)|0,L=L+Math.imul(J,xt)|0,U=U+Math.imul(J,st)|0,U=U+Math.imul(se,xt)|0,H=H+Math.imul(se,st)|0,L=L+Math.imul(Ge,mt)|0,U=U+Math.imul(Ge,qt)|0,U=U+Math.imul(Xe,mt)|0,H=H+Math.imul(Xe,qt)|0,L=L+Math.imul(Oe,Xt)|0,U=U+Math.imul(Oe,en)|0,U=U+Math.imul(ke,Xt)|0,H=H+Math.imul(ke,en)|0,L=L+Math.imul(pe,le)|0,U=U+Math.imul(pe,he)|0,U=U+Math.imul(Fe,le)|0,H=H+Math.imul(Fe,he)|0,L=L+Math.imul(ne,ge)|0,U=U+Math.imul(ne,Ne)|0,U=U+Math.imul(ae,ge)|0,H=H+Math.imul(ae,Ne)|0,L=L+Math.imul(ie,Ye)|0,U=U+Math.imul(ie,He)|0,U=U+Math.imul(de,Ye)|0,H=H+Math.imul(de,He)|0;var vn=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(vn>>>26)|0,vn&=67108863,L=Math.imul(ee,be),U=Math.imul(ee,Ue),U=U+Math.imul(te,be)|0,H=Math.imul(te,Ue),L=L+Math.imul(I,qe)|0,U=U+Math.imul(I,ct)|0,U=U+Math.imul(D,qe)|0,H=H+Math.imul(D,ct)|0,L=L+Math.imul(ve,xt)|0,U=U+Math.imul(ve,st)|0,U=U+Math.imul(W,xt)|0,H=H+Math.imul(W,st)|0,L=L+Math.imul(J,mt)|0,U=U+Math.imul(J,qt)|0,U=U+Math.imul(se,mt)|0,H=H+Math.imul(se,qt)|0,L=L+Math.imul(Ge,Xt)|0,U=U+Math.imul(Ge,en)|0,U=U+Math.imul(Xe,Xt)|0,H=H+Math.imul(Xe,en)|0,L=L+Math.imul(Oe,le)|0,U=U+Math.imul(Oe,he)|0,U=U+Math.imul(ke,le)|0,H=H+Math.imul(ke,he)|0,L=L+Math.imul(pe,ge)|0,U=U+Math.imul(pe,Ne)|0,U=U+Math.imul(Fe,ge)|0,H=H+Math.imul(Fe,Ne)|0,L=L+Math.imul(ne,Ye)|0,U=U+Math.imul(ne,He)|0,U=U+Math.imul(ae,Ye)|0,H=H+Math.imul(ae,He)|0;var Wr=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,L=Math.imul(ee,qe),U=Math.imul(ee,ct),U=U+Math.imul(te,qe)|0,H=Math.imul(te,ct),L=L+Math.imul(I,xt)|0,U=U+Math.imul(I,st)|0,U=U+Math.imul(D,xt)|0,H=H+Math.imul(D,st)|0,L=L+Math.imul(ve,mt)|0,U=U+Math.imul(ve,qt)|0,U=U+Math.imul(W,mt)|0,H=H+Math.imul(W,qt)|0,L=L+Math.imul(J,Xt)|0,U=U+Math.imul(J,en)|0,U=U+Math.imul(se,Xt)|0,H=H+Math.imul(se,en)|0,L=L+Math.imul(Ge,le)|0,U=U+Math.imul(Ge,he)|0,U=U+Math.imul(Xe,le)|0,H=H+Math.imul(Xe,he)|0,L=L+Math.imul(Oe,ge)|0,U=U+Math.imul(Oe,Ne)|0,U=U+Math.imul(ke,ge)|0,H=H+Math.imul(ke,Ne)|0,L=L+Math.imul(pe,Ye)|0,U=U+Math.imul(pe,He)|0,U=U+Math.imul(Fe,Ye)|0,H=H+Math.imul(Fe,He)|0;var xs=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(xs>>>26)|0,xs&=67108863,L=Math.imul(ee,xt),U=Math.imul(ee,st),U=U+Math.imul(te,xt)|0,H=Math.imul(te,st),L=L+Math.imul(I,mt)|0,U=U+Math.imul(I,qt)|0,U=U+Math.imul(D,mt)|0,H=H+Math.imul(D,qt)|0,L=L+Math.imul(ve,Xt)|0,U=U+Math.imul(ve,en)|0,U=U+Math.imul(W,Xt)|0,H=H+Math.imul(W,en)|0,L=L+Math.imul(J,le)|0,U=U+Math.imul(J,he)|0,U=U+Math.imul(se,le)|0,H=H+Math.imul(se,he)|0,L=L+Math.imul(Ge,ge)|0,U=U+Math.imul(Ge,Ne)|0,U=U+Math.imul(Xe,ge)|0,H=H+Math.imul(Xe,Ne)|0,L=L+Math.imul(Oe,Ye)|0,U=U+Math.imul(Oe,He)|0,U=U+Math.imul(ke,Ye)|0,H=H+Math.imul(ke,He)|0;var Oa=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Oa>>>26)|0,Oa&=67108863,L=Math.imul(ee,mt),U=Math.imul(ee,qt),U=U+Math.imul(te,mt)|0,H=Math.imul(te,qt),L=L+Math.imul(I,Xt)|0,U=U+Math.imul(I,en)|0,U=U+Math.imul(D,Xt)|0,H=H+Math.imul(D,en)|0,L=L+Math.imul(ve,le)|0,U=U+Math.imul(ve,he)|0,U=U+Math.imul(W,le)|0,H=H+Math.imul(W,he)|0,L=L+Math.imul(J,ge)|0,U=U+Math.imul(J,Ne)|0,U=U+Math.imul(se,ge)|0,H=H+Math.imul(se,Ne)|0,L=L+Math.imul(Ge,Ye)|0,U=U+Math.imul(Ge,He)|0,U=U+Math.imul(Xe,Ye)|0,H=H+Math.imul(Xe,He)|0;var mc=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(mc>>>26)|0,mc&=67108863,L=Math.imul(ee,Xt),U=Math.imul(ee,en),U=U+Math.imul(te,Xt)|0,H=Math.imul(te,en),L=L+Math.imul(I,le)|0,U=U+Math.imul(I,he)|0,U=U+Math.imul(D,le)|0,H=H+Math.imul(D,he)|0,L=L+Math.imul(ve,ge)|0,U=U+Math.imul(ve,Ne)|0,U=U+Math.imul(W,ge)|0,H=H+Math.imul(W,Ne)|0,L=L+Math.imul(J,Ye)|0,U=U+Math.imul(J,He)|0,U=U+Math.imul(se,Ye)|0,H=H+Math.imul(se,He)|0;var ar=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(ar>>>26)|0,ar&=67108863,L=Math.imul(ee,le),U=Math.imul(ee,he),U=U+Math.imul(te,le)|0,H=Math.imul(te,he),L=L+Math.imul(I,ge)|0,U=U+Math.imul(I,Ne)|0,U=U+Math.imul(D,ge)|0,H=H+Math.imul(D,Ne)|0,L=L+Math.imul(ve,Ye)|0,U=U+Math.imul(ve,He)|0,U=U+Math.imul(W,Ye)|0,H=H+Math.imul(W,He)|0;var uo=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(uo>>>26)|0,uo&=67108863,L=Math.imul(ee,ge),U=Math.imul(ee,Ne),U=U+Math.imul(te,ge)|0,H=Math.imul(te,Ne),L=L+Math.imul(I,Ye)|0,U=U+Math.imul(I,He)|0,U=U+Math.imul(D,Ye)|0,H=H+Math.imul(D,He)|0;var vc=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(vc>>>26)|0,vc&=67108863,L=Math.imul(ee,Ye),U=Math.imul(ee,He),U=U+Math.imul(te,Ye)|0,H=Math.imul(te,He);var Sr=(O+L|0)+((U&8191)<<13)|0;return O=(H+(U>>>13)|0)+(Sr>>>26)|0,Sr&=67108863,V[0]=vt,V[1]=ft,V[2]=gt,V[3]=zt,V[4]=Pr,V[5]=Oo,V[6]=Go,V[7]=wi,V[8]=Vt,V[9]=Zo,V[10]=vn,V[11]=Wr,V[12]=xs,V[13]=Oa,V[14]=mc,V[15]=ar,V[16]=uo,V[17]=vc,V[18]=Sr,O!==0&&(V[19]=O,R.length++),R};Math.imul||(v=g);function y(_,B,F){F.negative=B.negative^_.negative,F.length=_.length+B.length;for(var R=0,k=0,T=0;T>>26)|0,k+=V>>>26,V&=67108863}F.words[T]=O,R=V,V=k}return R!==0?F.words[T]=R:F.length--,F._strip()}function w(_,B,F){return y(_,B,F)}s.prototype.mulTo=function(B,F){var R,k=this.length+B.length;return this.length===10&&B.length===10?R=v(this,B,F):k<63?R=g(this,B,F):k<1024?R=y(this,B,F):R=w(this,B,F),R},s.prototype.mul=function(B){var F=new s(null);return F.words=new Array(this.length+B.length),this.mulTo(B,F)},s.prototype.mulf=function(B){var F=new s(null);return F.words=new Array(this.length+B.length),w(this,B,F)},s.prototype.imul=function(B){return this.clone().mulTo(B,this)},s.prototype.imuln=function(B){var F=B<0;F&&(B=-B),r(typeof B=="number"),r(B<67108864);for(var R=0,k=0;k>=26,R+=T/67108864|0,R+=V>>>26,this.words[k]=V&67108863}return R!==0&&(this.words[k]=R,this.length++),F?this.ineg():this},s.prototype.muln=function(B){return this.clone().imuln(B)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(B){var F=m(B);if(F.length===0)return new s(1);for(var R=this,k=0;k=0);var F=B%26,R=(B-F)/26,k=67108863>>>26-F<<26-F,T;if(F!==0){var V=0;for(T=0;T>>26-F}V&&(this.words[T]=V,this.length++)}if(R!==0){for(T=this.length-1;T>=0;T--)this.words[T+R]=this.words[T];for(T=0;T=0);var k;F?k=(F-F%26)/26:k=0;var T=B%26,V=Math.min((B-T)/26,this.length),O=67108863^67108863>>>T<V)for(this.length-=V,U=0;U=0&&(H!==0||U>=k);U--){var Ae=this.words[U]|0;this.words[U]=H<<26-T|Ae>>>T,H=Ae&O}return L&&H!==0&&(L.words[L.length++]=H),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(B,F,R){return r(this.negative===0),this.iushrn(B,F,R)},s.prototype.shln=function(B){return this.clone().ishln(B)},s.prototype.ushln=function(B){return this.clone().iushln(B)},s.prototype.shrn=function(B){return this.clone().ishrn(B)},s.prototype.ushrn=function(B){return this.clone().iushrn(B)},s.prototype.testn=function(B){r(typeof B=="number"&&B>=0);var F=B%26,R=(B-F)/26,k=1<=0);var F=B%26,R=(B-F)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=R)return this;if(F!==0&&R++,this.length=Math.min(R,this.length),F!==0){var k=67108863^67108863>>>F<=67108864;F++)this.words[F]-=67108864,F===this.length-1?this.words[F+1]=1:this.words[F+1]++;return this.length=Math.max(this.length,F+1),this},s.prototype.isubn=function(B){if(r(typeof B=="number"),r(B<67108864),B<0)return this.iaddn(-B);if(this.negative!==0)return this.negative=0,this.iaddn(B),this.negative=1,this;if(this.words[0]-=B,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var F=0;F>26)-(L/67108864|0),this.words[T+R]=V&67108863}for(;T>26,this.words[T+R]=V&67108863;if(O===0)return this._strip();for(r(O===-1),O=0,T=0;T>26,this.words[T]=V&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(B,F){var R=this.length-B.length,k=this.clone(),T=B,V=T.words[T.length-1]|0,O=this._countBits(V);R=26-O,R!==0&&(T=T.ushln(R),k.iushln(R),V=T.words[T.length-1]|0);var L=k.length-T.length,U;if(F!=="mod"){U=new s(null),U.length=L+1,U.words=new Array(U.length);for(var H=0;H=0;N--){var j=(k.words[T.length+N]|0)*67108864+(k.words[T.length+N-1]|0);for(j=Math.min(j/V|0,67108863),k._ishlnsubmul(T,j,N);k.negative!==0;)j--,k.negative=0,k._ishlnsubmul(T,1,N),k.isZero()||(k.negative^=1);U&&(U.words[N]=j)}return U&&U._strip(),k._strip(),F!=="div"&&R!==0&&k.iushrn(R),{div:U||null,mod:k}},s.prototype.divmod=function(B,F,R){if(r(!B.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var k,T,V;return this.negative!==0&&B.negative===0?(V=this.neg().divmod(B,F),F!=="mod"&&(k=V.div.neg()),F!=="div"&&(T=V.mod.neg(),R&&T.negative!==0&&T.iadd(B)),{div:k,mod:T}):this.negative===0&&B.negative!==0?(V=this.divmod(B.neg(),F),F!=="mod"&&(k=V.div.neg()),{div:k,mod:V.mod}):this.negative&B.negative?(V=this.neg().divmod(B.neg(),F),F!=="div"&&(T=V.mod.neg(),R&&T.negative!==0&&T.isub(B)),{div:V.div,mod:T}):B.length>this.length||this.cmp(B)<0?{div:new s(0),mod:this}:B.length===1?F==="div"?{div:this.divn(B.words[0]),mod:null}:F==="mod"?{div:null,mod:new s(this.modrn(B.words[0]))}:{div:this.divn(B.words[0]),mod:new s(this.modrn(B.words[0]))}:this._wordDiv(B,F)},s.prototype.div=function(B){return this.divmod(B,"div",!1).div},s.prototype.mod=function(B){return this.divmod(B,"mod",!1).mod},s.prototype.umod=function(B){return this.divmod(B,"mod",!0).mod},s.prototype.divRound=function(B){var F=this.divmod(B);if(F.mod.isZero())return F.div;var R=F.div.negative!==0?F.mod.isub(B):F.mod,k=B.ushrn(1),T=B.andln(1),V=R.cmp(k);return V<0||T===1&&V===0?F.div:F.div.negative!==0?F.div.isubn(1):F.div.iaddn(1)},s.prototype.modrn=function(B){var F=B<0;F&&(B=-B),r(B<=67108863);for(var R=(1<<26)%B,k=0,T=this.length-1;T>=0;T--)k=(R*k+(this.words[T]|0))%B;return F?-k:k},s.prototype.modn=function(B){return this.modrn(B)},s.prototype.idivn=function(B){var F=B<0;F&&(B=-B),r(B<=67108863);for(var R=0,k=this.length-1;k>=0;k--){var T=(this.words[k]|0)+R*67108864;this.words[k]=T/B|0,R=T%B}return this._strip(),F?this.ineg():this},s.prototype.divn=function(B){return this.clone().idivn(B)},s.prototype.egcd=function(B){r(B.negative===0),r(!B.isZero());var F=this,R=B.clone();F.negative!==0?F=F.umod(B):F=F.clone();for(var k=new s(1),T=new s(0),V=new s(0),O=new s(1),L=0;F.isEven()&&R.isEven();)F.iushrn(1),R.iushrn(1),++L;for(var U=R.clone(),H=F.clone();!F.isZero();){for(var Ae=0,N=1;!(F.words[0]&N)&&Ae<26;++Ae,N<<=1);if(Ae>0)for(F.iushrn(Ae);Ae-- >0;)(k.isOdd()||T.isOdd())&&(k.iadd(U),T.isub(H)),k.iushrn(1),T.iushrn(1);for(var j=0,oe=1;!(R.words[0]&oe)&&j<26;++j,oe<<=1);if(j>0)for(R.iushrn(j);j-- >0;)(V.isOdd()||O.isOdd())&&(V.iadd(U),O.isub(H)),V.iushrn(1),O.iushrn(1);F.cmp(R)>=0?(F.isub(R),k.isub(V),T.isub(O)):(R.isub(F),V.isub(k),O.isub(T))}return{a:V,b:O,gcd:R.iushln(L)}},s.prototype._invmp=function(B){r(B.negative===0),r(!B.isZero());var F=this,R=B.clone();F.negative!==0?F=F.umod(B):F=F.clone();for(var k=new s(1),T=new s(0),V=R.clone();F.cmpn(1)>0&&R.cmpn(1)>0;){for(var O=0,L=1;!(F.words[0]&L)&&O<26;++O,L<<=1);if(O>0)for(F.iushrn(O);O-- >0;)k.isOdd()&&k.iadd(V),k.iushrn(1);for(var U=0,H=1;!(R.words[0]&H)&&U<26;++U,H<<=1);if(U>0)for(R.iushrn(U);U-- >0;)T.isOdd()&&T.iadd(V),T.iushrn(1);F.cmp(R)>=0?(F.isub(R),k.isub(T)):(R.isub(F),T.isub(k))}var Ae;return F.cmpn(1)===0?Ae=k:Ae=T,Ae.cmpn(0)<0&&Ae.iadd(B),Ae},s.prototype.gcd=function(B){if(this.isZero())return B.abs();if(B.isZero())return this.abs();var F=this.clone(),R=B.clone();F.negative=0,R.negative=0;for(var k=0;F.isEven()&&R.isEven();k++)F.iushrn(1),R.iushrn(1);do{for(;F.isEven();)F.iushrn(1);for(;R.isEven();)R.iushrn(1);var T=F.cmp(R);if(T<0){var V=F;F=R,R=V}else if(T===0||R.cmpn(1)===0)break;F.isub(R)}while(!0);return R.iushln(k)},s.prototype.invm=function(B){return this.egcd(B).a.umod(B)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(B){return this.words[0]&B},s.prototype.bincn=function(B){r(typeof B=="number");var F=B%26,R=(B-F)/26,k=1<>>26,O&=67108863,this.words[V]=O}return T!==0&&(this.words[V]=T,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(B){var F=B<0;if(this.negative!==0&&!F)return-1;if(this.negative===0&&F)return 1;this._strip();var R;if(this.length>1)R=1;else{F&&(B=-B),r(B<=67108863,"Number is too big");var k=this.words[0]|0;R=k===B?0:kB.length)return 1;if(this.length=0;R--){var k=this.words[R]|0,T=B.words[R]|0;if(k!==T){kT&&(F=1);break}}return F},s.prototype.gtn=function(B){return this.cmpn(B)===1},s.prototype.gt=function(B){return this.cmp(B)===1},s.prototype.gten=function(B){return this.cmpn(B)>=0},s.prototype.gte=function(B){return this.cmp(B)>=0},s.prototype.ltn=function(B){return this.cmpn(B)===-1},s.prototype.lt=function(B){return this.cmp(B)===-1},s.prototype.lten=function(B){return this.cmpn(B)<=0},s.prototype.lte=function(B){return this.cmp(B)<=0},s.prototype.eqn=function(B){return this.cmpn(B)===0},s.prototype.eq=function(B){return this.cmp(B)===0},s.red=function(B){return new Z(B)},s.prototype.toRed=function(B){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),B.convertTo(this)._forceRed(B)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(B){return this.red=B,this},s.prototype.forceRed=function(B){return r(!this.red,"Already a number in reduction context"),this._forceRed(B)},s.prototype.redAdd=function(B){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,B)},s.prototype.redIAdd=function(B){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,B)},s.prototype.redSub=function(B){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,B)},s.prototype.redISub=function(B){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,B)},s.prototype.redShl=function(B){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,B)},s.prototype.redMul=function(B){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,B),this.red.mul(this,B)},s.prototype.redIMul=function(B){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,B),this.red.imul(this,B)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(B){return r(this.red&&!B.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,B)};var C={k256:null,p224:null,p192:null,p25519:null};function b(_,B){this.name=_,this.p=new s(B,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}b.prototype._tmp=function(){var B=new s(null);return B.words=new Array(Math.ceil(this.n/13)),B},b.prototype.ireduce=function(B){var F=B,R;do this.split(F,this.tmp),F=this.imulK(F),F=F.iadd(this.tmp),R=F.bitLength();while(R>this.n);var k=R0?F.isub(this.p):F.strip!==void 0?F.strip():F._strip(),F},b.prototype.split=function(B,F){B.iushrn(this.n,0,F)},b.prototype.imulK=function(B){return B.imul(this.k)};function E(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(E,b),E.prototype.split=function(B,F){for(var R=4194303,k=Math.min(B.length,9),T=0;T>>22,V=O}V>>>=22,B.words[T-10]=V,V===0&&B.length>10?B.length-=10:B.length-=9},E.prototype.imulK=function(B){B.words[B.length]=0,B.words[B.length+1]=0,B.length+=2;for(var F=0,R=0;R>>=26,B.words[R]=T,F=k}return F!==0&&(B.words[B.length++]=F),B},s._prime=function(B){if(C[B])return C[B];var F;if(B==="k256")F=new E;else if(B==="p224")F=new x;else if(B==="p192")F=new S;else if(B==="p25519")F=new M;else throw new Error("Unknown prime "+B);return C[B]=F,F};function Z(_){if(typeof _=="string"){var B=s._prime(_);this.m=B.p,this.prime=B}else r(_.gtn(1),"modulus must be greater than 1"),this.m=_,this.prime=null}Z.prototype._verify1=function(B){r(B.negative===0,"red works only with positives"),r(B.red,"red works only with red numbers")},Z.prototype._verify2=function(B,F){r((B.negative|F.negative)===0,"red works only with positives"),r(B.red&&B.red===F.red,"red works only with red numbers")},Z.prototype.imod=function(B){return this.prime?this.prime.ireduce(B)._forceRed(this):(c(B,B.umod(this.m)._forceRed(this)),B)},Z.prototype.neg=function(B){return B.isZero()?B.clone():this.m.sub(B)._forceRed(this)},Z.prototype.add=function(B,F){this._verify2(B,F);var R=B.add(F);return R.cmp(this.m)>=0&&R.isub(this.m),R._forceRed(this)},Z.prototype.iadd=function(B,F){this._verify2(B,F);var R=B.iadd(F);return R.cmp(this.m)>=0&&R.isub(this.m),R},Z.prototype.sub=function(B,F){this._verify2(B,F);var R=B.sub(F);return R.cmpn(0)<0&&R.iadd(this.m),R._forceRed(this)},Z.prototype.isub=function(B,F){this._verify2(B,F);var R=B.isub(F);return R.cmpn(0)<0&&R.iadd(this.m),R},Z.prototype.shl=function(B,F){return this._verify1(B),this.imod(B.ushln(F))},Z.prototype.imul=function(B,F){return this._verify2(B,F),this.imod(B.imul(F))},Z.prototype.mul=function(B,F){return this._verify2(B,F),this.imod(B.mul(F))},Z.prototype.isqr=function(B){return this.imul(B,B.clone())},Z.prototype.sqr=function(B){return this.mul(B,B)},Z.prototype.sqrt=function(B){if(B.isZero())return B.clone();var F=this.m.andln(3);if(r(F%2===1),F===3){var R=this.m.add(new s(1)).iushrn(2);return this.pow(B,R)}for(var k=this.m.subn(1),T=0;!k.isZero()&&k.andln(1)===0;)T++,k.iushrn(1);r(!k.isZero());var V=new s(1).toRed(this),O=V.redNeg(),L=this.m.subn(1).iushrn(1),U=this.m.bitLength();for(U=new s(2*U*U).toRed(this);this.pow(U,L).cmp(O)!==0;)U.redIAdd(O);for(var H=this.pow(U,k),Ae=this.pow(B,k.addn(1).iushrn(1)),N=this.pow(B,k),j=T;N.cmp(V)!==0;){for(var oe=N,ie=0;oe.cmp(V)!==0;ie++)oe=oe.redSqr();r(ie=0;T--){for(var H=F.words[T],Ae=U-1;Ae>=0;Ae--){var N=H>>Ae&1;if(V!==k[0]&&(V=this.sqr(V)),N===0&&O===0){L=0;continue}O<<=1,O|=N,L++,!(L!==R&&(T!==0||Ae!==0))&&(V=this.mul(V,k[O]),L=0,O=0)}U=26}return V},Z.prototype.convertTo=function(B){var F=B.umod(this.m);return F===B?F.clone():F},Z.prototype.convertFrom=function(B){var F=B.clone();return F.red=null,F},s.mont=function(B){return new K(B)};function K(_){Z.call(this,_),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(K,Z),K.prototype.convertTo=function(B){return this.imod(B.ushln(this.shift))},K.prototype.convertFrom=function(B){var F=this.imod(B.mul(this.rinv));return F.red=null,F},K.prototype.imul=function(B,F){if(B.isZero()||F.isZero())return B.words[0]=0,B.length=1,B;var R=B.imul(F),k=R.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),T=R.isub(k).iushrn(this.shift),V=T;return T.cmp(this.m)>=0?V=T.isub(this.m):T.cmpn(0)<0&&(V=T.iadd(this.m)),V._forceRed(this)},K.prototype.mul=function(B,F){if(B.isZero()||F.isZero())return new s(0)._forceRed(this);var R=B.mul(F),k=R.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),T=R.isub(k).iushrn(this.shift),V=T;return T.cmp(this.m)>=0?V=T.isub(this.m):T.cmpn(0)<0&&(V=T.iadd(this.m)),V._forceRed(this)},K.prototype.invm=function(B){var F=this.imod(B._invmp(this.m).mul(this.r2));return F._forceRed(this)}})(n,td)})(JU);var Zz=JU.exports;const pt=bu(Zz),Jz="logger/5.7.0";let fR=!1,dR=!1;const Dy={debug:1,default:2,info:2,warning:3,error:4,off:5};let hR=Dy.default,Jb=null;function Hz(){try{const n=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{n.push(e)}}),n.length)throw new Error("missing "+n.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(n){return n.message}return null}const pR=Hz();var Y1;(function(n){n.DEBUG="DEBUG",n.INFO="INFO",n.WARNING="WARNING",n.ERROR="ERROR",n.OFF="OFF"})(Y1||(Y1={}));var Io;(function(n){n.UNKNOWN_ERROR="UNKNOWN_ERROR",n.NOT_IMPLEMENTED="NOT_IMPLEMENTED",n.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",n.NETWORK_ERROR="NETWORK_ERROR",n.SERVER_ERROR="SERVER_ERROR",n.TIMEOUT="TIMEOUT",n.BUFFER_OVERRUN="BUFFER_OVERRUN",n.NUMERIC_FAULT="NUMERIC_FAULT",n.MISSING_NEW="MISSING_NEW",n.INVALID_ARGUMENT="INVALID_ARGUMENT",n.MISSING_ARGUMENT="MISSING_ARGUMENT",n.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",n.CALL_EXCEPTION="CALL_EXCEPTION",n.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",n.NONCE_EXPIRED="NONCE_EXPIRED",n.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",n.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",n.TRANSACTION_REPLACED="TRANSACTION_REPLACED",n.ACTION_REJECTED="ACTION_REJECTED"})(Io||(Io={}));const gR="0123456789abcdef";let ce=class Ar{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();Dy[r]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(hR>Dy[r])&&console.log.apply(console,t)}debug(...e){this._log(Ar.levels.DEBUG,e)}info(...e){this._log(Ar.levels.INFO,e)}warn(...e){this._log(Ar.levels.WARNING,e)}makeError(e,t,r){if(dR)return this.makeError("censored error",t,{});t||(t=Ar.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach(l=>{const A=r[l];try{if(A instanceof Uint8Array){let c="";for(let u=0;u>4],c+=gR[A[u]&15];i.push(l+"=Uint8Array(0x"+c+")")}else i.push(l+"="+JSON.stringify(A))}catch{i.push(l+"="+JSON.stringify(r[l].toString()))}}),i.push(`code=${t}`),i.push(`version=${this.version}`);const s=e;let o="";switch(t){case Io.NUMERIC_FAULT:{o="NUMERIC_FAULT";const l=e;switch(l){case"overflow":case"underflow":case"division-by-zero":o+="-"+l;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Io.CALL_EXCEPTION:case Io.INSUFFICIENT_FUNDS:case Io.MISSING_NEW:case Io.NONCE_EXPIRED:case Io.REPLACEMENT_UNDERPRICED:case Io.TRANSACTION_REPLACED:case Io.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(e+=" ("+i.join(", ")+")");const a=new Error(e);return a.reason=s,a.code=t,Object.keys(r).forEach(function(l){a[l]=r[l]}),a}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(e,t,r){return this.throwError(e,Ar.errors.INVALID_ARGUMENT,{argument:t,value:r})}assert(e,t,r,i){e||this.throwError(t,r,i)}assertArgument(e,t,r,i){e||this.throwArgumentError(t,r,i)}checkNormalize(e){pR&&this.throwError("platform missing String.prototype.normalize",Ar.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:pR})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,Ar.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,Ar.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r?r=": "+r:r="",et&&this.throwError("too many arguments"+r,Ar.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",Ar.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",Ar.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Ar.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Jb||(Jb=new Ar(Jz)),Jb}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",Ar.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),fR){if(!e)return;this.globalLogger().throwError("error censorship permanent",Ar.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}dR=!!e,fR=!!t}static setLogLevel(e){const t=Dy[e.toLowerCase()];if(t==null){Ar.globalLogger().warn("invalid log level - "+e);return}hR=t}static from(e){return new Ar(e)}};ce.errors=Io;ce.levels=Y1;const zz="bytes/5.7.0",Tn=new ce(zz);function D3(n){return!!n.toHexString}function _d(n){return n.slice||(n.slice=function(){const e=Array.prototype.slice.call(arguments);return _d(new Uint8Array(Array.prototype.slice.apply(n,e)))}),n}function HU(n){return bt(n)&&!(n.length%2)||vC(n)}function mR(n){return typeof n=="number"&&n==n&&n%1===0}function vC(n){if(n==null)return!1;if(n.constructor===Uint8Array)return!0;if(typeof n=="string"||!mR(n.length)||n.length<0)return!1;for(let e=0;e=256)return!1}return!0}function lt(n,e){if(e||(e={}),typeof n=="number"){Tn.checkSafeUint53(n,"invalid arrayify value");const t=[];for(;n;)t.unshift(n&255),n=parseInt(String(n/256));return t.length===0&&t.push(0),_d(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),D3(n)&&(n=n.toHexString()),bt(n)){let t=n.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":Tn.throwArgumentError("hex data is odd-length","value",n));const r=[];for(let i=0;ilt(i)),t=e.reduce((i,s)=>i+s.length,0),r=new Uint8Array(t);return e.reduce((i,s)=>(r.set(s,i),i+s.length),0),_d(r)}function $d(n){let e=lt(n);if(e.length===0)return e;let t=0;for(;te&&Tn.throwArgumentError("value out of range","value",arguments[0]);const t=new Uint8Array(e);return t.set(n,e-n.length),_d(t)}function bt(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||e&&n.length!==2+2*e)}const Hb="0123456789abcdef";function $e(n,e){if(e||(e={}),typeof n=="number"){Tn.checkSafeUint53(n,"invalid hexlify value");let t="";for(;n;)t=Hb[n&15]+t,n=Math.floor(n/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof n=="bigint")return n=n.toString(16),n.length%2?"0x0"+n:"0x"+n;if(e.allowMissingPrefix&&typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),D3(n))return n.toHexString();if(bt(n))return n.length%2&&(e.hexPad==="left"?n="0x0"+n.substring(2):e.hexPad==="right"?n+="0":Tn.throwArgumentError("hex data is odd-length","value",n)),n.toLowerCase();if(vC(n)){let t="0x";for(let r=0;r>4]+Hb[i&15]}return t}return Tn.throwArgumentError("invalid hexlify value","value",n)}function au(n){if(typeof n!="string")n=$e(n);else if(!bt(n)||n.length%2)return null;return(n.length-2)/2}function Jr(n,e,t){return typeof n!="string"?n=$e(n):(!bt(n)||n.length%2)&&Tn.throwArgumentError("invalid hexData","value",n),e=2+2*e,t!=null?"0x"+n.substring(e,2+2*t):"0x"+n.substring(e)}function Ui(n){let e="0x";return n.forEach(t=>{e+=$e(t).substring(2)}),e}function yC(n){const e=Xz($e(n,{hexPad:"left"}));return e==="0x"?"0x0":e}function Xz(n){typeof n!="string"&&(n=$e(n)),bt(n)||Tn.throwArgumentError("invalid hex string","value",n),n=n.substring(2);let e=0;for(;e2*e+2&&Tn.throwArgumentError("value out of range","value",arguments[1]);n.length<2*e+2;)n="0x0"+n.substring(2);return n}function BC(n){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(HU(n)){let t=lt(n);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=$e(t.slice(0,32)),e.s=$e(t.slice(32,64))):t.length===65?(e.r=$e(t.slice(0,32)),e.s=$e(t.slice(32,64)),e.v=t[64]):Tn.throwArgumentError("invalid signature string","signature",n),e.v<27&&(e.v===0||e.v===1?e.v+=27:Tn.throwArgumentError("signature invalid v byte","signature",n)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=$e(t.slice(32,64))}else{if(e.r=n.r,e.s=n.s,e.v=n.v,e.recoveryParam=n.recoveryParam,e._vs=n._vs,e._vs!=null){const i=Yz(lt(e._vs),32);e._vs=$e(i);const s=i[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&Tn.throwArgumentError("signature recoveryParam mismatch _vs","signature",n),i[0]&=127;const o=$e(i);e.s==null?e.s=o:e.s!==o&&Tn.throwArgumentError("signature v mismatch _vs","signature",n)}if(e.recoveryParam==null)e.v==null?Tn.throwArgumentError("signature missing v and recoveryParam","signature",n):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const i=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==i&&Tn.throwArgumentError("signature recoveryParam mismatch v","signature",n)}e.r==null||!bt(e.r)?Tn.throwArgumentError("signature missing or invalid r","signature",n):e.r=Ln(e.r,32),e.s==null||!bt(e.s)?Tn.throwArgumentError("signature missing or invalid s","signature",n):e.s=Ln(e.s,32);const t=lt(e.s);t[0]>=128&&Tn.throwArgumentError("signature s out of range","signature",n),e.recoveryParam&&(t[0]|=128);const r=$e(t);e._vs&&(bt(e._vs)||Tn.throwArgumentError("signature invalid _vs","signature",n),e._vs=Ln(e._vs,32)),e._vs==null?e._vs=r:e._vs!==r&&Tn.throwArgumentError("signature _vs mismatch v and s","signature",n)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}const Kz="bignumber/5.7.0";var EB=pt.BN;const sl=new ce(Kz),zb={},vR=9007199254740991;let yR=!1;class De{constructor(e,t){e!==zb&&sl.throwError("cannot call constructor directly; use BigNumber.from",ce.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Ci(Ft(this).fromTwos(e))}toTwos(e){return Ci(Ft(this).toTwos(e))}abs(){return this._hex[0]==="-"?De.from(this._hex.substring(1)):this}add(e){return Ci(Ft(this).add(Ft(e)))}sub(e){return Ci(Ft(this).sub(Ft(e)))}div(e){return De.from(e).isZero()&&Fs("division-by-zero","div"),Ci(Ft(this).div(Ft(e)))}mul(e){return Ci(Ft(this).mul(Ft(e)))}mod(e){const t=Ft(e);return t.isNeg()&&Fs("division-by-zero","mod"),Ci(Ft(this).umod(t))}pow(e){const t=Ft(e);return t.isNeg()&&Fs("negative-power","pow"),Ci(Ft(this).pow(t))}and(e){const t=Ft(e);return(this.isNegative()||t.isNeg())&&Fs("unbound-bitwise-result","and"),Ci(Ft(this).and(t))}or(e){const t=Ft(e);return(this.isNegative()||t.isNeg())&&Fs("unbound-bitwise-result","or"),Ci(Ft(this).or(t))}xor(e){const t=Ft(e);return(this.isNegative()||t.isNeg())&&Fs("unbound-bitwise-result","xor"),Ci(Ft(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&Fs("negative-width","mask"),Ci(Ft(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Fs("negative-width","shl"),Ci(Ft(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Fs("negative-width","shr"),Ci(Ft(this).shrn(e))}eq(e){return Ft(this).eq(Ft(e))}lt(e){return Ft(this).lt(Ft(e))}lte(e){return Ft(this).lte(Ft(e))}gt(e){return Ft(this).gt(Ft(e))}gte(e){return Ft(this).gte(Ft(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Ft(this).isZero()}toNumber(){try{return Ft(this).toNumber()}catch{Fs("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return sl.throwError("this platform does not support BigInt",ce.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?yR||(yR=!0,sl.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?sl.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",ce.errors.UNEXPECTED_ARGUMENT,{}):sl.throwError("BigNumber.toString does not accept parameters",ce.errors.UNEXPECTED_ARGUMENT,{})),Ft(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof De)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new De(zb,Kg(e)):e.match(/^-?[0-9]+$/)?new De(zb,Kg(new EB(e))):sl.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Fs("underflow","BigNumber.from",e),(e>=vR||e<=-vR)&&Fs("overflow","BigNumber.from",e),De.from(String(e));const t=e;if(typeof t=="bigint")return De.from(t.toString());if(vC(t))return De.from($e(t));if(t)if(t.toHexString){const r=t.toHexString();if(typeof r=="string")return De.from(r)}else{let r=t._hex;if(r==null&&t.type==="BigNumber"&&(r=t.hex),typeof r=="string"&&(bt(r)||r[0]==="-"&&bt(r.substring(1))))return De.from(r)}return sl.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function Kg(n){if(typeof n!="string")return Kg(n.toString(16));if(n[0]==="-")return n=n.substring(1),n[0]==="-"&&sl.throwArgumentError("invalid hex","value",n),n=Kg(n),n==="0x00"?n:"-"+n;if(n.substring(0,2)!=="0x"&&(n="0x"+n),n==="0x")return"0x00";for(n.length%2&&(n="0x0"+n.substring(2));n.length>4&&n.substring(0,4)==="0x00";)n="0x"+n.substring(4);return n}function Ci(n){return De.from(Kg(n))}function Ft(n){const e=De.from(n).toHexString();return e[0]==="-"?new EB("-"+e.substring(3),16):new EB(e.substring(2),16)}function Fs(n,e,t){const r={fault:n,operation:e};return t!=null&&(r.value=t),sl.throwError(n,ce.errors.NUMERIC_FAULT,r)}function jz(n){return new EB(n,36).toString(16)}const $z="properties/5.7.0";var qz=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const UB=new ce($z);function Ie(n,e,t){Object.defineProperty(n,e,{enumerable:!0,value:t,writable:!1})}function is(n,e){for(let t=0;t<32;t++){if(n[e])return n[e];if(!n.prototype||typeof n.prototype!="object")break;n=Object.getPrototypeOf(n.prototype).constructor}return null}function jn(n){return qz(this,void 0,void 0,function*(){const e=Object.keys(n).map(r=>{const i=n[r];return Promise.resolve(i).then(s=>({key:r,value:s}))});return(yield Promise.all(e)).reduce((r,i)=>(r[i.key]=i.value,r),{})})}function e9(n,e){(!n||typeof n!="object")&&UB.throwArgumentError("invalid object","object",n),Object.keys(n).forEach(t=>{e[t]||UB.throwArgumentError("invalid object key - "+t,"transaction:"+t,n)})}function xn(n){const e={};for(const t in n)e[t]=n[t];return e}const t9={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function k3(n){if(n==null||t9[typeof n])return!0;if(Array.isArray(n)||typeof n=="object"){if(!Object.isFrozen(n))return!1;const e=Object.keys(n);for(let t=0;tas(e)));if(typeof n=="object"){const e={};for(const t in n){const r=n[t];r!==void 0&&Ie(e,t,as(r))}return e}return UB.throwArgumentError(`Cannot deepCopy ${typeof n}`,"object",n)}function as(n){return n9(n)}class $m{constructor(e){for(const t in e)this[t]=as(e[t])}}const r9="abstract-provider/5.7.0";var i9=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const s9=new ce(r9);class o9 extends $m{static isForkEvent(e){return!!(e&&e._isForkEvent)}}class qm{constructor(){s9.checkAbstract(new.target,qm),Ie(this,"_isProvider",!0)}getFeeData(){return i9(this,void 0,void 0,function*(){const{block:e,gasPrice:t}=yield jn({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(o=>null)});let r=null,i=null,s=null;return e&&e.baseFeePerGas&&(r=e.baseFeePerGas,s=De.from("1500000000"),i=e.baseFeePerGas.mul(2).add(s)),{lastBaseFeePerGas:r,maxFeePerGas:i,maxPriorityFeePerGas:s,gasPrice:t}})}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}static isProvider(e){return!!(e&&e._isProvider)}}const a9="networks/5.7.1",BR=new ce(a9);function l9(n){return n&&typeof n.renetwork=="function"}function ul(n){const e=function(t,r){r==null&&(r={});const i=[];if(t.InfuraProvider&&r.infura!=="-")try{i.push(new t.InfuraProvider(n,r.infura))}catch{}if(t.EtherscanProvider&&r.etherscan!=="-")try{i.push(new t.EtherscanProvider(n,r.etherscan))}catch{}if(t.AlchemyProvider&&r.alchemy!=="-")try{i.push(new t.AlchemyProvider(n,r.alchemy))}catch{}if(t.PocketProvider&&r.pocket!=="-"){const s=["goerli","ropsten","rinkeby","sepolia"];try{const o=new t.PocketProvider(n,r.pocket);o.network&&s.indexOf(o.network.name)===-1&&i.push(o)}catch{}}if(t.CloudflareProvider&&r.cloudflare!=="-")try{i.push(new t.CloudflareProvider(n))}catch{}if(t.AnkrProvider&&r.ankr!=="-")try{const s=["ropsten"],o=new t.AnkrProvider(n,r.ankr);o.network&&s.indexOf(o.network.name)===-1&&i.push(o)}catch{}if(i.length===0)return null;if(t.FallbackProvider){let s=1;return r.quorum!=null?s=r.quorum:n==="homestead"&&(s=2),new t.FallbackProvider(i,s)}return i[0]};return e.renetwork=function(t){return ul(t)},e}function SB(n,e){const t=function(r,i){return r.JsonRpcProvider?new r.JsonRpcProvider(n,e):null};return t.renetwork=function(r){return SB(n,r)},t}const wR={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:ul("homestead")},CR={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:ul("ropsten")},bR={chainId:63,name:"classicMordor",_defaultProvider:SB("https://www.ethercluster.com/mordor","classicMordor")},T0={unspecified:{chainId:0,name:"unspecified"},homestead:wR,mainnet:wR,morden:{chainId:2,name:"morden"},ropsten:CR,testnet:CR,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:ul("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ul("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:ul("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:ul("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:SB("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:bR,classicTestnet:bR,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:SB("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:ul("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:ul("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function V3(n){if(n==null)return null;if(typeof n=="number"){for(const r in T0){const i=T0[r];if(i.chainId===n)return{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress||null,_defaultProvider:i._defaultProvider||null}}return{chainId:n,name:"unknown"}}if(typeof n=="string"){const r=T0[n];return r==null?null:{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress,_defaultProvider:r._defaultProvider||null}}const e=T0[n.name];if(!e)return typeof n.chainId!="number"&&BR.throwArgumentError("invalid network chainId","network",n),n;n.chainId!==0&&n.chainId!==e.chainId&&BR.throwArgumentError("network chainId mismatch","network",n);let t=n._defaultProvider||null;return t==null&&e._defaultProvider&&(l9(e._defaultProvider)?t=e._defaultProvider.renetwork(n):t=e._defaultProvider),{name:n.name,chainId:e.chainId,ensAddress:n.ensAddress||e.ensAddress||null,_defaultProvider:t}}function L3(n){n=atob(n);const e=[];for(let t=0;t0;)r.push(o%this.base),o=o/this.base|0}let i="";for(let s=0;t[s]===0&&s=0;--s)i+=this.alphabet[r[s]];return i}decode(e){if(typeof e!="string")throw new TypeError("Expected String");let t=[];if(e.length===0)return new Uint8Array(t);t.push(0);for(let r=0;r>=8;for(;s>0;)t.push(s&255),s>>=8}for(let r=0;e[r]===this._leader&&r0?B:F},s.min=function(B,F){return B.cmp(F)<0?B:F},s.prototype._init=function(B,F,R){if(typeof B=="number")return this._initNumber(B,F,R);if(typeof B=="object")return this._initArray(B,F,R);F==="hex"&&(F=16),r(F===(F|0)&&F>=2&&F<=36),B=B.toString().replace(/\s+/g,"");var k=0;B[0]==="-"&&(k++,this.negative=1),k=0;k-=3)V=B[k]|B[k-1]<<8|B[k-2]<<16,this.words[T]|=V<>>26-O&67108863,O+=24,O>=26&&(O-=26,T++);else if(R==="le")for(k=0,T=0;k>>26-O&67108863,O+=24,O>=26&&(O-=26,T++);return this._strip()};function a(_,B){var F=_.charCodeAt(B);if(F>=48&&F<=57)return F-48;if(F>=65&&F<=70)return F-55;if(F>=97&&F<=102)return F-87;r(!1,"Invalid character in "+_)}function l(_,B,F){var R=a(_,F);return F-1>=B&&(R|=a(_,F-1)<<4),R}s.prototype._parseHex=function(B,F,R){this.length=Math.ceil((B.length-F)/6),this.words=new Array(this.length);for(var k=0;k=F;k-=2)O=l(B,F,k)<=18?(T-=18,V+=1,this.words[V]|=O>>>26):T+=8;else{var L=B.length-F;for(k=L%2===0?F+1:F;k=18?(T-=18,V+=1,this.words[V]|=O>>>26):T+=8}this._strip()};function A(_,B,F,R){for(var k=0,T=0,V=Math.min(_.length,F),O=B;O=49?T=L-49+10:L>=17?T=L-17+10:T=L,r(L>=0&&T1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=u}catch{s.prototype.inspect=u}else s.prototype.inspect=u;function u(){return(this.red?""}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(B,F){B=B||10,F=F|0||1;var R;if(B===16||B==="hex"){R="";for(var k=0,T=0,V=0;V>>24-k&16777215,k+=2,k>=26&&(k-=26,V--),T!==0||V!==this.length-1?R=f[6-L.length]+L+R:R=L+R}for(T!==0&&(R=T.toString(16)+R);R.length%F!==0;)R="0"+R;return this.negative!==0&&(R="-"+R),R}if(B===(B|0)&&B>=2&&B<=36){var U=d[B],H=h[B];R="";var le=this.clone();for(le.negative=0;!le.isZero();){var N=le.modrn(H).toString(B);le=le.idivn(H),le.isZero()?R=N+R:R=f[U-N.length]+N+R}for(this.isZero()&&(R="0"+R);R.length%F!==0;)R="0"+R;return this.negative!==0&&(R="-"+R),R}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var B=this.words[0];return this.length===2?B+=this.words[1]*67108864:this.length===3&&this.words[2]===1?B+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-B:B},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(B,F){return this.toArrayLike(o,B,F)}),s.prototype.toArray=function(B,F){return this.toArrayLike(Array,B,F)};var p=function(B,F){return B.allocUnsafe?B.allocUnsafe(F):new B(F)};s.prototype.toArrayLike=function(B,F,R){this._strip();var k=this.byteLength(),T=R||Math.max(1,k);r(k<=T,"byte array longer than desired length"),r(T>0,"Requested array length <= 0");var V=p(B,T),O=F==="le"?"LE":"BE";return this["_toArrayLike"+O](V,k),V},s.prototype._toArrayLikeLE=function(B,F){for(var R=0,k=0,T=0,V=0;T>8&255),R>16&255),V===6?(R>24&255),k=0,V=0):(k=O>>>24,V+=2)}if(R=0&&(B[R--]=O>>8&255),R>=0&&(B[R--]=O>>16&255),V===6?(R>=0&&(B[R--]=O>>24&255),k=0,V=0):(k=O>>>24,V+=2)}if(R>=0)for(B[R--]=k;R>=0;)B[R--]=0},Math.clz32?s.prototype._countBits=function(B){return 32-Math.clz32(B)}:s.prototype._countBits=function(B){var F=B,R=0;return F>=4096&&(R+=13,F>>>=13),F>=64&&(R+=7,F>>>=7),F>=8&&(R+=4,F>>>=4),F>=2&&(R+=2,F>>>=2),R+F},s.prototype._zeroBits=function(B){if(B===0)return 26;var F=B,R=0;return F&8191||(R+=13,F>>>=13),F&127||(R+=7,F>>>=7),F&15||(R+=4,F>>>=4),F&3||(R+=2,F>>>=2),F&1||R++,R},s.prototype.bitLength=function(){var B=this.words[this.length-1],F=this._countBits(B);return(this.length-1)*26+F};function m(_){for(var B=new Array(_.bitLength()),F=0;F>>k&1}return B}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var B=0,F=0;FB.length?this.clone().ior(B):B.clone().ior(this)},s.prototype.uor=function(B){return this.length>B.length?this.clone().iuor(B):B.clone().iuor(this)},s.prototype.iuand=function(B){var F;this.length>B.length?F=B:F=this;for(var R=0;RB.length?this.clone().iand(B):B.clone().iand(this)},s.prototype.uand=function(B){return this.length>B.length?this.clone().iuand(B):B.clone().iuand(this)},s.prototype.iuxor=function(B){var F,R;this.length>B.length?(F=this,R=B):(F=B,R=this);for(var k=0;kB.length?this.clone().ixor(B):B.clone().ixor(this)},s.prototype.uxor=function(B){return this.length>B.length?this.clone().iuxor(B):B.clone().iuxor(this)},s.prototype.inotn=function(B){r(typeof B=="number"&&B>=0);var F=Math.ceil(B/26)|0,R=B%26;this._expand(F),R>0&&F--;for(var k=0;k0&&(this.words[k]=~this.words[k]&67108863>>26-R),this._strip()},s.prototype.notn=function(B){return this.clone().inotn(B)},s.prototype.setn=function(B,F){r(typeof B=="number"&&B>=0);var R=B/26|0,k=B%26;return this._expand(R+1),F?this.words[R]=this.words[R]|1<B.length?(R=this,k=B):(R=B,k=this);for(var T=0,V=0;V>>26;for(;T!==0&&V>>26;if(this.length=R.length,T!==0)this.words[this.length]=T,this.length++;else if(R!==this)for(;VB.length?this.clone().iadd(B):B.clone().iadd(this)},s.prototype.isub=function(B){if(B.negative!==0){B.negative=0;var F=this.iadd(B);return B.negative=1,F._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(B),this.negative=1,this._normSign();var R=this.cmp(B);if(R===0)return this.negative=0,this.length=1,this.words[0]=0,this;var k,T;R>0?(k=this,T=B):(k=B,T=this);for(var V=0,O=0;O>26,this.words[O]=F&67108863;for(;V!==0&&O>26,this.words[O]=F&67108863;if(V===0&&O>>26,le=L&67108863,N=Math.min(U,B.length-1),j=Math.max(0,U-_.length+1);j<=N;j++){var oe=U-j|0;k=_.words[oe]|0,T=B.words[j]|0,V=k*T+le,H+=V/67108864|0,le=V&67108863}F.words[U]=le|0,L=H|0}return L!==0?F.words[U]=L|0:F.length--,F._strip()}var v=function(B,F,R){var k=B.words,T=F.words,V=R.words,O=0,L,U,H,le=k[0]|0,N=le&8191,j=le>>>13,oe=k[1]|0,ie=oe&8191,de=oe>>>13,X=k[2]|0,ne=X&8191,ae=X>>>13,Be=k[3]|0,pe=Be&8191,Fe=Be>>>13,rt=k[4]|0,Oe=rt&8191,ke=rt>>>13,Qe=k[5]|0,Ge=Qe&8191,Xe=Qe>>>13,G=k[6]|0,J=G&8191,se=G>>>13,fe=k[7]|0,ve=fe&8191,W=fe>>>13,Q=k[8]|0,I=Q&8191,D=Q>>>13,$=k[9]|0,ee=$&8191,te=$>>>13,we=T[0]|0,Ce=we&8191,Ee=we>>>13,Ve=T[1]|0,_e=Ve&8191,re=Ve>>>13,ye=T[2]|0,be=ye&8191,Ue=ye>>>13,Je=T[3]|0,qe=Je&8191,ct=Je>>>13,An=T[4]|0,xt=An&8191,st=An>>>13,or=T[5]|0,mt=or&8191,qt=or>>>13,co=T[6]|0,Xt=co&8191,en=co>>>13,q=T[7]|0,Ae=q&8191,he=q>>>13,ue=T[8]|0,ge=ue&8191,Ne=ue>>>13,at=T[9]|0,Ye=at&8191,He=at>>>13;R.negative=B.negative^F.negative,R.length=19,L=Math.imul(N,Ce),U=Math.imul(N,Ee),U=U+Math.imul(j,Ce)|0,H=Math.imul(j,Ee);var vt=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(vt>>>26)|0,vt&=67108863,L=Math.imul(ie,Ce),U=Math.imul(ie,Ee),U=U+Math.imul(de,Ce)|0,H=Math.imul(de,Ee),L=L+Math.imul(N,_e)|0,U=U+Math.imul(N,re)|0,U=U+Math.imul(j,_e)|0,H=H+Math.imul(j,re)|0;var ft=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(ft>>>26)|0,ft&=67108863,L=Math.imul(ne,Ce),U=Math.imul(ne,Ee),U=U+Math.imul(ae,Ce)|0,H=Math.imul(ae,Ee),L=L+Math.imul(ie,_e)|0,U=U+Math.imul(ie,re)|0,U=U+Math.imul(de,_e)|0,H=H+Math.imul(de,re)|0,L=L+Math.imul(N,be)|0,U=U+Math.imul(N,Ue)|0,U=U+Math.imul(j,be)|0,H=H+Math.imul(j,Ue)|0;var gt=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(gt>>>26)|0,gt&=67108863,L=Math.imul(pe,Ce),U=Math.imul(pe,Ee),U=U+Math.imul(Fe,Ce)|0,H=Math.imul(Fe,Ee),L=L+Math.imul(ne,_e)|0,U=U+Math.imul(ne,re)|0,U=U+Math.imul(ae,_e)|0,H=H+Math.imul(ae,re)|0,L=L+Math.imul(ie,be)|0,U=U+Math.imul(ie,Ue)|0,U=U+Math.imul(de,be)|0,H=H+Math.imul(de,Ue)|0,L=L+Math.imul(N,qe)|0,U=U+Math.imul(N,ct)|0,U=U+Math.imul(j,qe)|0,H=H+Math.imul(j,ct)|0;var zt=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(zt>>>26)|0,zt&=67108863,L=Math.imul(Oe,Ce),U=Math.imul(Oe,Ee),U=U+Math.imul(ke,Ce)|0,H=Math.imul(ke,Ee),L=L+Math.imul(pe,_e)|0,U=U+Math.imul(pe,re)|0,U=U+Math.imul(Fe,_e)|0,H=H+Math.imul(Fe,re)|0,L=L+Math.imul(ne,be)|0,U=U+Math.imul(ne,Ue)|0,U=U+Math.imul(ae,be)|0,H=H+Math.imul(ae,Ue)|0,L=L+Math.imul(ie,qe)|0,U=U+Math.imul(ie,ct)|0,U=U+Math.imul(de,qe)|0,H=H+Math.imul(de,ct)|0,L=L+Math.imul(N,xt)|0,U=U+Math.imul(N,st)|0,U=U+Math.imul(j,xt)|0,H=H+Math.imul(j,st)|0;var Pr=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,L=Math.imul(Ge,Ce),U=Math.imul(Ge,Ee),U=U+Math.imul(Xe,Ce)|0,H=Math.imul(Xe,Ee),L=L+Math.imul(Oe,_e)|0,U=U+Math.imul(Oe,re)|0,U=U+Math.imul(ke,_e)|0,H=H+Math.imul(ke,re)|0,L=L+Math.imul(pe,be)|0,U=U+Math.imul(pe,Ue)|0,U=U+Math.imul(Fe,be)|0,H=H+Math.imul(Fe,Ue)|0,L=L+Math.imul(ne,qe)|0,U=U+Math.imul(ne,ct)|0,U=U+Math.imul(ae,qe)|0,H=H+Math.imul(ae,ct)|0,L=L+Math.imul(ie,xt)|0,U=U+Math.imul(ie,st)|0,U=U+Math.imul(de,xt)|0,H=H+Math.imul(de,st)|0,L=L+Math.imul(N,mt)|0,U=U+Math.imul(N,qt)|0,U=U+Math.imul(j,mt)|0,H=H+Math.imul(j,qt)|0;var Oo=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Oo>>>26)|0,Oo&=67108863,L=Math.imul(J,Ce),U=Math.imul(J,Ee),U=U+Math.imul(se,Ce)|0,H=Math.imul(se,Ee),L=L+Math.imul(Ge,_e)|0,U=U+Math.imul(Ge,re)|0,U=U+Math.imul(Xe,_e)|0,H=H+Math.imul(Xe,re)|0,L=L+Math.imul(Oe,be)|0,U=U+Math.imul(Oe,Ue)|0,U=U+Math.imul(ke,be)|0,H=H+Math.imul(ke,Ue)|0,L=L+Math.imul(pe,qe)|0,U=U+Math.imul(pe,ct)|0,U=U+Math.imul(Fe,qe)|0,H=H+Math.imul(Fe,ct)|0,L=L+Math.imul(ne,xt)|0,U=U+Math.imul(ne,st)|0,U=U+Math.imul(ae,xt)|0,H=H+Math.imul(ae,st)|0,L=L+Math.imul(ie,mt)|0,U=U+Math.imul(ie,qt)|0,U=U+Math.imul(de,mt)|0,H=H+Math.imul(de,qt)|0,L=L+Math.imul(N,Xt)|0,U=U+Math.imul(N,en)|0,U=U+Math.imul(j,Xt)|0,H=H+Math.imul(j,en)|0;var Go=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Go>>>26)|0,Go&=67108863,L=Math.imul(ve,Ce),U=Math.imul(ve,Ee),U=U+Math.imul(W,Ce)|0,H=Math.imul(W,Ee),L=L+Math.imul(J,_e)|0,U=U+Math.imul(J,re)|0,U=U+Math.imul(se,_e)|0,H=H+Math.imul(se,re)|0,L=L+Math.imul(Ge,be)|0,U=U+Math.imul(Ge,Ue)|0,U=U+Math.imul(Xe,be)|0,H=H+Math.imul(Xe,Ue)|0,L=L+Math.imul(Oe,qe)|0,U=U+Math.imul(Oe,ct)|0,U=U+Math.imul(ke,qe)|0,H=H+Math.imul(ke,ct)|0,L=L+Math.imul(pe,xt)|0,U=U+Math.imul(pe,st)|0,U=U+Math.imul(Fe,xt)|0,H=H+Math.imul(Fe,st)|0,L=L+Math.imul(ne,mt)|0,U=U+Math.imul(ne,qt)|0,U=U+Math.imul(ae,mt)|0,H=H+Math.imul(ae,qt)|0,L=L+Math.imul(ie,Xt)|0,U=U+Math.imul(ie,en)|0,U=U+Math.imul(de,Xt)|0,H=H+Math.imul(de,en)|0,L=L+Math.imul(N,Ae)|0,U=U+Math.imul(N,he)|0,U=U+Math.imul(j,Ae)|0,H=H+Math.imul(j,he)|0;var wi=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(wi>>>26)|0,wi&=67108863,L=Math.imul(I,Ce),U=Math.imul(I,Ee),U=U+Math.imul(D,Ce)|0,H=Math.imul(D,Ee),L=L+Math.imul(ve,_e)|0,U=U+Math.imul(ve,re)|0,U=U+Math.imul(W,_e)|0,H=H+Math.imul(W,re)|0,L=L+Math.imul(J,be)|0,U=U+Math.imul(J,Ue)|0,U=U+Math.imul(se,be)|0,H=H+Math.imul(se,Ue)|0,L=L+Math.imul(Ge,qe)|0,U=U+Math.imul(Ge,ct)|0,U=U+Math.imul(Xe,qe)|0,H=H+Math.imul(Xe,ct)|0,L=L+Math.imul(Oe,xt)|0,U=U+Math.imul(Oe,st)|0,U=U+Math.imul(ke,xt)|0,H=H+Math.imul(ke,st)|0,L=L+Math.imul(pe,mt)|0,U=U+Math.imul(pe,qt)|0,U=U+Math.imul(Fe,mt)|0,H=H+Math.imul(Fe,qt)|0,L=L+Math.imul(ne,Xt)|0,U=U+Math.imul(ne,en)|0,U=U+Math.imul(ae,Xt)|0,H=H+Math.imul(ae,en)|0,L=L+Math.imul(ie,Ae)|0,U=U+Math.imul(ie,he)|0,U=U+Math.imul(de,Ae)|0,H=H+Math.imul(de,he)|0,L=L+Math.imul(N,ge)|0,U=U+Math.imul(N,Ne)|0,U=U+Math.imul(j,ge)|0,H=H+Math.imul(j,Ne)|0;var Vt=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,L=Math.imul(ee,Ce),U=Math.imul(ee,Ee),U=U+Math.imul(te,Ce)|0,H=Math.imul(te,Ee),L=L+Math.imul(I,_e)|0,U=U+Math.imul(I,re)|0,U=U+Math.imul(D,_e)|0,H=H+Math.imul(D,re)|0,L=L+Math.imul(ve,be)|0,U=U+Math.imul(ve,Ue)|0,U=U+Math.imul(W,be)|0,H=H+Math.imul(W,Ue)|0,L=L+Math.imul(J,qe)|0,U=U+Math.imul(J,ct)|0,U=U+Math.imul(se,qe)|0,H=H+Math.imul(se,ct)|0,L=L+Math.imul(Ge,xt)|0,U=U+Math.imul(Ge,st)|0,U=U+Math.imul(Xe,xt)|0,H=H+Math.imul(Xe,st)|0,L=L+Math.imul(Oe,mt)|0,U=U+Math.imul(Oe,qt)|0,U=U+Math.imul(ke,mt)|0,H=H+Math.imul(ke,qt)|0,L=L+Math.imul(pe,Xt)|0,U=U+Math.imul(pe,en)|0,U=U+Math.imul(Fe,Xt)|0,H=H+Math.imul(Fe,en)|0,L=L+Math.imul(ne,Ae)|0,U=U+Math.imul(ne,he)|0,U=U+Math.imul(ae,Ae)|0,H=H+Math.imul(ae,he)|0,L=L+Math.imul(ie,ge)|0,U=U+Math.imul(ie,Ne)|0,U=U+Math.imul(de,ge)|0,H=H+Math.imul(de,Ne)|0,L=L+Math.imul(N,Ye)|0,U=U+Math.imul(N,He)|0,U=U+Math.imul(j,Ye)|0,H=H+Math.imul(j,He)|0;var Zo=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Zo>>>26)|0,Zo&=67108863,L=Math.imul(ee,_e),U=Math.imul(ee,re),U=U+Math.imul(te,_e)|0,H=Math.imul(te,re),L=L+Math.imul(I,be)|0,U=U+Math.imul(I,Ue)|0,U=U+Math.imul(D,be)|0,H=H+Math.imul(D,Ue)|0,L=L+Math.imul(ve,qe)|0,U=U+Math.imul(ve,ct)|0,U=U+Math.imul(W,qe)|0,H=H+Math.imul(W,ct)|0,L=L+Math.imul(J,xt)|0,U=U+Math.imul(J,st)|0,U=U+Math.imul(se,xt)|0,H=H+Math.imul(se,st)|0,L=L+Math.imul(Ge,mt)|0,U=U+Math.imul(Ge,qt)|0,U=U+Math.imul(Xe,mt)|0,H=H+Math.imul(Xe,qt)|0,L=L+Math.imul(Oe,Xt)|0,U=U+Math.imul(Oe,en)|0,U=U+Math.imul(ke,Xt)|0,H=H+Math.imul(ke,en)|0,L=L+Math.imul(pe,Ae)|0,U=U+Math.imul(pe,he)|0,U=U+Math.imul(Fe,Ae)|0,H=H+Math.imul(Fe,he)|0,L=L+Math.imul(ne,ge)|0,U=U+Math.imul(ne,Ne)|0,U=U+Math.imul(ae,ge)|0,H=H+Math.imul(ae,Ne)|0,L=L+Math.imul(ie,Ye)|0,U=U+Math.imul(ie,He)|0,U=U+Math.imul(de,Ye)|0,H=H+Math.imul(de,He)|0;var vn=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(vn>>>26)|0,vn&=67108863,L=Math.imul(ee,be),U=Math.imul(ee,Ue),U=U+Math.imul(te,be)|0,H=Math.imul(te,Ue),L=L+Math.imul(I,qe)|0,U=U+Math.imul(I,ct)|0,U=U+Math.imul(D,qe)|0,H=H+Math.imul(D,ct)|0,L=L+Math.imul(ve,xt)|0,U=U+Math.imul(ve,st)|0,U=U+Math.imul(W,xt)|0,H=H+Math.imul(W,st)|0,L=L+Math.imul(J,mt)|0,U=U+Math.imul(J,qt)|0,U=U+Math.imul(se,mt)|0,H=H+Math.imul(se,qt)|0,L=L+Math.imul(Ge,Xt)|0,U=U+Math.imul(Ge,en)|0,U=U+Math.imul(Xe,Xt)|0,H=H+Math.imul(Xe,en)|0,L=L+Math.imul(Oe,Ae)|0,U=U+Math.imul(Oe,he)|0,U=U+Math.imul(ke,Ae)|0,H=H+Math.imul(ke,he)|0,L=L+Math.imul(pe,ge)|0,U=U+Math.imul(pe,Ne)|0,U=U+Math.imul(Fe,ge)|0,H=H+Math.imul(Fe,Ne)|0,L=L+Math.imul(ne,Ye)|0,U=U+Math.imul(ne,He)|0,U=U+Math.imul(ae,Ye)|0,H=H+Math.imul(ae,He)|0;var Wr=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,L=Math.imul(ee,qe),U=Math.imul(ee,ct),U=U+Math.imul(te,qe)|0,H=Math.imul(te,ct),L=L+Math.imul(I,xt)|0,U=U+Math.imul(I,st)|0,U=U+Math.imul(D,xt)|0,H=H+Math.imul(D,st)|0,L=L+Math.imul(ve,mt)|0,U=U+Math.imul(ve,qt)|0,U=U+Math.imul(W,mt)|0,H=H+Math.imul(W,qt)|0,L=L+Math.imul(J,Xt)|0,U=U+Math.imul(J,en)|0,U=U+Math.imul(se,Xt)|0,H=H+Math.imul(se,en)|0,L=L+Math.imul(Ge,Ae)|0,U=U+Math.imul(Ge,he)|0,U=U+Math.imul(Xe,Ae)|0,H=H+Math.imul(Xe,he)|0,L=L+Math.imul(Oe,ge)|0,U=U+Math.imul(Oe,Ne)|0,U=U+Math.imul(ke,ge)|0,H=H+Math.imul(ke,Ne)|0,L=L+Math.imul(pe,Ye)|0,U=U+Math.imul(pe,He)|0,U=U+Math.imul(Fe,Ye)|0,H=H+Math.imul(Fe,He)|0;var xs=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(xs>>>26)|0,xs&=67108863,L=Math.imul(ee,xt),U=Math.imul(ee,st),U=U+Math.imul(te,xt)|0,H=Math.imul(te,st),L=L+Math.imul(I,mt)|0,U=U+Math.imul(I,qt)|0,U=U+Math.imul(D,mt)|0,H=H+Math.imul(D,qt)|0,L=L+Math.imul(ve,Xt)|0,U=U+Math.imul(ve,en)|0,U=U+Math.imul(W,Xt)|0,H=H+Math.imul(W,en)|0,L=L+Math.imul(J,Ae)|0,U=U+Math.imul(J,he)|0,U=U+Math.imul(se,Ae)|0,H=H+Math.imul(se,he)|0,L=L+Math.imul(Ge,ge)|0,U=U+Math.imul(Ge,Ne)|0,U=U+Math.imul(Xe,ge)|0,H=H+Math.imul(Xe,Ne)|0,L=L+Math.imul(Oe,Ye)|0,U=U+Math.imul(Oe,He)|0,U=U+Math.imul(ke,Ye)|0,H=H+Math.imul(ke,He)|0;var Oa=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(Oa>>>26)|0,Oa&=67108863,L=Math.imul(ee,mt),U=Math.imul(ee,qt),U=U+Math.imul(te,mt)|0,H=Math.imul(te,qt),L=L+Math.imul(I,Xt)|0,U=U+Math.imul(I,en)|0,U=U+Math.imul(D,Xt)|0,H=H+Math.imul(D,en)|0,L=L+Math.imul(ve,Ae)|0,U=U+Math.imul(ve,he)|0,U=U+Math.imul(W,Ae)|0,H=H+Math.imul(W,he)|0,L=L+Math.imul(J,ge)|0,U=U+Math.imul(J,Ne)|0,U=U+Math.imul(se,ge)|0,H=H+Math.imul(se,Ne)|0,L=L+Math.imul(Ge,Ye)|0,U=U+Math.imul(Ge,He)|0,U=U+Math.imul(Xe,Ye)|0,H=H+Math.imul(Xe,He)|0;var mc=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(mc>>>26)|0,mc&=67108863,L=Math.imul(ee,Xt),U=Math.imul(ee,en),U=U+Math.imul(te,Xt)|0,H=Math.imul(te,en),L=L+Math.imul(I,Ae)|0,U=U+Math.imul(I,he)|0,U=U+Math.imul(D,Ae)|0,H=H+Math.imul(D,he)|0,L=L+Math.imul(ve,ge)|0,U=U+Math.imul(ve,Ne)|0,U=U+Math.imul(W,ge)|0,H=H+Math.imul(W,Ne)|0,L=L+Math.imul(J,Ye)|0,U=U+Math.imul(J,He)|0,U=U+Math.imul(se,Ye)|0,H=H+Math.imul(se,He)|0;var ar=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(ar>>>26)|0,ar&=67108863,L=Math.imul(ee,Ae),U=Math.imul(ee,he),U=U+Math.imul(te,Ae)|0,H=Math.imul(te,he),L=L+Math.imul(I,ge)|0,U=U+Math.imul(I,Ne)|0,U=U+Math.imul(D,ge)|0,H=H+Math.imul(D,Ne)|0,L=L+Math.imul(ve,Ye)|0,U=U+Math.imul(ve,He)|0,U=U+Math.imul(W,Ye)|0,H=H+Math.imul(W,He)|0;var uo=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(uo>>>26)|0,uo&=67108863,L=Math.imul(ee,ge),U=Math.imul(ee,Ne),U=U+Math.imul(te,ge)|0,H=Math.imul(te,Ne),L=L+Math.imul(I,Ye)|0,U=U+Math.imul(I,He)|0,U=U+Math.imul(D,Ye)|0,H=H+Math.imul(D,He)|0;var vc=(O+L|0)+((U&8191)<<13)|0;O=(H+(U>>>13)|0)+(vc>>>26)|0,vc&=67108863,L=Math.imul(ee,Ye),U=Math.imul(ee,He),U=U+Math.imul(te,Ye)|0,H=Math.imul(te,He);var Sr=(O+L|0)+((U&8191)<<13)|0;return O=(H+(U>>>13)|0)+(Sr>>>26)|0,Sr&=67108863,V[0]=vt,V[1]=ft,V[2]=gt,V[3]=zt,V[4]=Pr,V[5]=Oo,V[6]=Go,V[7]=wi,V[8]=Vt,V[9]=Zo,V[10]=vn,V[11]=Wr,V[12]=xs,V[13]=Oa,V[14]=mc,V[15]=ar,V[16]=uo,V[17]=vc,V[18]=Sr,O!==0&&(V[19]=O,R.length++),R};Math.imul||(v=g);function y(_,B,F){F.negative=B.negative^_.negative,F.length=_.length+B.length;for(var R=0,k=0,T=0;T>>26)|0,k+=V>>>26,V&=67108863}F.words[T]=O,R=V,V=k}return R!==0?F.words[T]=R:F.length--,F._strip()}function w(_,B,F){return y(_,B,F)}s.prototype.mulTo=function(B,F){var R,k=this.length+B.length;return this.length===10&&B.length===10?R=v(this,B,F):k<63?R=g(this,B,F):k<1024?R=y(this,B,F):R=w(this,B,F),R},s.prototype.mul=function(B){var F=new s(null);return F.words=new Array(this.length+B.length),this.mulTo(B,F)},s.prototype.mulf=function(B){var F=new s(null);return F.words=new Array(this.length+B.length),w(this,B,F)},s.prototype.imul=function(B){return this.clone().mulTo(B,this)},s.prototype.imuln=function(B){var F=B<0;F&&(B=-B),r(typeof B=="number"),r(B<67108864);for(var R=0,k=0;k>=26,R+=T/67108864|0,R+=V>>>26,this.words[k]=V&67108863}return R!==0&&(this.words[k]=R,this.length++),F?this.ineg():this},s.prototype.muln=function(B){return this.clone().imuln(B)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(B){var F=m(B);if(F.length===0)return new s(1);for(var R=this,k=0;k=0);var F=B%26,R=(B-F)/26,k=67108863>>>26-F<<26-F,T;if(F!==0){var V=0;for(T=0;T>>26-F}V&&(this.words[T]=V,this.length++)}if(R!==0){for(T=this.length-1;T>=0;T--)this.words[T+R]=this.words[T];for(T=0;T=0);var k;F?k=(F-F%26)/26:k=0;var T=B%26,V=Math.min((B-T)/26,this.length),O=67108863^67108863>>>T<V)for(this.length-=V,U=0;U=0&&(H!==0||U>=k);U--){var le=this.words[U]|0;this.words[U]=H<<26-T|le>>>T,H=le&O}return L&&H!==0&&(L.words[L.length++]=H),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(B,F,R){return r(this.negative===0),this.iushrn(B,F,R)},s.prototype.shln=function(B){return this.clone().ishln(B)},s.prototype.ushln=function(B){return this.clone().iushln(B)},s.prototype.shrn=function(B){return this.clone().ishrn(B)},s.prototype.ushrn=function(B){return this.clone().iushrn(B)},s.prototype.testn=function(B){r(typeof B=="number"&&B>=0);var F=B%26,R=(B-F)/26,k=1<=0);var F=B%26,R=(B-F)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=R)return this;if(F!==0&&R++,this.length=Math.min(R,this.length),F!==0){var k=67108863^67108863>>>F<=67108864;F++)this.words[F]-=67108864,F===this.length-1?this.words[F+1]=1:this.words[F+1]++;return this.length=Math.max(this.length,F+1),this},s.prototype.isubn=function(B){if(r(typeof B=="number"),r(B<67108864),B<0)return this.iaddn(-B);if(this.negative!==0)return this.negative=0,this.iaddn(B),this.negative=1,this;if(this.words[0]-=B,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var F=0;F>26)-(L/67108864|0),this.words[T+R]=V&67108863}for(;T>26,this.words[T+R]=V&67108863;if(O===0)return this._strip();for(r(O===-1),O=0,T=0;T>26,this.words[T]=V&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(B,F){var R=this.length-B.length,k=this.clone(),T=B,V=T.words[T.length-1]|0,O=this._countBits(V);R=26-O,R!==0&&(T=T.ushln(R),k.iushln(R),V=T.words[T.length-1]|0);var L=k.length-T.length,U;if(F!=="mod"){U=new s(null),U.length=L+1,U.words=new Array(U.length);for(var H=0;H=0;N--){var j=(k.words[T.length+N]|0)*67108864+(k.words[T.length+N-1]|0);for(j=Math.min(j/V|0,67108863),k._ishlnsubmul(T,j,N);k.negative!==0;)j--,k.negative=0,k._ishlnsubmul(T,1,N),k.isZero()||(k.negative^=1);U&&(U.words[N]=j)}return U&&U._strip(),k._strip(),F!=="div"&&R!==0&&k.iushrn(R),{div:U||null,mod:k}},s.prototype.divmod=function(B,F,R){if(r(!B.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var k,T,V;return this.negative!==0&&B.negative===0?(V=this.neg().divmod(B,F),F!=="mod"&&(k=V.div.neg()),F!=="div"&&(T=V.mod.neg(),R&&T.negative!==0&&T.iadd(B)),{div:k,mod:T}):this.negative===0&&B.negative!==0?(V=this.divmod(B.neg(),F),F!=="mod"&&(k=V.div.neg()),{div:k,mod:V.mod}):this.negative&B.negative?(V=this.neg().divmod(B.neg(),F),F!=="div"&&(T=V.mod.neg(),R&&T.negative!==0&&T.isub(B)),{div:V.div,mod:T}):B.length>this.length||this.cmp(B)<0?{div:new s(0),mod:this}:B.length===1?F==="div"?{div:this.divn(B.words[0]),mod:null}:F==="mod"?{div:null,mod:new s(this.modrn(B.words[0]))}:{div:this.divn(B.words[0]),mod:new s(this.modrn(B.words[0]))}:this._wordDiv(B,F)},s.prototype.div=function(B){return this.divmod(B,"div",!1).div},s.prototype.mod=function(B){return this.divmod(B,"mod",!1).mod},s.prototype.umod=function(B){return this.divmod(B,"mod",!0).mod},s.prototype.divRound=function(B){var F=this.divmod(B);if(F.mod.isZero())return F.div;var R=F.div.negative!==0?F.mod.isub(B):F.mod,k=B.ushrn(1),T=B.andln(1),V=R.cmp(k);return V<0||T===1&&V===0?F.div:F.div.negative!==0?F.div.isubn(1):F.div.iaddn(1)},s.prototype.modrn=function(B){var F=B<0;F&&(B=-B),r(B<=67108863);for(var R=(1<<26)%B,k=0,T=this.length-1;T>=0;T--)k=(R*k+(this.words[T]|0))%B;return F?-k:k},s.prototype.modn=function(B){return this.modrn(B)},s.prototype.idivn=function(B){var F=B<0;F&&(B=-B),r(B<=67108863);for(var R=0,k=this.length-1;k>=0;k--){var T=(this.words[k]|0)+R*67108864;this.words[k]=T/B|0,R=T%B}return this._strip(),F?this.ineg():this},s.prototype.divn=function(B){return this.clone().idivn(B)},s.prototype.egcd=function(B){r(B.negative===0),r(!B.isZero());var F=this,R=B.clone();F.negative!==0?F=F.umod(B):F=F.clone();for(var k=new s(1),T=new s(0),V=new s(0),O=new s(1),L=0;F.isEven()&&R.isEven();)F.iushrn(1),R.iushrn(1),++L;for(var U=R.clone(),H=F.clone();!F.isZero();){for(var le=0,N=1;!(F.words[0]&N)&&le<26;++le,N<<=1);if(le>0)for(F.iushrn(le);le-- >0;)(k.isOdd()||T.isOdd())&&(k.iadd(U),T.isub(H)),k.iushrn(1),T.iushrn(1);for(var j=0,oe=1;!(R.words[0]&oe)&&j<26;++j,oe<<=1);if(j>0)for(R.iushrn(j);j-- >0;)(V.isOdd()||O.isOdd())&&(V.iadd(U),O.isub(H)),V.iushrn(1),O.iushrn(1);F.cmp(R)>=0?(F.isub(R),k.isub(V),T.isub(O)):(R.isub(F),V.isub(k),O.isub(T))}return{a:V,b:O,gcd:R.iushln(L)}},s.prototype._invmp=function(B){r(B.negative===0),r(!B.isZero());var F=this,R=B.clone();F.negative!==0?F=F.umod(B):F=F.clone();for(var k=new s(1),T=new s(0),V=R.clone();F.cmpn(1)>0&&R.cmpn(1)>0;){for(var O=0,L=1;!(F.words[0]&L)&&O<26;++O,L<<=1);if(O>0)for(F.iushrn(O);O-- >0;)k.isOdd()&&k.iadd(V),k.iushrn(1);for(var U=0,H=1;!(R.words[0]&H)&&U<26;++U,H<<=1);if(U>0)for(R.iushrn(U);U-- >0;)T.isOdd()&&T.iadd(V),T.iushrn(1);F.cmp(R)>=0?(F.isub(R),k.isub(T)):(R.isub(F),T.isub(k))}var le;return F.cmpn(1)===0?le=k:le=T,le.cmpn(0)<0&&le.iadd(B),le},s.prototype.gcd=function(B){if(this.isZero())return B.abs();if(B.isZero())return this.abs();var F=this.clone(),R=B.clone();F.negative=0,R.negative=0;for(var k=0;F.isEven()&&R.isEven();k++)F.iushrn(1),R.iushrn(1);do{for(;F.isEven();)F.iushrn(1);for(;R.isEven();)R.iushrn(1);var T=F.cmp(R);if(T<0){var V=F;F=R,R=V}else if(T===0||R.cmpn(1)===0)break;F.isub(R)}while(!0);return R.iushln(k)},s.prototype.invm=function(B){return this.egcd(B).a.umod(B)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(B){return this.words[0]&B},s.prototype.bincn=function(B){r(typeof B=="number");var F=B%26,R=(B-F)/26,k=1<>>26,O&=67108863,this.words[V]=O}return T!==0&&(this.words[V]=T,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(B){var F=B<0;if(this.negative!==0&&!F)return-1;if(this.negative===0&&F)return 1;this._strip();var R;if(this.length>1)R=1;else{F&&(B=-B),r(B<=67108863,"Number is too big");var k=this.words[0]|0;R=k===B?0:kB.length)return 1;if(this.length=0;R--){var k=this.words[R]|0,T=B.words[R]|0;if(k!==T){kT&&(F=1);break}}return F},s.prototype.gtn=function(B){return this.cmpn(B)===1},s.prototype.gt=function(B){return this.cmp(B)===1},s.prototype.gten=function(B){return this.cmpn(B)>=0},s.prototype.gte=function(B){return this.cmp(B)>=0},s.prototype.ltn=function(B){return this.cmpn(B)===-1},s.prototype.lt=function(B){return this.cmp(B)===-1},s.prototype.lten=function(B){return this.cmpn(B)<=0},s.prototype.lte=function(B){return this.cmp(B)<=0},s.prototype.eqn=function(B){return this.cmpn(B)===0},s.prototype.eq=function(B){return this.cmp(B)===0},s.red=function(B){return new Z(B)},s.prototype.toRed=function(B){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),B.convertTo(this)._forceRed(B)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(B){return this.red=B,this},s.prototype.forceRed=function(B){return r(!this.red,"Already a number in reduction context"),this._forceRed(B)},s.prototype.redAdd=function(B){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,B)},s.prototype.redIAdd=function(B){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,B)},s.prototype.redSub=function(B){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,B)},s.prototype.redISub=function(B){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,B)},s.prototype.redShl=function(B){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,B)},s.prototype.redMul=function(B){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,B),this.red.mul(this,B)},s.prototype.redIMul=function(B){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,B),this.red.imul(this,B)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(B){return r(this.red&&!B.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,B)};var C={k256:null,p224:null,p192:null,p25519:null};function b(_,B){this.name=_,this.p=new s(B,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}b.prototype._tmp=function(){var B=new s(null);return B.words=new Array(Math.ceil(this.n/13)),B},b.prototype.ireduce=function(B){var F=B,R;do this.split(F,this.tmp),F=this.imulK(F),F=F.iadd(this.tmp),R=F.bitLength();while(R>this.n);var k=R0?F.isub(this.p):F.strip!==void 0?F.strip():F._strip(),F},b.prototype.split=function(B,F){B.iushrn(this.n,0,F)},b.prototype.imulK=function(B){return B.imul(this.k)};function E(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(E,b),E.prototype.split=function(B,F){for(var R=4194303,k=Math.min(B.length,9),T=0;T>>22,V=O}V>>>=22,B.words[T-10]=V,V===0&&B.length>10?B.length-=10:B.length-=9},E.prototype.imulK=function(B){B.words[B.length]=0,B.words[B.length+1]=0,B.length+=2;for(var F=0,R=0;R>>=26,B.words[R]=T,F=k}return F!==0&&(B.words[B.length++]=F),B},s._prime=function(B){if(C[B])return C[B];var F;if(B==="k256")F=new E;else if(B==="p224")F=new x;else if(B==="p192")F=new S;else if(B==="p25519")F=new M;else throw new Error("Unknown prime "+B);return C[B]=F,F};function Z(_){if(typeof _=="string"){var B=s._prime(_);this.m=B.p,this.prime=B}else r(_.gtn(1),"modulus must be greater than 1"),this.m=_,this.prime=null}Z.prototype._verify1=function(B){r(B.negative===0,"red works only with positives"),r(B.red,"red works only with red numbers")},Z.prototype._verify2=function(B,F){r((B.negative|F.negative)===0,"red works only with positives"),r(B.red&&B.red===F.red,"red works only with red numbers")},Z.prototype.imod=function(B){return this.prime?this.prime.ireduce(B)._forceRed(this):(c(B,B.umod(this.m)._forceRed(this)),B)},Z.prototype.neg=function(B){return B.isZero()?B.clone():this.m.sub(B)._forceRed(this)},Z.prototype.add=function(B,F){this._verify2(B,F);var R=B.add(F);return R.cmp(this.m)>=0&&R.isub(this.m),R._forceRed(this)},Z.prototype.iadd=function(B,F){this._verify2(B,F);var R=B.iadd(F);return R.cmp(this.m)>=0&&R.isub(this.m),R},Z.prototype.sub=function(B,F){this._verify2(B,F);var R=B.sub(F);return R.cmpn(0)<0&&R.iadd(this.m),R._forceRed(this)},Z.prototype.isub=function(B,F){this._verify2(B,F);var R=B.isub(F);return R.cmpn(0)<0&&R.iadd(this.m),R},Z.prototype.shl=function(B,F){return this._verify1(B),this.imod(B.ushln(F))},Z.prototype.imul=function(B,F){return this._verify2(B,F),this.imod(B.imul(F))},Z.prototype.mul=function(B,F){return this._verify2(B,F),this.imod(B.mul(F))},Z.prototype.isqr=function(B){return this.imul(B,B.clone())},Z.prototype.sqr=function(B){return this.mul(B,B)},Z.prototype.sqrt=function(B){if(B.isZero())return B.clone();var F=this.m.andln(3);if(r(F%2===1),F===3){var R=this.m.add(new s(1)).iushrn(2);return this.pow(B,R)}for(var k=this.m.subn(1),T=0;!k.isZero()&&k.andln(1)===0;)T++,k.iushrn(1);r(!k.isZero());var V=new s(1).toRed(this),O=V.redNeg(),L=this.m.subn(1).iushrn(1),U=this.m.bitLength();for(U=new s(2*U*U).toRed(this);this.pow(U,L).cmp(O)!==0;)U.redIAdd(O);for(var H=this.pow(U,k),le=this.pow(B,k.addn(1).iushrn(1)),N=this.pow(B,k),j=T;N.cmp(V)!==0;){for(var oe=N,ie=0;oe.cmp(V)!==0;ie++)oe=oe.redSqr();r(ie=0;T--){for(var H=F.words[T],le=U-1;le>=0;le--){var N=H>>le&1;if(V!==k[0]&&(V=this.sqr(V)),N===0&&O===0){L=0;continue}O<<=1,O|=N,L++,!(L!==R&&(T!==0||le!==0))&&(V=this.mul(V,k[O]),L=0,O=0)}U=26}return V},Z.prototype.convertTo=function(B){var F=B.umod(this.m);return F===B?F.clone():F},Z.prototype.convertFrom=function(B){var F=B.clone();return F.red=null,F},s.mont=function(B){return new K(B)};function K(_){Z.call(this,_),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(K,Z),K.prototype.convertTo=function(B){return this.imod(B.ushln(this.shift))},K.prototype.convertFrom=function(B){var F=this.imod(B.mul(this.rinv));return F.red=null,F},K.prototype.imul=function(B,F){if(B.isZero()||F.isZero())return B.words[0]=0,B.length=1,B;var R=B.imul(F),k=R.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),T=R.isub(k).iushrn(this.shift),V=T;return T.cmp(this.m)>=0?V=T.isub(this.m):T.cmpn(0)<0&&(V=T.iadd(this.m)),V._forceRed(this)},K.prototype.mul=function(B,F){if(B.isZero()||F.isZero())return new s(0)._forceRed(this);var R=B.mul(F),k=R.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),T=R.isub(k).iushrn(this.shift),V=T;return T.cmp(this.m)>=0?V=T.isub(this.m):T.cmpn(0)<0&&(V=T.iadd(this.m)),V._forceRed(this)},K.prototype.invm=function(B){var F=this.imod(B._invmp(this.m).mul(this.r2));return F._forceRed(this)}})(n,td)})(JU);var Zz=JU.exports;const pt=bu(Zz),Jz="logger/5.7.0";let fR=!1,dR=!1;const Dy={debug:1,default:2,info:2,warning:3,error:4,off:5};let hR=Dy.default,Jb=null;function Hz(){try{const n=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{n.push(e)}}),n.length)throw new Error("missing "+n.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(n){return n.message}return null}const pR=Hz();var Y1;(function(n){n.DEBUG="DEBUG",n.INFO="INFO",n.WARNING="WARNING",n.ERROR="ERROR",n.OFF="OFF"})(Y1||(Y1={}));var Io;(function(n){n.UNKNOWN_ERROR="UNKNOWN_ERROR",n.NOT_IMPLEMENTED="NOT_IMPLEMENTED",n.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",n.NETWORK_ERROR="NETWORK_ERROR",n.SERVER_ERROR="SERVER_ERROR",n.TIMEOUT="TIMEOUT",n.BUFFER_OVERRUN="BUFFER_OVERRUN",n.NUMERIC_FAULT="NUMERIC_FAULT",n.MISSING_NEW="MISSING_NEW",n.INVALID_ARGUMENT="INVALID_ARGUMENT",n.MISSING_ARGUMENT="MISSING_ARGUMENT",n.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",n.CALL_EXCEPTION="CALL_EXCEPTION",n.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",n.NONCE_EXPIRED="NONCE_EXPIRED",n.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",n.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",n.TRANSACTION_REPLACED="TRANSACTION_REPLACED",n.ACTION_REJECTED="ACTION_REJECTED"})(Io||(Io={}));const gR="0123456789abcdef";let ce=class Ar{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();Dy[r]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(hR>Dy[r])&&console.log.apply(console,t)}debug(...e){this._log(Ar.levels.DEBUG,e)}info(...e){this._log(Ar.levels.INFO,e)}warn(...e){this._log(Ar.levels.WARNING,e)}makeError(e,t,r){if(dR)return this.makeError("censored error",t,{});t||(t=Ar.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach(l=>{const A=r[l];try{if(A instanceof Uint8Array){let c="";for(let u=0;u>4],c+=gR[A[u]&15];i.push(l+"=Uint8Array(0x"+c+")")}else i.push(l+"="+JSON.stringify(A))}catch{i.push(l+"="+JSON.stringify(r[l].toString()))}}),i.push(`code=${t}`),i.push(`version=${this.version}`);const s=e;let o="";switch(t){case Io.NUMERIC_FAULT:{o="NUMERIC_FAULT";const l=e;switch(l){case"overflow":case"underflow":case"division-by-zero":o+="-"+l;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Io.CALL_EXCEPTION:case Io.INSUFFICIENT_FUNDS:case Io.MISSING_NEW:case Io.NONCE_EXPIRED:case Io.REPLACEMENT_UNDERPRICED:case Io.TRANSACTION_REPLACED:case Io.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(e+=" ("+i.join(", ")+")");const a=new Error(e);return a.reason=s,a.code=t,Object.keys(r).forEach(function(l){a[l]=r[l]}),a}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(e,t,r){return this.throwError(e,Ar.errors.INVALID_ARGUMENT,{argument:t,value:r})}assert(e,t,r,i){e||this.throwError(t,r,i)}assertArgument(e,t,r,i){e||this.throwArgumentError(t,r,i)}checkNormalize(e){pR&&this.throwError("platform missing String.prototype.normalize",Ar.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:pR})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,Ar.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,Ar.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r?r=": "+r:r="",et&&this.throwError("too many arguments"+r,Ar.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",Ar.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",Ar.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Ar.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Jb||(Jb=new Ar(Jz)),Jb}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",Ar.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),fR){if(!e)return;this.globalLogger().throwError("error censorship permanent",Ar.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}dR=!!e,fR=!!t}static setLogLevel(e){const t=Dy[e.toLowerCase()];if(t==null){Ar.globalLogger().warn("invalid log level - "+e);return}hR=t}static from(e){return new Ar(e)}};ce.errors=Io;ce.levels=Y1;const zz="bytes/5.7.0",Tn=new ce(zz);function D3(n){return!!n.toHexString}function _d(n){return n.slice||(n.slice=function(){const e=Array.prototype.slice.call(arguments);return _d(new Uint8Array(Array.prototype.slice.apply(n,e)))}),n}function HU(n){return bt(n)&&!(n.length%2)||vC(n)}function mR(n){return typeof n=="number"&&n==n&&n%1===0}function vC(n){if(n==null)return!1;if(n.constructor===Uint8Array)return!0;if(typeof n=="string"||!mR(n.length)||n.length<0)return!1;for(let e=0;e=256)return!1}return!0}function lt(n,e){if(e||(e={}),typeof n=="number"){Tn.checkSafeUint53(n,"invalid arrayify value");const t=[];for(;n;)t.unshift(n&255),n=parseInt(String(n/256));return t.length===0&&t.push(0),_d(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),D3(n)&&(n=n.toHexString()),bt(n)){let t=n.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":Tn.throwArgumentError("hex data is odd-length","value",n));const r=[];for(let i=0;ilt(i)),t=e.reduce((i,s)=>i+s.length,0),r=new Uint8Array(t);return e.reduce((i,s)=>(r.set(s,i),i+s.length),0),_d(r)}function $d(n){let e=lt(n);if(e.length===0)return e;let t=0;for(;te&&Tn.throwArgumentError("value out of range","value",arguments[0]);const t=new Uint8Array(e);return t.set(n,e-n.length),_d(t)}function bt(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||e&&n.length!==2+2*e)}const Hb="0123456789abcdef";function $e(n,e){if(e||(e={}),typeof n=="number"){Tn.checkSafeUint53(n,"invalid hexlify value");let t="";for(;n;)t=Hb[n&15]+t,n=Math.floor(n/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof n=="bigint")return n=n.toString(16),n.length%2?"0x0"+n:"0x"+n;if(e.allowMissingPrefix&&typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),D3(n))return n.toHexString();if(bt(n))return n.length%2&&(e.hexPad==="left"?n="0x0"+n.substring(2):e.hexPad==="right"?n+="0":Tn.throwArgumentError("hex data is odd-length","value",n)),n.toLowerCase();if(vC(n)){let t="0x";for(let r=0;r>4]+Hb[i&15]}return t}return Tn.throwArgumentError("invalid hexlify value","value",n)}function au(n){if(typeof n!="string")n=$e(n);else if(!bt(n)||n.length%2)return null;return(n.length-2)/2}function Jr(n,e,t){return typeof n!="string"?n=$e(n):(!bt(n)||n.length%2)&&Tn.throwArgumentError("invalid hexData","value",n),e=2+2*e,t!=null?"0x"+n.substring(e,2+2*t):"0x"+n.substring(e)}function Ui(n){let e="0x";return n.forEach(t=>{e+=$e(t).substring(2)}),e}function yC(n){const e=Xz($e(n,{hexPad:"left"}));return e==="0x"?"0x0":e}function Xz(n){typeof n!="string"&&(n=$e(n)),bt(n)||Tn.throwArgumentError("invalid hex string","value",n),n=n.substring(2);let e=0;for(;e2*e+2&&Tn.throwArgumentError("value out of range","value",arguments[1]);n.length<2*e+2;)n="0x0"+n.substring(2);return n}function BC(n){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(HU(n)){let t=lt(n);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=$e(t.slice(0,32)),e.s=$e(t.slice(32,64))):t.length===65?(e.r=$e(t.slice(0,32)),e.s=$e(t.slice(32,64)),e.v=t[64]):Tn.throwArgumentError("invalid signature string","signature",n),e.v<27&&(e.v===0||e.v===1?e.v+=27:Tn.throwArgumentError("signature invalid v byte","signature",n)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=$e(t.slice(32,64))}else{if(e.r=n.r,e.s=n.s,e.v=n.v,e.recoveryParam=n.recoveryParam,e._vs=n._vs,e._vs!=null){const i=Yz(lt(e._vs),32);e._vs=$e(i);const s=i[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&Tn.throwArgumentError("signature recoveryParam mismatch _vs","signature",n),i[0]&=127;const o=$e(i);e.s==null?e.s=o:e.s!==o&&Tn.throwArgumentError("signature v mismatch _vs","signature",n)}if(e.recoveryParam==null)e.v==null?Tn.throwArgumentError("signature missing v and recoveryParam","signature",n):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const i=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==i&&Tn.throwArgumentError("signature recoveryParam mismatch v","signature",n)}e.r==null||!bt(e.r)?Tn.throwArgumentError("signature missing or invalid r","signature",n):e.r=Ln(e.r,32),e.s==null||!bt(e.s)?Tn.throwArgumentError("signature missing or invalid s","signature",n):e.s=Ln(e.s,32);const t=lt(e.s);t[0]>=128&&Tn.throwArgumentError("signature s out of range","signature",n),e.recoveryParam&&(t[0]|=128);const r=$e(t);e._vs&&(bt(e._vs)||Tn.throwArgumentError("signature invalid _vs","signature",n),e._vs=Ln(e._vs,32)),e._vs==null?e._vs=r:e._vs!==r&&Tn.throwArgumentError("signature _vs mismatch v and s","signature",n)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}const Kz="bignumber/5.7.0";var EB=pt.BN;const sl=new ce(Kz),zb={},vR=9007199254740991;let yR=!1;class De{constructor(e,t){e!==zb&&sl.throwError("cannot call constructor directly; use BigNumber.from",ce.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Ci(Ft(this).fromTwos(e))}toTwos(e){return Ci(Ft(this).toTwos(e))}abs(){return this._hex[0]==="-"?De.from(this._hex.substring(1)):this}add(e){return Ci(Ft(this).add(Ft(e)))}sub(e){return Ci(Ft(this).sub(Ft(e)))}div(e){return De.from(e).isZero()&&Fs("division-by-zero","div"),Ci(Ft(this).div(Ft(e)))}mul(e){return Ci(Ft(this).mul(Ft(e)))}mod(e){const t=Ft(e);return t.isNeg()&&Fs("division-by-zero","mod"),Ci(Ft(this).umod(t))}pow(e){const t=Ft(e);return t.isNeg()&&Fs("negative-power","pow"),Ci(Ft(this).pow(t))}and(e){const t=Ft(e);return(this.isNegative()||t.isNeg())&&Fs("unbound-bitwise-result","and"),Ci(Ft(this).and(t))}or(e){const t=Ft(e);return(this.isNegative()||t.isNeg())&&Fs("unbound-bitwise-result","or"),Ci(Ft(this).or(t))}xor(e){const t=Ft(e);return(this.isNegative()||t.isNeg())&&Fs("unbound-bitwise-result","xor"),Ci(Ft(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&Fs("negative-width","mask"),Ci(Ft(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Fs("negative-width","shl"),Ci(Ft(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Fs("negative-width","shr"),Ci(Ft(this).shrn(e))}eq(e){return Ft(this).eq(Ft(e))}lt(e){return Ft(this).lt(Ft(e))}lte(e){return Ft(this).lte(Ft(e))}gt(e){return Ft(this).gt(Ft(e))}gte(e){return Ft(this).gte(Ft(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Ft(this).isZero()}toNumber(){try{return Ft(this).toNumber()}catch{Fs("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return sl.throwError("this platform does not support BigInt",ce.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?yR||(yR=!0,sl.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?sl.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",ce.errors.UNEXPECTED_ARGUMENT,{}):sl.throwError("BigNumber.toString does not accept parameters",ce.errors.UNEXPECTED_ARGUMENT,{})),Ft(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof De)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new De(zb,Kg(e)):e.match(/^-?[0-9]+$/)?new De(zb,Kg(new EB(e))):sl.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Fs("underflow","BigNumber.from",e),(e>=vR||e<=-vR)&&Fs("overflow","BigNumber.from",e),De.from(String(e));const t=e;if(typeof t=="bigint")return De.from(t.toString());if(vC(t))return De.from($e(t));if(t)if(t.toHexString){const r=t.toHexString();if(typeof r=="string")return De.from(r)}else{let r=t._hex;if(r==null&&t.type==="BigNumber"&&(r=t.hex),typeof r=="string"&&(bt(r)||r[0]==="-"&&bt(r.substring(1))))return De.from(r)}return sl.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function Kg(n){if(typeof n!="string")return Kg(n.toString(16));if(n[0]==="-")return n=n.substring(1),n[0]==="-"&&sl.throwArgumentError("invalid hex","value",n),n=Kg(n),n==="0x00"?n:"-"+n;if(n.substring(0,2)!=="0x"&&(n="0x"+n),n==="0x")return"0x00";for(n.length%2&&(n="0x0"+n.substring(2));n.length>4&&n.substring(0,4)==="0x00";)n="0x"+n.substring(4);return n}function Ci(n){return De.from(Kg(n))}function Ft(n){const e=De.from(n).toHexString();return e[0]==="-"?new EB("-"+e.substring(3),16):new EB(e.substring(2),16)}function Fs(n,e,t){const r={fault:n,operation:e};return t!=null&&(r.value=t),sl.throwError(n,ce.errors.NUMERIC_FAULT,r)}function jz(n){return new EB(n,36).toString(16)}const $z="properties/5.7.0";var qz=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const UB=new ce($z);function Ie(n,e,t){Object.defineProperty(n,e,{enumerable:!0,value:t,writable:!1})}function is(n,e){for(let t=0;t<32;t++){if(n[e])return n[e];if(!n.prototype||typeof n.prototype!="object")break;n=Object.getPrototypeOf(n.prototype).constructor}return null}function jn(n){return qz(this,void 0,void 0,function*(){const e=Object.keys(n).map(r=>{const i=n[r];return Promise.resolve(i).then(s=>({key:r,value:s}))});return(yield Promise.all(e)).reduce((r,i)=>(r[i.key]=i.value,r),{})})}function e9(n,e){(!n||typeof n!="object")&&UB.throwArgumentError("invalid object","object",n),Object.keys(n).forEach(t=>{e[t]||UB.throwArgumentError("invalid object key - "+t,"transaction:"+t,n)})}function xn(n){const e={};for(const t in n)e[t]=n[t];return e}const t9={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function k3(n){if(n==null||t9[typeof n])return!0;if(Array.isArray(n)||typeof n=="object"){if(!Object.isFrozen(n))return!1;const e=Object.keys(n);for(let t=0;tas(e)));if(typeof n=="object"){const e={};for(const t in n){const r=n[t];r!==void 0&&Ie(e,t,as(r))}return e}return UB.throwArgumentError(`Cannot deepCopy ${typeof n}`,"object",n)}function as(n){return n9(n)}class $m{constructor(e){for(const t in e)this[t]=as(e[t])}}const r9="abstract-provider/5.7.0";var i9=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const s9=new ce(r9);class o9 extends $m{static isForkEvent(e){return!!(e&&e._isForkEvent)}}class qm{constructor(){s9.checkAbstract(new.target,qm),Ie(this,"_isProvider",!0)}getFeeData(){return i9(this,void 0,void 0,function*(){const{block:e,gasPrice:t}=yield jn({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(o=>null)});let r=null,i=null,s=null;return e&&e.baseFeePerGas&&(r=e.baseFeePerGas,s=De.from("1500000000"),i=e.baseFeePerGas.mul(2).add(s)),{lastBaseFeePerGas:r,maxFeePerGas:i,maxPriorityFeePerGas:s,gasPrice:t}})}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}static isProvider(e){return!!(e&&e._isProvider)}}const a9="networks/5.7.1",BR=new ce(a9);function l9(n){return n&&typeof n.renetwork=="function"}function ul(n){const e=function(t,r){r==null&&(r={});const i=[];if(t.InfuraProvider&&r.infura!=="-")try{i.push(new t.InfuraProvider(n,r.infura))}catch{}if(t.EtherscanProvider&&r.etherscan!=="-")try{i.push(new t.EtherscanProvider(n,r.etherscan))}catch{}if(t.AlchemyProvider&&r.alchemy!=="-")try{i.push(new t.AlchemyProvider(n,r.alchemy))}catch{}if(t.PocketProvider&&r.pocket!=="-"){const s=["goerli","ropsten","rinkeby","sepolia"];try{const o=new t.PocketProvider(n,r.pocket);o.network&&s.indexOf(o.network.name)===-1&&i.push(o)}catch{}}if(t.CloudflareProvider&&r.cloudflare!=="-")try{i.push(new t.CloudflareProvider(n))}catch{}if(t.AnkrProvider&&r.ankr!=="-")try{const s=["ropsten"],o=new t.AnkrProvider(n,r.ankr);o.network&&s.indexOf(o.network.name)===-1&&i.push(o)}catch{}if(i.length===0)return null;if(t.FallbackProvider){let s=1;return r.quorum!=null?s=r.quorum:n==="homestead"&&(s=2),new t.FallbackProvider(i,s)}return i[0]};return e.renetwork=function(t){return ul(t)},e}function SB(n,e){const t=function(r,i){return r.JsonRpcProvider?new r.JsonRpcProvider(n,e):null};return t.renetwork=function(r){return SB(n,r)},t}const wR={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:ul("homestead")},CR={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:ul("ropsten")},bR={chainId:63,name:"classicMordor",_defaultProvider:SB("https://www.ethercluster.com/mordor","classicMordor")},T0={unspecified:{chainId:0,name:"unspecified"},homestead:wR,mainnet:wR,morden:{chainId:2,name:"morden"},ropsten:CR,testnet:CR,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:ul("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ul("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:ul("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:ul("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:SB("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:bR,classicTestnet:bR,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:SB("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:ul("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:ul("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function V3(n){if(n==null)return null;if(typeof n=="number"){for(const r in T0){const i=T0[r];if(i.chainId===n)return{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress||null,_defaultProvider:i._defaultProvider||null}}return{chainId:n,name:"unknown"}}if(typeof n=="string"){const r=T0[n];return r==null?null:{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress,_defaultProvider:r._defaultProvider||null}}const e=T0[n.name];if(!e)return typeof n.chainId!="number"&&BR.throwArgumentError("invalid network chainId","network",n),n;n.chainId!==0&&n.chainId!==e.chainId&&BR.throwArgumentError("network chainId mismatch","network",n);let t=n._defaultProvider||null;return t==null&&e._defaultProvider&&(l9(e._defaultProvider)?t=e._defaultProvider.renetwork(n):t=e._defaultProvider),{name:n.name,chainId:e.chainId,ensAddress:n.ensAddress||e.ensAddress||null,_defaultProvider:t}}function L3(n){n=atob(n);const e=[];for(let t=0;t0;)r.push(o%this.base),o=o/this.base|0}let i="";for(let s=0;t[s]===0&&s=0;--s)i+=this.alphabet[r[s]];return i}decode(e){if(typeof e!="string")throw new TypeError("Expected String");let t=[];if(e.length===0)return new Uint8Array(t);t.push(0);for(let r=0;r>=8;for(;s>0;)t.push(s&255),s>>=8}for(let r=0;e[r]===this._leader&&r>5,this.byteCount=this.blockCount<<2,this.outputBlocks=oe>>5,this.extraBytes=(oe&31)>>3;for(var ie=0;ie<50;++ie)this.s[ie]=0}U.prototype.update=function(N){if(this.finalized)throw new Error(t);var j,oe=typeof N;if(oe!=="string"){if(oe==="object"){if(N===null)throw new Error(e);if(l&&N.constructor===ArrayBuffer)N=new Uint8Array(N);else if(!Array.isArray(N)&&(!l||!ArrayBuffer.isView(N)))throw new Error(e)}else throw new Error(e);j=!0}for(var ie=this.blocks,de=this.byteCount,X=N.length,ne=this.blockCount,ae=0,Be=this.s,pe,Fe;ae>2]|=N[ae]<>2]|=Fe<>2]|=(192|Fe>>6)<>2]|=(128|Fe&63)<=57344?(ie[pe>>2]|=(224|Fe>>12)<>2]|=(128|Fe>>6&63)<>2]|=(128|Fe&63)<>2]|=(240|Fe>>18)<>2]|=(128|Fe>>12&63)<>2]|=(128|Fe>>6&63)<>2]|=(128|Fe&63)<=de){for(this.start=pe-de,this.block=ie[ne],pe=0;pe>8,oe=N&255;oe>0;)de.unshift(oe),N=N>>8,oe=N&255,++ie;return j?de.push(ie):de.unshift(ie),this.update(de),de.length},U.prototype.encodeString=function(N){var j,oe=typeof N;if(oe!=="string"){if(oe==="object"){if(N===null)throw new Error(e);if(l&&N.constructor===ArrayBuffer)N=new Uint8Array(N);else if(!Array.isArray(N)&&(!l||!ArrayBuffer.isView(N)))throw new Error(e)}else throw new Error(e);j=!0}var ie=0,de=N.length;if(j)ie=de;else for(var X=0;X=57344?ie+=3:(ne=65536+((ne&1023)<<10|N.charCodeAt(++X)&1023),ie+=4)}return ie+=this.encode(ie*8),this.update(N),ie},U.prototype.bytepad=function(N,j){for(var oe=this.encode(j),ie=0;ie>2]|=this.padding[j&3],this.lastByteIndex===this.byteCount)for(N[0]=N[oe],j=1;j>4&15]+A[ae&15]+A[ae>>12&15]+A[ae>>8&15]+A[ae>>20&15]+A[ae>>16&15]+A[ae>>28&15]+A[ae>>24&15];X%N===0&&(Ae(j),de=0)}return ie&&(ae=j[de],ne+=A[ae>>4&15]+A[ae&15],ie>1&&(ne+=A[ae>>12&15]+A[ae>>8&15]),ie>2&&(ne+=A[ae>>20&15]+A[ae>>16&15])),ne},U.prototype.arrayBuffer=function(){this.finalize();var N=this.blockCount,j=this.s,oe=this.outputBlocks,ie=this.extraBytes,de=0,X=0,ne=this.outputBits>>3,ae;ie?ae=new ArrayBuffer(oe+1<<2):ae=new ArrayBuffer(ne);for(var Be=new Uint32Array(ae);X>8&255,ne[ae+2]=Be>>16&255,ne[ae+3]=Be>>24&255;X%N===0&&Ae(j)}return ie&&(ae=X<<2,Be=j[de],ne[ae]=Be&255,ie>1&&(ne[ae+1]=Be>>8&255),ie>2&&(ne[ae+2]=Be>>16&255)),ne};function H(N,j,oe){U.call(this,N,j,oe)}H.prototype=new U,H.prototype.finalize=function(){return this.encode(this.outputBits,!0),U.prototype.finalize.call(this)};var Ae=function(N){var j,oe,ie,de,X,ne,ae,Be,pe,Fe,rt,Oe,ke,Qe,Ge,Xe,G,J,se,fe,ve,W,Q,I,D,$,ee,te,we,Ce,Ee,Ve,_e,re,ye,be,Ue,Je,qe,ct,An,xt,st,or,mt,qt,co,Xt,en,q,le,he,ue,ge,Ne,at,Ye,He,vt,ft,gt,zt,Pr;for(ie=0;ie<48;ie+=2)de=N[0]^N[10]^N[20]^N[30]^N[40],X=N[1]^N[11]^N[21]^N[31]^N[41],ne=N[2]^N[12]^N[22]^N[32]^N[42],ae=N[3]^N[13]^N[23]^N[33]^N[43],Be=N[4]^N[14]^N[24]^N[34]^N[44],pe=N[5]^N[15]^N[25]^N[35]^N[45],Fe=N[6]^N[16]^N[26]^N[36]^N[46],rt=N[7]^N[17]^N[27]^N[37]^N[47],Oe=N[8]^N[18]^N[28]^N[38]^N[48],ke=N[9]^N[19]^N[29]^N[39]^N[49],j=Oe^(ne<<1|ae>>>31),oe=ke^(ae<<1|ne>>>31),N[0]^=j,N[1]^=oe,N[10]^=j,N[11]^=oe,N[20]^=j,N[21]^=oe,N[30]^=j,N[31]^=oe,N[40]^=j,N[41]^=oe,j=de^(Be<<1|pe>>>31),oe=X^(pe<<1|Be>>>31),N[2]^=j,N[3]^=oe,N[12]^=j,N[13]^=oe,N[22]^=j,N[23]^=oe,N[32]^=j,N[33]^=oe,N[42]^=j,N[43]^=oe,j=ne^(Fe<<1|rt>>>31),oe=ae^(rt<<1|Fe>>>31),N[4]^=j,N[5]^=oe,N[14]^=j,N[15]^=oe,N[24]^=j,N[25]^=oe,N[34]^=j,N[35]^=oe,N[44]^=j,N[45]^=oe,j=Be^(Oe<<1|ke>>>31),oe=pe^(ke<<1|Oe>>>31),N[6]^=j,N[7]^=oe,N[16]^=j,N[17]^=oe,N[26]^=j,N[27]^=oe,N[36]^=j,N[37]^=oe,N[46]^=j,N[47]^=oe,j=Fe^(de<<1|X>>>31),oe=rt^(X<<1|de>>>31),N[8]^=j,N[9]^=oe,N[18]^=j,N[19]^=oe,N[28]^=j,N[29]^=oe,N[38]^=j,N[39]^=oe,N[48]^=j,N[49]^=oe,Qe=N[0],Ge=N[1],qt=N[11]<<4|N[10]>>>28,co=N[10]<<4|N[11]>>>28,te=N[20]<<3|N[21]>>>29,we=N[21]<<3|N[20]>>>29,ft=N[31]<<9|N[30]>>>23,gt=N[30]<<9|N[31]>>>23,xt=N[40]<<18|N[41]>>>14,st=N[41]<<18|N[40]>>>14,re=N[2]<<1|N[3]>>>31,ye=N[3]<<1|N[2]>>>31,Xe=N[13]<<12|N[12]>>>20,G=N[12]<<12|N[13]>>>20,Xt=N[22]<<10|N[23]>>>22,en=N[23]<<10|N[22]>>>22,Ce=N[33]<<13|N[32]>>>19,Ee=N[32]<<13|N[33]>>>19,zt=N[42]<<2|N[43]>>>30,Pr=N[43]<<2|N[42]>>>30,ge=N[5]<<30|N[4]>>>2,Ne=N[4]<<30|N[5]>>>2,be=N[14]<<6|N[15]>>>26,Ue=N[15]<<6|N[14]>>>26,J=N[25]<<11|N[24]>>>21,se=N[24]<<11|N[25]>>>21,q=N[34]<<15|N[35]>>>17,le=N[35]<<15|N[34]>>>17,Ve=N[45]<<29|N[44]>>>3,_e=N[44]<<29|N[45]>>>3,I=N[6]<<28|N[7]>>>4,D=N[7]<<28|N[6]>>>4,at=N[17]<<23|N[16]>>>9,Ye=N[16]<<23|N[17]>>>9,Je=N[26]<<25|N[27]>>>7,qe=N[27]<<25|N[26]>>>7,fe=N[36]<<21|N[37]>>>11,ve=N[37]<<21|N[36]>>>11,he=N[47]<<24|N[46]>>>8,ue=N[46]<<24|N[47]>>>8,or=N[8]<<27|N[9]>>>5,mt=N[9]<<27|N[8]>>>5,$=N[18]<<20|N[19]>>>12,ee=N[19]<<20|N[18]>>>12,He=N[29]<<7|N[28]>>>25,vt=N[28]<<7|N[29]>>>25,ct=N[38]<<8|N[39]>>>24,An=N[39]<<8|N[38]>>>24,W=N[48]<<14|N[49]>>>18,Q=N[49]<<14|N[48]>>>18,N[0]=Qe^~Xe&J,N[1]=Ge^~G&se,N[10]=I^~$&te,N[11]=D^~ee&we,N[20]=re^~be&Je,N[21]=ye^~Ue&qe,N[30]=or^~qt&Xt,N[31]=mt^~co&en,N[40]=ge^~at&He,N[41]=Ne^~Ye&vt,N[2]=Xe^~J&fe,N[3]=G^~se&ve,N[12]=$^~te&Ce,N[13]=ee^~we&Ee,N[22]=be^~Je&ct,N[23]=Ue^~qe&An,N[32]=qt^~Xt&q,N[33]=co^~en&le,N[42]=at^~He&ft,N[43]=Ye^~vt>,N[4]=J^~fe&W,N[5]=se^~ve&Q,N[14]=te^~Ce&Ve,N[15]=we^~Ee&_e,N[24]=Je^~ct&xt,N[25]=qe^~An&st,N[34]=Xt^~q&he,N[35]=en^~le&ue,N[44]=He^~ft&zt,N[45]=vt^~gt&Pr,N[6]=fe^~W&Qe,N[7]=ve^~Q&Ge,N[16]=Ce^~Ve&I,N[17]=Ee^~_e&D,N[26]=ct^~xt&re,N[27]=An^~st&ye,N[36]=q^~he&or,N[37]=le^~ue&mt,N[46]=ft^~zt&ge,N[47]=gt^~Pr&Ne,N[8]=W^~Qe&Xe,N[9]=Q^~Ge&G,N[18]=Ve^~I&$,N[19]=_e^~D&ee,N[28]=xt^~re&be,N[29]=st^~ye&Ue,N[38]=he^~or&qt,N[39]=ue^~mt&co,N[48]=zt^~ge&at,N[49]=Pr^~Ne&Ye,N[0]^=p[ie],N[1]^=p[ie+1]};if(a)n.exports=B;else for(R=0;R>6===2;o++)s++;return s}return n===$i.OVERRUN?t.length-e-1:0}function v9(n,e,t,r,i){return n===$i.OVERLONG?(r.push(i),0):(r.push(65533),J3(n,e,t))}const y9=Object.freeze({error:m9,ignore:J3,replace:v9});function H3(n,e){e==null&&(e=y9.error),n=lt(n);const t=[];let r=0;for(;r>7)){t.push(i);continue}let s=null,o=null;if((i&224)===192)s=1,o=127;else if((i&240)===224)s=2,o=2047;else if((i&248)===240)s=3,o=65535;else{(i&192)===128?r+=e($i.UNEXPECTED_CONTINUE,r-1,n,t):r+=e($i.BAD_PREFIX,r-1,n,t);continue}if(r-1+s>=n.length){r+=e($i.OVERRUN,r-1,n,t);continue}let a=i&(1<<8-s-1)-1;for(let l=0;l1114111){r+=e($i.OUT_OF_RANGE,r-1-s,n,t,a);continue}if(a>=55296&&a<=57343){r+=e($i.UTF16_SURROGATE,r-1-s,n,t,a);continue}if(a<=o){r+=e($i.OVERLONG,r-1-s,n,t,a);continue}t.push(a)}}return t}function Ia(n,e=jg.current){e!=jg.current&&(Z3.checkNormalize(),n=n.normalize(e));let t=[];for(let r=0;r>6|192),t.push(i&63|128);else if((i&64512)==55296){r++;const s=n.charCodeAt(r);if(r>=n.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((i&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(i>>12|224),t.push(i>>6&63|128),t.push(i&63|128)}return lt(t)}function B9(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function e0(n,e){return B9(H3(n,e))}function w9(n,e=jg.current){return H3(Ia(n,e))}function nd(n){return nr(Ia(n))}const z3="hash/5.7.0";function Y3(n,e){e==null&&(e=1);const t=[],r=t.forEach,i=function(s,o){r.call(s,function(a){o>0&&Array.isArray(a)?i(a,o-1):t.push(a)})};return i(n,e),t}function C9(n){const e={};for(let t=0;t>--l&1}const u=31,f=Math.pow(2,u),d=f>>>1,h=d>>1,p=f-1;let m=0;for(let C=0;C1;){let M=b+E>>>1;C>>1|c(),x=x<<1^d,S=(S^d)<<1|d|1;v=x,y=1+S-x}let w=r-4;return g.map(C=>{switch(C-w){case 3:return w+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return w+256+(n[a++]<<8|n[a++]);case 1:return w+n[a++];default:return C-1}})}function x9(n){let e=0;return()=>n[e++]}function I9(n){return x9(b9(n))}function F9(n){return n&1?~n>>1:n>>1}function E9(n,e){let t=Array(n);for(let r=0;re[o]):t}function S9(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(Q9(t,n))}for(;;){let t=n()-1;if(t<0)break;e.push(R9(t,n))}return C9(Y3(e))}function _9(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(t)}return e}function X3(n,e,t){let r=Array(n).fill(void 0).map(()=>[]);for(let i=0;ir[o].push(s));return r}function Q9(n,e){let t=1+e(),r=e(),i=_9(e),s=X3(i.length,1+n,e);return Y3(s.map((o,a)=>{const l=o[0],A=o.slice(1);return Array(i[a]).fill(void 0).map((c,u)=>{let f=u*r;return[l+u*t,A.map(d=>d+f)]})}))}function R9(n,e){let t=1+e();return X3(t,1+n,e).map(i=>[i[0],i.slice(1)])}function M9(n){let e=_B(n).sort((r,i)=>r-i);return t();function t(){let r=[];for(;;){let A=_B(n,e);if(A.length==0)break;r.push({set:new Set(A),node:t()})}r.sort((A,c)=>c.set.size-A.set.size);let i=n(),s=i%3;i=i/3|0;let o=!!(i&1);i>>=1;let a=i==1,l=i==2;return{branches:r,valid:s,fe0f:o,save:a,check:l}}}function T9(){return I9(L3("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const wC=T9(),N9=new Set(_B(wC)),D9=new Set(_B(wC)),k9=S9(wC),V9=M9(wC),IR=45,FR=95;function K3(n){return w9(n)}function L9(n){return n.filter(e=>e!=65039)}function j3(n){for(let e of n.split(".")){let t=K3(e);try{for(let r=t.lastIndexOf(FR)-1;r>=0;r--)if(t[r]!==FR)throw new Error("underscore only allowed at start");if(t.length>=4&&t.every(r=>r<128)&&t[2]===IR&&t[3]===IR)throw new Error("invalid label extension")}catch(r){throw new Error(`Invalid label "${e}": ${r.message}`)}}return n}function P9(n){return j3(W9(n,L9))}function W9(n,e){let t=K3(n).reverse(),r=[];for(;t.length;){let i=G9(t);if(i){r.push(...e(i));continue}let s=t.pop();if(N9.has(s)){r.push(s);continue}if(D9.has(s))continue;let o=k9[s];if(o){r.push(...o);continue}throw new Error(`Disallowed codepoint: 0x${s.toString(16).toUpperCase()}`)}return j3(O9(String.fromCodePoint(...r)))}function O9(n){return n.normalize("NFC")}function G9(n,e){var t;let r=V9,i,s,o=[],a=n.length;for(e&&(e.length=0);a;){let l=n[--a];if(r=(t=r.branches.find(A=>A.set.has(l)))===null||t===void 0?void 0:t.node,!r)break;if(r.save)s=l;else if(r.check&&l===s)break;o.push(l),r.fe0f&&(o.push(65039),a>0&&n[a-1]==65039&&a--),r.valid&&(i=o.slice(),r.valid==2&&i.splice(1,1),e&&e.push(...n.slice(a).reverse()),n.length=a)}return i}const Z9=new ce(z3),$3=new Uint8Array(32);$3.fill(0);function ER(n){if(n.length===0)throw new Error("invalid ENS name; empty component");return n}function q3(n){const e=Ia(P9(n)),t=[];if(n.length===0)return t;let r=0;for(let i=0;i=e.length)throw new Error("invalid ENS name; empty component");return t.push(ER(e.slice(r))),t}function ky(n){typeof n!="string"&&Z9.throwArgumentError("invalid ENS name; not a string","name",n);let e=$3;const t=q3(n);for(;t.length;)e=nr(rs([e,nr(t.pop())]));return $e(e)}function J9(n){return $e(rs(q3(n).map(e=>{if(e.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");const t=new Uint8Array(e.length+1);return t.set(e,1),t[0]=t.length-1,t})))+"00"}const H9="rlp/5.7.0",ia=new ce(H9);function UR(n){const e=[];for(;n;)e.unshift(n&255),n>>=8;return e}function SR(n,e,t){let r=0;for(let i=0;ie+1+r&&ia.throwError("child data too short",ce.errors.BUFFER_OVERRUN,{})}return{consumed:1+r,result:i}}function tP(n,e){if(n.length===0&&ia.throwError("data too short",ce.errors.BUFFER_OVERRUN,{}),n[e]>=248){const t=n[e]-247;e+1+t>n.length&&ia.throwError("data short segment too short",ce.errors.BUFFER_OVERRUN,{});const r=SR(n,e+1,t);return e+1+t+r>n.length&&ia.throwError("data long segment too short",ce.errors.BUFFER_OVERRUN,{}),_R(n,e,e+1+t,t+r)}else if(n[e]>=192){const t=n[e]-192;return e+1+t>n.length&&ia.throwError("data array too short",ce.errors.BUFFER_OVERRUN,{}),_R(n,e,e+1,t)}else if(n[e]>=184){const t=n[e]-183;e+1+t>n.length&&ia.throwError("data array too short",ce.errors.BUFFER_OVERRUN,{});const r=SR(n,e+1,t);e+1+t+r>n.length&&ia.throwError("data array too short",ce.errors.BUFFER_OVERRUN,{});const i=$e(n.slice(e+1+t,e+1+t+r));return{consumed:1+t+r,result:i}}else if(n[e]>=128){const t=n[e]-128;e+1+t>n.length&&ia.throwError("data too short",ce.errors.BUFFER_OVERRUN,{});const r=$e(n.slice(e+1,e+1+t));return{consumed:1+t,result:r}}return{consumed:1,result:$e(n[e])}}function zU(n){const e=lt(n),t=tP(e,0);return t.consumed!==e.length&&ia.throwArgumentError("invalid rlp data","data",n),t.result}const z9="address/5.7.0",rd=new ce(z9);function QR(n){bt(n,20)||rd.throwArgumentError("invalid address","address",n),n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let i=0;i<40;i++)t[i]=e[i].charCodeAt(0);const r=lt(nr(t));for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(r[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const Y9=9007199254740991;function X9(n){return Math.log10?Math.log10(n):Math.log(n)/Math.LN10}const YU={};for(let n=0;n<10;n++)YU[String(n)]=String(n);for(let n=0;n<26;n++)YU[String.fromCharCode(65+n)]=String(10+n);const RR=Math.floor(X9(Y9));function K9(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>YU[r]).join("");for(;e.length>=RR;){let r=e.substring(0,RR);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function kr(n){let e=null;if(typeof n!="string"&&rd.throwArgumentError("invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/))n.substring(0,2)!=="0x"&&(n="0x"+n),e=QR(n),n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==n&&rd.throwArgumentError("bad address checksum","address",n);else if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(n.substring(2,4)!==K9(n)&&rd.throwArgumentError("bad icap checksum","address",n),e=jz(n.substring(4));e.length<40;)e="0"+e;e=QR("0x"+e)}else rd.throwArgumentError("invalid address","address",n);return e}function nP(n){let e=null;try{e=kr(n.from)}catch{rd.throwArgumentError("missing from address","transaction",n)}const t=$d(lt(De.from(n.nonce).toHexString()));return kr(Jr(nr(CC([e,t])),12))}var j9=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const En=new ce(z3),rP=new Uint8Array(32);rP.fill(0);const $9=De.from(-1),iP=De.from(0),sP=De.from(1),q9=De.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function eY(n){const e=lt(n),t=e.length%32;return t?Ui([e,rP.slice(t)]):$e(e)}const tY=Ln(sP.toHexString(),32),nY=Ln(iP.toHexString(),32),MR={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Yb=["name","version","chainId","verifyingContract","salt"];function TR(n){return function(e){return typeof e!="string"&&En.throwArgumentError(`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,e),e}}const rY={name:TR("name"),version:TR("version"),chainId:function(n){try{return De.from(n).toString()}catch{}return En.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",n)},verifyingContract:function(n){try{return kr(n).toLowerCase()}catch{}return En.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){try{const e=lt(n);if(e.length!==32)throw new Error("bad length");return $e(e)}catch{}return En.throwArgumentError('invalid domain value "salt"',"domain.salt",n)}};function Xb(n){{const e=n.match(/^(u?)int(\d*)$/);if(e){const t=e[1]==="",r=parseInt(e[2]||"256");(r%8!==0||r>256||e[2]&&e[2]!==String(r))&&En.throwArgumentError("invalid numeric width","type",n);const i=q9.mask(t?r-1:r),s=t?i.add(sP).mul($9):iP;return function(o){const a=De.from(o);return(a.lt(s)||a.gt(i))&&En.throwArgumentError(`value out-of-bounds for ${n}`,"value",o),Ln(a.toTwos(256).toHexString(),32)}}}{const e=n.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return(t===0||t>32||e[1]!==String(t))&&En.throwArgumentError("invalid bytes width","type",n),function(r){return lt(r).length!==t&&En.throwArgumentError(`invalid length for ${n}`,"value",r),eY(r)}}}switch(n){case"address":return function(e){return Ln(kr(e),32)};case"bool":return function(e){return e?tY:nY};case"bytes":return function(e){return nr(e)};case"string":return function(e){return nd(e)}}return null}function NR(n,e){return`${n}(${e.map(({name:t,type:r})=>r+" "+t).join(",")})`}class Xi{constructor(e){Ie(this,"types",Object.freeze(as(e))),Ie(this,"_encoderCache",{}),Ie(this,"_types",{});const t={},r={},i={};Object.keys(e).forEach(a=>{t[a]={},r[a]=[],i[a]={}});for(const a in e){const l={};e[a].forEach(A=>{l[A.name]&&En.throwArgumentError(`duplicate variable name ${JSON.stringify(A.name)} in ${JSON.stringify(a)}`,"types",e),l[A.name]=!0;const c=A.type.match(/^([^\x5b]*)(\x5b|$)/)[1];c===a&&En.throwArgumentError(`circular type reference to ${JSON.stringify(c)}`,"types",e),!Xb(c)&&(r[c]||En.throwArgumentError(`unknown type ${JSON.stringify(c)}`,"types",e),r[c].push(a),t[a][c]=!0)})}const s=Object.keys(r).filter(a=>r[a].length===0);s.length===0?En.throwArgumentError("missing primary type","types",e):s.length>1&&En.throwArgumentError(`ambiguous primary types or unused types: ${s.map(a=>JSON.stringify(a)).join(", ")}`,"types",e),Ie(this,"primaryType",s[0]);function o(a,l){l[a]&&En.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",e),l[a]=!0,Object.keys(t[a]).forEach(A=>{r[A]&&(o(A,l),Object.keys(l).forEach(c=>{i[c][A]=!0}))}),delete l[a]}o(this.primaryType,{});for(const a in i){const l=Object.keys(i[a]);l.sort(),this._types[a]=NR(a,e[a])+l.map(A=>NR(A,e[A])).join("")}}getEncoder(e){let t=this._encoderCache[e];return t||(t=this._encoderCache[e]=this._getEncoder(e)),t}_getEncoder(e){{const i=Xb(e);if(i)return i}const t=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){const i=t[1],s=this.getEncoder(i),o=parseInt(t[3]);return a=>{o>=0&&a.length!==o&&En.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",a);let l=a.map(s);return this._types[i]&&(l=l.map(nr)),nr(Ui(l))}}const r=this.types[e];if(r){const i=nd(this._types[e]);return s=>{const o=r.map(({name:a,type:l})=>{const A=this.getEncoder(l)(s[a]);return this._types[l]?nr(A):A});return o.unshift(i),Ui(o)}}return En.throwArgumentError(`unknown type: ${e}`,"type",e)}encodeType(e){const t=this._types[e];return t||En.throwArgumentError(`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return nr(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,r){if(Xb(e))return r(e,t);const i=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const o=i[1],a=parseInt(i[3]);return a>=0&&t.length!==a&&En.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t),t.map(l=>this._visit(o,l,r))}const s=this.types[e];return s?s.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,t[a],r),o),{}):En.throwArgumentError(`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Xi(e)}static getPrimaryType(e){return Xi.from(e).primaryType}static hashStruct(e,t,r){return Xi.from(t).hashStruct(e,r)}static hashDomain(e){const t=[];for(const r in e){const i=MR[r];i||En.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",e),t.push({name:r,type:i})}return t.sort((r,i)=>Yb.indexOf(r.name)-Yb.indexOf(i.name)),Xi.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,r){return Ui(["0x1901",Xi.hashDomain(e),Xi.from(t).hash(r)])}static hash(e,t,r){return nr(Xi.encode(e,t,r))}static resolveNames(e,t,r,i){return j9(this,void 0,void 0,function*(){e=xn(e);const s={};e.verifyingContract&&!bt(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const o=Xi.from(t);o.visit(r,(a,l)=>(a==="address"&&!bt(l,20)&&(s[l]="0x"),l));for(const a in s)s[a]=yield i(a);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),r=o.visit(r,(a,l)=>a==="address"&&s[l]?s[l]:l),{domain:e,value:r}})}static getPayload(e,t,r){Xi.hashDomain(e);const i={},s=[];Yb.forEach(l=>{const A=e[l];A!=null&&(i[l]=rY[l](A),s.push({name:l,type:MR[l]}))});const o=Xi.from(t),a=xn(t);return a.EIP712Domain?En.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",t):a.EIP712Domain=s,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,(l,A)=>{if(l.match(/^bytes(\d*)/))return $e(lt(A));if(l.match(/^u?int/))return De.from(A).toString();switch(l){case"address":return A.toLowerCase();case"bool":return!!A;case"string":return typeof A!="string"&&En.throwArgumentError("invalid string","value",A),A}return En.throwArgumentError("unsupported type","type",l)})}}}var oP={},_t={},t0=aP;function aP(n,e){if(!n)throw new Error(e||"Assertion failed")}aP.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)};var K1={exports:{}};typeof Object.create=="function"?K1.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:K1.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}};var iY=K1.exports,sY=t0,oY=iY;_t.inherits=oY;function aY(n,e){return(n.charCodeAt(e)&64512)!==55296||e<0||e+1>=n.length?!1:(n.charCodeAt(e+1)&64512)===56320}function lY(n,e){if(Array.isArray(n))return n.slice();if(!n)return[];var t=[];if(typeof n=="string")if(e){if(e==="hex")for(n=n.replace(/[^a-z0-9]+/ig,""),n.length%2!==0&&(n="0"+n),i=0;i>6|192,t[r++]=s&63|128):aY(n,i)?(s=65536+((s&1023)<<10)+(n.charCodeAt(++i)&1023),t[r++]=s>>18|240,t[r++]=s>>12&63|128,t[r++]=s>>6&63|128,t[r++]=s&63|128):(t[r++]=s>>12|224,t[r++]=s>>6&63|128,t[r++]=s&63|128)}else for(i=0;i>>24|n>>>8&65280|n<<8&16711680|(n&255)<<24;return e>>>0}_t.htonl=lP;function cY(n,e){for(var t="",r=0;r>>0}return s}_t.join32=uY;function fY(n,e){for(var t=new Array(n.length*4),r=0,i=0;r>>24,t[i+1]=s>>>16&255,t[i+2]=s>>>8&255,t[i+3]=s&255):(t[i+3]=s>>>24,t[i+2]=s>>>16&255,t[i+1]=s>>>8&255,t[i]=s&255)}return t}_t.split32=fY;function dY(n,e){return n>>>e|n<<32-e}_t.rotr32=dY;function hY(n,e){return n<>>32-e}_t.rotl32=hY;function pY(n,e){return n+e>>>0}_t.sum32=pY;function gY(n,e,t){return n+e+t>>>0}_t.sum32_3=gY;function mY(n,e,t,r){return n+e+t+r>>>0}_t.sum32_4=mY;function vY(n,e,t,r,i){return n+e+t+r+i>>>0}_t.sum32_5=vY;function yY(n,e,t,r){var i=n[e],s=n[e+1],o=r+s>>>0,a=(o>>0,n[e+1]=o}_t.sum64=yY;function BY(n,e,t,r){var i=e+r>>>0,s=(i>>0}_t.sum64_hi=BY;function wY(n,e,t,r){var i=e+r;return i>>>0}_t.sum64_lo=wY;function CY(n,e,t,r,i,s,o,a){var l=0,A=e;A=A+r>>>0,l+=A>>0,l+=A>>0,l+=A>>0}_t.sum64_4_hi=CY;function bY(n,e,t,r,i,s,o,a){var l=e+r+s+a;return l>>>0}_t.sum64_4_lo=bY;function xY(n,e,t,r,i,s,o,a,l,A){var c=0,u=e;u=u+r>>>0,c+=u>>0,c+=u>>0,c+=u>>0,c+=u>>0}_t.sum64_5_hi=xY;function IY(n,e,t,r,i,s,o,a,l,A){var c=e+r+s+a+A;return c>>>0}_t.sum64_5_lo=IY;function FY(n,e,t){var r=e<<32-t|n>>>t;return r>>>0}_t.rotr64_hi=FY;function EY(n,e,t){var r=n<<32-t|e>>>t;return r>>>0}_t.rotr64_lo=EY;function UY(n,e,t){return n>>>t}_t.shr64_hi=UY;function SY(n,e,t){var r=n<<32-t|e>>>t;return r>>>0}_t.shr64_lo=SY;var Sh={},DR=_t,_Y=t0;function bC(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Sh.BlockHash=bC;bC.prototype.update=function(e,t){if(e=DR.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var r=e.length%this._delta8;this.pending=e.slice(e.length-r,e.length),this.pending.length===0&&(this.pending=null),e=DR.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,i[s++]=e>>>16&255,i[s++]=e>>>8&255,i[s++]=e&255}else for(i[s++]=e&255,i[s++]=e>>>8&255,i[s++]=e>>>16&255,i[s++]=e>>>24&255,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,o=8;o>>3}Na.g0_256=NY;function DY(n){return ma(n,17)^ma(n,19)^n>>>10}Na.g1_256=DY;var qd=_t,kY=Sh,VY=Na,Kb=qd.rotl32,Ap=qd.sum32,LY=qd.sum32_5,PY=VY.ft_1,hP=kY.BlockHash,WY=[1518500249,1859775393,2400959708,3395469782];function Fa(){if(!(this instanceof Fa))return new Fa;hP.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}qd.inherits(Fa,hP);var OY=Fa;Fa.blockSize=512;Fa.outSize=160;Fa.hmacStrength=80;Fa.padLength=64;Fa.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;ithis.blockSize&&(e=new this.Hash().update(e).digest()),SX(e.length<=this.blockSize);for(var t=e.length;t{s[a.toLowerCase()]=o}):r.headers.keys().forEach(o=>{s[o.toLowerCase()]=r.headers.get(o)}),{headers:s,statusCode:r.status,statusMessage:r.statusText,body:lt(new Uint8Array(i))}})}var TX=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const wo=new ce(QX);function WR(n){return new Promise(e=>{setTimeout(e,n)})}function zl(n,e){if(n==null)return null;if(typeof n=="string")return n;if(HU(n)){if(e&&(e.split("/")[0]==="text"||e.split(";")[0].trim()==="application/json"))try{return e0(n)}catch{}return $e(n)}return n}function NX(n){return Ia(n.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function DX(n,e,t){const r=typeof n=="object"&&n.throttleLimit!=null?n.throttleLimit:12;wo.assertArgument(r>0&&r%1===0,"invalid connection throttle limit","connection.throttleLimit",r);const i=typeof n=="object"?n.throttleCallback:null,s=typeof n=="object"&&typeof n.throttleSlotInterval=="number"?n.throttleSlotInterval:100;wo.assertArgument(s>0&&s%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",s);const o=typeof n=="object"?!!n.errorPassThrough:!1,a={};let l=null;const A={method:"GET"};let c=!1,u=2*60*1e3;if(typeof n=="string")l=n;else if(typeof n=="object"){if((n==null||n.url==null)&&wo.throwArgumentError("missing URL","connection.url",n),l=n.url,typeof n.timeout=="number"&&n.timeout>0&&(u=n.timeout),n.headers)for(const g in n.headers)a[g.toLowerCase()]={key:g,value:String(n.headers[g])},["if-none-match","if-modified-since"].indexOf(g.toLowerCase())>=0&&(c=!0);if(A.allowGzip=!!n.allowGzip,n.user!=null&&n.password!=null){l.substring(0,6)!=="https:"&&n.allowInsecureAuthentication!==!0&&wo.throwError("basic authentication requires a secure https url",ce.errors.INVALID_ARGUMENT,{argument:"url",url:l,user:n.user,password:"[REDACTED]"});const g=n.user+":"+n.password;a.authorization={key:"Authorization",value:"Basic "+P3(Ia(g))}}n.skipFetchSetup!=null&&(A.skipFetchSetup=!!n.skipFetchSetup),n.fetchOptions!=null&&(A.fetchOptions=xn(n.fetchOptions))}const f=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),d=l?l.match(f):null;if(d)try{const g={statusCode:200,statusMessage:"OK",headers:{"content-type":d[1]||"text/plain"},body:d[2]?L3(d[3]):NX(d[3])};let v=g.body;return t&&(v=t(g.body,g)),Promise.resolve(v)}catch(g){wo.throwError("processing response error",ce.errors.SERVER_ERROR,{body:zl(d[1],d[2]),error:g,requestBody:null,requestMethod:"GET",url:l})}e&&(A.method="POST",A.body=e,a["content-type"]==null&&(a["content-type"]={key:"Content-Type",value:"application/octet-stream"}),a["content-length"]==null&&(a["content-length"]={key:"Content-Length",value:String(e.length)}));const h={};Object.keys(a).forEach(g=>{const v=a[g];h[v.key]=v.value}),A.headers=h;const p=function(){let g=null;return{promise:new Promise(function(w,C){u&&(g=setTimeout(()=>{g!=null&&(g=null,C(wo.makeError("timeout",ce.errors.TIMEOUT,{requestBody:zl(A.body,h["content-type"]),requestMethod:A.method,timeout:u,url:l})))},u))}),cancel:function(){g!=null&&(clearTimeout(g),g=null)}}}(),m=function(){return TX(this,void 0,void 0,function*(){for(let g=0;g=300)&&(p.cancel(),wo.throwError("bad response",ce.errors.SERVER_ERROR,{status:v.statusCode,headers:v.headers,body:zl(y,v.headers?v.headers["content-type"]:null),requestBody:zl(A.body,h["content-type"]),requestMethod:A.method,url:l})),t)try{const w=yield t(y,v);return p.cancel(),w}catch(w){if(w.throttleRetry&&g{let a=null;if(s!=null)try{a=JSON.parse(e0(s))}catch(l){wo.throwError("invalid JSON",ce.errors.SERVER_ERROR,{body:s,error:l})}return t&&(a=t(a,o)),a},i=null;if(e!=null){i=Ia(e);const s=typeof n=="string"?{url:n}:xn(n);s.headers?Object.keys(s.headers).filter(a=>a.toLowerCase()==="content-type").length!==0||(s.headers=xn(s.headers),s.headers["content-type"]="application/json"):s.headers={"content-type":"application/json"},n=s}return DX(n,i,r)}function id(n,e){return e||(e={}),e=xn(e),e.floor==null&&(e.floor=0),e.ceiling==null&&(e.ceiling=1e4),e.interval==null&&(e.interval=250),new Promise(function(t,r){let i=null,s=!1;const o=()=>s?!1:(s=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{o()&&r(new Error("timeout"))},e.timeout));const a=e.retryLimit;let l=0;function A(){return n().then(function(c){if(c!==void 0)o()&&t(c);else if(e.oncePoll)e.oncePoll.once("poll",A);else if(e.onceBlock)e.onceBlock.once("block",A);else if(!s){if(l++,l>a){o()&&r(new Error("retry limit reached"));return}let u=e.interval*parseInt(String(Math.random()*Math.pow(2,l)));ue.ceiling&&(u=e.ceiling),setTimeout(A,u)}return null},function(c){o()&&r(c)})}A()})}var QB="qpzry9x8gf2tvdw0s3jn54khce6mua7l",q1={};for(var D0=0;D0>25;return(n&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function IP(n){for(var e=1,t=0;t126)return"Invalid prefix ("+n+")";e=Qd(e)^r>>5}for(e=Qd(e),t=0;tt)throw new TypeError("Exceeds length limit");n=n.toLowerCase();var r=IP(n);if(typeof r=="string")throw new Error(r);for(var i=n+"1",s=0;s>5)throw new Error("Non 5-bit word");r=Qd(r)^o,i+=QB.charAt(o)}for(s=0;s<6;++s)r=Qd(r);for(r^=1,s=0;s<6;++s){var a=r>>(5-s)*5&31;i+=QB.charAt(a)}return i}function FP(n,e){if(e=e||90,n.length<8)return n+" too short";if(n.length>e)return"Exceeds length limit";var t=n.toLowerCase(),r=n.toUpperCase();if(n!==t&&n!==r)return"Mixed-case string "+n;n=t;var i=n.lastIndexOf("1");if(i===-1)return"No separator character for "+n;if(i===0)return"Missing prefix for "+n;var s=n.slice(0,i),o=n.slice(i+1);if(o.length<6)return"Data too short";var a=IP(s);if(typeof a=="string")return a;for(var l=[],A=0;A=o.length)&&l.push(u)}return a!==1?"Invalid checksum for "+n:{prefix:s,words:l}}function VX(){var n=FP.apply(null,arguments);if(typeof n=="object")return n}function LX(n){var e=FP.apply(null,arguments);if(typeof e=="object")return e;throw new Error(e)}function IC(n,e,t,r){for(var i=0,s=0,o=(1<=t;)s-=t,a.push(i>>s&o);if(r)s>0&&a.push(i<=e)return"Excess padding";if(i<>8,f=c&255;u?l.push(u,f):l.push(f)}return l}t.toArray=r;function i(o){return o.length===1?"0"+o:o}t.zero2=i;function s(o){for(var a="",l=0;l(f>>1)-1?p=(f>>1)-m:p=m,d.isubn(p)):p=0,u[h]=p,d.iushrn(1)}return u}t.getNAF=r;function i(l,A){var c=[[],[]];l=l.clone(),A=A.clone();for(var u=0,f=0,d;l.cmpn(-u)>0||A.cmpn(-f)>0;){var h=l.andln(3)+u&3,p=A.andln(3)+f&3;h===3&&(h=-1),p===3&&(p=-1);var m;h&1?(d=l.andln(7)+u&7,(d===3||d===5)&&p===2?m=-h:m=h):m=0,c[0].push(m);var g;p&1?(d=A.andln(7)+f&7,(d===3||d===5)&&h===2?g=-p:g=p):g=0,c[1].push(g),2*u===m+1&&(u=1-u),2*f===g+1&&(f=1-f),l.iushrn(1),A.iushrn(1)}return c}t.getJSF=i;function s(l,A,c){var u="_"+A;l.prototype[A]=function(){return this[u]!==void 0?this[u]:this[u]=c.call(this)}}t.cachedProperty=s;function o(l){return typeof l=="string"?t.toArray(l,"hex"):l}t.parseBytes=o;function a(l){return new pt(l,"hex","le")}t.intFromLE=a}),RB=ms.getNAF,HX=ms.getJSF,MB=ms.assert;function ac(n,e){this.type=n,this.p=new pt(e.p,16),this.red=e.prime?pt.red(e.prime):pt.mont(this.p),this.zero=new pt(0).toRed(this.red),this.one=new pt(1).toRed(this.red),this.two=new pt(2).toRed(this.red),this.n=e.n&&new pt(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var xu=ac;ac.prototype.point=function(){throw new Error("Not implemented")};ac.prototype.validate=function(){throw new Error("Not implemented")};ac.prototype._fixedNafMul=function(e,t){MB(e.precomputed);var r=e._getDoubles(),i=RB(t,1,this._bitLength),s=(1<=a;A--)l=(l<<1)+i[A];o.push(l)}for(var c=this.jpoint(null,null,null),u=this.jpoint(null,null,null),f=s;f>0;f--){for(a=0;a=0;l--){for(var A=0;l>=0&&o[l]===0;l--)A++;if(l>=0&&A++,a=a.dblp(A),l<0)break;var c=o[l];MB(c!==0),e.type==="affine"?c>0?a=a.mixedAdd(s[c-1>>1]):a=a.mixedAdd(s[-c-1>>1].neg()):c>0?a=a.add(s[c-1>>1]):a=a.add(s[-c-1>>1].neg())}return e.type==="affine"?a.toP():a};ac.prototype._wnafMulAdd=function(e,t,r,i,s){var o=this._wnafT1,a=this._wnafT2,l=this._wnafT3,A=0,c,u,f;for(c=0;c=1;c-=2){var h=c-1,p=c;if(o[h]!==1||o[p]!==1){l[h]=RB(r[h],o[h],this._bitLength),l[p]=RB(r[p],o[p],this._bitLength),A=Math.max(l[h].length,A),A=Math.max(l[p].length,A);continue}var m=[t[h],null,null,t[p]];t[h].y.cmp(t[p].y)===0?(m[1]=t[h].add(t[p]),m[2]=t[h].toJ().mixedAdd(t[p].neg())):t[h].y.cmp(t[p].y.redNeg())===0?(m[1]=t[h].toJ().mixedAdd(t[p]),m[2]=t[h].add(t[p].neg())):(m[1]=t[h].toJ().mixedAdd(t[p]),m[2]=t[h].toJ().mixedAdd(t[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],v=HX(r[h],r[p]);for(A=Math.max(v[0].length,A),l[h]=new Array(A),l[p]=new Array(A),u=0;u=0;c--){for(var E=0;c>=0;){var x=!0;for(u=0;u=0&&E++,C=C.dblp(E),c<0)break;for(u=0;u0?f=a[u][S-1>>1]:S<0&&(f=a[u][-S-1>>1].neg()),f.type==="affine"?C=C.mixedAdd(f):C=C.add(f))}}for(c=0;c=Math.ceil((e.bitLength()+1)/t.step):!1};oo.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,s=0;s=0&&(d=A,h=c),u.negative&&(u=u.neg(),f=f.neg()),d.negative&&(d=d.neg(),h=h.neg()),[{a:u,b:f},{a:d,b:h}]};ao.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],s=i.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=s.mul(r.a),l=o.mul(i.a),A=s.mul(r.b),c=o.mul(i.b),u=e.sub(a).sub(l),f=A.add(c).neg();return{k1:u,k2:f}};ao.prototype.pointFromX=function(e,t){e=new pt(e,16),e.red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(i.redSqr().redSub(r).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(e,i)};ao.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return r.redSqr().redISub(s).cmpn(0)===0};ao.prototype._endoWnafMulAdd=function(e,t,r){for(var i=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};Ur.prototype.isInfinity=function(){return this.inf};Ur.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)};Ur.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),s=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};Ur.prototype.getX=function(){return this.x.fromRed()};Ur.prototype.getY=function(){return this.y.fromRed()};Ur.prototype.mul=function(e){return e=new pt(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Ur.prototype.mulAdd=function(e,t,r){var i=[this,t],s=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)};Ur.prototype.jmulAdd=function(e,t,r){var i=[this,t],s=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)};Ur.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Ur.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(s){return s.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t};Ur.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Lr(n,e,t,r){xu.BasePoint.call(this,n,"jacobian"),e===null&&t===null&&r===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new pt(0)):(this.x=new pt(e,16),this.y=new pt(t,16),this.z=new pt(r,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}KU(Lr,xu.BasePoint);ao.prototype.jpoint=function(e,t,r){return new Lr(this,e,t,r)};Lr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)};Lr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Lr.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),s=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),l=i.redSub(s),A=o.redSub(a);if(l.cmpn(0)===0)return A.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=l.redSqr(),u=c.redMul(l),f=i.redMul(c),d=A.redSqr().redIAdd(u).redISub(f).redISub(f),h=A.redMul(f.redISub(d)).redISub(o.redMul(u)),p=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(d,h,p)};Lr.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(i),l=s.redSub(o);if(a.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var A=a.redSqr(),c=A.redMul(a),u=r.redMul(A),f=l.redSqr().redIAdd(c).redISub(u).redISub(u),d=l.redMul(u.redISub(f)).redISub(s.redMul(c)),h=this.z.redMul(a);return this.curve.jpoint(f,d,h)};Lr.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(s),this.x.cmp(r)===0)return!0}};Lr.prototype.inspect=function(){return this.isInfinity()?"":""};Lr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Vy=Rh(function(n,e){var t=e;t.base=xu,t.short=YX,t.mont=null,t.edwards=null}),Ly=Rh(function(n,e){var t=e,r=ms.assert;function i(a){a.type==="short"?this.curve=new Vy.short(a):a.type==="edwards"?this.curve=new Vy.edwards(a):this.curve=new Vy.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,r(this.g.validate(),"Invalid curve"),r(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=i;function s(a,l){Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){var A=new i(l);return Object.defineProperty(t,a,{configurable:!0,enumerable:!0,value:A}),A}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:ta.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:ta.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:ta.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:ta.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:ta.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:ta.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:ta.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:ta.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function zA(n){if(!(this instanceof zA))return new zA(n);this.hash=n.hash,this.predResist=!!n.predResist,this.outLen=this.hash.outSize,this.minEntropy=n.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=_o.toArray(n.entropy,n.entropyEnc||"hex"),t=_o.toArray(n.nonce,n.nonceEnc||"hex"),r=_o.toArray(n.pers,n.persEnc||"hex");XU(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,r)}var UP=zA;zA.prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1};zA.prototype.generate=function(e,t,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(i=r,r=t,t=null),r&&(r=_o.toArray(r,i||"hex"),this._update(r));for(var s=[];s.length"};var XX=ms.assert;function FC(n,e){if(n instanceof FC)return n;this._importDER(n,e)||(XX(n.r&&n.s,"Signature without r or s"),this.r=new pt(n.r,16),this.s=new pt(n.s,16),n.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=n.recoveryParam)}var EC=FC;function KX(){this.place=0}function ex(n,e){var t=n[e.place++];if(!(t&128))return t;var r=t&15;if(r===0||r>4)return!1;for(var i=0,s=0,o=e.place;s>>=0;return i<=127?!1:(e.place=o,i)}function GR(n){for(var e=0,t=n.length-1;!n[e]&&!(n[e+1]&128)&&e>>3);for(n.push(t|128);--t;)n.push(e>>>(t<<3)&255);n.push(e)}FC.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),r[0]&128&&(r=[0].concat(r)),t=GR(t),r=GR(r);!r[0]&&!(r[1]&128);)r=r.slice(1);var i=[2];tx(i,t.length),i=i.concat(t),i.push(2),tx(i,r.length);var s=i.concat(r),o=[48];return tx(o,s.length),o=o.concat(s),ms.encode(o,e)};var jX=function(){throw new Error("unsupported")},SP=ms.assert;function eo(n){if(!(this instanceof eo))return new eo(n);typeof n=="string"&&(SP(Object.prototype.hasOwnProperty.call(Ly,n),"Unknown curve "+n),n=Ly[n]),n instanceof Ly.PresetCurve&&(n={curve:n}),this.curve=n.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=n.curve.g,this.g.precompute(n.curve.n.bitLength()+1),this.hash=n.hash||n.curve.hash}var $X=eo;eo.prototype.keyPair=function(e){return new jU(this,e)};eo.prototype.keyFromPrivate=function(e,t){return jU.fromPrivate(this,e,t)};eo.prototype.keyFromPublic=function(e,t){return jU.fromPublic(this,e,t)};eo.prototype.genKeyPair=function(e){e||(e={});for(var t=new UP({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||jX(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new pt(2));;){var s=new pt(t.generate(r));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}};eo.prototype._truncateToN=function(e,t){var r=e.byteLength()*8-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};eo.prototype.sign=function(e,t,r,i){typeof r=="object"&&(i=r,r=null),i||(i={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new pt(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),l=new UP({hash:this.hash,entropy:o,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),A=this.n.sub(new pt(1)),c=0;;c++){var u=i.k?i.k(c):new pt(l.generate(this.n.byteLength()));if(u=this._truncateToN(u,!0),!(u.cmpn(1)<=0||u.cmp(A)>=0)){var f=this.g.mul(u);if(!f.isInfinity()){var d=f.getX(),h=d.umod(this.n);if(h.cmpn(0)!==0){var p=u.invm(this.n).mul(h.mul(t.getPrivate()).iadd(e));if(p=p.umod(this.n),p.cmpn(0)!==0){var m=(f.getY().isOdd()?1:0)|(d.cmp(h)!==0?2:0);return i.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),m^=1),new EC({r:h,s:p,recoveryParam:m})}}}}}};eo.prototype.verify=function(e,t,r,i){e=this._truncateToN(new pt(e,16)),r=this.keyFromPublic(r,i),t=new EC(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),l=a.mul(e).umod(this.n),A=a.mul(s).umod(this.n),c;return this.curve._maxwellTrick?(c=this.g.jmulAdd(l,r.getPublic(),A),c.isInfinity()?!1:c.eqXToP(s)):(c=this.g.mulAdd(l,r.getPublic(),A),c.isInfinity()?!1:c.getX().umod(this.n).cmp(s)===0)};eo.prototype.recoverPubKey=function(n,e,t,r){SP((3&t)===t,"The recovery param is more than two bits"),e=new EC(e,r);var i=this.n,s=new pt(n),o=e.r,a=e.s,l=t&1,A=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&A)throw new Error("Unable to find sencond key candinate");A?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var c=e.r.invm(i),u=i.sub(s).mul(c).umod(i),f=a.mul(c).umod(i);return this.g.mulAdd(u,o,f)};eo.prototype.getKeyRecoveryParam=function(n,e,t,r){if(e=new EC(e,r),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(n,e,i)}catch{continue}if(s.eq(t))return i}throw new Error("Unable to find valid recovery factor")};var qX=Rh(function(n,e){var t=e;t.version="6.5.4",t.utils=ms,t.rand=function(){throw new Error("unsupported")},t.curve=Vy,t.curves=Ly,t.ec=$X,t.eddsa=null}),e6=qX.ec;const t6="signing-key/5.7.0",tF=new ce(t6);let nx=null;function sa(){return nx||(nx=new e6("secp256k1")),nx}class n6{constructor(e){Ie(this,"curve","secp256k1"),Ie(this,"privateKey",$e(e)),au(this.privateKey)!==32&&tF.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=sa().keyFromPrivate(lt(this.privateKey));Ie(this,"publicKey","0x"+t.getPublic(!1,"hex")),Ie(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Ie(this,"_isSigningKey",!0)}_addPoint(e){const t=sa().keyFromPublic(lt(this.publicKey)),r=sa().keyFromPublic(lt(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")}signDigest(e){const t=sa().keyFromPrivate(lt(this.privateKey)),r=lt(e);r.length!==32&&tF.throwArgumentError("bad digest length","digest",e);const i=t.sign(r,{canonical:!0});return BC({recoveryParam:i.recoveryParam,r:Ln("0x"+i.r.toString(16),32),s:Ln("0x"+i.s.toString(16),32)})}computeSharedSecret(e){const t=sa().keyFromPrivate(lt(this.privateKey)),r=sa().keyFromPublic(lt(_P(e)));return Ln("0x"+t.derive(r.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function r6(n,e){const t=BC(e),r={r:lt(t.r),s:lt(t.s)};return"0x"+sa().recoverPubKey(lt(n),r,t.recoveryParam).encode("hex",!1)}function _P(n,e){const t=lt(n);if(t.length===32){const r=new n6(t);return e?"0x"+sa().keyFromPrivate(t).getPublic(!0,"hex"):r.publicKey}else{if(t.length===33)return e?$e(t):"0x"+sa().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+sa().keyFromPublic(t).getPublic(!0,"hex"):$e(t)}return tF.throwArgumentError("invalid public or private key","key","[REDACTED]")}const i6="transactions/5.7.0",Ll=new ce(i6);var ZR;(function(n){n[n.legacy=0]="legacy",n[n.eip2930=1]="eip2930",n[n.eip1559=2]="eip1559"})(ZR||(ZR={}));function $U(n){return n==="0x"?null:kr(n)}function zr(n){return n==="0x"?O3:De.from(n)}function s6(n){const e=_P(n);return kr(Jr(nr(Jr(e,1)),12))}function QP(n,e){return s6(r6(lt(n),e))}function qi(n,e){const t=$d(De.from(n).toHexString());return t.length>32&&Ll.throwArgumentError("invalid length for "+e,"transaction:"+e,n),t}function rx(n,e){return{address:kr(n),storageKeys:(e||[]).map((t,r)=>(au(t)!==32&&Ll.throwArgumentError("invalid access list storageKey",`accessList[${n}:${r}]`,t),t.toLowerCase()))}}function Iu(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(t.length>2&&Ll.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${r}]`,t),rx(t[0],t[1])):rx(t.address,t.storageKeys));const e=Object.keys(n).map(t=>{const r=n[t].reduce((i,s)=>(i[s]=!0,i),{});return rx(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function RP(n){return Iu(n).map(e=>[e.address,e.storageKeys])}function o6(n,e){if(n.gasPrice!=null){const r=De.from(n.gasPrice),i=De.from(n.maxFeePerGas||0);r.eq(i)||Ll.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:r,maxFeePerGas:i})}const t=[qi(n.chainId||0,"chainId"),qi(n.nonce||0,"nonce"),qi(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),qi(n.maxFeePerGas||0,"maxFeePerGas"),qi(n.gasLimit||0,"gasLimit"),n.to!=null?kr(n.to):"0x",qi(n.value||0,"value"),n.data||"0x",RP(n.accessList||[])];if(e){const r=BC(e);t.push(qi(r.recoveryParam,"recoveryParam")),t.push($d(r.r)),t.push($d(r.s))}return Ui(["0x02",CC(t)])}function a6(n,e){const t=[qi(n.chainId||0,"chainId"),qi(n.nonce||0,"nonce"),qi(n.gasPrice||0,"gasPrice"),qi(n.gasLimit||0,"gasLimit"),n.to!=null?kr(n.to):"0x",qi(n.value||0,"value"),n.data||"0x",RP(n.accessList||[])];if(e){const r=BC(e);t.push(qi(r.recoveryParam,"recoveryParam")),t.push($d(r.r)),t.push($d(r.s))}return Ui(["0x01",CC(t)])}function MP(n,e,t){try{const r=zr(e[0]).toNumber();if(r!==0&&r!==1)throw new Error("bad recid");n.v=r}catch{Ll.throwArgumentError("invalid v for transaction type: 1","v",e[0])}n.r=Ln(e[1],32),n.s=Ln(e[2],32);try{const r=nr(t(n));n.from=QP(r,{r:n.r,s:n.s,recoveryParam:n.v})}catch{}}function l6(n){const e=zU(n.slice(1));e.length!==9&&e.length!==12&&Ll.throwArgumentError("invalid component count for transaction type: 2","payload",$e(n));const t=zr(e[2]),r=zr(e[3]),i={type:2,chainId:zr(e[0]).toNumber(),nonce:zr(e[1]).toNumber(),maxPriorityFeePerGas:t,maxFeePerGas:r,gasPrice:null,gasLimit:zr(e[4]),to:$U(e[5]),value:zr(e[6]),data:e[7],accessList:Iu(e[8])};return e.length===9||(i.hash=nr(n),MP(i,e.slice(9),o6)),i}function A6(n){const e=zU(n.slice(1));e.length!==8&&e.length!==11&&Ll.throwArgumentError("invalid component count for transaction type: 1","payload",$e(n));const t={type:1,chainId:zr(e[0]).toNumber(),nonce:zr(e[1]).toNumber(),gasPrice:zr(e[2]),gasLimit:zr(e[3]),to:$U(e[4]),value:zr(e[5]),data:e[6],accessList:Iu(e[7])};return e.length===8||(t.hash=nr(n),MP(t,e.slice(8),a6)),t}function c6(n){const e=zU(n);e.length!==9&&e.length!==6&&Ll.throwArgumentError("invalid raw transaction","rawTransaction",n);const t={nonce:zr(e[0]).toNumber(),gasPrice:zr(e[1]),gasLimit:zr(e[2]),to:$U(e[3]),value:zr(e[4]),data:e[5],chainId:0};if(e.length===6)return t;try{t.v=De.from(e[6]).toNumber()}catch{return t}if(t.r=Ln(e[7],32),t.s=Ln(e[8],32),De.from(t.r).isZero()&&De.from(t.s).isZero())t.chainId=t.v,t.v=0;else{t.chainId=Math.floor((t.v-35)/2),t.chainId<0&&(t.chainId=0);let r=t.v-27;const i=e.slice(0,6);t.chainId!==0&&(i.push($e(t.chainId)),i.push("0x"),i.push("0x"),r-=t.chainId*2+8);const s=nr(CC(i));try{t.from=QP(s,{r:$e(t.r),s:$e(t.s),recoveryParam:r})}catch{}t.hash=nr(n)}return t.type=null,t}function u6(n){const e=lt(n);if(e[0]>127)return c6(e);switch(e[0]){case 1:return A6(e);case 2:return l6(e)}return Ll.throwError(`unsupported transaction type: ${e[0]}`,ce.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}const up=new ce(ti);let JR=class Ke{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const e={},t=this.address.bind(this),r=this.bigNumber.bind(this),i=this.blockTag.bind(this),s=this.data.bind(this),o=this.hash.bind(this),a=this.hex.bind(this),l=this.number.bind(this),A=this.type.bind(this),c=u=>this.data(u,!0);return e.transaction={hash:o,type:A,accessList:Ke.allowNull(this.accessList.bind(this),null),blockHash:Ke.allowNull(o,null),blockNumber:Ke.allowNull(l,null),transactionIndex:Ke.allowNull(l,null),confirmations:Ke.allowNull(l,null),from:t,gasPrice:Ke.allowNull(r),maxPriorityFeePerGas:Ke.allowNull(r),maxFeePerGas:Ke.allowNull(r),gasLimit:r,to:Ke.allowNull(t,null),value:r,nonce:l,data:s,r:Ke.allowNull(this.uint256),s:Ke.allowNull(this.uint256),v:Ke.allowNull(l),creates:Ke.allowNull(t,null),raw:Ke.allowNull(s)},e.transactionRequest={from:Ke.allowNull(t),nonce:Ke.allowNull(l),gasLimit:Ke.allowNull(r),gasPrice:Ke.allowNull(r),maxPriorityFeePerGas:Ke.allowNull(r),maxFeePerGas:Ke.allowNull(r),to:Ke.allowNull(t),value:Ke.allowNull(r),data:Ke.allowNull(c),type:Ke.allowNull(l),accessList:Ke.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:l,blockNumber:l,transactionHash:o,address:t,topics:Ke.arrayOf(o),data:s,logIndex:l,blockHash:o},e.receipt={to:Ke.allowNull(this.address,null),from:Ke.allowNull(this.address,null),contractAddress:Ke.allowNull(t,null),transactionIndex:l,root:Ke.allowNull(a),gasUsed:r,logsBloom:Ke.allowNull(s),blockHash:o,transactionHash:o,logs:Ke.arrayOf(this.receiptLog.bind(this)),blockNumber:l,confirmations:Ke.allowNull(l,null),cumulativeGasUsed:r,effectiveGasPrice:Ke.allowNull(r),status:Ke.allowNull(l),type:A},e.block={hash:Ke.allowNull(o),parentHash:o,number:l,timestamp:l,nonce:Ke.allowNull(a),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:Ke.allowNull(t),extraData:s,transactions:Ke.allowNull(Ke.arrayOf(o)),baseFeePerGas:Ke.allowNull(r)},e.blockWithTransactions=xn(e.block),e.blockWithTransactions.transactions=Ke.allowNull(Ke.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:Ke.allowNull(i,void 0),toBlock:Ke.allowNull(i,void 0),blockHash:Ke.allowNull(o,void 0),address:Ke.allowNull(t,void 0),topics:Ke.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:Ke.allowNull(l),blockHash:Ke.allowNull(o),transactionIndex:l,removed:Ke.allowNull(this.boolean.bind(this)),address:t,data:Ke.allowFalsish(s,"0x"),topics:Ke.arrayOf(o),transactionHash:o,logIndex:l},e}accessList(e){return Iu(e||[])}number(e){return e==="0x"?0:De.from(e).toNumber()}type(e){return e==="0x"||e==null?0:De.from(e).toNumber()}bigNumber(e){return De.from(e)}boolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){if(e=e.toLowerCase(),e==="true")return!0;if(e==="false")return!1}throw new Error("invalid boolean - "+e)}hex(e,t){return typeof e=="string"&&(!t&&e.substring(0,2)!=="0x"&&(e="0x"+e),bt(e))?e.toLowerCase():up.throwArgumentError("invalid hash","value",e)}data(e,t){const r=this.hex(e,t);if(r.length%2!==0)throw new Error("invalid data; odd-length - "+e);return r}address(e){return kr(e)}callAddress(e){if(!bt(e,32))return null;const t=kr(Jr(e,12));return t===A9?null:t}contractAddress(e){return nP(e)}blockTag(e){if(e==null)return"latest";if(e==="earliest")return"0x0";switch(e){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return e}if(typeof e=="number"||bt(e))return yC(e);throw new Error("invalid blockTag")}hash(e,t){const r=this.hex(e,t);return au(r)!==32?up.throwArgumentError("invalid hash","value",e):r}difficulty(e){if(e==null)return null;const t=De.from(e);try{return t.toNumber()}catch{}return null}uint256(e){if(!bt(e))throw new Error("invalid uint256");return Ln(e,32)}_block(e,t){e.author!=null&&e.miner==null&&(e.miner=e.author);const r=e._difficulty!=null?e._difficulty:e.difficulty,i=Ke.check(t,e);return i._difficulty=r==null?null:De.from(r),i}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return Ke.check(this.formats.transactionRequest,e)}transactionResponse(e){e.gas!=null&&e.gasLimit==null&&(e.gasLimit=e.gas),e.to&&De.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),e.input!=null&&e.data==null&&(e.data=e.input),e.to==null&&e.creates==null&&(e.creates=this.contractAddress(e)),(e.type===1||e.type===2)&&e.accessList==null&&(e.accessList=[]);const t=Ke.check(this.formats.transaction,e);if(e.chainId!=null){let r=e.chainId;bt(r)&&(r=De.from(r).toNumber()),t.chainId=r}else{let r=e.networkId;r==null&&t.v==null&&(r=e.chainId),bt(r)&&(r=De.from(r).toNumber()),typeof r!="number"&&t.v!=null&&(r=(t.v-35)/2,r<0&&(r=0),r=parseInt(r)),typeof r!="number"&&(r=0),t.chainId=r}return t.blockHash&&t.blockHash.replace(/0/g,"")==="x"&&(t.blockHash=null),t}transaction(e){return u6(e)}receiptLog(e){return Ke.check(this.formats.receiptLog,e)}receipt(e){const t=Ke.check(this.formats.receipt,e);if(t.root!=null)if(t.root.length<=4){const r=De.from(t.root).toNumber();r===0||r===1?(t.status!=null&&t.status!==r&&up.throwArgumentError("alt-root-status/status mismatch","value",{root:t.root,status:t.status}),t.status=r,delete t.root):up.throwArgumentError("invalid alt-root-status","value.root",t.root)}else t.root.length!==66&&up.throwArgumentError("invalid root hash","value.root",t.root);return t.status!=null&&(t.byzantium=!0),t}topics(e){return Array.isArray(e)?e.map(t=>this.topics(t)):e!=null?this.hash(e,!0):null}filter(e){return Ke.check(this.formats.filter,e)}filterLog(e){return Ke.check(this.formats.filterLog,e)}static check(e,t){const r={};for(const i in e)try{const s=e[i](t[i]);s!==void 0&&(r[i]=s)}catch(s){throw s.checkKey=i,s.checkValue=t[i],s}return r}static allowNull(e,t){return function(r){return r==null?t:e(r)}}static allowFalsish(e,t){return function(r){return r?e(r):t}}static arrayOf(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");const r=[];return t.forEach(function(i){r.push(e(i))}),r}}};function f6(n){return n&&typeof n.isCommunityResource=="function"}function HR(n){return f6(n)&&n.isCommunityResource()}let zR=!1;function UC(){zR||(zR=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var dt=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const wt=new ce(ti),d6=10;function YR(n){return n==null?"null":(au(n)!==32&&wt.throwArgumentError("invalid topic","topic",n),n.toLowerCase())}function XR(n){for(n=n.slice();n.length>0&&n[n.length-1]==null;)n.pop();return n.map(e=>{if(Array.isArray(e)){const t={};e.forEach(i=>{t[YR(i)]=!0});const r=Object.keys(t);return r.sort(),r.join("|")}else return YR(e)}).join("&")}function h6(n){return n===""?[]:n.split(/&/g).map(e=>{if(e==="")return[];const t=e.split("|").map(r=>r==="null"?null:r);return t.length===1?t[0]:t})}function Ju(n){if(typeof n=="string"){if(n=n.toLowerCase(),au(n)===32)return"tx:"+n;if(n.indexOf(":")===-1)return n}else{if(Array.isArray(n))return"filter:*:"+XR(n);if(o9.isForkEvent(n))throw wt.warn("not implemented"),new Error("not implemented");if(n&&typeof n=="object")return"filter:"+(n.address||"*")+":"+XR(n.topics||[])}throw new Error("invalid event - "+n)}function fp(){return new Date().getTime()}function KR(n){return new Promise(e=>{setTimeout(e,n)})}const p6=["block","network","pending","poll"];let g6=class{constructor(e,t,r){Ie(this,"tag",e),Ie(this,"listener",t),Ie(this,"once",r),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const e=this.tag.split(":");return e[0]!=="tx"?null:e[1]}get filter(){const e=this.tag.split(":");if(e[0]!=="filter")return null;const t=e[1],r=h6(e[2]),i={};return r.length>0&&(i.topics=r),t&&t!=="*"&&(i.address=t),i}pollable(){return this.tag.indexOf(":")>=0||p6.indexOf(this.tag)>=0}};const m6={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function ix(n){return Ln(De.from(n).toHexString(),32)}function jR(n){return X1.encode(rs([n,Jr(PR(PR(n)),0,4)]))}const TP=new RegExp("^(ipfs)://(.*)$","i"),$R=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),TP,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Py(n,e){try{return e0($g(n,e))}catch{}return null}function $g(n,e){if(n==="0x")return null;const t=De.from(Jr(n,e,e+32)).toNumber(),r=De.from(Jr(n,t,t+32)).toNumber();return Jr(n,t+32,t+32+r)}function sx(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):wt.throwArgumentError("unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}function qR(n){const e=lt(n);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function v6(n){if(n.length%32===0)return n;const e=new Uint8Array(Math.ceil(n.length/32)*32);return e.set(n),e}function NP(n){const e=[];let t=0;for(let r=0;rDe.from(e).eq(1)).catch(e=>{if(e.code===ce.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,e})),this._supportsEip2544}_fetch(e,t){return dt(this,void 0,void 0,function*(){const r={to:this.address,ccipReadEnabled:!0,data:Ui([e,ky(this.name),t||"0x"])};let i=!1;(yield this.supportsWildcard())&&(i=!0,r.data=Ui(["0x9061b923",NP([J9(this.name),r.data])]));try{let s=yield this.provider.call(r);return lt(s).length%32===4&&wt.throwError("resolver threw error",ce.errors.CALL_EXCEPTION,{transaction:r,data:s}),i&&(s=$g(s,0)),s}catch(s){if(s.code===ce.errors.CALL_EXCEPTION)return null;throw s}})}_fetchBytes(e,t){return dt(this,void 0,void 0,function*(){const r=yield this._fetch(e,t);return r!=null?$g(r,0):null})}_getAddress(e,t){const r=m6[String(e)];if(r==null&&wt.throwError(`unsupported coin type: ${e}`,ce.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),r.ilk==="eth")return this.provider.formatter.address(t);const i=lt(t);if(r.p2pkh!=null){const s=t.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(s){const o=parseInt(s[1],16);if(s[2].length===o*2&&o>=1&&o<=75)return jR(rs([[r.p2pkh],"0x"+s[2]]))}}if(r.p2sh!=null){const s=t.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(s){const o=parseInt(s[1],16);if(s[2].length===o*2&&o>=1&&o<=75)return jR(rs([[r.p2sh],"0x"+s[2]]))}}if(r.prefix!=null){const s=i[1];let o=i[0];if(o===0?s!==20&&s!==32&&(o=-1):o=-1,o>=0&&i.length===2+s&&s>=1&&s<=75){const a=OR.toWords(i.slice(2));return a.unshift(o),OR.encode(r.prefix,a)}}return null}getAddress(e){return dt(this,void 0,void 0,function*(){if(e==null&&(e=60),e===60)try{const i=yield this._fetch("0x3b3b57de");return i==="0x"||i===d9?null:this.provider.formatter.callAddress(i)}catch(i){if(i.code===ce.errors.CALL_EXCEPTION)return null;throw i}const t=yield this._fetchBytes("0xf1cb7e06",ix(e));if(t==null||t==="0x")return null;const r=this._getAddress(e,t);return r==null&&wt.throwError("invalid or unsupported coin data",ce.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:t}),r})}getAvatar(){return dt(this,void 0,void 0,function*(){const e=[{type:"name",content:this.name}];try{const t=yield this.getText("avatar");if(t==null)return null;for(let r=0;r<$R.length;r++){const i=t.match($R[r]);if(i==null)continue;const s=i[1].toLowerCase();switch(s){case"https":return e.push({type:"url",content:t}),{linkage:e,url:t};case"data":return e.push({type:"data",content:t}),{linkage:e,url:t};case"ipfs":return e.push({type:"ipfs",content:t}),{linkage:e,url:sx(t)};case"erc721":case"erc1155":{const o=s==="erc721"?"0xc87b56dd":"0x0e89341c";e.push({type:s,content:t});const a=this._resolvedAddress||(yield this.getAddress()),l=(i[2]||"").split("/");if(l.length!==2)return null;const A=yield this.provider.formatter.address(l[0]),c=Ln(De.from(l[1]).toHexString(),32);if(s==="erc721"){const p=this.provider.formatter.callAddress(yield this.provider.call({to:A,data:Ui(["0x6352211e",c])}));if(a!==p)return null;e.push({type:"owner",content:p})}else if(s==="erc1155"){const p=De.from(yield this.provider.call({to:A,data:Ui(["0x00fdd58e",Ln(a,32),c])}));if(p.isZero())return null;e.push({type:"balance",content:p.toString()})}const u={to:this.provider.formatter.address(l[0]),data:Ui([o,c])};let f=Py(yield this.provider.call(u),0);if(f==null)return null;e.push({type:"metadata-url-base",content:f}),s==="erc1155"&&(f=f.replace("{id}",c.substring(2)),e.push({type:"metadata-url-expanded",content:f})),f.match(/^ipfs:/i)&&(f=sx(f)),e.push({type:"metadata-url",content:f});const d=yield xC(f);if(!d)return null;e.push({type:"metadata",content:JSON.stringify(d)});let h=d.image;if(typeof h!="string")return null;if(!h.match(/^(https:\/\/|data:)/i)){if(h.match(TP)==null)return null;e.push({type:"url-ipfs",content:h}),h=sx(h)}return e.push({type:"url",content:h}),{linkage:e,url:h}}}}}catch{}return null})}getContentHash(){return dt(this,void 0,void 0,function*(){const e=yield this._fetchBytes("0xbc1c58d1");if(e==null||e==="0x")return null;const t=e.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const o=parseInt(t[3],16);if(t[4].length===o*2)return"ipfs://"+X1.encode("0x"+t[1])}const r=e.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(r){const o=parseInt(r[3],16);if(r[4].length===o*2)return"ipns://"+X1.encode("0x"+r[1])}const i=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(i&&i[1].length===32*2)return"bzz://"+i[1];const s=e.match(/^0x90b2c605([0-9a-f]*)$/);if(s&&s[1].length===34*2){const o={"=":"","+":"-","/":"_"};return"sia://"+P3("0x"+s[1]).replace(/[=+\/]/g,l=>o[l])}return wt.throwError("invalid or unsupported content hash data",ce.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})})}getText(e){return dt(this,void 0,void 0,function*(){let t=Ia(e);t=rs([ix(64),ix(t.length),t]),t.length%32!==0&&(t=rs([t,Ln("0x",32-e.length%32)]));const r=yield this._fetchBytes("0x59d1d43c",$e(t));return r==null||r==="0x"?null:e0(r)})}}let ox=null,y6=1;class qU extends qm{constructor(e){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),Ie(this,"anyNetwork",e==="any"),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch(t=>{}),this._ready().catch(t=>{});else{const t=is(new.target,"getNetwork")(e);t?(Ie(this,"_network",t),this.emit("network",t,null)):wt.throwArgumentError("invalid network","network",e)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return dt(this,void 0,void 0,function*(){if(this._network==null){let e=null;if(this._networkPromise)try{e=yield this._networkPromise}catch{}e==null&&(e=yield this.detectNetwork()),e||wt.throwError("no network detected",ce.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=e:Ie(this,"_network",e),this.emit("network",e,null))}return this._network})}get ready(){return id(()=>this._ready().then(e=>e,e=>{if(!(e.code===ce.errors.NETWORK_ERROR&&e.event==="noNetwork"))throw e}))}static getFormatter(){return ox==null&&(ox=new JR),ox}static getNetwork(e){return V3(e??"homestead")}ccipReadFetch(e,t,r){return dt(this,void 0,void 0,function*(){if(this.disableCcipRead||r.length===0)return null;const i=e.to.toLowerCase(),s=t.toLowerCase(),o=[];for(let a=0;a=0?null:JSON.stringify({data:s,sender:i}),u=yield xC({url:A,errorPassThrough:!0},c,(d,h)=>(d.status=h.statusCode,d));if(u.data)return u.data;const f=u.message||"unknown error";if(u.status>=400&&u.status<500)return wt.throwError(`response not found during CCIP fetch: ${f}`,ce.errors.SERVER_ERROR,{url:l,errorMessage:f});o.push(f)}return wt.throwError(`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,ce.errors.SERVER_ERROR,{urls:r,errorMessages:o})})}_getInternalBlockNumber(e){return dt(this,void 0,void 0,function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){const i=this._internalBlockNumber;try{const s=yield i;if(fp()-s.respTime<=e)return s.blockNumber;break}catch{if(this._internalBlockNumber===i)break}}const t=fp(),r=jn({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(i=>null,i=>i)}).then(({blockNumber:i,networkError:s})=>{if(s)throw this._internalBlockNumber===r&&(this._internalBlockNumber=null),s;const o=fp();return i=De.from(i).toNumber(),i{this._internalBlockNumber===r&&(this._internalBlockNumber=null)}),(yield r).blockNumber})}poll(){return dt(this,void 0,void 0,function*(){const e=y6++,t=[];let r=null;try{r=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(i){this.emit("error",i);return}if(this._setFastBlockNumber(r),this.emit("poll",e,r),r===this._lastBlockNumber){this.emit("didPoll",e);return}if(this._emitted.block===-2&&(this._emitted.block=r-1),Math.abs(this._emitted.block-r)>1e3)wt.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${r})`),this.emit("error",wt.makeError("network block skew detected",ce.errors.NETWORK_ERROR,{blockNumber:r,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",r);else for(let i=this._emitted.block+1;i<=r;i++)this.emit("block",i);this._emitted.block!==r&&(this._emitted.block=r,Object.keys(this._emitted).forEach(i=>{if(i==="block")return;const s=this._emitted[i];s!=="pending"&&r-s>12&&delete this._emitted[i]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=r-1),this._events.forEach(i=>{switch(i.type){case"tx":{const s=i.hash;let o=this.getTransactionReceipt(s).then(a=>(!a||a.blockNumber==null||(this._emitted["t:"+s]=a.blockNumber,this.emit(s,a)),null)).catch(a=>{this.emit("error",a)});t.push(o);break}case"filter":{if(!i._inflight){i._inflight=!0,i._lastBlockNumber===-2&&(i._lastBlockNumber=r-1);const s=i.filter;s.fromBlock=i._lastBlockNumber+1,s.toBlock=r;const o=s.toBlock-this._maxFilterBlockRange;o>s.fromBlock&&(s.fromBlock=o),s.fromBlock<0&&(s.fromBlock=0);const a=this.getLogs(s).then(l=>{i._inflight=!1,l.length!==0&&l.forEach(A=>{A.blockNumber>i._lastBlockNumber&&(i._lastBlockNumber=A.blockNumber),this._emitted["b:"+A.blockHash]=A.blockNumber,this._emitted["t:"+A.transactionHash]=A.blockNumber,this.emit(s,A)})}).catch(l=>{this.emit("error",l),i._inflight=!1});t.push(a)}break}}}),this._lastBlockNumber=r,Promise.all(t).then(()=>{this.emit("didPoll",e)}).catch(i=>{this.emit("error",i)})})}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return dt(this,void 0,void 0,function*(){return wt.throwError("provider does not support network detection",ce.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return dt(this,void 0,void 0,function*(){const e=yield this._ready(),t=yield this.detectNetwork();if(e.chainId!==t.chainId){if(this.anyNetwork)return this._network=t,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",t,e),yield KR(0),this._network;const r=wt.makeError("underlying network changed",ce.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:t});throw this.emit("error",r),r}return e})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(e=>{this._setFastBlockNumber(e)},e=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(e){e&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if(typeof e!="number"||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const e=fp();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(e){this._fastBlockNumber!=null&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}waitForTransaction(e,t,r){return dt(this,void 0,void 0,function*(){return this._waitForTransaction(e,t??1,r||0,null)})}_waitForTransaction(e,t,r,i){return dt(this,void 0,void 0,function*(){const s=yield this.getTransactionReceipt(e);return(s?s.confirmations:0)>=t?s:new Promise((o,a)=>{const l=[];let A=!1;const c=function(){return A?!0:(A=!0,l.forEach(f=>{f()}),!1)},u=f=>{f.confirmations{this.removeListener(e,u)}),i){let f=i.startBlock,d=null;const h=p=>dt(this,void 0,void 0,function*(){A||(yield KR(1e3),this.getTransactionCount(i.from).then(m=>dt(this,void 0,void 0,function*(){if(!A){if(m<=i.nonce)f=p;else{{const g=yield this.getTransaction(e);if(g&&g.blockNumber!=null)return}for(d==null&&(d=f-3,d{A||this.once("block",h)}))});if(A)return;this.once("block",h),l.push(()=>{this.removeListener("block",h)})}if(typeof r=="number"&&r>0){const f=setTimeout(()=>{c()||a(wt.makeError("timeout exceeded",ce.errors.TIMEOUT,{timeout:r}))},r);f.unref&&f.unref(),l.push(()=>{clearTimeout(f)})}})})}getBlockNumber(){return dt(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const e=yield this.perform("getGasPrice",{});try{return De.from(e)}catch(t){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:t})}})}getBalance(e,t){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield jn({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),i=yield this.perform("getBalance",r);try{return De.from(i)}catch(s){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getBalance",params:r,result:i,error:s})}})}getTransactionCount(e,t){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield jn({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),i=yield this.perform("getTransactionCount",r);try{return De.from(i).toNumber()}catch(s){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getTransactionCount",params:r,result:i,error:s})}})}getCode(e,t){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield jn({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),i=yield this.perform("getCode",r);try{return $e(i)}catch(s){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getCode",params:r,result:i,error:s})}})}getStorageAt(e,t,r){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const i=yield jn({address:this._getAddress(e),blockTag:this._getBlockTag(r),position:Promise.resolve(t).then(o=>yC(o))}),s=yield this.perform("getStorageAt",i);try{return $e(s)}catch(o){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getStorageAt",params:i,result:s,error:o})}})}_wrapTransaction(e,t,r){if(t!=null&&au(t)!==32)throw new Error("invalid response - sendTransaction");const i=e;return t!=null&&e.hash!==t&&wt.throwError("Transaction hash mismatch from Provider.sendTransaction.",ce.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:t}),i.wait=(s,o)=>dt(this,void 0,void 0,function*(){s==null&&(s=1),o==null&&(o=0);let a;s!==0&&r!=null&&(a={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:r});const l=yield this._waitForTransaction(e.hash,s,o,a);return l==null&&s===0?null:(this._emitted["t:"+e.hash]=l.blockNumber,l.status===0&&wt.throwError("transaction failed",ce.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:l}),l)}),i}sendTransaction(e){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield Promise.resolve(e).then(s=>$e(s)),r=this.formatter.transaction(e);r.confirmations==null&&(r.confirmations=0);const i=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const s=yield this.perform("sendTransaction",{signedTransaction:t});return this._wrapTransaction(r,s,i)}catch(s){throw s.transaction=r,s.transactionHash=r.hash,s}})}_getTransactionRequest(e){return dt(this,void 0,void 0,function*(){const t=yield e,r={};return["from","to"].forEach(i=>{t[i]!=null&&(r[i]=Promise.resolve(t[i]).then(s=>s?this._getAddress(s):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(i=>{t[i]!=null&&(r[i]=Promise.resolve(t[i]).then(s=>s?De.from(s):null))}),["type"].forEach(i=>{t[i]!=null&&(r[i]=Promise.resolve(t[i]).then(s=>s??null))}),t.accessList&&(r.accessList=this.formatter.accessList(t.accessList)),["data"].forEach(i=>{t[i]!=null&&(r[i]=Promise.resolve(t[i]).then(s=>s?$e(s):null))}),this.formatter.transactionRequest(yield jn(r))})}_getFilter(e){return dt(this,void 0,void 0,function*(){e=yield e;const t={};return e.address!=null&&(t.address=this._getAddress(e.address)),["blockHash","topics"].forEach(r=>{e[r]!=null&&(t[r]=e[r])}),["fromBlock","toBlock"].forEach(r=>{e[r]!=null&&(t[r]=this._getBlockTag(e[r]))}),this.formatter.filter(yield jn(t))})}_call(e,t,r){return dt(this,void 0,void 0,function*(){r>=d6&&wt.throwError("CCIP read exceeded maximum redirections",ce.errors.SERVER_ERROR,{redirects:r,transaction:e});const i=e.to,s=yield this.perform("call",{transaction:e,blockTag:t});if(r>=0&&t==="latest"&&i!=null&&s.substring(0,10)==="0x556f1830"&&au(s)%32===4)try{const o=Jr(s,4),a=Jr(o,0,32);De.from(a).eq(i)||wt.throwError("CCIP Read sender did not match",ce.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:s});const l=[],A=De.from(Jr(o,32,64)).toNumber(),c=De.from(Jr(o,A,A+32)).toNumber(),u=Jr(o,A+32);for(let g=0;gdt(this,void 0,void 0,function*(){const s=yield this.perform("getBlock",i);if(s==null)return i.blockHash!=null&&this._emitted["b:"+i.blockHash]==null||i.blockTag!=null&&r>this._emitted.block?null:void 0;if(t){let o=null;for(let l=0;lthis._wrapTransaction(l)),a}return this.formatter.block(s)}),{oncePoll:this})})}getBlock(e){return this._getBlock(e,!1)}getBlockWithTransactions(e){return this._getBlock(e,!0)}getTransaction(e){return dt(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return id(()=>dt(this,void 0,void 0,function*(){const r=yield this.perform("getTransaction",t);if(r==null)return this._emitted["t:"+e]==null?null:void 0;const i=this.formatter.transactionResponse(r);if(i.blockNumber==null)i.confirmations=0;else if(i.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-i.blockNumber+1;o<=0&&(o=1),i.confirmations=o}return this._wrapTransaction(i)}),{oncePoll:this})})}getTransactionReceipt(e){return dt(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return id(()=>dt(this,void 0,void 0,function*(){const r=yield this.perform("getTransactionReceipt",t);if(r==null)return this._emitted["t:"+e]==null?null:void 0;if(r.blockHash==null)return;const i=this.formatter.receipt(r);if(i.blockNumber==null)i.confirmations=0;else if(i.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-i.blockNumber+1;o<=0&&(o=1),i.confirmations=o}return i}),{oncePoll:this})})}getLogs(e){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield jn({filter:this._getFilter(e)}),r=yield this.perform("getLogs",t);return r.forEach(i=>{i.removed==null&&(i.removed=!1)}),JR.arrayOf(this.formatter.filterLog.bind(this.formatter))(r)})}getEtherPrice(){return dt(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(e){return dt(this,void 0,void 0,function*(){if(e=yield e,typeof e=="number"&&e<0){e%1&&wt.throwArgumentError("invalid BlockTag","blockTag",e);let t=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return t+=e,t<0&&(t=0),this.formatter.blockTag(t)}return this.formatter.blockTag(e)})}getResolver(e){return dt(this,void 0,void 0,function*(){let t=e;for(;;){if(t===""||t==="."||e!=="eth"&&t==="eth")return null;const r=yield this._getResolver(t,"getResolver");if(r!=null){const i=new eM(this,r,e);return t!==e&&!(yield i.supportsWildcard())?null:i}t=t.split(".").slice(1).join(".")}})}_getResolver(e,t){return dt(this,void 0,void 0,function*(){t==null&&(t="ENS");const r=yield this.getNetwork();r.ensAddress||wt.throwError("network does not support ENS",ce.errors.UNSUPPORTED_OPERATION,{operation:t,network:r.name});try{const i=yield this.call({to:r.ensAddress,data:"0x0178b8bf"+ky(e).substring(2)});return this.formatter.callAddress(i)}catch{}return null})}resolveName(e){return dt(this,void 0,void 0,function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(r){if(bt(e))throw r}typeof e!="string"&&wt.throwArgumentError("invalid ENS name","name",e);const t=yield this.getResolver(e);return t?yield t.getAddress():null})}lookupAddress(e){return dt(this,void 0,void 0,function*(){e=yield e,e=this.formatter.address(e);const t=e.substring(2).toLowerCase()+".addr.reverse",r=yield this._getResolver(t,"lookupAddress");if(r==null)return null;const i=Py(yield this.call({to:r,data:"0x691f3431"+ky(t).substring(2)}),0);return(yield this.resolveName(i))!=e?null:i})}getAvatar(e){return dt(this,void 0,void 0,function*(){let t=null;if(bt(e)){const s=this.formatter.address(e).substring(2).toLowerCase()+".addr.reverse",o=yield this._getResolver(s,"getAvatar");if(!o)return null;t=new eM(this,o,s);try{const a=yield t.getAvatar();if(a)return a.url}catch(a){if(a.code!==ce.errors.CALL_EXCEPTION)throw a}try{const a=Py(yield this.call({to:o,data:"0x691f3431"+ky(s).substring(2)}),0);t=yield this.getResolver(a)}catch(a){if(a.code!==ce.errors.CALL_EXCEPTION)throw a;return null}}else if(t=yield this.getResolver(e),!t)return null;const r=yield t.getAvatar();return r==null?null:r.url})}perform(e,t){return wt.throwError(e+" not implemented",ce.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter(t=>t.pollable()).length>0}_stopEvent(e){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(e,t,r){const i=new g6(Ju(e),t,r);return this._events.push(i),this._startEvent(i),this}on(e,t){return this._addEventListener(e,t,!1)}once(e,t){return this._addEventListener(e,t,!0)}emit(e,...t){let r=!1,i=[],s=Ju(e);return this._events=this._events.filter(o=>o.tag!==s?!0:(setTimeout(()=>{o.listener.apply(this,t)},0),r=!0,o.once?(i.push(o),!1):!0)),i.forEach(o=>{this._stopEvent(o)}),r}listenerCount(e){if(!e)return this._events.length;let t=Ju(e);return this._events.filter(r=>r.tag===t).length}listeners(e){if(e==null)return this._events.map(r=>r.listener);let t=Ju(e);return this._events.filter(r=>r.tag===t).map(r=>r.listener)}off(e,t){if(t==null)return this.removeAllListeners(e);const r=[];let i=!1,s=Ju(e);return this._events=this._events.filter(o=>o.tag!==s||o.listener!=t||i?!0:(i=!0,r.push(o),!1)),r.forEach(o=>{this._stopEvent(o)}),this}removeAllListeners(e){let t=[];if(e==null)t=this._events,this._events=[];else{const r=Ju(e);this._events=this._events.filter(i=>i.tag!==r?!0:(t.push(i),!1))}return t.forEach(r=>{this._stopEvent(r)}),this}}const B6="abstract-signer/5.7.0";var ho=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const _s=new ce(B6),w6=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],C6=[ce.errors.INSUFFICIENT_FUNDS,ce.errors.NONCE_EXPIRED,ce.errors.REPLACEMENT_UNDERPRICED];class n0{constructor(){_s.checkAbstract(new.target,n0),Ie(this,"_isSigner",!0)}getBalance(e){return ho(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),e)})}getTransactionCount(e){return ho(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),e)})}estimateGas(e){return ho(this,void 0,void 0,function*(){this._checkProvider("estimateGas");const t=yield jn(this.checkTransaction(e));return yield this.provider.estimateGas(t)})}call(e,t){return ho(this,void 0,void 0,function*(){this._checkProvider("call");const r=yield jn(this.checkTransaction(e));return yield this.provider.call(r,t)})}sendTransaction(e){return ho(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");const t=yield this.populateTransaction(e),r=yield this.signTransaction(t);return yield this.provider.sendTransaction(r)})}getChainId(){return ho(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return ho(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return ho(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(e){return ho(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(e)})}checkTransaction(e){for(const r in e)w6.indexOf(r)===-1&&_s.throwArgumentError("invalid transaction key: "+r,"transaction",e);const t=xn(e);return t.from==null?t.from=this.getAddress():t.from=Promise.all([Promise.resolve(t.from),this.getAddress()]).then(r=>(r[0].toLowerCase()!==r[1].toLowerCase()&&_s.throwArgumentError("from address mismatch","transaction",e),r[0])),t}populateTransaction(e){return ho(this,void 0,void 0,function*(){const t=yield jn(this.checkTransaction(e));t.to!=null&&(t.to=Promise.resolve(t.to).then(i=>ho(this,void 0,void 0,function*(){if(i==null)return null;const s=yield this.resolveName(i);return s==null&&_s.throwArgumentError("provided ENS name resolves to null","tx.to",i),s})),t.to.catch(i=>{}));const r=t.maxFeePerGas!=null||t.maxPriorityFeePerGas!=null;if(t.gasPrice!=null&&(t.type===2||r)?_s.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",e):(t.type===0||t.type===1)&&r&&_s.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",e),(t.type===2||t.type==null)&&t.maxFeePerGas!=null&&t.maxPriorityFeePerGas!=null)t.type=2;else if(t.type===0||t.type===1)t.gasPrice==null&&(t.gasPrice=this.getGasPrice());else{const i=yield this.getFeeData();if(t.type==null)if(i.maxFeePerGas!=null&&i.maxPriorityFeePerGas!=null)if(t.type=2,t.gasPrice!=null){const s=t.gasPrice;delete t.gasPrice,t.maxFeePerGas=s,t.maxPriorityFeePerGas=s}else t.maxFeePerGas==null&&(t.maxFeePerGas=i.maxFeePerGas),t.maxPriorityFeePerGas==null&&(t.maxPriorityFeePerGas=i.maxPriorityFeePerGas);else i.gasPrice!=null?(r&&_s.throwError("network does not support EIP-1559",ce.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),t.gasPrice==null&&(t.gasPrice=i.gasPrice),t.type=0):_s.throwError("failed to get consistent fee data",ce.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else t.type===2&&(t.maxFeePerGas==null&&(t.maxFeePerGas=i.maxFeePerGas),t.maxPriorityFeePerGas==null&&(t.maxPriorityFeePerGas=i.maxPriorityFeePerGas))}return t.nonce==null&&(t.nonce=this.getTransactionCount("pending")),t.gasLimit==null&&(t.gasLimit=this.estimateGas(t).catch(i=>{if(C6.indexOf(i.code)>=0)throw i;return _s.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",ce.errors.UNPREDICTABLE_GAS_LIMIT,{error:i,tx:t})})),t.chainId==null?t.chainId=this.getChainId():t.chainId=Promise.all([Promise.resolve(t.chainId),this.getChainId()]).then(i=>(i[1]!==0&&i[0]!==i[1]&&_s.throwArgumentError("chainId address mismatch","transaction",e),i[0])),yield jn(t)})}_checkProvider(e){this.provider||_s.throwError("missing provider",ce.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})}static isSigner(e){return!!(e&&e._isSigner)}}class eS extends n0{constructor(e,t){super(),Ie(this,"address",e),Ie(this,"provider",t||null)}getAddress(){return Promise.resolve(this.address)}_fail(e,t){return Promise.resolve().then(()=>{_s.throwError(e,ce.errors.UNSUPPORTED_OPERATION,{operation:t})})}signMessage(e){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(e,t,r){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(e){return new eS(this.address,e)}}var ol=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const $n=new ce(ti),b6=["call","estimateGas"];function Ug(n,e){if(n==null)return null;if(typeof n.message=="string"&&n.message.match("reverted")){const t=bt(n.data)?n.data:null;if(!e||t)return{message:n.message,data:t}}if(typeof n=="object"){for(const t in n){const r=Ug(n[t],e);if(r)return r}return null}if(typeof n=="string")try{return Ug(JSON.parse(n),e)}catch{}return null}function DP(n,e,t){const r=t.transaction||t.signedTransaction;if(n==="call"){const s=Ug(e,!0);if(s)return s.data;$n.throwError("missing revert data in call exception; Transaction reverted without a reason string",ce.errors.CALL_EXCEPTION,{data:"0x",transaction:r,error:e})}if(n==="estimateGas"){let s=Ug(e.body,!1);s==null&&(s=Ug(e,!1)),s&&$n.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",ce.errors.UNPREDICTABLE_GAS_LIMIT,{reason:s.message,method:n,transaction:r,error:e})}let i=e.message;throw e.code===ce.errors.SERVER_ERROR&&e.error&&typeof e.error.message=="string"?i=e.error.message:typeof e.body=="string"?i=e.body:typeof e.responseText=="string"&&(i=e.responseText),i=(i||"").toLowerCase(),i.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&$n.throwError("insufficient funds for intrinsic transaction cost",ce.errors.INSUFFICIENT_FUNDS,{error:e,method:n,transaction:r}),i.match(/nonce (is )?too low/i)&&$n.throwError("nonce has already been used",ce.errors.NONCE_EXPIRED,{error:e,method:n,transaction:r}),i.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&$n.throwError("replacement fee too low",ce.errors.REPLACEMENT_UNDERPRICED,{error:e,method:n,transaction:r}),i.match(/only replay-protected/i)&&$n.throwError("legacy pre-eip-155 transactions not supported",ce.errors.UNSUPPORTED_OPERATION,{error:e,method:n,transaction:r}),b6.indexOf(n)>=0&&i.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&$n.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",ce.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:n,transaction:r}),e}function tM(n){return new Promise(function(e){setTimeout(e,n)})}function x6(n){if(n.error){const e=new Error(n.error.message);throw e.code=n.error.code,e.data=n.error.data,e}return n.result}function dp(n){return n&&n.toLowerCase()}const nF={};class kP extends n0{constructor(e,t,r){if(super(),e!==nF)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");Ie(this,"provider",t),r==null&&(r=0),typeof r=="string"?(Ie(this,"_address",this.provider.formatter.address(r)),Ie(this,"_index",null)):typeof r=="number"?(Ie(this,"_index",r),Ie(this,"_address",null)):$n.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(e){return $n.throwError("cannot alter JSON-RPC Signer connection",ce.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new I6(nF,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(e=>(e.length<=this._index&&$n.throwError("unknown account #"+this._index,ce.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index])))}sendUncheckedTransaction(e){e=xn(e);const t=this.getAddress().then(r=>(r&&(r=r.toLowerCase()),r));if(e.gasLimit==null){const r=xn(e);r.from=t,e.gasLimit=this.provider.estimateGas(r)}return e.to!=null&&(e.to=Promise.resolve(e.to).then(r=>ol(this,void 0,void 0,function*(){if(r==null)return null;const i=yield this.provider.resolveName(r);return i==null&&$n.throwArgumentError("provided ENS name resolves to null","tx.to",r),i}))),jn({tx:jn(e),sender:t}).then(({tx:r,sender:i})=>{r.from!=null?r.from.toLowerCase()!==i&&$n.throwArgumentError("from address mismatch","transaction",e):r.from=i;const s=this.provider.constructor.hexlifyTransaction(r,{from:!0});return this.provider.send("eth_sendTransaction",[s]).then(o=>o,o=>(typeof o.message=="string"&&o.message.match(/user denied/i)&&$n.throwError("user rejected transaction",ce.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:r}),DP("sendTransaction",o,s)))})}signTransaction(e){return $n.throwError("signing transactions is unsupported",ce.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return ol(this,void 0,void 0,function*(){const t=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),r=yield this.sendUncheckedTransaction(e);try{return yield id(()=>ol(this,void 0,void 0,function*(){const i=yield this.provider.getTransaction(r);if(i!==null)return this.provider._wrapTransaction(i,r,t)}),{oncePoll:this.provider})}catch(i){throw i.transactionHash=r,i}})}signMessage(e){return ol(this,void 0,void 0,function*(){const t=typeof e=="string"?Ia(e):e,r=yield this.getAddress();try{return yield this.provider.send("personal_sign",[$e(t),r.toLowerCase()])}catch(i){throw typeof i.message=="string"&&i.message.match(/user denied/i)&&$n.throwError("user rejected signing",ce.errors.ACTION_REJECTED,{action:"signMessage",from:r,messageData:e}),i}})}_legacySignMessage(e){return ol(this,void 0,void 0,function*(){const t=typeof e=="string"?Ia(e):e,r=yield this.getAddress();try{return yield this.provider.send("eth_sign",[r.toLowerCase(),$e(t)])}catch(i){throw typeof i.message=="string"&&i.message.match(/user denied/i)&&$n.throwError("user rejected signing",ce.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:r,messageData:e}),i}})}_signTypedData(e,t,r){return ol(this,void 0,void 0,function*(){const i=yield Xi.resolveNames(e,t,r,o=>this.provider.resolveName(o)),s=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[s.toLowerCase(),JSON.stringify(Xi.getPayload(i.domain,t,i.value))])}catch(o){throw typeof o.message=="string"&&o.message.match(/user denied/i)&&$n.throwError("user rejected signing",ce.errors.ACTION_REJECTED,{action:"_signTypedData",from:s,messageData:{domain:i.domain,types:t,value:i.value}}),o}})}unlock(e){return ol(this,void 0,void 0,function*(){const t=this.provider,r=yield this.getAddress();return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})}}class I6 extends kP{sendTransaction(e){return this.sendUncheckedTransaction(e).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:r=>this.provider.waitForTransaction(t,r)}))}}const F6={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class qg extends qU{constructor(e,t){let r=t;r==null&&(r=new Promise((i,s)=>{setTimeout(()=>{this.detectNetwork().then(o=>{i(o)},o=>{s(o)})},0)})),super(r),e||(e=is(this.constructor,"defaultUrl")()),typeof e=="string"?Ie(this,"connection",Object.freeze({url:e})):Ie(this,"connection",Object.freeze(xn(e))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return ol(this,void 0,void 0,function*(){yield tM(0);let e=null;try{e=yield this.send("eth_chainId",[])}catch{try{e=yield this.send("net_version",[])}catch{}}if(e!=null){const t=is(this.constructor,"getNetwork");try{return t(De.from(e).toNumber())}catch(r){return $n.throwError("could not detect network",ce.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:r})}}return $n.throwError("could not detect network",ce.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(e){return new kP(nF,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(e=>e.map(t=>this.formatter.address(t)))}send(e,t){const r={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:as(r),provider:this});const i=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(i&&this._cache[e])return this._cache[e];const s=xC(this.connection,JSON.stringify(r),x6).then(o=>(this.emit("debug",{action:"response",request:r,response:o,provider:this}),o),o=>{throw this.emit("debug",{action:"response",error:o,request:r,provider:this}),o});return i&&(this._cache[e]=s,setTimeout(()=>{this._cache[e]=null},0)),s}prepareRequest(e,t){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[dp(t.address),t.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[dp(t.address),t.blockTag]];case"getCode":return["eth_getCode",[dp(t.address),t.blockTag]];case"getStorageAt":return["eth_getStorageAt",[dp(t.address),Ln(t.position,32),t.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[t.signedTransaction]];case"getBlock":return t.blockTag?["eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]]:t.blockHash?["eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[t.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[t.transactionHash]];case"call":return["eth_call",[is(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0}),t.blockTag]];case"estimateGas":return["eth_estimateGas",[is(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0})]];case"getLogs":return t.filter&&t.filter.address!=null&&(t.filter.address=dp(t.filter.address)),["eth_getLogs",[t.filter]]}return null}perform(e,t){return ol(this,void 0,void 0,function*(){if(e==="call"||e==="estimateGas"){const i=t.transaction;if(i&&i.type!=null&&De.from(i.type).isZero()&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=yield this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(t=xn(t),t.transaction=xn(i),delete t.transaction.type)}}const r=this.prepareRequest(e,t);r==null&&$n.throwError(e+" not implemented",ce.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(r[0],r[1])}catch(i){return DP(e,i,t)}})}_startEvent(e){e.tag==="pending"&&this._startPending(),super._startEvent(e)}_startPending(){if(this._pendingFilter!=null)return;const e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){function i(){e.send("eth_getFilterChanges",[r]).then(function(s){if(e._pendingFilter!=t)return null;let o=Promise.resolve();return s.forEach(function(a){e._emitted["t:"+a.toLowerCase()]="pending",o=o.then(function(){return e.getTransaction(a).then(function(l){return e.emit("pending",l),null})})}),o.then(function(){return tM(1e3)})}).then(function(){if(e._pendingFilter!=t){e.send("eth_uninstallFilter",[r]);return}return setTimeout(function(){i()},0),null}).catch(s=>{})}return i(),r}).catch(r=>{})}_stopEvent(e){e.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(e)}static hexlifyTransaction(e,t){const r=xn(F6);if(t)for(const s in t)t[s]&&(r[s]=!0);e9(e,r);const i={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(s){if(e[s]==null)return;const o=yC(De.from(e[s]));s==="gasLimit"&&(s="gas"),i[s]=o}),["from","to","data"].forEach(function(s){e[s]!=null&&(i[s]=$e(e[s]))}),e.accessList&&(i.accessList=Iu(e.accessList)),i}}let Sg=null;try{if(Sg=WebSocket,Sg==null)throw new Error("inject please")}catch{const e=new ce(ti);Sg=function(){e.throwError("WebSockets not supported in this environment",ce.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var ax=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const k0=new ce(ti);let E6=1;class tS extends qg{constructor(e,t){t==="any"&&k0.throwError("WebSocketProvider does not support 'any' network yet",ce.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),typeof e=="string"?super(e,t):super("_websocket",t),this._pollingInterval=-1,this._wsReady=!1,typeof e=="string"?Ie(this,"_websocket",new Sg(this.connection.url)):Ie(this,"_websocket",e),Ie(this,"_requests",{}),Ie(this,"_subs",{}),Ie(this,"_subIds",{}),Ie(this,"_detectNetwork",super.detectNetwork()),this.websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach(i=>{this.websocket.send(this._requests[i].payload)})},this.websocket.onmessage=i=>{const s=i.data,o=JSON.parse(s);if(o.id!=null){const a=String(o.id),l=this._requests[a];if(delete this._requests[a],o.result!==void 0)l.callback(null,o.result),this.emit("debug",{action:"response",request:JSON.parse(l.payload),response:o.result,provider:this});else{let A=null;o.error?(A=new Error(o.error.message||"unknown error"),Ie(A,"code",o.error.code||null),Ie(A,"response",s)):A=new Error("unknown error"),l.callback(A,void 0),this.emit("debug",{action:"response",error:A,request:JSON.parse(l.payload),provider:this})}}else if(o.method==="eth_subscription"){const a=this._subs[o.params.subscription];a&&a.processFunc(o.params.result)}else console.warn("this should not happen")};const r=setInterval(()=>{this.emit("poll")},1e3);r.unref&&r.unref()}get websocket(){return this._websocket}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(e){k0.throwError("cannot reset events block on WebSocketProvider",ce.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(e){k0.throwError("cannot set polling interval on WebSocketProvider",ce.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return ax(this,void 0,void 0,function*(){return null})}set polling(e){e&&k0.throwError("cannot set polling on WebSocketProvider",ce.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(e,t){const r=E6++;return new Promise((i,s)=>{function o(l,A){return l?s(l):i(A)}const a=JSON.stringify({method:e,params:t,id:r,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(a),provider:this}),this._requests[String(r)]={callback:o,payload:a},this._wsReady&&this.websocket.send(a)})}static defaultUrl(){return"ws://localhost:8546"}_subscribe(e,t,r){return ax(this,void 0,void 0,function*(){let i=this._subIds[e];i==null&&(i=Promise.all(t).then(o=>this.send("eth_subscribe",o)),this._subIds[e]=i);const s=yield i;this._subs[s]={tag:e,processFunc:r}})}_startEvent(e){switch(e.type){case"block":this._subscribe("block",["newHeads"],t=>{const r=De.from(t.number).toNumber();this._emitted.block=r,this.emit("block",r)});break;case"pending":this._subscribe("pending",["newPendingTransactions"],t=>{this.emit("pending",t)});break;case"filter":this._subscribe(e.tag,["logs",this._getFilter(e.filter)],t=>{t.removed==null&&(t.removed=!1),this.emit(e.filter,this.formatter.filterLog(t))});break;case"tx":{const t=r=>{const i=r.hash;this.getTransactionReceipt(i).then(s=>{s&&this.emit(i,s)})};t(e),this._subscribe("tx",["newHeads"],r=>{this._events.filter(i=>i.type==="tx").forEach(t)});break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",e);break}}_stopEvent(e){let t=e.tag;if(e.type==="tx"){if(this._events.filter(i=>i.type==="tx").length)return;t="tx"}else if(this.listenerCount(e.event))return;const r=this._subIds[t];r&&(delete this._subIds[t],r.then(i=>{this._subs[i]&&(delete this._subs[i],this.send("eth_unsubscribe",[i]))}))}destroy(){return ax(this,void 0,void 0,function*(){this.websocket.readyState===Sg.CONNECTING&&(yield new Promise(e=>{this.websocket.onopen=function(){e(!0)},this.websocket.onerror=function(){e(!1)}})),this.websocket.close(1e3)})}}var U6=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const rg=new ce(ti);class VP extends qg{detectNetwork(){const e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return U6(this,void 0,void 0,function*(){let t=this.network;return t==null&&(t=yield e.detectNetwork.call(this),t||rg.throwError("no network detected",ce.errors.UNKNOWN_ERROR,{}),this._network==null&&(Ie(this,"_network",t),this.emit("network",t,null))),t})}}class lc extends VP{constructor(e,t){rg.checkAbstract(new.target,lc),e=is(new.target,"getNetwork")(e),t=is(new.target,"getApiKey")(t);const r=is(new.target,"getUrl")(e,t);super(r,e),typeof t=="string"?Ie(this,"apiKey",t):t!=null&&Object.keys(t).forEach(i=>{Ie(this,i,t[i])})}_startPending(){rg.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(e){return rg.throwError("API provider does not support signing",ce.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(e){return e}static getUrl(e,t){return rg.throwError("not implemented; sub-classes must override getUrl",ce.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const nM=new ce(ti),Wy="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";class S6 extends tS{constructor(e,t){const r=new LP(e,t),i=r.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi.");super(i,r.network),Ie(this,"apiKey",r.apiKey)}isCommunityResource(){return this.apiKey===Wy}}class LP extends lc{static getWebSocketProvider(e,t){return new S6(e,t)}static getApiKey(e){return e==null?Wy:(e&&typeof e!="string"&&nM.throwArgumentError("invalid apiKey","apiKey",e),e)}static getUrl(e,t){let r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/v2/";break;case"goerli":r="eth-goerli.g.alchemy.com/v2/";break;case"matic":r="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":r="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":r="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-goerli":r="arb-goerli.g.alchemy.com/v2/";break;case"optimism":r="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-goerli":r="opt-goerli.g.alchemy.com/v2/";break;default:nM.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+r+t,throttleCallback:(i,s)=>(t===Wy&&UC(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===Wy}}const _6=new ce(ti),V0="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function Q6(n){switch(n){case"homestead":return"rpc.ankr.com/eth/";case"ropsten":return"rpc.ankr.com/eth_ropsten/";case"rinkeby":return"rpc.ankr.com/eth_rinkeby/";case"goerli":return"rpc.ankr.com/eth_goerli/";case"matic":return"rpc.ankr.com/polygon/";case"arbitrum":return"rpc.ankr.com/arbitrum/"}return _6.throwArgumentError("unsupported network","name",n)}class R6 extends lc{isCommunityResource(){return this.apiKey===V0}static getApiKey(e){return e??V0}static getUrl(e,t){t==null&&(t=V0);const r={allowGzip:!0,url:"https://"+Q6(e.name)+t,throttleCallback:(i,s)=>(t.apiKey===V0&&UC(),Promise.resolve(!0))};return t.projectSecret!=null&&(r.user="",r.password=t.projectSecret),r}}var M6=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const rM=new ce(ti);class T6 extends lc{static getApiKey(e){return e!=null&&rM.throwArgumentError("apiKey not supported for cloudflare","apiKey",e),null}static getUrl(e,t){let r=null;switch(e.name){case"homestead":r="https://cloudflare-eth.com/";break;default:rM.throwArgumentError("unsupported network","network",arguments[0])}return r}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return M6(this,void 0,void 0,function*(){return e==="getBlockNumber"?(yield r.perform.call(this,"getBlock",{blockTag:"latest"})).number:r.perform.call(this,e,t)})}}var L0=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const gA=new ce(ti);function iM(n){const e={};for(let t in n){if(n[t]==null)continue;let r=n[t];t==="type"&&r===0||({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[t]?r=yC($e(r)):t==="accessList"?r="["+Iu(r).map(i=>`{address:"${i.address}",storageKeys:["${i.storageKeys.join('","')}"]}`).join(",")+"]":r=$e(r),e[t]=r)}return e}function N6(n){if(n.status==0&&(n.message==="No records found"||n.message==="No transactions found"))return n.result;if(n.status!=1||typeof n.message!="string"||!n.message.match(/^OK/)){const e=new Error("invalid response");throw e.result=JSON.stringify(n),(n.result||"").toLowerCase().indexOf("rate limit")>=0&&(e.throttleRetry=!0),e}return n.result}function sM(n){if(n&&n.status==0&&n.message=="NOTOK"&&(n.result||"").toLowerCase().indexOf("rate limit")>=0){const e=new Error("throttled response");throw e.result=JSON.stringify(n),e.throttleRetry=!0,e}if(n.jsonrpc!="2.0"){const e=new Error("invalid response");throw e.result=JSON.stringify(n),e}if(n.error){const e=new Error(n.error.message||"unknown error");throw n.error.code&&(e.code=n.error.code),n.error.data&&(e.data=n.error.data),e}return n.result}function oM(n){if(n==="pending")throw new Error("pending not supported");return n==="latest"?n:parseInt(n.substring(2),16)}function lx(n,e,t){if(n==="call"&&e.code===ce.errors.SERVER_ERROR){const i=e.error;if(i&&(i.message.match(/reverted/i)||i.message.match(/VM execution error/i))){let s=i.data;if(s&&(s="0x"+s.replace(/^.*0x/i,"")),bt(s))return s;gA.throwError("missing revert data in call exception",ce.errors.CALL_EXCEPTION,{error:e,data:"0x"})}}let r=e.message;throw e.code===ce.errors.SERVER_ERROR&&(e.error&&typeof e.error.message=="string"?r=e.error.message:typeof e.body=="string"?r=e.body:typeof e.responseText=="string"&&(r=e.responseText)),r=(r||"").toLowerCase(),r.match(/insufficient funds/)&&gA.throwError("insufficient funds for intrinsic transaction cost",ce.errors.INSUFFICIENT_FUNDS,{error:e,method:n,transaction:t}),r.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&gA.throwError("nonce has already been used",ce.errors.NONCE_EXPIRED,{error:e,method:n,transaction:t}),r.match(/another transaction with same nonce/)&&gA.throwError("replacement fee too low",ce.errors.REPLACEMENT_UNDERPRICED,{error:e,method:n,transaction:t}),r.match(/execution failed due to an exception|execution reverted/)&&gA.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",ce.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:n,transaction:t}),e}class D6 extends qU{constructor(e,t){super(e),Ie(this,"baseUrl",this.getBaseUrl()),Ie(this,"apiKey",t||null)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"matic":return"https://api.polygonscan.com";case"maticmum":return"https://api-testnet.polygonscan.com";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}return gA.throwArgumentError("unsupported network","network",this.network.name)}getUrl(e,t){const r=Object.keys(t).reduce((s,o)=>{const a=t[o];return a!=null&&(s+=`&${o}=${a}`),s},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${e}${r}${i}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(e,t){return t.module=e,t.apikey=this.apiKey,t}fetch(e,t,r){return L0(this,void 0,void 0,function*(){const i=r?this.getPostUrl():this.getUrl(e,t),s=r?this.getPostData(e,t):null,o=e==="proxy"?sM:N6;this.emit("debug",{action:"request",request:i,provider:this});const a={url:i,throttleSlotInterval:1e3,throttleCallback:(c,u)=>(this.isCommunityResource()&&UC(),Promise.resolve(!0))};let l=null;s&&(a.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},l=Object.keys(s).map(c=>`${c}=${s[c]}`).join("&"));const A=yield xC(a,l,o||sM);return this.emit("debug",{action:"response",request:i,response:as(A),provider:this}),A})}detectNetwork(){return L0(this,void 0,void 0,function*(){return this.network})}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return L0(this,void 0,void 0,function*(){switch(e){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch(i=>lx("sendTransaction",i,t.signedTransaction));case"getBlock":if(t.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.transactionHash});case"call":{if(t.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const i=iM(t.transaction);i.module="proxy",i.action="eth_call";try{return yield this.fetch("proxy",i,!0)}catch(s){return lx("call",s,t.transaction)}}case"estimateGas":{const i=iM(t.transaction);i.module="proxy",i.action="eth_estimateGas";try{return yield this.fetch("proxy",i,!0)}catch(s){return lx("estimateGas",s,t.transaction)}}case"getLogs":{const i={action:"getLogs"};if(t.filter.fromBlock&&(i.fromBlock=oM(t.filter.fromBlock)),t.filter.toBlock&&(i.toBlock=oM(t.filter.toBlock)),t.filter.address&&(i.address=t.filter.address),t.filter.topics&&t.filter.topics.length>0&&(t.filter.topics.length>1&&gA.throwError("unsupported topic count",ce.errors.UNSUPPORTED_OPERATION,{topics:t.filter.topics}),t.filter.topics.length===1)){const a=t.filter.topics[0];(typeof a!="string"||a.length!==66)&&gA.throwError("unsupported topic format",ce.errors.UNSUPPORTED_OPERATION,{topic0:a}),i.topic0=a}const s=yield this.fetch("logs",i);let o={};for(let a=0;a{["contractAddress","to"].forEach(function(l){o[l]==""&&delete o[l]}),o.creates==null&&o.contractAddress!=null&&(o.creates=o.contractAddress);const a=this.formatter.transactionResponse(o);return o.timeStamp&&(a.timestamp=parseInt(o.timeStamp)),a})})}isCommunityResource(){return this.apiKey==null}}function k6(n){n=n.slice();for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}var TB=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const Vc=new ce(ti);function P0(){return new Date().getTime()}function aM(n){let e=null;for(let t=0;te?null:(r+i)/2}function sd(n){if(n===null)return"null";if(typeof n=="number"||typeof n=="boolean")return JSON.stringify(n);if(typeof n=="string")return n;if(De.isBigNumber(n))return n.toString();if(Array.isArray(n))return JSON.stringify(n.map(e=>sd(e)));if(typeof n=="object"){const e=Object.keys(n);return e.sort(),"{"+e.map(t=>{let r=n[t];return typeof r=="function"?r="[function]":r=sd(r),JSON.stringify(t)+":"+r}).join(",")+"}"}throw new Error("unknown value type: "+typeof n)}let V6=1;function AM(n){let e=null,t=null,r=new Promise(o=>{e=function(){t&&(clearTimeout(t),t=null),o()},t=setTimeout(e,n)});const i=o=>(r=r.then(o),r);function s(){return r}return{cancel:e,getPromise:s,wait:i}}const L6=[ce.errors.CALL_EXCEPTION,ce.errors.INSUFFICIENT_FUNDS,ce.errors.NONCE_EXPIRED,ce.errors.REPLACEMENT_UNDERPRICED,ce.errors.UNPREDICTABLE_GAS_LIMIT],P6=["address","args","errorArgs","errorSignature","method","transaction"];function W0(n,e){const t={weight:n.weight};return Object.defineProperty(t,"provider",{get:()=>n.provider}),n.start&&(t.start=n.start),e&&(t.duration=e-n.start),n.done&&(n.error?t.error=n.error:t.result=n.result||null),t}function W6(n,e){return function(t){const r={};t.forEach(s=>{const o=n(s.result);r[o]||(r[o]={count:0,result:s.result}),r[o].count++});const i=Object.keys(r);for(let s=0;s=e)return o.result}}}function O6(n,e,t){let r=sd;switch(e){case"getBlockNumber":return function(i){const s=i.map(a=>a.result);let o=lM(i.map(a=>a.result),2);if(o!=null)return o=Math.ceil(o),s.indexOf(o+1)>=0&&o++,o>=n._highestBlockNumber&&(n._highestBlockNumber=o),n._highestBlockNumber};case"getGasPrice":return function(i){const s=i.map(o=>o.result);return s.sort(),s[Math.floor(s.length/2)]};case"getEtherPrice":return function(i){return lM(i.map(s=>s.result))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":r=function(i){return i==null?null:(i=xn(i),i.confirmations=-1,sd(i))};break;case"getBlock":t.includeTransactions?r=function(i){return i==null?null:(i=xn(i),i.transactions=i.transactions.map(s=>(s=xn(s),s.confirmations=-1,s)),sd(i))}:r=function(i){return i==null?null:sd(i)};break;default:throw new Error("unknown method: "+e)}return W6(r,n.quorum)}function hp(n,e){return TB(this,void 0,void 0,function*(){const t=n.provider;return t.blockNumber!=null&&t.blockNumber>=e||e===-1?t:id(()=>new Promise((r,i)=>{setTimeout(function(){return t.blockNumber>=e?r(t):n.cancelled?r(null):r(void 0)},0)}),{oncePoll:t})})}function G6(n,e,t,r){return TB(this,void 0,void 0,function*(){let i=n.provider;switch(t){case"getBlockNumber":case"getGasPrice":return i[t]();case"getEtherPrice":if(i.getEtherPrice)return i.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return r.blockTag&&bt(r.blockTag)&&(i=yield hp(n,e)),i[t](r.address,r.blockTag||"latest");case"getStorageAt":return r.blockTag&&bt(r.blockTag)&&(i=yield hp(n,e)),i.getStorageAt(r.address,r.position,r.blockTag||"latest");case"getBlock":return r.blockTag&&bt(r.blockTag)&&(i=yield hp(n,e)),i[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return r.blockTag&&bt(r.blockTag)&&(i=yield hp(n,e)),t==="call"&&r.blockTag?i[t](r.transaction,r.blockTag):i[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return i[t](r.transactionHash);case"getLogs":{let s=r.filter;return(s.fromBlock&&bt(s.fromBlock)||s.toBlock&&bt(s.toBlock))&&(i=yield hp(n,e)),i.getLogs(s)}}return Vc.throwError("unknown method error",ce.errors.UNKNOWN_ERROR,{method:t,params:r})})}class Z6 extends qU{constructor(e,t){e.length===0&&Vc.throwArgumentError("missing providers","providers",e);const r=e.map((o,a)=>{if(qm.isProvider(o)){const c=HR(o)?2e3:750;return Object.freeze({provider:o,weight:1,stallTimeout:c,priority:1})}const l=xn(o);l.priority==null&&(l.priority=1),l.stallTimeout==null&&(l.stallTimeout=HR(o)?2e3:750),l.weight==null&&(l.weight=1);const A=l.weight;return(A%1||A>512||A<1)&&Vc.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${a}].weight`,A),Object.freeze(l)}),i=r.reduce((o,a)=>o+a.weight,0);t==null?t=i/2:t>i&&Vc.throwArgumentError("quorum will always fail; larger than total weight","quorum",t);let s=aM(r.map(o=>o.provider.network));s==null&&(s=new Promise((o,a)=>{setTimeout(()=>{this.detectNetwork().then(o,a)},0)})),super(s),Ie(this,"providerConfigs",Object.freeze(r)),Ie(this,"quorum",t),this._highestBlockNumber=-1}detectNetwork(){return TB(this,void 0,void 0,function*(){const e=yield Promise.all(this.providerConfigs.map(t=>t.provider.getNetwork()));return aM(e)})}perform(e,t){return TB(this,void 0,void 0,function*(){if(e==="sendTransaction"){const l=yield Promise.all(this.providerConfigs.map(A=>A.provider.sendTransaction(t.signedTransaction).then(c=>c.hash,c=>c)));for(let A=0;Al.priority-A.priority);const s=this._highestBlockNumber;let o=0,a=!0;for(;;){const l=P0();let A=i.filter(d=>d.runner&&l-d.startd+h.weight,0);for(;A{d.staller=null}),d.runner=G6(d,s,e,t).then(p=>{d.done=!0,d.result=p,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:h,backend:W0(d,P0()),request:{method:e,params:as(t)},provider:this})},p=>{d.done=!0,d.error=p,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:h,backend:W0(d,P0()),request:{method:e,params:as(t)},provider:this})}),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:h,backend:W0(d,null),request:{method:e,params:as(t)},provider:this}),A+=d.weight}const c=[];i.forEach(d=>{d.done||!d.runner||(c.push(d.runner),d.staller&&c.push(d.staller.getPromise()))}),c.length&&(yield Promise.race(c));const u=i.filter(d=>d.done&&d.error==null);if(u.length>=this.quorum){const d=r(u);if(d!==void 0)return i.forEach(h=>{h.staller&&h.staller.cancel(),h.cancelled=!0}),d;a||(yield AM(100).getPromise()),a=!1}const f=i.reduce((d,h)=>{if(!h.done||h.error==null)return d;const p=h.error.code;return L6.indexOf(p)>=0&&(d[p]||(d[p]={error:h.error,weight:0}),d[p].weight+=h.weight),d},{});if(Object.keys(f).forEach(d=>{const h=f[d];if(h.weight{g.staller&&g.staller.cancel(),g.cancelled=!0});const p=h.error,m={};P6.forEach(g=>{p[g]!=null&&(m[g]=p[g])}),Vc.throwError(p.reason||p.message,d,m)}),i.filter(d=>!d.done).length===0)break}return i.forEach(l=>{l.staller&&l.staller.cancel(),l.cancelled=!0}),Vc.throwError("failed to meet quorum",ce.errors.SERVER_ERROR,{method:e,params:t,results:i.map(l=>W0(l)),provider:this})})}}const J6=null,Oy=new ce(ti),ig="84842078b09946638c03157f83405213";class H6 extends tS{constructor(e,t){const r=new PP(e,t),i=r.connection;i.password&&Oy.throwError("INFURA WebSocket project secrets unsupported",ce.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});const s=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(s,e),Ie(this,"apiKey",r.projectId),Ie(this,"projectId",r.projectId),Ie(this,"projectSecret",r.projectSecret)}isCommunityResource(){return this.projectId===ig}}class PP extends lc{static getWebSocketProvider(e,t){return new H6(e,t)}static getApiKey(e){const t={apiKey:ig,projectId:ig,projectSecret:null};return e==null||(typeof e=="string"?t.projectId=e:e.projectSecret!=null?(Oy.assertArgument(typeof e.projectId=="string","projectSecret requires a projectId","projectId",e.projectId),Oy.assertArgument(typeof e.projectSecret=="string","invalid projectSecret","projectSecret","[REDACTED]"),t.projectId=e.projectId,t.projectSecret=e.projectSecret):e.projectId&&(t.projectId=e.projectId),t.apiKey=t.projectId),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"homestead":r="mainnet.infura.io";break;case"goerli":r="goerli.infura.io";break;case"sepolia":r="sepolia.infura.io";break;case"matic":r="polygon-mainnet.infura.io";break;case"maticmum":r="polygon-mumbai.infura.io";break;case"optimism":r="optimism-mainnet.infura.io";break;case"optimism-goerli":r="optimism-goerli.infura.io";break;case"arbitrum":r="arbitrum-mainnet.infura.io";break;case"arbitrum-goerli":r="arbitrum-goerli.infura.io";break;default:Oy.throwError("unsupported network",ce.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const i={allowGzip:!0,url:"https://"+r+"/v3/"+t.projectId,throttleCallback:(s,o)=>(t.projectId===ig&&UC(),Promise.resolve(!0))};return t.projectSecret!=null&&(i.user="",i.password=t.projectSecret),i}isCommunityResource(){return this.projectId===ig}}const Ax=new ce(ti),z6="ETHERS_JS_SHARED";class Y6 extends lc{static getApiKey(e){return e&&typeof e!="string"&&Ax.throwArgumentError("invalid apiKey","apiKey",e),e||z6}static getUrl(e,t){Ax.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let r=null;switch(e.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:Ax.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+t}}const cM=new ce(ti),uM="62e1ad51b37b8e00394bda3b";class X6 extends lc{static getApiKey(e){const t={applicationId:null,loadBalancer:!0,applicationSecretKey:null};return e==null?t.applicationId=uM:typeof e=="string"?t.applicationId=e:e.applicationSecretKey!=null?(t.applicationId=e.applicationId,t.applicationSecretKey=e.applicationSecretKey):e.applicationId?t.applicationId=e.applicationId:cM.throwArgumentError("unsupported PocketProvider apiKey","apiKey",e),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"goerli":r="eth-goerli.gateway.pokt.network";break;case"homestead":r="eth-mainnet.gateway.pokt.network";break;case"kovan":r="poa-kovan.gateway.pokt.network";break;case"matic":r="poly-mainnet.gateway.pokt.network";break;case"maticmum":r="polygon-mumbai-rpc.gateway.pokt.network";break;case"rinkeby":r="eth-rinkeby.gateway.pokt.network";break;case"ropsten":r="eth-ropsten.gateway.pokt.network";break;default:cM.throwError("unsupported network",ce.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const i=`https://${r}/v1/lb/${t.applicationId}`,s={headers:{},url:i};return t.applicationSecretKey!=null&&(s.user="",s.password=t.applicationSecretKey),s}isCommunityResource(){return this.applicationId===uM}}const fM=new ce(ti);let K6=1;function dM(n,e){const t="Web3LegacyFetcher";return function(r,i){const s={method:r,params:i,id:K6++,jsonrpc:"2.0"};return new Promise((o,a)=>{this.emit("debug",{action:"request",fetcher:t,request:as(s),provider:this}),e(s,(l,A)=>{if(l)return this.emit("debug",{action:"response",fetcher:t,error:l,request:s,provider:this}),a(l);if(this.emit("debug",{action:"response",fetcher:t,request:s,response:A,provider:this}),A.error){const c=new Error(A.error.message);return c.code=A.error.code,c.data=A.error.data,a(c)}o(A.result)})})}}function j6(n){return function(e,t){t==null&&(t=[]);const r={method:e,params:t};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:as(r),provider:this}),n.request(r).then(i=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:r,response:i,provider:this}),i),i=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:r,error:i,provider:this}),i})}}class nS extends qg{constructor(e,t){e==null&&fM.throwArgumentError("missing provider","provider",e);let r=null,i=null,s=null;typeof e=="function"?(r="unknown:",i=e):(r=e.host||e.path||"",!r&&e.isMetaMask&&(r="metamask"),s=e,e.request?(r===""&&(r="eip-1193:"),i=j6(e)):e.sendAsync?i=dM(e,e.sendAsync.bind(e)):e.send?i=dM(e,e.send.bind(e)):fM.throwArgumentError("unsupported provider","provider",e),r||(r="unknown:")),super(r,t),Ie(this,"jsonRpcFetchFunc",i),Ie(this,"provider",s)}send(e,t){return this.jsonRpcFetchFunc(e,t)}}const hM=new ce(ti);function $6(n,e){if(n==null&&(n="homestead"),typeof n=="string"){const r=n.match(/^(ws|http)s?:/i);if(r)switch(r[1].toLowerCase()){case"http":case"https":return new qg(n);case"ws":case"wss":return new tS(n);default:hM.throwArgumentError("unsupported URL scheme","network",n)}}const t=V3(n);return(!t||!t._defaultProvider)&&hM.throwError("unsupported getDefaultProvider network",ce.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:n}),t._defaultProvider({FallbackProvider:Z6,AlchemyProvider:LP,AnkrProvider:R6,CloudflareProvider:T6,EtherscanProvider:D6,InfuraProvider:PP,JsonRpcProvider:qg,NodesmithProvider:Y6,PocketProvider:X6,Web3Provider:nS,IpcProvider:J6},e)}var q6=!0,cx="Invariant failed";function gl(n,e){if(!n){if(q6)throw new Error(cx);var t=typeof e=="function"?e():e,r=t?"".concat(cx,": ").concat(t):cx;throw new Error(r)}}var Uo;(function(n){n.Update="Web3ReactUpdate",n.Error="Web3ReactError",n.Deactivate="Web3ReactDeactivate"})(Uo||(Uo={}));function em(){return em=Object.assign||function(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Gy(n,e,t){return eK()?Gy=Reflect.construct:Gy=function(i,s,o){var a=[null];a.push.apply(a,s);var l=Function.bind.apply(i,a),A=new l;return o&&tm(A,o.prototype),A},Gy.apply(null,arguments)}function tK(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function NB(n){var e=typeof Map=="function"?new Map:void 0;return NB=function(r){if(r===null||!tK(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return Gy(r,arguments,rF(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),tm(i,r)},NB(n)}typeof Symbol<"u"&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")));typeof Symbol<"u"&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));function pM(n,e){try{var t=n()}catch(r){return e(r)}return t&&t.then?t.then(void 0,e):t}function OP(n){if(typeof n=="string"){n=n.replace(/^Ox/,"0x");var e=Number.parseInt(n,n.trim().substring(0,2)==="0x"?16:10);return Number.isNaN(e)&&gl(!1),e}else return Number.isInteger(n)||gl(!1),n}function GP(n){typeof n=="string"&&n.match(/^(0x)?[0-9a-fA-F]{40}$/)||gl(!1);for(var e=n.substring(0,2)==="0x"?n:"0x"+n,t=e.toLowerCase().substring(2).split(""),r=new Uint8Array(40),i=0;i<40;i++)r[i]=t[i].charCodeAt(0);for(var s=lt(nr(r)),o=0;o<40;o+=2)s[o>>1]>>4>=8&&(t[o]=t[o].toUpperCase()),(s[o>>1]&15)>=8&&(t[o+1]=t[o+1].toUpperCase());var a="0x"+t.join("");return e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==a&&gl(!1),a}var gM=function(e,t){try{var r=function(o){return Promise.resolve(Promise.all([t.chainId===void 0?e.getChainId():t.chainId,t.account===void 0?e.getAccount():t.account])).then(function(a){var l=a[0],A=a[1],c=OP(l);if(e.supportedChainIds&&!e.supportedChainIds.includes(c))throw new ZP(c,e.supportedChainIds);var u=A===null?A:GP(A);return{provider:o,chainId:c,account:u}})},i=t.provider===void 0;return Promise.resolve(i?Promise.resolve(e.getProvider()).then(r):r(t.provider))}catch(s){return Promise.reject(s)}},O0=function(n){WP(e,n);function e(){var t;return t=n.call(this)||this,t.name=t.constructor.name,t}return e}(NB(Error)),ZP=function(n){WP(e,n);function e(t,r){var i;return i=n.call(this)||this,i.name=i.constructor.name,i.message="Unsupported chain id: "+t+". Supported chain ids are: "+r+".",i}return e}(NB(Error)),yr;(function(n){n[n.ACTIVATE_CONNECTOR=0]="ACTIVATE_CONNECTOR",n[n.UPDATE=1]="UPDATE",n[n.UPDATE_FROM_ERROR=2]="UPDATE_FROM_ERROR",n[n.ERROR=3]="ERROR",n[n.ERROR_FROM_ACTIVATION=4]="ERROR_FROM_ACTIVATION",n[n.DEACTIVATE_CONNECTOR=5]="DEACTIVATE_CONNECTOR"})(yr||(yr={}));function nK(n,e){var t=e.type,r=e.payload;switch(t){case yr.ACTIVATE_CONNECTOR:{var i=r.connector,s=r.provider,o=r.chainId,a=r.account,l=r.onError;return{connector:i,provider:s,chainId:o,account:a,onError:l}}case yr.UPDATE:{var A=r.provider,c=r.chainId,u=r.account;return em({},n,A===void 0?{}:{provider:A},c===void 0?{}:{chainId:c},u===void 0?{}:{account:u})}case yr.UPDATE_FROM_ERROR:{var f=r.provider,d=r.chainId,h=r.account;return em({},n,f===void 0?{}:{provider:f},d===void 0?{}:{chainId:d},h===void 0?{}:{account:h},{error:void 0})}case yr.ERROR:{var p=r.error,m=n.connector,g=n.onError;return{connector:m,error:p,onError:g}}case yr.ERROR_FROM_ACTIVATION:{var v=r.connector,y=r.error;return{connector:v,error:y}}case yr.DEACTIVATE_CONNECTOR:return{}}}function rK(){var n=me.useReducer(nK,{}),e=n[0],t=n[1],r=e.connector,i=e.provider,s=e.chainId,o=e.account,a=e.onError,l=e.error,A=me.useRef(-1);A.current+=1;var c=me.useCallback(function(m,g,v){v===void 0&&(v=!1);try{var y=A.current,w=!1;return Promise.resolve(pM(function(){return Promise.resolve(m.activate().then(function(C){return w=!0,C})).then(function(C){return Promise.resolve(gM(m,C)).then(function(b){if(A.current>y)throw new O0;t({type:yr.ACTIVATE_CONNECTOR,payload:em({connector:m},b,{onError:g})})})})},function(C){if(C instanceof O0)w&&m.deactivate();else{if(v)throw w&&m.deactivate(),C;g?(w&&m.deactivate(),g(C)):t({type:yr.ERROR_FROM_ACTIVATION,payload:{connector:m,error:C}})}}))}catch(C){return Promise.reject(C)}},[]),u=me.useCallback(function(m){t({type:yr.ERROR,payload:{error:m}})},[]),f=me.useCallback(function(){t({type:yr.DEACTIVATE_CONNECTOR})},[]),d=me.useCallback(function(m){try{if(!r)throw Error("This should never happen, it's just so Typescript stops complaining");var g=A.current;return Promise.resolve(function(){if(l)return pM(function(){return Promise.resolve(gM(r,m)).then(function(C){if(A.current>g)throw new O0;t({type:yr.UPDATE_FROM_ERROR,payload:C})})},function(C){C instanceof O0||(a?a(C):t({type:yr.ERROR,payload:{error:C}}))});var v=m.chainId===void 0?void 0:OP(m.chainId);if(v!==void 0&&r.supportedChainIds&&!r.supportedChainIds.includes(v)){var y=new ZP(v,r.supportedChainIds);a?a(y):t({type:yr.ERROR,payload:{error:y}})}else{var w=typeof m.account=="string"?GP(m.account):m.account;t({type:yr.UPDATE,payload:{provider:m.provider,chainId:v,account:w}})}}())}catch(v){return Promise.reject(v)}},[r,l,a]),h=me.useCallback(function(m){a?a(m):t({type:yr.ERROR,payload:{error:m}})},[a]),p=me.useCallback(function(){t({type:yr.DEACTIVATE_CONNECTOR})},[]);return me.useEffect(function(){return function(){r&&r.deactivate()}},[r]),me.useEffect(function(){return r&&r.on(Uo.Update,d).on(Uo.Error,h).on(Uo.Deactivate,p),function(){r&&r.off(Uo.Update,d).off(Uo.Error,h).off(Uo.Deactivate,p)}},[r,d,h,p]),{connector:r,provider:i,chainId:s,account:o,activate:c,setError:u,deactivate:f,error:l}}var JP="primary",od={};function iK(n){od[n]&&gl(!1),od[n]=me.createContext({activate:function(){try{return gl(!1),Promise.resolve()}catch(t){return Promise.reject(t)}},setError:function(){gl(!1)},deactivate:function(){gl(!1)},active:!1}),od[n].displayName="Web3ReactContext - "+n;var e=od[n].Provider;return function(r){var i=r.getLibrary,s=r.children,o=rK(),a=o.connector,l=o.provider,A=o.chainId,c=o.account,u=o.activate,f=o.setError,d=o.deactivate,h=o.error,p=a!==void 0&&A!==void 0&&c!==void 0&&!h,m=me.useMemo(function(){return p&&A!==void 0&&Number.isInteger(A)&&a?i(l,a):void 0},[p,i,l,a,A]),g={connector:a,library:m,chainId:A,account:c,activate:u,setError:f,deactivate:d,active:p,error:h};return Y.createElement(e,{value:g},s)}}var sK=iK(JP);function oK(n){return n===void 0&&(n=JP),Object.keys(od).includes(n)||gl(!1),od[n]}function aK(n){return me.useContext(oK(n))}var iF={},HP={exports:{}},vs={},zP={exports:{}},YP={};/** + */(function(n){(function(){var e="input is invalid type",t="finalize already called",r=typeof window=="object",i=r?window:{};i.JS_SHA3_NO_WINDOW&&(r=!1);var s=!r&&typeof self=="object",o=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?i=td:s&&(i=self);var a=!i.JS_SHA3_NO_COMMON_JS&&!0&&n.exports,l=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",A="0123456789abcdef".split(""),c=[31,7936,2031616,520093696],u=[4,1024,262144,67108864],f=[1,256,65536,16777216],d=[6,1536,393216,100663296],h=[0,8,16,24],p=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],m=[224,256,384,512],g=[128,256],v=["hex","buffer","arrayBuffer","array","digest"],y={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(N){return Object.prototype.toString.call(N)==="[object Array]"}),l&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(N){return typeof N=="object"&&N.buffer&&N.buffer.constructor===ArrayBuffer});for(var w=function(N,j,oe){return function(ie){return new U(N,j,N).update(ie)[oe]()}},C=function(N,j,oe){return function(ie,de){return new U(N,j,de).update(ie)[oe]()}},b=function(N,j,oe){return function(ie,de,X,ne){return B["cshake"+N].update(ie,de,X,ne)[oe]()}},E=function(N,j,oe){return function(ie,de,X,ne){return B["kmac"+N].update(ie,de,X,ne)[oe]()}},x=function(N,j,oe,ie){for(var de=0;de>5,this.byteCount=this.blockCount<<2,this.outputBlocks=oe>>5,this.extraBytes=(oe&31)>>3;for(var ie=0;ie<50;++ie)this.s[ie]=0}U.prototype.update=function(N){if(this.finalized)throw new Error(t);var j,oe=typeof N;if(oe!=="string"){if(oe==="object"){if(N===null)throw new Error(e);if(l&&N.constructor===ArrayBuffer)N=new Uint8Array(N);else if(!Array.isArray(N)&&(!l||!ArrayBuffer.isView(N)))throw new Error(e)}else throw new Error(e);j=!0}for(var ie=this.blocks,de=this.byteCount,X=N.length,ne=this.blockCount,ae=0,Be=this.s,pe,Fe;ae>2]|=N[ae]<>2]|=Fe<>2]|=(192|Fe>>6)<>2]|=(128|Fe&63)<=57344?(ie[pe>>2]|=(224|Fe>>12)<>2]|=(128|Fe>>6&63)<>2]|=(128|Fe&63)<>2]|=(240|Fe>>18)<>2]|=(128|Fe>>12&63)<>2]|=(128|Fe>>6&63)<>2]|=(128|Fe&63)<=de){for(this.start=pe-de,this.block=ie[ne],pe=0;pe>8,oe=N&255;oe>0;)de.unshift(oe),N=N>>8,oe=N&255,++ie;return j?de.push(ie):de.unshift(ie),this.update(de),de.length},U.prototype.encodeString=function(N){var j,oe=typeof N;if(oe!=="string"){if(oe==="object"){if(N===null)throw new Error(e);if(l&&N.constructor===ArrayBuffer)N=new Uint8Array(N);else if(!Array.isArray(N)&&(!l||!ArrayBuffer.isView(N)))throw new Error(e)}else throw new Error(e);j=!0}var ie=0,de=N.length;if(j)ie=de;else for(var X=0;X=57344?ie+=3:(ne=65536+((ne&1023)<<10|N.charCodeAt(++X)&1023),ie+=4)}return ie+=this.encode(ie*8),this.update(N),ie},U.prototype.bytepad=function(N,j){for(var oe=this.encode(j),ie=0;ie>2]|=this.padding[j&3],this.lastByteIndex===this.byteCount)for(N[0]=N[oe],j=1;j>4&15]+A[ae&15]+A[ae>>12&15]+A[ae>>8&15]+A[ae>>20&15]+A[ae>>16&15]+A[ae>>28&15]+A[ae>>24&15];X%N===0&&(le(j),de=0)}return ie&&(ae=j[de],ne+=A[ae>>4&15]+A[ae&15],ie>1&&(ne+=A[ae>>12&15]+A[ae>>8&15]),ie>2&&(ne+=A[ae>>20&15]+A[ae>>16&15])),ne},U.prototype.arrayBuffer=function(){this.finalize();var N=this.blockCount,j=this.s,oe=this.outputBlocks,ie=this.extraBytes,de=0,X=0,ne=this.outputBits>>3,ae;ie?ae=new ArrayBuffer(oe+1<<2):ae=new ArrayBuffer(ne);for(var Be=new Uint32Array(ae);X>8&255,ne[ae+2]=Be>>16&255,ne[ae+3]=Be>>24&255;X%N===0&&le(j)}return ie&&(ae=X<<2,Be=j[de],ne[ae]=Be&255,ie>1&&(ne[ae+1]=Be>>8&255),ie>2&&(ne[ae+2]=Be>>16&255)),ne};function H(N,j,oe){U.call(this,N,j,oe)}H.prototype=new U,H.prototype.finalize=function(){return this.encode(this.outputBits,!0),U.prototype.finalize.call(this)};var le=function(N){var j,oe,ie,de,X,ne,ae,Be,pe,Fe,rt,Oe,ke,Qe,Ge,Xe,G,J,se,fe,ve,W,Q,I,D,$,ee,te,we,Ce,Ee,Ve,_e,re,ye,be,Ue,Je,qe,ct,An,xt,st,or,mt,qt,co,Xt,en,q,Ae,he,ue,ge,Ne,at,Ye,He,vt,ft,gt,zt,Pr;for(ie=0;ie<48;ie+=2)de=N[0]^N[10]^N[20]^N[30]^N[40],X=N[1]^N[11]^N[21]^N[31]^N[41],ne=N[2]^N[12]^N[22]^N[32]^N[42],ae=N[3]^N[13]^N[23]^N[33]^N[43],Be=N[4]^N[14]^N[24]^N[34]^N[44],pe=N[5]^N[15]^N[25]^N[35]^N[45],Fe=N[6]^N[16]^N[26]^N[36]^N[46],rt=N[7]^N[17]^N[27]^N[37]^N[47],Oe=N[8]^N[18]^N[28]^N[38]^N[48],ke=N[9]^N[19]^N[29]^N[39]^N[49],j=Oe^(ne<<1|ae>>>31),oe=ke^(ae<<1|ne>>>31),N[0]^=j,N[1]^=oe,N[10]^=j,N[11]^=oe,N[20]^=j,N[21]^=oe,N[30]^=j,N[31]^=oe,N[40]^=j,N[41]^=oe,j=de^(Be<<1|pe>>>31),oe=X^(pe<<1|Be>>>31),N[2]^=j,N[3]^=oe,N[12]^=j,N[13]^=oe,N[22]^=j,N[23]^=oe,N[32]^=j,N[33]^=oe,N[42]^=j,N[43]^=oe,j=ne^(Fe<<1|rt>>>31),oe=ae^(rt<<1|Fe>>>31),N[4]^=j,N[5]^=oe,N[14]^=j,N[15]^=oe,N[24]^=j,N[25]^=oe,N[34]^=j,N[35]^=oe,N[44]^=j,N[45]^=oe,j=Be^(Oe<<1|ke>>>31),oe=pe^(ke<<1|Oe>>>31),N[6]^=j,N[7]^=oe,N[16]^=j,N[17]^=oe,N[26]^=j,N[27]^=oe,N[36]^=j,N[37]^=oe,N[46]^=j,N[47]^=oe,j=Fe^(de<<1|X>>>31),oe=rt^(X<<1|de>>>31),N[8]^=j,N[9]^=oe,N[18]^=j,N[19]^=oe,N[28]^=j,N[29]^=oe,N[38]^=j,N[39]^=oe,N[48]^=j,N[49]^=oe,Qe=N[0],Ge=N[1],qt=N[11]<<4|N[10]>>>28,co=N[10]<<4|N[11]>>>28,te=N[20]<<3|N[21]>>>29,we=N[21]<<3|N[20]>>>29,ft=N[31]<<9|N[30]>>>23,gt=N[30]<<9|N[31]>>>23,xt=N[40]<<18|N[41]>>>14,st=N[41]<<18|N[40]>>>14,re=N[2]<<1|N[3]>>>31,ye=N[3]<<1|N[2]>>>31,Xe=N[13]<<12|N[12]>>>20,G=N[12]<<12|N[13]>>>20,Xt=N[22]<<10|N[23]>>>22,en=N[23]<<10|N[22]>>>22,Ce=N[33]<<13|N[32]>>>19,Ee=N[32]<<13|N[33]>>>19,zt=N[42]<<2|N[43]>>>30,Pr=N[43]<<2|N[42]>>>30,ge=N[5]<<30|N[4]>>>2,Ne=N[4]<<30|N[5]>>>2,be=N[14]<<6|N[15]>>>26,Ue=N[15]<<6|N[14]>>>26,J=N[25]<<11|N[24]>>>21,se=N[24]<<11|N[25]>>>21,q=N[34]<<15|N[35]>>>17,Ae=N[35]<<15|N[34]>>>17,Ve=N[45]<<29|N[44]>>>3,_e=N[44]<<29|N[45]>>>3,I=N[6]<<28|N[7]>>>4,D=N[7]<<28|N[6]>>>4,at=N[17]<<23|N[16]>>>9,Ye=N[16]<<23|N[17]>>>9,Je=N[26]<<25|N[27]>>>7,qe=N[27]<<25|N[26]>>>7,fe=N[36]<<21|N[37]>>>11,ve=N[37]<<21|N[36]>>>11,he=N[47]<<24|N[46]>>>8,ue=N[46]<<24|N[47]>>>8,or=N[8]<<27|N[9]>>>5,mt=N[9]<<27|N[8]>>>5,$=N[18]<<20|N[19]>>>12,ee=N[19]<<20|N[18]>>>12,He=N[29]<<7|N[28]>>>25,vt=N[28]<<7|N[29]>>>25,ct=N[38]<<8|N[39]>>>24,An=N[39]<<8|N[38]>>>24,W=N[48]<<14|N[49]>>>18,Q=N[49]<<14|N[48]>>>18,N[0]=Qe^~Xe&J,N[1]=Ge^~G&se,N[10]=I^~$&te,N[11]=D^~ee&we,N[20]=re^~be&Je,N[21]=ye^~Ue&qe,N[30]=or^~qt&Xt,N[31]=mt^~co&en,N[40]=ge^~at&He,N[41]=Ne^~Ye&vt,N[2]=Xe^~J&fe,N[3]=G^~se&ve,N[12]=$^~te&Ce,N[13]=ee^~we&Ee,N[22]=be^~Je&ct,N[23]=Ue^~qe&An,N[32]=qt^~Xt&q,N[33]=co^~en&Ae,N[42]=at^~He&ft,N[43]=Ye^~vt>,N[4]=J^~fe&W,N[5]=se^~ve&Q,N[14]=te^~Ce&Ve,N[15]=we^~Ee&_e,N[24]=Je^~ct&xt,N[25]=qe^~An&st,N[34]=Xt^~q&he,N[35]=en^~Ae&ue,N[44]=He^~ft&zt,N[45]=vt^~gt&Pr,N[6]=fe^~W&Qe,N[7]=ve^~Q&Ge,N[16]=Ce^~Ve&I,N[17]=Ee^~_e&D,N[26]=ct^~xt&re,N[27]=An^~st&ye,N[36]=q^~he&or,N[37]=Ae^~ue&mt,N[46]=ft^~zt&ge,N[47]=gt^~Pr&Ne,N[8]=W^~Qe&Xe,N[9]=Q^~Ge&G,N[18]=Ve^~I&$,N[19]=_e^~D&ee,N[28]=xt^~re&be,N[29]=st^~ye&Ue,N[38]=he^~or&qt,N[39]=ue^~mt&co,N[48]=zt^~ge&at,N[49]=Pr^~Ne&Ye,N[0]^=p[ie],N[1]^=p[ie+1]};if(a)n.exports=B;else for(R=0;R>6===2;o++)s++;return s}return n===$i.OVERRUN?t.length-e-1:0}function v9(n,e,t,r,i){return n===$i.OVERLONG?(r.push(i),0):(r.push(65533),J3(n,e,t))}const y9=Object.freeze({error:m9,ignore:J3,replace:v9});function H3(n,e){e==null&&(e=y9.error),n=lt(n);const t=[];let r=0;for(;r>7)){t.push(i);continue}let s=null,o=null;if((i&224)===192)s=1,o=127;else if((i&240)===224)s=2,o=2047;else if((i&248)===240)s=3,o=65535;else{(i&192)===128?r+=e($i.UNEXPECTED_CONTINUE,r-1,n,t):r+=e($i.BAD_PREFIX,r-1,n,t);continue}if(r-1+s>=n.length){r+=e($i.OVERRUN,r-1,n,t);continue}let a=i&(1<<8-s-1)-1;for(let l=0;l1114111){r+=e($i.OUT_OF_RANGE,r-1-s,n,t,a);continue}if(a>=55296&&a<=57343){r+=e($i.UTF16_SURROGATE,r-1-s,n,t,a);continue}if(a<=o){r+=e($i.OVERLONG,r-1-s,n,t,a);continue}t.push(a)}}return t}function Ia(n,e=jg.current){e!=jg.current&&(Z3.checkNormalize(),n=n.normalize(e));let t=[];for(let r=0;r>6|192),t.push(i&63|128);else if((i&64512)==55296){r++;const s=n.charCodeAt(r);if(r>=n.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((i&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(i>>12|224),t.push(i>>6&63|128),t.push(i&63|128)}return lt(t)}function B9(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function e0(n,e){return B9(H3(n,e))}function w9(n,e=jg.current){return H3(Ia(n,e))}function nd(n){return nr(Ia(n))}const z3="hash/5.7.0";function Y3(n,e){e==null&&(e=1);const t=[],r=t.forEach,i=function(s,o){r.call(s,function(a){o>0&&Array.isArray(a)?i(a,o-1):t.push(a)})};return i(n,e),t}function C9(n){const e={};for(let t=0;t>--l&1}const u=31,f=Math.pow(2,u),d=f>>>1,h=d>>1,p=f-1;let m=0;for(let C=0;C1;){let M=b+E>>>1;C>>1|c(),x=x<<1^d,S=(S^d)<<1|d|1;v=x,y=1+S-x}let w=r-4;return g.map(C=>{switch(C-w){case 3:return w+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return w+256+(n[a++]<<8|n[a++]);case 1:return w+n[a++];default:return C-1}})}function x9(n){let e=0;return()=>n[e++]}function I9(n){return x9(b9(n))}function F9(n){return n&1?~n>>1:n>>1}function E9(n,e){let t=Array(n);for(let r=0;re[o]):t}function S9(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(Q9(t,n))}for(;;){let t=n()-1;if(t<0)break;e.push(R9(t,n))}return C9(Y3(e))}function _9(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(t)}return e}function X3(n,e,t){let r=Array(n).fill(void 0).map(()=>[]);for(let i=0;ir[o].push(s));return r}function Q9(n,e){let t=1+e(),r=e(),i=_9(e),s=X3(i.length,1+n,e);return Y3(s.map((o,a)=>{const l=o[0],A=o.slice(1);return Array(i[a]).fill(void 0).map((c,u)=>{let f=u*r;return[l+u*t,A.map(d=>d+f)]})}))}function R9(n,e){let t=1+e();return X3(t,1+n,e).map(i=>[i[0],i.slice(1)])}function M9(n){let e=_B(n).sort((r,i)=>r-i);return t();function t(){let r=[];for(;;){let A=_B(n,e);if(A.length==0)break;r.push({set:new Set(A),node:t()})}r.sort((A,c)=>c.set.size-A.set.size);let i=n(),s=i%3;i=i/3|0;let o=!!(i&1);i>>=1;let a=i==1,l=i==2;return{branches:r,valid:s,fe0f:o,save:a,check:l}}}function T9(){return I9(L3("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const wC=T9(),N9=new Set(_B(wC)),D9=new Set(_B(wC)),k9=S9(wC),V9=M9(wC),IR=45,FR=95;function K3(n){return w9(n)}function L9(n){return n.filter(e=>e!=65039)}function j3(n){for(let e of n.split(".")){let t=K3(e);try{for(let r=t.lastIndexOf(FR)-1;r>=0;r--)if(t[r]!==FR)throw new Error("underscore only allowed at start");if(t.length>=4&&t.every(r=>r<128)&&t[2]===IR&&t[3]===IR)throw new Error("invalid label extension")}catch(r){throw new Error(`Invalid label "${e}": ${r.message}`)}}return n}function P9(n){return j3(W9(n,L9))}function W9(n,e){let t=K3(n).reverse(),r=[];for(;t.length;){let i=G9(t);if(i){r.push(...e(i));continue}let s=t.pop();if(N9.has(s)){r.push(s);continue}if(D9.has(s))continue;let o=k9[s];if(o){r.push(...o);continue}throw new Error(`Disallowed codepoint: 0x${s.toString(16).toUpperCase()}`)}return j3(O9(String.fromCodePoint(...r)))}function O9(n){return n.normalize("NFC")}function G9(n,e){var t;let r=V9,i,s,o=[],a=n.length;for(e&&(e.length=0);a;){let l=n[--a];if(r=(t=r.branches.find(A=>A.set.has(l)))===null||t===void 0?void 0:t.node,!r)break;if(r.save)s=l;else if(r.check&&l===s)break;o.push(l),r.fe0f&&(o.push(65039),a>0&&n[a-1]==65039&&a--),r.valid&&(i=o.slice(),r.valid==2&&i.splice(1,1),e&&e.push(...n.slice(a).reverse()),n.length=a)}return i}const Z9=new ce(z3),$3=new Uint8Array(32);$3.fill(0);function ER(n){if(n.length===0)throw new Error("invalid ENS name; empty component");return n}function q3(n){const e=Ia(P9(n)),t=[];if(n.length===0)return t;let r=0;for(let i=0;i=e.length)throw new Error("invalid ENS name; empty component");return t.push(ER(e.slice(r))),t}function ky(n){typeof n!="string"&&Z9.throwArgumentError("invalid ENS name; not a string","name",n);let e=$3;const t=q3(n);for(;t.length;)e=nr(rs([e,nr(t.pop())]));return $e(e)}function J9(n){return $e(rs(q3(n).map(e=>{if(e.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");const t=new Uint8Array(e.length+1);return t.set(e,1),t[0]=t.length-1,t})))+"00"}const H9="rlp/5.7.0",ia=new ce(H9);function UR(n){const e=[];for(;n;)e.unshift(n&255),n>>=8;return e}function SR(n,e,t){let r=0;for(let i=0;ie+1+r&&ia.throwError("child data too short",ce.errors.BUFFER_OVERRUN,{})}return{consumed:1+r,result:i}}function tP(n,e){if(n.length===0&&ia.throwError("data too short",ce.errors.BUFFER_OVERRUN,{}),n[e]>=248){const t=n[e]-247;e+1+t>n.length&&ia.throwError("data short segment too short",ce.errors.BUFFER_OVERRUN,{});const r=SR(n,e+1,t);return e+1+t+r>n.length&&ia.throwError("data long segment too short",ce.errors.BUFFER_OVERRUN,{}),_R(n,e,e+1+t,t+r)}else if(n[e]>=192){const t=n[e]-192;return e+1+t>n.length&&ia.throwError("data array too short",ce.errors.BUFFER_OVERRUN,{}),_R(n,e,e+1,t)}else if(n[e]>=184){const t=n[e]-183;e+1+t>n.length&&ia.throwError("data array too short",ce.errors.BUFFER_OVERRUN,{});const r=SR(n,e+1,t);e+1+t+r>n.length&&ia.throwError("data array too short",ce.errors.BUFFER_OVERRUN,{});const i=$e(n.slice(e+1+t,e+1+t+r));return{consumed:1+t+r,result:i}}else if(n[e]>=128){const t=n[e]-128;e+1+t>n.length&&ia.throwError("data too short",ce.errors.BUFFER_OVERRUN,{});const r=$e(n.slice(e+1,e+1+t));return{consumed:1+t,result:r}}return{consumed:1,result:$e(n[e])}}function zU(n){const e=lt(n),t=tP(e,0);return t.consumed!==e.length&&ia.throwArgumentError("invalid rlp data","data",n),t.result}const z9="address/5.7.0",rd=new ce(z9);function QR(n){bt(n,20)||rd.throwArgumentError("invalid address","address",n),n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let i=0;i<40;i++)t[i]=e[i].charCodeAt(0);const r=lt(nr(t));for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(r[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const Y9=9007199254740991;function X9(n){return Math.log10?Math.log10(n):Math.log(n)/Math.LN10}const YU={};for(let n=0;n<10;n++)YU[String(n)]=String(n);for(let n=0;n<26;n++)YU[String.fromCharCode(65+n)]=String(10+n);const RR=Math.floor(X9(Y9));function K9(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>YU[r]).join("");for(;e.length>=RR;){let r=e.substring(0,RR);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function kr(n){let e=null;if(typeof n!="string"&&rd.throwArgumentError("invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/))n.substring(0,2)!=="0x"&&(n="0x"+n),e=QR(n),n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==n&&rd.throwArgumentError("bad address checksum","address",n);else if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(n.substring(2,4)!==K9(n)&&rd.throwArgumentError("bad icap checksum","address",n),e=jz(n.substring(4));e.length<40;)e="0"+e;e=QR("0x"+e)}else rd.throwArgumentError("invalid address","address",n);return e}function nP(n){let e=null;try{e=kr(n.from)}catch{rd.throwArgumentError("missing from address","transaction",n)}const t=$d(lt(De.from(n.nonce).toHexString()));return kr(Jr(nr(CC([e,t])),12))}var j9=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const En=new ce(z3),rP=new Uint8Array(32);rP.fill(0);const $9=De.from(-1),iP=De.from(0),sP=De.from(1),q9=De.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function eY(n){const e=lt(n),t=e.length%32;return t?Ui([e,rP.slice(t)]):$e(e)}const tY=Ln(sP.toHexString(),32),nY=Ln(iP.toHexString(),32),MR={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Yb=["name","version","chainId","verifyingContract","salt"];function TR(n){return function(e){return typeof e!="string"&&En.throwArgumentError(`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,e),e}}const rY={name:TR("name"),version:TR("version"),chainId:function(n){try{return De.from(n).toString()}catch{}return En.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",n)},verifyingContract:function(n){try{return kr(n).toLowerCase()}catch{}return En.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){try{const e=lt(n);if(e.length!==32)throw new Error("bad length");return $e(e)}catch{}return En.throwArgumentError('invalid domain value "salt"',"domain.salt",n)}};function Xb(n){{const e=n.match(/^(u?)int(\d*)$/);if(e){const t=e[1]==="",r=parseInt(e[2]||"256");(r%8!==0||r>256||e[2]&&e[2]!==String(r))&&En.throwArgumentError("invalid numeric width","type",n);const i=q9.mask(t?r-1:r),s=t?i.add(sP).mul($9):iP;return function(o){const a=De.from(o);return(a.lt(s)||a.gt(i))&&En.throwArgumentError(`value out-of-bounds for ${n}`,"value",o),Ln(a.toTwos(256).toHexString(),32)}}}{const e=n.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return(t===0||t>32||e[1]!==String(t))&&En.throwArgumentError("invalid bytes width","type",n),function(r){return lt(r).length!==t&&En.throwArgumentError(`invalid length for ${n}`,"value",r),eY(r)}}}switch(n){case"address":return function(e){return Ln(kr(e),32)};case"bool":return function(e){return e?tY:nY};case"bytes":return function(e){return nr(e)};case"string":return function(e){return nd(e)}}return null}function NR(n,e){return`${n}(${e.map(({name:t,type:r})=>r+" "+t).join(",")})`}class Xi{constructor(e){Ie(this,"types",Object.freeze(as(e))),Ie(this,"_encoderCache",{}),Ie(this,"_types",{});const t={},r={},i={};Object.keys(e).forEach(a=>{t[a]={},r[a]=[],i[a]={}});for(const a in e){const l={};e[a].forEach(A=>{l[A.name]&&En.throwArgumentError(`duplicate variable name ${JSON.stringify(A.name)} in ${JSON.stringify(a)}`,"types",e),l[A.name]=!0;const c=A.type.match(/^([^\x5b]*)(\x5b|$)/)[1];c===a&&En.throwArgumentError(`circular type reference to ${JSON.stringify(c)}`,"types",e),!Xb(c)&&(r[c]||En.throwArgumentError(`unknown type ${JSON.stringify(c)}`,"types",e),r[c].push(a),t[a][c]=!0)})}const s=Object.keys(r).filter(a=>r[a].length===0);s.length===0?En.throwArgumentError("missing primary type","types",e):s.length>1&&En.throwArgumentError(`ambiguous primary types or unused types: ${s.map(a=>JSON.stringify(a)).join(", ")}`,"types",e),Ie(this,"primaryType",s[0]);function o(a,l){l[a]&&En.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",e),l[a]=!0,Object.keys(t[a]).forEach(A=>{r[A]&&(o(A,l),Object.keys(l).forEach(c=>{i[c][A]=!0}))}),delete l[a]}o(this.primaryType,{});for(const a in i){const l=Object.keys(i[a]);l.sort(),this._types[a]=NR(a,e[a])+l.map(A=>NR(A,e[A])).join("")}}getEncoder(e){let t=this._encoderCache[e];return t||(t=this._encoderCache[e]=this._getEncoder(e)),t}_getEncoder(e){{const i=Xb(e);if(i)return i}const t=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){const i=t[1],s=this.getEncoder(i),o=parseInt(t[3]);return a=>{o>=0&&a.length!==o&&En.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",a);let l=a.map(s);return this._types[i]&&(l=l.map(nr)),nr(Ui(l))}}const r=this.types[e];if(r){const i=nd(this._types[e]);return s=>{const o=r.map(({name:a,type:l})=>{const A=this.getEncoder(l)(s[a]);return this._types[l]?nr(A):A});return o.unshift(i),Ui(o)}}return En.throwArgumentError(`unknown type: ${e}`,"type",e)}encodeType(e){const t=this._types[e];return t||En.throwArgumentError(`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return nr(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,r){if(Xb(e))return r(e,t);const i=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const o=i[1],a=parseInt(i[3]);return a>=0&&t.length!==a&&En.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t),t.map(l=>this._visit(o,l,r))}const s=this.types[e];return s?s.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,t[a],r),o),{}):En.throwArgumentError(`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Xi(e)}static getPrimaryType(e){return Xi.from(e).primaryType}static hashStruct(e,t,r){return Xi.from(t).hashStruct(e,r)}static hashDomain(e){const t=[];for(const r in e){const i=MR[r];i||En.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",e),t.push({name:r,type:i})}return t.sort((r,i)=>Yb.indexOf(r.name)-Yb.indexOf(i.name)),Xi.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,r){return Ui(["0x1901",Xi.hashDomain(e),Xi.from(t).hash(r)])}static hash(e,t,r){return nr(Xi.encode(e,t,r))}static resolveNames(e,t,r,i){return j9(this,void 0,void 0,function*(){e=xn(e);const s={};e.verifyingContract&&!bt(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const o=Xi.from(t);o.visit(r,(a,l)=>(a==="address"&&!bt(l,20)&&(s[l]="0x"),l));for(const a in s)s[a]=yield i(a);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),r=o.visit(r,(a,l)=>a==="address"&&s[l]?s[l]:l),{domain:e,value:r}})}static getPayload(e,t,r){Xi.hashDomain(e);const i={},s=[];Yb.forEach(l=>{const A=e[l];A!=null&&(i[l]=rY[l](A),s.push({name:l,type:MR[l]}))});const o=Xi.from(t),a=xn(t);return a.EIP712Domain?En.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",t):a.EIP712Domain=s,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,(l,A)=>{if(l.match(/^bytes(\d*)/))return $e(lt(A));if(l.match(/^u?int/))return De.from(A).toString();switch(l){case"address":return A.toLowerCase();case"bool":return!!A;case"string":return typeof A!="string"&&En.throwArgumentError("invalid string","value",A),A}return En.throwArgumentError("unsupported type","type",l)})}}}var oP={},_t={},t0=aP;function aP(n,e){if(!n)throw new Error(e||"Assertion failed")}aP.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)};var K1={exports:{}};typeof Object.create=="function"?K1.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:K1.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}};var iY=K1.exports,sY=t0,oY=iY;_t.inherits=oY;function aY(n,e){return(n.charCodeAt(e)&64512)!==55296||e<0||e+1>=n.length?!1:(n.charCodeAt(e+1)&64512)===56320}function lY(n,e){if(Array.isArray(n))return n.slice();if(!n)return[];var t=[];if(typeof n=="string")if(e){if(e==="hex")for(n=n.replace(/[^a-z0-9]+/ig,""),n.length%2!==0&&(n="0"+n),i=0;i>6|192,t[r++]=s&63|128):aY(n,i)?(s=65536+((s&1023)<<10)+(n.charCodeAt(++i)&1023),t[r++]=s>>18|240,t[r++]=s>>12&63|128,t[r++]=s>>6&63|128,t[r++]=s&63|128):(t[r++]=s>>12|224,t[r++]=s>>6&63|128,t[r++]=s&63|128)}else for(i=0;i>>24|n>>>8&65280|n<<8&16711680|(n&255)<<24;return e>>>0}_t.htonl=lP;function cY(n,e){for(var t="",r=0;r>>0}return s}_t.join32=uY;function fY(n,e){for(var t=new Array(n.length*4),r=0,i=0;r>>24,t[i+1]=s>>>16&255,t[i+2]=s>>>8&255,t[i+3]=s&255):(t[i+3]=s>>>24,t[i+2]=s>>>16&255,t[i+1]=s>>>8&255,t[i]=s&255)}return t}_t.split32=fY;function dY(n,e){return n>>>e|n<<32-e}_t.rotr32=dY;function hY(n,e){return n<>>32-e}_t.rotl32=hY;function pY(n,e){return n+e>>>0}_t.sum32=pY;function gY(n,e,t){return n+e+t>>>0}_t.sum32_3=gY;function mY(n,e,t,r){return n+e+t+r>>>0}_t.sum32_4=mY;function vY(n,e,t,r,i){return n+e+t+r+i>>>0}_t.sum32_5=vY;function yY(n,e,t,r){var i=n[e],s=n[e+1],o=r+s>>>0,a=(o>>0,n[e+1]=o}_t.sum64=yY;function BY(n,e,t,r){var i=e+r>>>0,s=(i>>0}_t.sum64_hi=BY;function wY(n,e,t,r){var i=e+r;return i>>>0}_t.sum64_lo=wY;function CY(n,e,t,r,i,s,o,a){var l=0,A=e;A=A+r>>>0,l+=A>>0,l+=A>>0,l+=A>>0}_t.sum64_4_hi=CY;function bY(n,e,t,r,i,s,o,a){var l=e+r+s+a;return l>>>0}_t.sum64_4_lo=bY;function xY(n,e,t,r,i,s,o,a,l,A){var c=0,u=e;u=u+r>>>0,c+=u>>0,c+=u>>0,c+=u>>0,c+=u>>0}_t.sum64_5_hi=xY;function IY(n,e,t,r,i,s,o,a,l,A){var c=e+r+s+a+A;return c>>>0}_t.sum64_5_lo=IY;function FY(n,e,t){var r=e<<32-t|n>>>t;return r>>>0}_t.rotr64_hi=FY;function EY(n,e,t){var r=n<<32-t|e>>>t;return r>>>0}_t.rotr64_lo=EY;function UY(n,e,t){return n>>>t}_t.shr64_hi=UY;function SY(n,e,t){var r=n<<32-t|e>>>t;return r>>>0}_t.shr64_lo=SY;var Sh={},DR=_t,_Y=t0;function bC(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Sh.BlockHash=bC;bC.prototype.update=function(e,t){if(e=DR.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var r=e.length%this._delta8;this.pending=e.slice(e.length-r,e.length),this.pending.length===0&&(this.pending=null),e=DR.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,i[s++]=e>>>16&255,i[s++]=e>>>8&255,i[s++]=e&255}else for(i[s++]=e&255,i[s++]=e>>>8&255,i[s++]=e>>>16&255,i[s++]=e>>>24&255,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,o=8;o>>3}Na.g0_256=NY;function DY(n){return ma(n,17)^ma(n,19)^n>>>10}Na.g1_256=DY;var qd=_t,kY=Sh,VY=Na,Kb=qd.rotl32,Ap=qd.sum32,LY=qd.sum32_5,PY=VY.ft_1,hP=kY.BlockHash,WY=[1518500249,1859775393,2400959708,3395469782];function Fa(){if(!(this instanceof Fa))return new Fa;hP.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}qd.inherits(Fa,hP);var OY=Fa;Fa.blockSize=512;Fa.outSize=160;Fa.hmacStrength=80;Fa.padLength=64;Fa.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;ithis.blockSize&&(e=new this.Hash().update(e).digest()),SX(e.length<=this.blockSize);for(var t=e.length;t{s[a.toLowerCase()]=o}):r.headers.keys().forEach(o=>{s[o.toLowerCase()]=r.headers.get(o)}),{headers:s,statusCode:r.status,statusMessage:r.statusText,body:lt(new Uint8Array(i))}})}var TX=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const wo=new ce(QX);function WR(n){return new Promise(e=>{setTimeout(e,n)})}function zl(n,e){if(n==null)return null;if(typeof n=="string")return n;if(HU(n)){if(e&&(e.split("/")[0]==="text"||e.split(";")[0].trim()==="application/json"))try{return e0(n)}catch{}return $e(n)}return n}function NX(n){return Ia(n.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function DX(n,e,t){const r=typeof n=="object"&&n.throttleLimit!=null?n.throttleLimit:12;wo.assertArgument(r>0&&r%1===0,"invalid connection throttle limit","connection.throttleLimit",r);const i=typeof n=="object"?n.throttleCallback:null,s=typeof n=="object"&&typeof n.throttleSlotInterval=="number"?n.throttleSlotInterval:100;wo.assertArgument(s>0&&s%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",s);const o=typeof n=="object"?!!n.errorPassThrough:!1,a={};let l=null;const A={method:"GET"};let c=!1,u=2*60*1e3;if(typeof n=="string")l=n;else if(typeof n=="object"){if((n==null||n.url==null)&&wo.throwArgumentError("missing URL","connection.url",n),l=n.url,typeof n.timeout=="number"&&n.timeout>0&&(u=n.timeout),n.headers)for(const g in n.headers)a[g.toLowerCase()]={key:g,value:String(n.headers[g])},["if-none-match","if-modified-since"].indexOf(g.toLowerCase())>=0&&(c=!0);if(A.allowGzip=!!n.allowGzip,n.user!=null&&n.password!=null){l.substring(0,6)!=="https:"&&n.allowInsecureAuthentication!==!0&&wo.throwError("basic authentication requires a secure https url",ce.errors.INVALID_ARGUMENT,{argument:"url",url:l,user:n.user,password:"[REDACTED]"});const g=n.user+":"+n.password;a.authorization={key:"Authorization",value:"Basic "+P3(Ia(g))}}n.skipFetchSetup!=null&&(A.skipFetchSetup=!!n.skipFetchSetup),n.fetchOptions!=null&&(A.fetchOptions=xn(n.fetchOptions))}const f=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),d=l?l.match(f):null;if(d)try{const g={statusCode:200,statusMessage:"OK",headers:{"content-type":d[1]||"text/plain"},body:d[2]?L3(d[3]):NX(d[3])};let v=g.body;return t&&(v=t(g.body,g)),Promise.resolve(v)}catch(g){wo.throwError("processing response error",ce.errors.SERVER_ERROR,{body:zl(d[1],d[2]),error:g,requestBody:null,requestMethod:"GET",url:l})}e&&(A.method="POST",A.body=e,a["content-type"]==null&&(a["content-type"]={key:"Content-Type",value:"application/octet-stream"}),a["content-length"]==null&&(a["content-length"]={key:"Content-Length",value:String(e.length)}));const h={};Object.keys(a).forEach(g=>{const v=a[g];h[v.key]=v.value}),A.headers=h;const p=function(){let g=null;return{promise:new Promise(function(w,C){u&&(g=setTimeout(()=>{g!=null&&(g=null,C(wo.makeError("timeout",ce.errors.TIMEOUT,{requestBody:zl(A.body,h["content-type"]),requestMethod:A.method,timeout:u,url:l})))},u))}),cancel:function(){g!=null&&(clearTimeout(g),g=null)}}}(),m=function(){return TX(this,void 0,void 0,function*(){for(let g=0;g=300)&&(p.cancel(),wo.throwError("bad response",ce.errors.SERVER_ERROR,{status:v.statusCode,headers:v.headers,body:zl(y,v.headers?v.headers["content-type"]:null),requestBody:zl(A.body,h["content-type"]),requestMethod:A.method,url:l})),t)try{const w=yield t(y,v);return p.cancel(),w}catch(w){if(w.throttleRetry&&g{let a=null;if(s!=null)try{a=JSON.parse(e0(s))}catch(l){wo.throwError("invalid JSON",ce.errors.SERVER_ERROR,{body:s,error:l})}return t&&(a=t(a,o)),a},i=null;if(e!=null){i=Ia(e);const s=typeof n=="string"?{url:n}:xn(n);s.headers?Object.keys(s.headers).filter(a=>a.toLowerCase()==="content-type").length!==0||(s.headers=xn(s.headers),s.headers["content-type"]="application/json"):s.headers={"content-type":"application/json"},n=s}return DX(n,i,r)}function id(n,e){return e||(e={}),e=xn(e),e.floor==null&&(e.floor=0),e.ceiling==null&&(e.ceiling=1e4),e.interval==null&&(e.interval=250),new Promise(function(t,r){let i=null,s=!1;const o=()=>s?!1:(s=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{o()&&r(new Error("timeout"))},e.timeout));const a=e.retryLimit;let l=0;function A(){return n().then(function(c){if(c!==void 0)o()&&t(c);else if(e.oncePoll)e.oncePoll.once("poll",A);else if(e.onceBlock)e.onceBlock.once("block",A);else if(!s){if(l++,l>a){o()&&r(new Error("retry limit reached"));return}let u=e.interval*parseInt(String(Math.random()*Math.pow(2,l)));ue.ceiling&&(u=e.ceiling),setTimeout(A,u)}return null},function(c){o()&&r(c)})}A()})}var QB="qpzry9x8gf2tvdw0s3jn54khce6mua7l",q1={};for(var D0=0;D0>25;return(n&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function IP(n){for(var e=1,t=0;t126)return"Invalid prefix ("+n+")";e=Qd(e)^r>>5}for(e=Qd(e),t=0;tt)throw new TypeError("Exceeds length limit");n=n.toLowerCase();var r=IP(n);if(typeof r=="string")throw new Error(r);for(var i=n+"1",s=0;s>5)throw new Error("Non 5-bit word");r=Qd(r)^o,i+=QB.charAt(o)}for(s=0;s<6;++s)r=Qd(r);for(r^=1,s=0;s<6;++s){var a=r>>(5-s)*5&31;i+=QB.charAt(a)}return i}function FP(n,e){if(e=e||90,n.length<8)return n+" too short";if(n.length>e)return"Exceeds length limit";var t=n.toLowerCase(),r=n.toUpperCase();if(n!==t&&n!==r)return"Mixed-case string "+n;n=t;var i=n.lastIndexOf("1");if(i===-1)return"No separator character for "+n;if(i===0)return"Missing prefix for "+n;var s=n.slice(0,i),o=n.slice(i+1);if(o.length<6)return"Data too short";var a=IP(s);if(typeof a=="string")return a;for(var l=[],A=0;A=o.length)&&l.push(u)}return a!==1?"Invalid checksum for "+n:{prefix:s,words:l}}function VX(){var n=FP.apply(null,arguments);if(typeof n=="object")return n}function LX(n){var e=FP.apply(null,arguments);if(typeof e=="object")return e;throw new Error(e)}function IC(n,e,t,r){for(var i=0,s=0,o=(1<=t;)s-=t,a.push(i>>s&o);if(r)s>0&&a.push(i<=e)return"Excess padding";if(i<>8,f=c&255;u?l.push(u,f):l.push(f)}return l}t.toArray=r;function i(o){return o.length===1?"0"+o:o}t.zero2=i;function s(o){for(var a="",l=0;l(f>>1)-1?p=(f>>1)-m:p=m,d.isubn(p)):p=0,u[h]=p,d.iushrn(1)}return u}t.getNAF=r;function i(l,A){var c=[[],[]];l=l.clone(),A=A.clone();for(var u=0,f=0,d;l.cmpn(-u)>0||A.cmpn(-f)>0;){var h=l.andln(3)+u&3,p=A.andln(3)+f&3;h===3&&(h=-1),p===3&&(p=-1);var m;h&1?(d=l.andln(7)+u&7,(d===3||d===5)&&p===2?m=-h:m=h):m=0,c[0].push(m);var g;p&1?(d=A.andln(7)+f&7,(d===3||d===5)&&h===2?g=-p:g=p):g=0,c[1].push(g),2*u===m+1&&(u=1-u),2*f===g+1&&(f=1-f),l.iushrn(1),A.iushrn(1)}return c}t.getJSF=i;function s(l,A,c){var u="_"+A;l.prototype[A]=function(){return this[u]!==void 0?this[u]:this[u]=c.call(this)}}t.cachedProperty=s;function o(l){return typeof l=="string"?t.toArray(l,"hex"):l}t.parseBytes=o;function a(l){return new pt(l,"hex","le")}t.intFromLE=a}),RB=ms.getNAF,HX=ms.getJSF,MB=ms.assert;function ac(n,e){this.type=n,this.p=new pt(e.p,16),this.red=e.prime?pt.red(e.prime):pt.mont(this.p),this.zero=new pt(0).toRed(this.red),this.one=new pt(1).toRed(this.red),this.two=new pt(2).toRed(this.red),this.n=e.n&&new pt(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var xu=ac;ac.prototype.point=function(){throw new Error("Not implemented")};ac.prototype.validate=function(){throw new Error("Not implemented")};ac.prototype._fixedNafMul=function(e,t){MB(e.precomputed);var r=e._getDoubles(),i=RB(t,1,this._bitLength),s=(1<=a;A--)l=(l<<1)+i[A];o.push(l)}for(var c=this.jpoint(null,null,null),u=this.jpoint(null,null,null),f=s;f>0;f--){for(a=0;a=0;l--){for(var A=0;l>=0&&o[l]===0;l--)A++;if(l>=0&&A++,a=a.dblp(A),l<0)break;var c=o[l];MB(c!==0),e.type==="affine"?c>0?a=a.mixedAdd(s[c-1>>1]):a=a.mixedAdd(s[-c-1>>1].neg()):c>0?a=a.add(s[c-1>>1]):a=a.add(s[-c-1>>1].neg())}return e.type==="affine"?a.toP():a};ac.prototype._wnafMulAdd=function(e,t,r,i,s){var o=this._wnafT1,a=this._wnafT2,l=this._wnafT3,A=0,c,u,f;for(c=0;c=1;c-=2){var h=c-1,p=c;if(o[h]!==1||o[p]!==1){l[h]=RB(r[h],o[h],this._bitLength),l[p]=RB(r[p],o[p],this._bitLength),A=Math.max(l[h].length,A),A=Math.max(l[p].length,A);continue}var m=[t[h],null,null,t[p]];t[h].y.cmp(t[p].y)===0?(m[1]=t[h].add(t[p]),m[2]=t[h].toJ().mixedAdd(t[p].neg())):t[h].y.cmp(t[p].y.redNeg())===0?(m[1]=t[h].toJ().mixedAdd(t[p]),m[2]=t[h].add(t[p].neg())):(m[1]=t[h].toJ().mixedAdd(t[p]),m[2]=t[h].toJ().mixedAdd(t[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],v=HX(r[h],r[p]);for(A=Math.max(v[0].length,A),l[h]=new Array(A),l[p]=new Array(A),u=0;u=0;c--){for(var E=0;c>=0;){var x=!0;for(u=0;u=0&&E++,C=C.dblp(E),c<0)break;for(u=0;u0?f=a[u][S-1>>1]:S<0&&(f=a[u][-S-1>>1].neg()),f.type==="affine"?C=C.mixedAdd(f):C=C.add(f))}}for(c=0;c=Math.ceil((e.bitLength()+1)/t.step):!1};oo.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,s=0;s=0&&(d=A,h=c),u.negative&&(u=u.neg(),f=f.neg()),d.negative&&(d=d.neg(),h=h.neg()),[{a:u,b:f},{a:d,b:h}]};ao.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],s=i.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=s.mul(r.a),l=o.mul(i.a),A=s.mul(r.b),c=o.mul(i.b),u=e.sub(a).sub(l),f=A.add(c).neg();return{k1:u,k2:f}};ao.prototype.pointFromX=function(e,t){e=new pt(e,16),e.red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(i.redSqr().redSub(r).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(e,i)};ao.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return r.redSqr().redISub(s).cmpn(0)===0};ao.prototype._endoWnafMulAdd=function(e,t,r){for(var i=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};Ur.prototype.isInfinity=function(){return this.inf};Ur.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)};Ur.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),s=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};Ur.prototype.getX=function(){return this.x.fromRed()};Ur.prototype.getY=function(){return this.y.fromRed()};Ur.prototype.mul=function(e){return e=new pt(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Ur.prototype.mulAdd=function(e,t,r){var i=[this,t],s=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)};Ur.prototype.jmulAdd=function(e,t,r){var i=[this,t],s=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)};Ur.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Ur.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(s){return s.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t};Ur.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Lr(n,e,t,r){xu.BasePoint.call(this,n,"jacobian"),e===null&&t===null&&r===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new pt(0)):(this.x=new pt(e,16),this.y=new pt(t,16),this.z=new pt(r,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}KU(Lr,xu.BasePoint);ao.prototype.jpoint=function(e,t,r){return new Lr(this,e,t,r)};Lr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)};Lr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Lr.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),s=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),l=i.redSub(s),A=o.redSub(a);if(l.cmpn(0)===0)return A.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=l.redSqr(),u=c.redMul(l),f=i.redMul(c),d=A.redSqr().redIAdd(u).redISub(f).redISub(f),h=A.redMul(f.redISub(d)).redISub(o.redMul(u)),p=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(d,h,p)};Lr.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(i),l=s.redSub(o);if(a.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var A=a.redSqr(),c=A.redMul(a),u=r.redMul(A),f=l.redSqr().redIAdd(c).redISub(u).redISub(u),d=l.redMul(u.redISub(f)).redISub(s.redMul(c)),h=this.z.redMul(a);return this.curve.jpoint(f,d,h)};Lr.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(s),this.x.cmp(r)===0)return!0}};Lr.prototype.inspect=function(){return this.isInfinity()?"":""};Lr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Vy=Rh(function(n,e){var t=e;t.base=xu,t.short=YX,t.mont=null,t.edwards=null}),Ly=Rh(function(n,e){var t=e,r=ms.assert;function i(a){a.type==="short"?this.curve=new Vy.short(a):a.type==="edwards"?this.curve=new Vy.edwards(a):this.curve=new Vy.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,r(this.g.validate(),"Invalid curve"),r(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=i;function s(a,l){Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){var A=new i(l);return Object.defineProperty(t,a,{configurable:!0,enumerable:!0,value:A}),A}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:ta.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:ta.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:ta.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:ta.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:ta.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:ta.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:ta.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:ta.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function zA(n){if(!(this instanceof zA))return new zA(n);this.hash=n.hash,this.predResist=!!n.predResist,this.outLen=this.hash.outSize,this.minEntropy=n.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=_o.toArray(n.entropy,n.entropyEnc||"hex"),t=_o.toArray(n.nonce,n.nonceEnc||"hex"),r=_o.toArray(n.pers,n.persEnc||"hex");XU(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,r)}var UP=zA;zA.prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1};zA.prototype.generate=function(e,t,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(i=r,r=t,t=null),r&&(r=_o.toArray(r,i||"hex"),this._update(r));for(var s=[];s.length"};var XX=ms.assert;function FC(n,e){if(n instanceof FC)return n;this._importDER(n,e)||(XX(n.r&&n.s,"Signature without r or s"),this.r=new pt(n.r,16),this.s=new pt(n.s,16),n.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=n.recoveryParam)}var EC=FC;function KX(){this.place=0}function ex(n,e){var t=n[e.place++];if(!(t&128))return t;var r=t&15;if(r===0||r>4)return!1;for(var i=0,s=0,o=e.place;s>>=0;return i<=127?!1:(e.place=o,i)}function GR(n){for(var e=0,t=n.length-1;!n[e]&&!(n[e+1]&128)&&e>>3);for(n.push(t|128);--t;)n.push(e>>>(t<<3)&255);n.push(e)}FC.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),r[0]&128&&(r=[0].concat(r)),t=GR(t),r=GR(r);!r[0]&&!(r[1]&128);)r=r.slice(1);var i=[2];tx(i,t.length),i=i.concat(t),i.push(2),tx(i,r.length);var s=i.concat(r),o=[48];return tx(o,s.length),o=o.concat(s),ms.encode(o,e)};var jX=function(){throw new Error("unsupported")},SP=ms.assert;function eo(n){if(!(this instanceof eo))return new eo(n);typeof n=="string"&&(SP(Object.prototype.hasOwnProperty.call(Ly,n),"Unknown curve "+n),n=Ly[n]),n instanceof Ly.PresetCurve&&(n={curve:n}),this.curve=n.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=n.curve.g,this.g.precompute(n.curve.n.bitLength()+1),this.hash=n.hash||n.curve.hash}var $X=eo;eo.prototype.keyPair=function(e){return new jU(this,e)};eo.prototype.keyFromPrivate=function(e,t){return jU.fromPrivate(this,e,t)};eo.prototype.keyFromPublic=function(e,t){return jU.fromPublic(this,e,t)};eo.prototype.genKeyPair=function(e){e||(e={});for(var t=new UP({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||jX(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new pt(2));;){var s=new pt(t.generate(r));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}};eo.prototype._truncateToN=function(e,t){var r=e.byteLength()*8-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};eo.prototype.sign=function(e,t,r,i){typeof r=="object"&&(i=r,r=null),i||(i={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new pt(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),l=new UP({hash:this.hash,entropy:o,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),A=this.n.sub(new pt(1)),c=0;;c++){var u=i.k?i.k(c):new pt(l.generate(this.n.byteLength()));if(u=this._truncateToN(u,!0),!(u.cmpn(1)<=0||u.cmp(A)>=0)){var f=this.g.mul(u);if(!f.isInfinity()){var d=f.getX(),h=d.umod(this.n);if(h.cmpn(0)!==0){var p=u.invm(this.n).mul(h.mul(t.getPrivate()).iadd(e));if(p=p.umod(this.n),p.cmpn(0)!==0){var m=(f.getY().isOdd()?1:0)|(d.cmp(h)!==0?2:0);return i.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),m^=1),new EC({r:h,s:p,recoveryParam:m})}}}}}};eo.prototype.verify=function(e,t,r,i){e=this._truncateToN(new pt(e,16)),r=this.keyFromPublic(r,i),t=new EC(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),l=a.mul(e).umod(this.n),A=a.mul(s).umod(this.n),c;return this.curve._maxwellTrick?(c=this.g.jmulAdd(l,r.getPublic(),A),c.isInfinity()?!1:c.eqXToP(s)):(c=this.g.mulAdd(l,r.getPublic(),A),c.isInfinity()?!1:c.getX().umod(this.n).cmp(s)===0)};eo.prototype.recoverPubKey=function(n,e,t,r){SP((3&t)===t,"The recovery param is more than two bits"),e=new EC(e,r);var i=this.n,s=new pt(n),o=e.r,a=e.s,l=t&1,A=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&A)throw new Error("Unable to find sencond key candinate");A?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var c=e.r.invm(i),u=i.sub(s).mul(c).umod(i),f=a.mul(c).umod(i);return this.g.mulAdd(u,o,f)};eo.prototype.getKeyRecoveryParam=function(n,e,t,r){if(e=new EC(e,r),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(n,e,i)}catch{continue}if(s.eq(t))return i}throw new Error("Unable to find valid recovery factor")};var qX=Rh(function(n,e){var t=e;t.version="6.5.4",t.utils=ms,t.rand=function(){throw new Error("unsupported")},t.curve=Vy,t.curves=Ly,t.ec=$X,t.eddsa=null}),e6=qX.ec;const t6="signing-key/5.7.0",tF=new ce(t6);let nx=null;function sa(){return nx||(nx=new e6("secp256k1")),nx}class n6{constructor(e){Ie(this,"curve","secp256k1"),Ie(this,"privateKey",$e(e)),au(this.privateKey)!==32&&tF.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=sa().keyFromPrivate(lt(this.privateKey));Ie(this,"publicKey","0x"+t.getPublic(!1,"hex")),Ie(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Ie(this,"_isSigningKey",!0)}_addPoint(e){const t=sa().keyFromPublic(lt(this.publicKey)),r=sa().keyFromPublic(lt(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")}signDigest(e){const t=sa().keyFromPrivate(lt(this.privateKey)),r=lt(e);r.length!==32&&tF.throwArgumentError("bad digest length","digest",e);const i=t.sign(r,{canonical:!0});return BC({recoveryParam:i.recoveryParam,r:Ln("0x"+i.r.toString(16),32),s:Ln("0x"+i.s.toString(16),32)})}computeSharedSecret(e){const t=sa().keyFromPrivate(lt(this.privateKey)),r=sa().keyFromPublic(lt(_P(e)));return Ln("0x"+t.derive(r.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function r6(n,e){const t=BC(e),r={r:lt(t.r),s:lt(t.s)};return"0x"+sa().recoverPubKey(lt(n),r,t.recoveryParam).encode("hex",!1)}function _P(n,e){const t=lt(n);if(t.length===32){const r=new n6(t);return e?"0x"+sa().keyFromPrivate(t).getPublic(!0,"hex"):r.publicKey}else{if(t.length===33)return e?$e(t):"0x"+sa().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+sa().keyFromPublic(t).getPublic(!0,"hex"):$e(t)}return tF.throwArgumentError("invalid public or private key","key","[REDACTED]")}const i6="transactions/5.7.0",Ll=new ce(i6);var ZR;(function(n){n[n.legacy=0]="legacy",n[n.eip2930=1]="eip2930",n[n.eip1559=2]="eip1559"})(ZR||(ZR={}));function $U(n){return n==="0x"?null:kr(n)}function zr(n){return n==="0x"?O3:De.from(n)}function s6(n){const e=_P(n);return kr(Jr(nr(Jr(e,1)),12))}function QP(n,e){return s6(r6(lt(n),e))}function qi(n,e){const t=$d(De.from(n).toHexString());return t.length>32&&Ll.throwArgumentError("invalid length for "+e,"transaction:"+e,n),t}function rx(n,e){return{address:kr(n),storageKeys:(e||[]).map((t,r)=>(au(t)!==32&&Ll.throwArgumentError("invalid access list storageKey",`accessList[${n}:${r}]`,t),t.toLowerCase()))}}function Iu(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(t.length>2&&Ll.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${r}]`,t),rx(t[0],t[1])):rx(t.address,t.storageKeys));const e=Object.keys(n).map(t=>{const r=n[t].reduce((i,s)=>(i[s]=!0,i),{});return rx(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function RP(n){return Iu(n).map(e=>[e.address,e.storageKeys])}function o6(n,e){if(n.gasPrice!=null){const r=De.from(n.gasPrice),i=De.from(n.maxFeePerGas||0);r.eq(i)||Ll.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:r,maxFeePerGas:i})}const t=[qi(n.chainId||0,"chainId"),qi(n.nonce||0,"nonce"),qi(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),qi(n.maxFeePerGas||0,"maxFeePerGas"),qi(n.gasLimit||0,"gasLimit"),n.to!=null?kr(n.to):"0x",qi(n.value||0,"value"),n.data||"0x",RP(n.accessList||[])];if(e){const r=BC(e);t.push(qi(r.recoveryParam,"recoveryParam")),t.push($d(r.r)),t.push($d(r.s))}return Ui(["0x02",CC(t)])}function a6(n,e){const t=[qi(n.chainId||0,"chainId"),qi(n.nonce||0,"nonce"),qi(n.gasPrice||0,"gasPrice"),qi(n.gasLimit||0,"gasLimit"),n.to!=null?kr(n.to):"0x",qi(n.value||0,"value"),n.data||"0x",RP(n.accessList||[])];if(e){const r=BC(e);t.push(qi(r.recoveryParam,"recoveryParam")),t.push($d(r.r)),t.push($d(r.s))}return Ui(["0x01",CC(t)])}function MP(n,e,t){try{const r=zr(e[0]).toNumber();if(r!==0&&r!==1)throw new Error("bad recid");n.v=r}catch{Ll.throwArgumentError("invalid v for transaction type: 1","v",e[0])}n.r=Ln(e[1],32),n.s=Ln(e[2],32);try{const r=nr(t(n));n.from=QP(r,{r:n.r,s:n.s,recoveryParam:n.v})}catch{}}function l6(n){const e=zU(n.slice(1));e.length!==9&&e.length!==12&&Ll.throwArgumentError("invalid component count for transaction type: 2","payload",$e(n));const t=zr(e[2]),r=zr(e[3]),i={type:2,chainId:zr(e[0]).toNumber(),nonce:zr(e[1]).toNumber(),maxPriorityFeePerGas:t,maxFeePerGas:r,gasPrice:null,gasLimit:zr(e[4]),to:$U(e[5]),value:zr(e[6]),data:e[7],accessList:Iu(e[8])};return e.length===9||(i.hash=nr(n),MP(i,e.slice(9),o6)),i}function A6(n){const e=zU(n.slice(1));e.length!==8&&e.length!==11&&Ll.throwArgumentError("invalid component count for transaction type: 1","payload",$e(n));const t={type:1,chainId:zr(e[0]).toNumber(),nonce:zr(e[1]).toNumber(),gasPrice:zr(e[2]),gasLimit:zr(e[3]),to:$U(e[4]),value:zr(e[5]),data:e[6],accessList:Iu(e[7])};return e.length===8||(t.hash=nr(n),MP(t,e.slice(8),a6)),t}function c6(n){const e=zU(n);e.length!==9&&e.length!==6&&Ll.throwArgumentError("invalid raw transaction","rawTransaction",n);const t={nonce:zr(e[0]).toNumber(),gasPrice:zr(e[1]),gasLimit:zr(e[2]),to:$U(e[3]),value:zr(e[4]),data:e[5],chainId:0};if(e.length===6)return t;try{t.v=De.from(e[6]).toNumber()}catch{return t}if(t.r=Ln(e[7],32),t.s=Ln(e[8],32),De.from(t.r).isZero()&&De.from(t.s).isZero())t.chainId=t.v,t.v=0;else{t.chainId=Math.floor((t.v-35)/2),t.chainId<0&&(t.chainId=0);let r=t.v-27;const i=e.slice(0,6);t.chainId!==0&&(i.push($e(t.chainId)),i.push("0x"),i.push("0x"),r-=t.chainId*2+8);const s=nr(CC(i));try{t.from=QP(s,{r:$e(t.r),s:$e(t.s),recoveryParam:r})}catch{}t.hash=nr(n)}return t.type=null,t}function u6(n){const e=lt(n);if(e[0]>127)return c6(e);switch(e[0]){case 1:return A6(e);case 2:return l6(e)}return Ll.throwError(`unsupported transaction type: ${e[0]}`,ce.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}const up=new ce(ti);let JR=class Ke{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const e={},t=this.address.bind(this),r=this.bigNumber.bind(this),i=this.blockTag.bind(this),s=this.data.bind(this),o=this.hash.bind(this),a=this.hex.bind(this),l=this.number.bind(this),A=this.type.bind(this),c=u=>this.data(u,!0);return e.transaction={hash:o,type:A,accessList:Ke.allowNull(this.accessList.bind(this),null),blockHash:Ke.allowNull(o,null),blockNumber:Ke.allowNull(l,null),transactionIndex:Ke.allowNull(l,null),confirmations:Ke.allowNull(l,null),from:t,gasPrice:Ke.allowNull(r),maxPriorityFeePerGas:Ke.allowNull(r),maxFeePerGas:Ke.allowNull(r),gasLimit:r,to:Ke.allowNull(t,null),value:r,nonce:l,data:s,r:Ke.allowNull(this.uint256),s:Ke.allowNull(this.uint256),v:Ke.allowNull(l),creates:Ke.allowNull(t,null),raw:Ke.allowNull(s)},e.transactionRequest={from:Ke.allowNull(t),nonce:Ke.allowNull(l),gasLimit:Ke.allowNull(r),gasPrice:Ke.allowNull(r),maxPriorityFeePerGas:Ke.allowNull(r),maxFeePerGas:Ke.allowNull(r),to:Ke.allowNull(t),value:Ke.allowNull(r),data:Ke.allowNull(c),type:Ke.allowNull(l),accessList:Ke.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:l,blockNumber:l,transactionHash:o,address:t,topics:Ke.arrayOf(o),data:s,logIndex:l,blockHash:o},e.receipt={to:Ke.allowNull(this.address,null),from:Ke.allowNull(this.address,null),contractAddress:Ke.allowNull(t,null),transactionIndex:l,root:Ke.allowNull(a),gasUsed:r,logsBloom:Ke.allowNull(s),blockHash:o,transactionHash:o,logs:Ke.arrayOf(this.receiptLog.bind(this)),blockNumber:l,confirmations:Ke.allowNull(l,null),cumulativeGasUsed:r,effectiveGasPrice:Ke.allowNull(r),status:Ke.allowNull(l),type:A},e.block={hash:Ke.allowNull(o),parentHash:o,number:l,timestamp:l,nonce:Ke.allowNull(a),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:Ke.allowNull(t),extraData:s,transactions:Ke.allowNull(Ke.arrayOf(o)),baseFeePerGas:Ke.allowNull(r)},e.blockWithTransactions=xn(e.block),e.blockWithTransactions.transactions=Ke.allowNull(Ke.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:Ke.allowNull(i,void 0),toBlock:Ke.allowNull(i,void 0),blockHash:Ke.allowNull(o,void 0),address:Ke.allowNull(t,void 0),topics:Ke.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:Ke.allowNull(l),blockHash:Ke.allowNull(o),transactionIndex:l,removed:Ke.allowNull(this.boolean.bind(this)),address:t,data:Ke.allowFalsish(s,"0x"),topics:Ke.arrayOf(o),transactionHash:o,logIndex:l},e}accessList(e){return Iu(e||[])}number(e){return e==="0x"?0:De.from(e).toNumber()}type(e){return e==="0x"||e==null?0:De.from(e).toNumber()}bigNumber(e){return De.from(e)}boolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){if(e=e.toLowerCase(),e==="true")return!0;if(e==="false")return!1}throw new Error("invalid boolean - "+e)}hex(e,t){return typeof e=="string"&&(!t&&e.substring(0,2)!=="0x"&&(e="0x"+e),bt(e))?e.toLowerCase():up.throwArgumentError("invalid hash","value",e)}data(e,t){const r=this.hex(e,t);if(r.length%2!==0)throw new Error("invalid data; odd-length - "+e);return r}address(e){return kr(e)}callAddress(e){if(!bt(e,32))return null;const t=kr(Jr(e,12));return t===A9?null:t}contractAddress(e){return nP(e)}blockTag(e){if(e==null)return"latest";if(e==="earliest")return"0x0";switch(e){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return e}if(typeof e=="number"||bt(e))return yC(e);throw new Error("invalid blockTag")}hash(e,t){const r=this.hex(e,t);return au(r)!==32?up.throwArgumentError("invalid hash","value",e):r}difficulty(e){if(e==null)return null;const t=De.from(e);try{return t.toNumber()}catch{}return null}uint256(e){if(!bt(e))throw new Error("invalid uint256");return Ln(e,32)}_block(e,t){e.author!=null&&e.miner==null&&(e.miner=e.author);const r=e._difficulty!=null?e._difficulty:e.difficulty,i=Ke.check(t,e);return i._difficulty=r==null?null:De.from(r),i}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return Ke.check(this.formats.transactionRequest,e)}transactionResponse(e){e.gas!=null&&e.gasLimit==null&&(e.gasLimit=e.gas),e.to&&De.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),e.input!=null&&e.data==null&&(e.data=e.input),e.to==null&&e.creates==null&&(e.creates=this.contractAddress(e)),(e.type===1||e.type===2)&&e.accessList==null&&(e.accessList=[]);const t=Ke.check(this.formats.transaction,e);if(e.chainId!=null){let r=e.chainId;bt(r)&&(r=De.from(r).toNumber()),t.chainId=r}else{let r=e.networkId;r==null&&t.v==null&&(r=e.chainId),bt(r)&&(r=De.from(r).toNumber()),typeof r!="number"&&t.v!=null&&(r=(t.v-35)/2,r<0&&(r=0),r=parseInt(r)),typeof r!="number"&&(r=0),t.chainId=r}return t.blockHash&&t.blockHash.replace(/0/g,"")==="x"&&(t.blockHash=null),t}transaction(e){return u6(e)}receiptLog(e){return Ke.check(this.formats.receiptLog,e)}receipt(e){const t=Ke.check(this.formats.receipt,e);if(t.root!=null)if(t.root.length<=4){const r=De.from(t.root).toNumber();r===0||r===1?(t.status!=null&&t.status!==r&&up.throwArgumentError("alt-root-status/status mismatch","value",{root:t.root,status:t.status}),t.status=r,delete t.root):up.throwArgumentError("invalid alt-root-status","value.root",t.root)}else t.root.length!==66&&up.throwArgumentError("invalid root hash","value.root",t.root);return t.status!=null&&(t.byzantium=!0),t}topics(e){return Array.isArray(e)?e.map(t=>this.topics(t)):e!=null?this.hash(e,!0):null}filter(e){return Ke.check(this.formats.filter,e)}filterLog(e){return Ke.check(this.formats.filterLog,e)}static check(e,t){const r={};for(const i in e)try{const s=e[i](t[i]);s!==void 0&&(r[i]=s)}catch(s){throw s.checkKey=i,s.checkValue=t[i],s}return r}static allowNull(e,t){return function(r){return r==null?t:e(r)}}static allowFalsish(e,t){return function(r){return r?e(r):t}}static arrayOf(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");const r=[];return t.forEach(function(i){r.push(e(i))}),r}}};function f6(n){return n&&typeof n.isCommunityResource=="function"}function HR(n){return f6(n)&&n.isCommunityResource()}let zR=!1;function UC(){zR||(zR=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var dt=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const wt=new ce(ti),d6=10;function YR(n){return n==null?"null":(au(n)!==32&&wt.throwArgumentError("invalid topic","topic",n),n.toLowerCase())}function XR(n){for(n=n.slice();n.length>0&&n[n.length-1]==null;)n.pop();return n.map(e=>{if(Array.isArray(e)){const t={};e.forEach(i=>{t[YR(i)]=!0});const r=Object.keys(t);return r.sort(),r.join("|")}else return YR(e)}).join("&")}function h6(n){return n===""?[]:n.split(/&/g).map(e=>{if(e==="")return[];const t=e.split("|").map(r=>r==="null"?null:r);return t.length===1?t[0]:t})}function Ju(n){if(typeof n=="string"){if(n=n.toLowerCase(),au(n)===32)return"tx:"+n;if(n.indexOf(":")===-1)return n}else{if(Array.isArray(n))return"filter:*:"+XR(n);if(o9.isForkEvent(n))throw wt.warn("not implemented"),new Error("not implemented");if(n&&typeof n=="object")return"filter:"+(n.address||"*")+":"+XR(n.topics||[])}throw new Error("invalid event - "+n)}function fp(){return new Date().getTime()}function KR(n){return new Promise(e=>{setTimeout(e,n)})}const p6=["block","network","pending","poll"];let g6=class{constructor(e,t,r){Ie(this,"tag",e),Ie(this,"listener",t),Ie(this,"once",r),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const e=this.tag.split(":");return e[0]!=="tx"?null:e[1]}get filter(){const e=this.tag.split(":");if(e[0]!=="filter")return null;const t=e[1],r=h6(e[2]),i={};return r.length>0&&(i.topics=r),t&&t!=="*"&&(i.address=t),i}pollable(){return this.tag.indexOf(":")>=0||p6.indexOf(this.tag)>=0}};const m6={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function ix(n){return Ln(De.from(n).toHexString(),32)}function jR(n){return X1.encode(rs([n,Jr(PR(PR(n)),0,4)]))}const TP=new RegExp("^(ipfs)://(.*)$","i"),$R=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),TP,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Py(n,e){try{return e0($g(n,e))}catch{}return null}function $g(n,e){if(n==="0x")return null;const t=De.from(Jr(n,e,e+32)).toNumber(),r=De.from(Jr(n,t,t+32)).toNumber();return Jr(n,t+32,t+32+r)}function sx(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):wt.throwArgumentError("unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}function qR(n){const e=lt(n);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function v6(n){if(n.length%32===0)return n;const e=new Uint8Array(Math.ceil(n.length/32)*32);return e.set(n),e}function NP(n){const e=[];let t=0;for(let r=0;rDe.from(e).eq(1)).catch(e=>{if(e.code===ce.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,e})),this._supportsEip2544}_fetch(e,t){return dt(this,void 0,void 0,function*(){const r={to:this.address,ccipReadEnabled:!0,data:Ui([e,ky(this.name),t||"0x"])};let i=!1;(yield this.supportsWildcard())&&(i=!0,r.data=Ui(["0x9061b923",NP([J9(this.name),r.data])]));try{let s=yield this.provider.call(r);return lt(s).length%32===4&&wt.throwError("resolver threw error",ce.errors.CALL_EXCEPTION,{transaction:r,data:s}),i&&(s=$g(s,0)),s}catch(s){if(s.code===ce.errors.CALL_EXCEPTION)return null;throw s}})}_fetchBytes(e,t){return dt(this,void 0,void 0,function*(){const r=yield this._fetch(e,t);return r!=null?$g(r,0):null})}_getAddress(e,t){const r=m6[String(e)];if(r==null&&wt.throwError(`unsupported coin type: ${e}`,ce.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),r.ilk==="eth")return this.provider.formatter.address(t);const i=lt(t);if(r.p2pkh!=null){const s=t.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(s){const o=parseInt(s[1],16);if(s[2].length===o*2&&o>=1&&o<=75)return jR(rs([[r.p2pkh],"0x"+s[2]]))}}if(r.p2sh!=null){const s=t.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(s){const o=parseInt(s[1],16);if(s[2].length===o*2&&o>=1&&o<=75)return jR(rs([[r.p2sh],"0x"+s[2]]))}}if(r.prefix!=null){const s=i[1];let o=i[0];if(o===0?s!==20&&s!==32&&(o=-1):o=-1,o>=0&&i.length===2+s&&s>=1&&s<=75){const a=OR.toWords(i.slice(2));return a.unshift(o),OR.encode(r.prefix,a)}}return null}getAddress(e){return dt(this,void 0,void 0,function*(){if(e==null&&(e=60),e===60)try{const i=yield this._fetch("0x3b3b57de");return i==="0x"||i===d9?null:this.provider.formatter.callAddress(i)}catch(i){if(i.code===ce.errors.CALL_EXCEPTION)return null;throw i}const t=yield this._fetchBytes("0xf1cb7e06",ix(e));if(t==null||t==="0x")return null;const r=this._getAddress(e,t);return r==null&&wt.throwError("invalid or unsupported coin data",ce.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:t}),r})}getAvatar(){return dt(this,void 0,void 0,function*(){const e=[{type:"name",content:this.name}];try{const t=yield this.getText("avatar");if(t==null)return null;for(let r=0;r<$R.length;r++){const i=t.match($R[r]);if(i==null)continue;const s=i[1].toLowerCase();switch(s){case"https":return e.push({type:"url",content:t}),{linkage:e,url:t};case"data":return e.push({type:"data",content:t}),{linkage:e,url:t};case"ipfs":return e.push({type:"ipfs",content:t}),{linkage:e,url:sx(t)};case"erc721":case"erc1155":{const o=s==="erc721"?"0xc87b56dd":"0x0e89341c";e.push({type:s,content:t});const a=this._resolvedAddress||(yield this.getAddress()),l=(i[2]||"").split("/");if(l.length!==2)return null;const A=yield this.provider.formatter.address(l[0]),c=Ln(De.from(l[1]).toHexString(),32);if(s==="erc721"){const p=this.provider.formatter.callAddress(yield this.provider.call({to:A,data:Ui(["0x6352211e",c])}));if(a!==p)return null;e.push({type:"owner",content:p})}else if(s==="erc1155"){const p=De.from(yield this.provider.call({to:A,data:Ui(["0x00fdd58e",Ln(a,32),c])}));if(p.isZero())return null;e.push({type:"balance",content:p.toString()})}const u={to:this.provider.formatter.address(l[0]),data:Ui([o,c])};let f=Py(yield this.provider.call(u),0);if(f==null)return null;e.push({type:"metadata-url-base",content:f}),s==="erc1155"&&(f=f.replace("{id}",c.substring(2)),e.push({type:"metadata-url-expanded",content:f})),f.match(/^ipfs:/i)&&(f=sx(f)),e.push({type:"metadata-url",content:f});const d=yield xC(f);if(!d)return null;e.push({type:"metadata",content:JSON.stringify(d)});let h=d.image;if(typeof h!="string")return null;if(!h.match(/^(https:\/\/|data:)/i)){if(h.match(TP)==null)return null;e.push({type:"url-ipfs",content:h}),h=sx(h)}return e.push({type:"url",content:h}),{linkage:e,url:h}}}}}catch{}return null})}getContentHash(){return dt(this,void 0,void 0,function*(){const e=yield this._fetchBytes("0xbc1c58d1");if(e==null||e==="0x")return null;const t=e.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const o=parseInt(t[3],16);if(t[4].length===o*2)return"ipfs://"+X1.encode("0x"+t[1])}const r=e.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(r){const o=parseInt(r[3],16);if(r[4].length===o*2)return"ipns://"+X1.encode("0x"+r[1])}const i=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(i&&i[1].length===32*2)return"bzz://"+i[1];const s=e.match(/^0x90b2c605([0-9a-f]*)$/);if(s&&s[1].length===34*2){const o={"=":"","+":"-","/":"_"};return"sia://"+P3("0x"+s[1]).replace(/[=+\/]/g,l=>o[l])}return wt.throwError("invalid or unsupported content hash data",ce.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})})}getText(e){return dt(this,void 0,void 0,function*(){let t=Ia(e);t=rs([ix(64),ix(t.length),t]),t.length%32!==0&&(t=rs([t,Ln("0x",32-e.length%32)]));const r=yield this._fetchBytes("0x59d1d43c",$e(t));return r==null||r==="0x"?null:e0(r)})}}let ox=null,y6=1;class qU extends qm{constructor(e){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),Ie(this,"anyNetwork",e==="any"),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch(t=>{}),this._ready().catch(t=>{});else{const t=is(new.target,"getNetwork")(e);t?(Ie(this,"_network",t),this.emit("network",t,null)):wt.throwArgumentError("invalid network","network",e)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return dt(this,void 0,void 0,function*(){if(this._network==null){let e=null;if(this._networkPromise)try{e=yield this._networkPromise}catch{}e==null&&(e=yield this.detectNetwork()),e||wt.throwError("no network detected",ce.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=e:Ie(this,"_network",e),this.emit("network",e,null))}return this._network})}get ready(){return id(()=>this._ready().then(e=>e,e=>{if(!(e.code===ce.errors.NETWORK_ERROR&&e.event==="noNetwork"))throw e}))}static getFormatter(){return ox==null&&(ox=new JR),ox}static getNetwork(e){return V3(e??"homestead")}ccipReadFetch(e,t,r){return dt(this,void 0,void 0,function*(){if(this.disableCcipRead||r.length===0)return null;const i=e.to.toLowerCase(),s=t.toLowerCase(),o=[];for(let a=0;a=0?null:JSON.stringify({data:s,sender:i}),u=yield xC({url:A,errorPassThrough:!0},c,(d,h)=>(d.status=h.statusCode,d));if(u.data)return u.data;const f=u.message||"unknown error";if(u.status>=400&&u.status<500)return wt.throwError(`response not found during CCIP fetch: ${f}`,ce.errors.SERVER_ERROR,{url:l,errorMessage:f});o.push(f)}return wt.throwError(`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,ce.errors.SERVER_ERROR,{urls:r,errorMessages:o})})}_getInternalBlockNumber(e){return dt(this,void 0,void 0,function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){const i=this._internalBlockNumber;try{const s=yield i;if(fp()-s.respTime<=e)return s.blockNumber;break}catch{if(this._internalBlockNumber===i)break}}const t=fp(),r=jn({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(i=>null,i=>i)}).then(({blockNumber:i,networkError:s})=>{if(s)throw this._internalBlockNumber===r&&(this._internalBlockNumber=null),s;const o=fp();return i=De.from(i).toNumber(),i{this._internalBlockNumber===r&&(this._internalBlockNumber=null)}),(yield r).blockNumber})}poll(){return dt(this,void 0,void 0,function*(){const e=y6++,t=[];let r=null;try{r=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(i){this.emit("error",i);return}if(this._setFastBlockNumber(r),this.emit("poll",e,r),r===this._lastBlockNumber){this.emit("didPoll",e);return}if(this._emitted.block===-2&&(this._emitted.block=r-1),Math.abs(this._emitted.block-r)>1e3)wt.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${r})`),this.emit("error",wt.makeError("network block skew detected",ce.errors.NETWORK_ERROR,{blockNumber:r,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",r);else for(let i=this._emitted.block+1;i<=r;i++)this.emit("block",i);this._emitted.block!==r&&(this._emitted.block=r,Object.keys(this._emitted).forEach(i=>{if(i==="block")return;const s=this._emitted[i];s!=="pending"&&r-s>12&&delete this._emitted[i]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=r-1),this._events.forEach(i=>{switch(i.type){case"tx":{const s=i.hash;let o=this.getTransactionReceipt(s).then(a=>(!a||a.blockNumber==null||(this._emitted["t:"+s]=a.blockNumber,this.emit(s,a)),null)).catch(a=>{this.emit("error",a)});t.push(o);break}case"filter":{if(!i._inflight){i._inflight=!0,i._lastBlockNumber===-2&&(i._lastBlockNumber=r-1);const s=i.filter;s.fromBlock=i._lastBlockNumber+1,s.toBlock=r;const o=s.toBlock-this._maxFilterBlockRange;o>s.fromBlock&&(s.fromBlock=o),s.fromBlock<0&&(s.fromBlock=0);const a=this.getLogs(s).then(l=>{i._inflight=!1,l.length!==0&&l.forEach(A=>{A.blockNumber>i._lastBlockNumber&&(i._lastBlockNumber=A.blockNumber),this._emitted["b:"+A.blockHash]=A.blockNumber,this._emitted["t:"+A.transactionHash]=A.blockNumber,this.emit(s,A)})}).catch(l=>{this.emit("error",l),i._inflight=!1});t.push(a)}break}}}),this._lastBlockNumber=r,Promise.all(t).then(()=>{this.emit("didPoll",e)}).catch(i=>{this.emit("error",i)})})}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return dt(this,void 0,void 0,function*(){return wt.throwError("provider does not support network detection",ce.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return dt(this,void 0,void 0,function*(){const e=yield this._ready(),t=yield this.detectNetwork();if(e.chainId!==t.chainId){if(this.anyNetwork)return this._network=t,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",t,e),yield KR(0),this._network;const r=wt.makeError("underlying network changed",ce.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:t});throw this.emit("error",r),r}return e})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(e=>{this._setFastBlockNumber(e)},e=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(e){e&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if(typeof e!="number"||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const e=fp();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(e){this._fastBlockNumber!=null&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}waitForTransaction(e,t,r){return dt(this,void 0,void 0,function*(){return this._waitForTransaction(e,t??1,r||0,null)})}_waitForTransaction(e,t,r,i){return dt(this,void 0,void 0,function*(){const s=yield this.getTransactionReceipt(e);return(s?s.confirmations:0)>=t?s:new Promise((o,a)=>{const l=[];let A=!1;const c=function(){return A?!0:(A=!0,l.forEach(f=>{f()}),!1)},u=f=>{f.confirmations{this.removeListener(e,u)}),i){let f=i.startBlock,d=null;const h=p=>dt(this,void 0,void 0,function*(){A||(yield KR(1e3),this.getTransactionCount(i.from).then(m=>dt(this,void 0,void 0,function*(){if(!A){if(m<=i.nonce)f=p;else{{const g=yield this.getTransaction(e);if(g&&g.blockNumber!=null)return}for(d==null&&(d=f-3,d{A||this.once("block",h)}))});if(A)return;this.once("block",h),l.push(()=>{this.removeListener("block",h)})}if(typeof r=="number"&&r>0){const f=setTimeout(()=>{c()||a(wt.makeError("timeout exceeded",ce.errors.TIMEOUT,{timeout:r}))},r);f.unref&&f.unref(),l.push(()=>{clearTimeout(f)})}})})}getBlockNumber(){return dt(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const e=yield this.perform("getGasPrice",{});try{return De.from(e)}catch(t){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:t})}})}getBalance(e,t){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield jn({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),i=yield this.perform("getBalance",r);try{return De.from(i)}catch(s){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getBalance",params:r,result:i,error:s})}})}getTransactionCount(e,t){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield jn({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),i=yield this.perform("getTransactionCount",r);try{return De.from(i).toNumber()}catch(s){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getTransactionCount",params:r,result:i,error:s})}})}getCode(e,t){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield jn({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),i=yield this.perform("getCode",r);try{return $e(i)}catch(s){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getCode",params:r,result:i,error:s})}})}getStorageAt(e,t,r){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const i=yield jn({address:this._getAddress(e),blockTag:this._getBlockTag(r),position:Promise.resolve(t).then(o=>yC(o))}),s=yield this.perform("getStorageAt",i);try{return $e(s)}catch(o){return wt.throwError("bad result from backend",ce.errors.SERVER_ERROR,{method:"getStorageAt",params:i,result:s,error:o})}})}_wrapTransaction(e,t,r){if(t!=null&&au(t)!==32)throw new Error("invalid response - sendTransaction");const i=e;return t!=null&&e.hash!==t&&wt.throwError("Transaction hash mismatch from Provider.sendTransaction.",ce.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:t}),i.wait=(s,o)=>dt(this,void 0,void 0,function*(){s==null&&(s=1),o==null&&(o=0);let a;s!==0&&r!=null&&(a={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:r});const l=yield this._waitForTransaction(e.hash,s,o,a);return l==null&&s===0?null:(this._emitted["t:"+e.hash]=l.blockNumber,l.status===0&&wt.throwError("transaction failed",ce.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:l}),l)}),i}sendTransaction(e){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield Promise.resolve(e).then(s=>$e(s)),r=this.formatter.transaction(e);r.confirmations==null&&(r.confirmations=0);const i=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const s=yield this.perform("sendTransaction",{signedTransaction:t});return this._wrapTransaction(r,s,i)}catch(s){throw s.transaction=r,s.transactionHash=r.hash,s}})}_getTransactionRequest(e){return dt(this,void 0,void 0,function*(){const t=yield e,r={};return["from","to"].forEach(i=>{t[i]!=null&&(r[i]=Promise.resolve(t[i]).then(s=>s?this._getAddress(s):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(i=>{t[i]!=null&&(r[i]=Promise.resolve(t[i]).then(s=>s?De.from(s):null))}),["type"].forEach(i=>{t[i]!=null&&(r[i]=Promise.resolve(t[i]).then(s=>s??null))}),t.accessList&&(r.accessList=this.formatter.accessList(t.accessList)),["data"].forEach(i=>{t[i]!=null&&(r[i]=Promise.resolve(t[i]).then(s=>s?$e(s):null))}),this.formatter.transactionRequest(yield jn(r))})}_getFilter(e){return dt(this,void 0,void 0,function*(){e=yield e;const t={};return e.address!=null&&(t.address=this._getAddress(e.address)),["blockHash","topics"].forEach(r=>{e[r]!=null&&(t[r]=e[r])}),["fromBlock","toBlock"].forEach(r=>{e[r]!=null&&(t[r]=this._getBlockTag(e[r]))}),this.formatter.filter(yield jn(t))})}_call(e,t,r){return dt(this,void 0,void 0,function*(){r>=d6&&wt.throwError("CCIP read exceeded maximum redirections",ce.errors.SERVER_ERROR,{redirects:r,transaction:e});const i=e.to,s=yield this.perform("call",{transaction:e,blockTag:t});if(r>=0&&t==="latest"&&i!=null&&s.substring(0,10)==="0x556f1830"&&au(s)%32===4)try{const o=Jr(s,4),a=Jr(o,0,32);De.from(a).eq(i)||wt.throwError("CCIP Read sender did not match",ce.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:s});const l=[],A=De.from(Jr(o,32,64)).toNumber(),c=De.from(Jr(o,A,A+32)).toNumber(),u=Jr(o,A+32);for(let g=0;gdt(this,void 0,void 0,function*(){const s=yield this.perform("getBlock",i);if(s==null)return i.blockHash!=null&&this._emitted["b:"+i.blockHash]==null||i.blockTag!=null&&r>this._emitted.block?null:void 0;if(t){let o=null;for(let l=0;lthis._wrapTransaction(l)),a}return this.formatter.block(s)}),{oncePoll:this})})}getBlock(e){return this._getBlock(e,!1)}getBlockWithTransactions(e){return this._getBlock(e,!0)}getTransaction(e){return dt(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return id(()=>dt(this,void 0,void 0,function*(){const r=yield this.perform("getTransaction",t);if(r==null)return this._emitted["t:"+e]==null?null:void 0;const i=this.formatter.transactionResponse(r);if(i.blockNumber==null)i.confirmations=0;else if(i.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-i.blockNumber+1;o<=0&&(o=1),i.confirmations=o}return this._wrapTransaction(i)}),{oncePoll:this})})}getTransactionReceipt(e){return dt(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return id(()=>dt(this,void 0,void 0,function*(){const r=yield this.perform("getTransactionReceipt",t);if(r==null)return this._emitted["t:"+e]==null?null:void 0;if(r.blockHash==null)return;const i=this.formatter.receipt(r);if(i.blockNumber==null)i.confirmations=0;else if(i.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-i.blockNumber+1;o<=0&&(o=1),i.confirmations=o}return i}),{oncePoll:this})})}getLogs(e){return dt(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield jn({filter:this._getFilter(e)}),r=yield this.perform("getLogs",t);return r.forEach(i=>{i.removed==null&&(i.removed=!1)}),JR.arrayOf(this.formatter.filterLog.bind(this.formatter))(r)})}getEtherPrice(){return dt(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(e){return dt(this,void 0,void 0,function*(){if(e=yield e,typeof e=="number"&&e<0){e%1&&wt.throwArgumentError("invalid BlockTag","blockTag",e);let t=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return t+=e,t<0&&(t=0),this.formatter.blockTag(t)}return this.formatter.blockTag(e)})}getResolver(e){return dt(this,void 0,void 0,function*(){let t=e;for(;;){if(t===""||t==="."||e!=="eth"&&t==="eth")return null;const r=yield this._getResolver(t,"getResolver");if(r!=null){const i=new eM(this,r,e);return t!==e&&!(yield i.supportsWildcard())?null:i}t=t.split(".").slice(1).join(".")}})}_getResolver(e,t){return dt(this,void 0,void 0,function*(){t==null&&(t="ENS");const r=yield this.getNetwork();r.ensAddress||wt.throwError("network does not support ENS",ce.errors.UNSUPPORTED_OPERATION,{operation:t,network:r.name});try{const i=yield this.call({to:r.ensAddress,data:"0x0178b8bf"+ky(e).substring(2)});return this.formatter.callAddress(i)}catch{}return null})}resolveName(e){return dt(this,void 0,void 0,function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(r){if(bt(e))throw r}typeof e!="string"&&wt.throwArgumentError("invalid ENS name","name",e);const t=yield this.getResolver(e);return t?yield t.getAddress():null})}lookupAddress(e){return dt(this,void 0,void 0,function*(){e=yield e,e=this.formatter.address(e);const t=e.substring(2).toLowerCase()+".addr.reverse",r=yield this._getResolver(t,"lookupAddress");if(r==null)return null;const i=Py(yield this.call({to:r,data:"0x691f3431"+ky(t).substring(2)}),0);return(yield this.resolveName(i))!=e?null:i})}getAvatar(e){return dt(this,void 0,void 0,function*(){let t=null;if(bt(e)){const s=this.formatter.address(e).substring(2).toLowerCase()+".addr.reverse",o=yield this._getResolver(s,"getAvatar");if(!o)return null;t=new eM(this,o,s);try{const a=yield t.getAvatar();if(a)return a.url}catch(a){if(a.code!==ce.errors.CALL_EXCEPTION)throw a}try{const a=Py(yield this.call({to:o,data:"0x691f3431"+ky(s).substring(2)}),0);t=yield this.getResolver(a)}catch(a){if(a.code!==ce.errors.CALL_EXCEPTION)throw a;return null}}else if(t=yield this.getResolver(e),!t)return null;const r=yield t.getAvatar();return r==null?null:r.url})}perform(e,t){return wt.throwError(e+" not implemented",ce.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter(t=>t.pollable()).length>0}_stopEvent(e){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(e,t,r){const i=new g6(Ju(e),t,r);return this._events.push(i),this._startEvent(i),this}on(e,t){return this._addEventListener(e,t,!1)}once(e,t){return this._addEventListener(e,t,!0)}emit(e,...t){let r=!1,i=[],s=Ju(e);return this._events=this._events.filter(o=>o.tag!==s?!0:(setTimeout(()=>{o.listener.apply(this,t)},0),r=!0,o.once?(i.push(o),!1):!0)),i.forEach(o=>{this._stopEvent(o)}),r}listenerCount(e){if(!e)return this._events.length;let t=Ju(e);return this._events.filter(r=>r.tag===t).length}listeners(e){if(e==null)return this._events.map(r=>r.listener);let t=Ju(e);return this._events.filter(r=>r.tag===t).map(r=>r.listener)}off(e,t){if(t==null)return this.removeAllListeners(e);const r=[];let i=!1,s=Ju(e);return this._events=this._events.filter(o=>o.tag!==s||o.listener!=t||i?!0:(i=!0,r.push(o),!1)),r.forEach(o=>{this._stopEvent(o)}),this}removeAllListeners(e){let t=[];if(e==null)t=this._events,this._events=[];else{const r=Ju(e);this._events=this._events.filter(i=>i.tag!==r?!0:(t.push(i),!1))}return t.forEach(r=>{this._stopEvent(r)}),this}}const B6="abstract-signer/5.7.0";var ho=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const _s=new ce(B6),w6=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],C6=[ce.errors.INSUFFICIENT_FUNDS,ce.errors.NONCE_EXPIRED,ce.errors.REPLACEMENT_UNDERPRICED];class n0{constructor(){_s.checkAbstract(new.target,n0),Ie(this,"_isSigner",!0)}getBalance(e){return ho(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),e)})}getTransactionCount(e){return ho(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),e)})}estimateGas(e){return ho(this,void 0,void 0,function*(){this._checkProvider("estimateGas");const t=yield jn(this.checkTransaction(e));return yield this.provider.estimateGas(t)})}call(e,t){return ho(this,void 0,void 0,function*(){this._checkProvider("call");const r=yield jn(this.checkTransaction(e));return yield this.provider.call(r,t)})}sendTransaction(e){return ho(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");const t=yield this.populateTransaction(e),r=yield this.signTransaction(t);return yield this.provider.sendTransaction(r)})}getChainId(){return ho(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return ho(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return ho(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(e){return ho(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(e)})}checkTransaction(e){for(const r in e)w6.indexOf(r)===-1&&_s.throwArgumentError("invalid transaction key: "+r,"transaction",e);const t=xn(e);return t.from==null?t.from=this.getAddress():t.from=Promise.all([Promise.resolve(t.from),this.getAddress()]).then(r=>(r[0].toLowerCase()!==r[1].toLowerCase()&&_s.throwArgumentError("from address mismatch","transaction",e),r[0])),t}populateTransaction(e){return ho(this,void 0,void 0,function*(){const t=yield jn(this.checkTransaction(e));t.to!=null&&(t.to=Promise.resolve(t.to).then(i=>ho(this,void 0,void 0,function*(){if(i==null)return null;const s=yield this.resolveName(i);return s==null&&_s.throwArgumentError("provided ENS name resolves to null","tx.to",i),s})),t.to.catch(i=>{}));const r=t.maxFeePerGas!=null||t.maxPriorityFeePerGas!=null;if(t.gasPrice!=null&&(t.type===2||r)?_s.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",e):(t.type===0||t.type===1)&&r&&_s.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",e),(t.type===2||t.type==null)&&t.maxFeePerGas!=null&&t.maxPriorityFeePerGas!=null)t.type=2;else if(t.type===0||t.type===1)t.gasPrice==null&&(t.gasPrice=this.getGasPrice());else{const i=yield this.getFeeData();if(t.type==null)if(i.maxFeePerGas!=null&&i.maxPriorityFeePerGas!=null)if(t.type=2,t.gasPrice!=null){const s=t.gasPrice;delete t.gasPrice,t.maxFeePerGas=s,t.maxPriorityFeePerGas=s}else t.maxFeePerGas==null&&(t.maxFeePerGas=i.maxFeePerGas),t.maxPriorityFeePerGas==null&&(t.maxPriorityFeePerGas=i.maxPriorityFeePerGas);else i.gasPrice!=null?(r&&_s.throwError("network does not support EIP-1559",ce.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),t.gasPrice==null&&(t.gasPrice=i.gasPrice),t.type=0):_s.throwError("failed to get consistent fee data",ce.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else t.type===2&&(t.maxFeePerGas==null&&(t.maxFeePerGas=i.maxFeePerGas),t.maxPriorityFeePerGas==null&&(t.maxPriorityFeePerGas=i.maxPriorityFeePerGas))}return t.nonce==null&&(t.nonce=this.getTransactionCount("pending")),t.gasLimit==null&&(t.gasLimit=this.estimateGas(t).catch(i=>{if(C6.indexOf(i.code)>=0)throw i;return _s.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",ce.errors.UNPREDICTABLE_GAS_LIMIT,{error:i,tx:t})})),t.chainId==null?t.chainId=this.getChainId():t.chainId=Promise.all([Promise.resolve(t.chainId),this.getChainId()]).then(i=>(i[1]!==0&&i[0]!==i[1]&&_s.throwArgumentError("chainId address mismatch","transaction",e),i[0])),yield jn(t)})}_checkProvider(e){this.provider||_s.throwError("missing provider",ce.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})}static isSigner(e){return!!(e&&e._isSigner)}}class eS extends n0{constructor(e,t){super(),Ie(this,"address",e),Ie(this,"provider",t||null)}getAddress(){return Promise.resolve(this.address)}_fail(e,t){return Promise.resolve().then(()=>{_s.throwError(e,ce.errors.UNSUPPORTED_OPERATION,{operation:t})})}signMessage(e){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(e,t,r){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(e){return new eS(this.address,e)}}var ol=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const $n=new ce(ti),b6=["call","estimateGas"];function Ug(n,e){if(n==null)return null;if(typeof n.message=="string"&&n.message.match("reverted")){const t=bt(n.data)?n.data:null;if(!e||t)return{message:n.message,data:t}}if(typeof n=="object"){for(const t in n){const r=Ug(n[t],e);if(r)return r}return null}if(typeof n=="string")try{return Ug(JSON.parse(n),e)}catch{}return null}function DP(n,e,t){const r=t.transaction||t.signedTransaction;if(n==="call"){const s=Ug(e,!0);if(s)return s.data;$n.throwError("missing revert data in call exception; Transaction reverted without a reason string",ce.errors.CALL_EXCEPTION,{data:"0x",transaction:r,error:e})}if(n==="estimateGas"){let s=Ug(e.body,!1);s==null&&(s=Ug(e,!1)),s&&$n.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",ce.errors.UNPREDICTABLE_GAS_LIMIT,{reason:s.message,method:n,transaction:r,error:e})}let i=e.message;throw e.code===ce.errors.SERVER_ERROR&&e.error&&typeof e.error.message=="string"?i=e.error.message:typeof e.body=="string"?i=e.body:typeof e.responseText=="string"&&(i=e.responseText),i=(i||"").toLowerCase(),i.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&$n.throwError("insufficient funds for intrinsic transaction cost",ce.errors.INSUFFICIENT_FUNDS,{error:e,method:n,transaction:r}),i.match(/nonce (is )?too low/i)&&$n.throwError("nonce has already been used",ce.errors.NONCE_EXPIRED,{error:e,method:n,transaction:r}),i.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&$n.throwError("replacement fee too low",ce.errors.REPLACEMENT_UNDERPRICED,{error:e,method:n,transaction:r}),i.match(/only replay-protected/i)&&$n.throwError("legacy pre-eip-155 transactions not supported",ce.errors.UNSUPPORTED_OPERATION,{error:e,method:n,transaction:r}),b6.indexOf(n)>=0&&i.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&$n.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",ce.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:n,transaction:r}),e}function tM(n){return new Promise(function(e){setTimeout(e,n)})}function x6(n){if(n.error){const e=new Error(n.error.message);throw e.code=n.error.code,e.data=n.error.data,e}return n.result}function dp(n){return n&&n.toLowerCase()}const nF={};class kP extends n0{constructor(e,t,r){if(super(),e!==nF)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");Ie(this,"provider",t),r==null&&(r=0),typeof r=="string"?(Ie(this,"_address",this.provider.formatter.address(r)),Ie(this,"_index",null)):typeof r=="number"?(Ie(this,"_index",r),Ie(this,"_address",null)):$n.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(e){return $n.throwError("cannot alter JSON-RPC Signer connection",ce.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new I6(nF,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(e=>(e.length<=this._index&&$n.throwError("unknown account #"+this._index,ce.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index])))}sendUncheckedTransaction(e){e=xn(e);const t=this.getAddress().then(r=>(r&&(r=r.toLowerCase()),r));if(e.gasLimit==null){const r=xn(e);r.from=t,e.gasLimit=this.provider.estimateGas(r)}return e.to!=null&&(e.to=Promise.resolve(e.to).then(r=>ol(this,void 0,void 0,function*(){if(r==null)return null;const i=yield this.provider.resolveName(r);return i==null&&$n.throwArgumentError("provided ENS name resolves to null","tx.to",r),i}))),jn({tx:jn(e),sender:t}).then(({tx:r,sender:i})=>{r.from!=null?r.from.toLowerCase()!==i&&$n.throwArgumentError("from address mismatch","transaction",e):r.from=i;const s=this.provider.constructor.hexlifyTransaction(r,{from:!0});return this.provider.send("eth_sendTransaction",[s]).then(o=>o,o=>(typeof o.message=="string"&&o.message.match(/user denied/i)&&$n.throwError("user rejected transaction",ce.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:r}),DP("sendTransaction",o,s)))})}signTransaction(e){return $n.throwError("signing transactions is unsupported",ce.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return ol(this,void 0,void 0,function*(){const t=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),r=yield this.sendUncheckedTransaction(e);try{return yield id(()=>ol(this,void 0,void 0,function*(){const i=yield this.provider.getTransaction(r);if(i!==null)return this.provider._wrapTransaction(i,r,t)}),{oncePoll:this.provider})}catch(i){throw i.transactionHash=r,i}})}signMessage(e){return ol(this,void 0,void 0,function*(){const t=typeof e=="string"?Ia(e):e,r=yield this.getAddress();try{return yield this.provider.send("personal_sign",[$e(t),r.toLowerCase()])}catch(i){throw typeof i.message=="string"&&i.message.match(/user denied/i)&&$n.throwError("user rejected signing",ce.errors.ACTION_REJECTED,{action:"signMessage",from:r,messageData:e}),i}})}_legacySignMessage(e){return ol(this,void 0,void 0,function*(){const t=typeof e=="string"?Ia(e):e,r=yield this.getAddress();try{return yield this.provider.send("eth_sign",[r.toLowerCase(),$e(t)])}catch(i){throw typeof i.message=="string"&&i.message.match(/user denied/i)&&$n.throwError("user rejected signing",ce.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:r,messageData:e}),i}})}_signTypedData(e,t,r){return ol(this,void 0,void 0,function*(){const i=yield Xi.resolveNames(e,t,r,o=>this.provider.resolveName(o)),s=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[s.toLowerCase(),JSON.stringify(Xi.getPayload(i.domain,t,i.value))])}catch(o){throw typeof o.message=="string"&&o.message.match(/user denied/i)&&$n.throwError("user rejected signing",ce.errors.ACTION_REJECTED,{action:"_signTypedData",from:s,messageData:{domain:i.domain,types:t,value:i.value}}),o}})}unlock(e){return ol(this,void 0,void 0,function*(){const t=this.provider,r=yield this.getAddress();return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})}}class I6 extends kP{sendTransaction(e){return this.sendUncheckedTransaction(e).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:r=>this.provider.waitForTransaction(t,r)}))}}const F6={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class qg extends qU{constructor(e,t){let r=t;r==null&&(r=new Promise((i,s)=>{setTimeout(()=>{this.detectNetwork().then(o=>{i(o)},o=>{s(o)})},0)})),super(r),e||(e=is(this.constructor,"defaultUrl")()),typeof e=="string"?Ie(this,"connection",Object.freeze({url:e})):Ie(this,"connection",Object.freeze(xn(e))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return ol(this,void 0,void 0,function*(){yield tM(0);let e=null;try{e=yield this.send("eth_chainId",[])}catch{try{e=yield this.send("net_version",[])}catch{}}if(e!=null){const t=is(this.constructor,"getNetwork");try{return t(De.from(e).toNumber())}catch(r){return $n.throwError("could not detect network",ce.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:r})}}return $n.throwError("could not detect network",ce.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(e){return new kP(nF,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(e=>e.map(t=>this.formatter.address(t)))}send(e,t){const r={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:as(r),provider:this});const i=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(i&&this._cache[e])return this._cache[e];const s=xC(this.connection,JSON.stringify(r),x6).then(o=>(this.emit("debug",{action:"response",request:r,response:o,provider:this}),o),o=>{throw this.emit("debug",{action:"response",error:o,request:r,provider:this}),o});return i&&(this._cache[e]=s,setTimeout(()=>{this._cache[e]=null},0)),s}prepareRequest(e,t){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[dp(t.address),t.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[dp(t.address),t.blockTag]];case"getCode":return["eth_getCode",[dp(t.address),t.blockTag]];case"getStorageAt":return["eth_getStorageAt",[dp(t.address),Ln(t.position,32),t.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[t.signedTransaction]];case"getBlock":return t.blockTag?["eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]]:t.blockHash?["eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[t.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[t.transactionHash]];case"call":return["eth_call",[is(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0}),t.blockTag]];case"estimateGas":return["eth_estimateGas",[is(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0})]];case"getLogs":return t.filter&&t.filter.address!=null&&(t.filter.address=dp(t.filter.address)),["eth_getLogs",[t.filter]]}return null}perform(e,t){return ol(this,void 0,void 0,function*(){if(e==="call"||e==="estimateGas"){const i=t.transaction;if(i&&i.type!=null&&De.from(i.type).isZero()&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=yield this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(t=xn(t),t.transaction=xn(i),delete t.transaction.type)}}const r=this.prepareRequest(e,t);r==null&&$n.throwError(e+" not implemented",ce.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(r[0],r[1])}catch(i){return DP(e,i,t)}})}_startEvent(e){e.tag==="pending"&&this._startPending(),super._startEvent(e)}_startPending(){if(this._pendingFilter!=null)return;const e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){function i(){e.send("eth_getFilterChanges",[r]).then(function(s){if(e._pendingFilter!=t)return null;let o=Promise.resolve();return s.forEach(function(a){e._emitted["t:"+a.toLowerCase()]="pending",o=o.then(function(){return e.getTransaction(a).then(function(l){return e.emit("pending",l),null})})}),o.then(function(){return tM(1e3)})}).then(function(){if(e._pendingFilter!=t){e.send("eth_uninstallFilter",[r]);return}return setTimeout(function(){i()},0),null}).catch(s=>{})}return i(),r}).catch(r=>{})}_stopEvent(e){e.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(e)}static hexlifyTransaction(e,t){const r=xn(F6);if(t)for(const s in t)t[s]&&(r[s]=!0);e9(e,r);const i={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(s){if(e[s]==null)return;const o=yC(De.from(e[s]));s==="gasLimit"&&(s="gas"),i[s]=o}),["from","to","data"].forEach(function(s){e[s]!=null&&(i[s]=$e(e[s]))}),e.accessList&&(i.accessList=Iu(e.accessList)),i}}let Sg=null;try{if(Sg=WebSocket,Sg==null)throw new Error("inject please")}catch{const e=new ce(ti);Sg=function(){e.throwError("WebSockets not supported in this environment",ce.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var ax=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const k0=new ce(ti);let E6=1;class tS extends qg{constructor(e,t){t==="any"&&k0.throwError("WebSocketProvider does not support 'any' network yet",ce.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),typeof e=="string"?super(e,t):super("_websocket",t),this._pollingInterval=-1,this._wsReady=!1,typeof e=="string"?Ie(this,"_websocket",new Sg(this.connection.url)):Ie(this,"_websocket",e),Ie(this,"_requests",{}),Ie(this,"_subs",{}),Ie(this,"_subIds",{}),Ie(this,"_detectNetwork",super.detectNetwork()),this.websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach(i=>{this.websocket.send(this._requests[i].payload)})},this.websocket.onmessage=i=>{const s=i.data,o=JSON.parse(s);if(o.id!=null){const a=String(o.id),l=this._requests[a];if(delete this._requests[a],o.result!==void 0)l.callback(null,o.result),this.emit("debug",{action:"response",request:JSON.parse(l.payload),response:o.result,provider:this});else{let A=null;o.error?(A=new Error(o.error.message||"unknown error"),Ie(A,"code",o.error.code||null),Ie(A,"response",s)):A=new Error("unknown error"),l.callback(A,void 0),this.emit("debug",{action:"response",error:A,request:JSON.parse(l.payload),provider:this})}}else if(o.method==="eth_subscription"){const a=this._subs[o.params.subscription];a&&a.processFunc(o.params.result)}else console.warn("this should not happen")};const r=setInterval(()=>{this.emit("poll")},1e3);r.unref&&r.unref()}get websocket(){return this._websocket}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(e){k0.throwError("cannot reset events block on WebSocketProvider",ce.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(e){k0.throwError("cannot set polling interval on WebSocketProvider",ce.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return ax(this,void 0,void 0,function*(){return null})}set polling(e){e&&k0.throwError("cannot set polling on WebSocketProvider",ce.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(e,t){const r=E6++;return new Promise((i,s)=>{function o(l,A){return l?s(l):i(A)}const a=JSON.stringify({method:e,params:t,id:r,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(a),provider:this}),this._requests[String(r)]={callback:o,payload:a},this._wsReady&&this.websocket.send(a)})}static defaultUrl(){return"ws://localhost:8546"}_subscribe(e,t,r){return ax(this,void 0,void 0,function*(){let i=this._subIds[e];i==null&&(i=Promise.all(t).then(o=>this.send("eth_subscribe",o)),this._subIds[e]=i);const s=yield i;this._subs[s]={tag:e,processFunc:r}})}_startEvent(e){switch(e.type){case"block":this._subscribe("block",["newHeads"],t=>{const r=De.from(t.number).toNumber();this._emitted.block=r,this.emit("block",r)});break;case"pending":this._subscribe("pending",["newPendingTransactions"],t=>{this.emit("pending",t)});break;case"filter":this._subscribe(e.tag,["logs",this._getFilter(e.filter)],t=>{t.removed==null&&(t.removed=!1),this.emit(e.filter,this.formatter.filterLog(t))});break;case"tx":{const t=r=>{const i=r.hash;this.getTransactionReceipt(i).then(s=>{s&&this.emit(i,s)})};t(e),this._subscribe("tx",["newHeads"],r=>{this._events.filter(i=>i.type==="tx").forEach(t)});break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",e);break}}_stopEvent(e){let t=e.tag;if(e.type==="tx"){if(this._events.filter(i=>i.type==="tx").length)return;t="tx"}else if(this.listenerCount(e.event))return;const r=this._subIds[t];r&&(delete this._subIds[t],r.then(i=>{this._subs[i]&&(delete this._subs[i],this.send("eth_unsubscribe",[i]))}))}destroy(){return ax(this,void 0,void 0,function*(){this.websocket.readyState===Sg.CONNECTING&&(yield new Promise(e=>{this.websocket.onopen=function(){e(!0)},this.websocket.onerror=function(){e(!1)}})),this.websocket.close(1e3)})}}var U6=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const rg=new ce(ti);class VP extends qg{detectNetwork(){const e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return U6(this,void 0,void 0,function*(){let t=this.network;return t==null&&(t=yield e.detectNetwork.call(this),t||rg.throwError("no network detected",ce.errors.UNKNOWN_ERROR,{}),this._network==null&&(Ie(this,"_network",t),this.emit("network",t,null))),t})}}class lc extends VP{constructor(e,t){rg.checkAbstract(new.target,lc),e=is(new.target,"getNetwork")(e),t=is(new.target,"getApiKey")(t);const r=is(new.target,"getUrl")(e,t);super(r,e),typeof t=="string"?Ie(this,"apiKey",t):t!=null&&Object.keys(t).forEach(i=>{Ie(this,i,t[i])})}_startPending(){rg.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(e){return rg.throwError("API provider does not support signing",ce.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(e){return e}static getUrl(e,t){return rg.throwError("not implemented; sub-classes must override getUrl",ce.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const nM=new ce(ti),Wy="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";class S6 extends tS{constructor(e,t){const r=new LP(e,t),i=r.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi.");super(i,r.network),Ie(this,"apiKey",r.apiKey)}isCommunityResource(){return this.apiKey===Wy}}class LP extends lc{static getWebSocketProvider(e,t){return new S6(e,t)}static getApiKey(e){return e==null?Wy:(e&&typeof e!="string"&&nM.throwArgumentError("invalid apiKey","apiKey",e),e)}static getUrl(e,t){let r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/v2/";break;case"goerli":r="eth-goerli.g.alchemy.com/v2/";break;case"matic":r="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":r="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":r="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-goerli":r="arb-goerli.g.alchemy.com/v2/";break;case"optimism":r="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-goerli":r="opt-goerli.g.alchemy.com/v2/";break;default:nM.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+r+t,throttleCallback:(i,s)=>(t===Wy&&UC(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===Wy}}const _6=new ce(ti),V0="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function Q6(n){switch(n){case"homestead":return"rpc.ankr.com/eth/";case"ropsten":return"rpc.ankr.com/eth_ropsten/";case"rinkeby":return"rpc.ankr.com/eth_rinkeby/";case"goerli":return"rpc.ankr.com/eth_goerli/";case"matic":return"rpc.ankr.com/polygon/";case"arbitrum":return"rpc.ankr.com/arbitrum/"}return _6.throwArgumentError("unsupported network","name",n)}class R6 extends lc{isCommunityResource(){return this.apiKey===V0}static getApiKey(e){return e??V0}static getUrl(e,t){t==null&&(t=V0);const r={allowGzip:!0,url:"https://"+Q6(e.name)+t,throttleCallback:(i,s)=>(t.apiKey===V0&&UC(),Promise.resolve(!0))};return t.projectSecret!=null&&(r.user="",r.password=t.projectSecret),r}}var M6=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const rM=new ce(ti);class T6 extends lc{static getApiKey(e){return e!=null&&rM.throwArgumentError("apiKey not supported for cloudflare","apiKey",e),null}static getUrl(e,t){let r=null;switch(e.name){case"homestead":r="https://cloudflare-eth.com/";break;default:rM.throwArgumentError("unsupported network","network",arguments[0])}return r}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return M6(this,void 0,void 0,function*(){return e==="getBlockNumber"?(yield r.perform.call(this,"getBlock",{blockTag:"latest"})).number:r.perform.call(this,e,t)})}}var L0=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const gA=new ce(ti);function iM(n){const e={};for(let t in n){if(n[t]==null)continue;let r=n[t];t==="type"&&r===0||({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[t]?r=yC($e(r)):t==="accessList"?r="["+Iu(r).map(i=>`{address:"${i.address}",storageKeys:["${i.storageKeys.join('","')}"]}`).join(",")+"]":r=$e(r),e[t]=r)}return e}function N6(n){if(n.status==0&&(n.message==="No records found"||n.message==="No transactions found"))return n.result;if(n.status!=1||typeof n.message!="string"||!n.message.match(/^OK/)){const e=new Error("invalid response");throw e.result=JSON.stringify(n),(n.result||"").toLowerCase().indexOf("rate limit")>=0&&(e.throttleRetry=!0),e}return n.result}function sM(n){if(n&&n.status==0&&n.message=="NOTOK"&&(n.result||"").toLowerCase().indexOf("rate limit")>=0){const e=new Error("throttled response");throw e.result=JSON.stringify(n),e.throttleRetry=!0,e}if(n.jsonrpc!="2.0"){const e=new Error("invalid response");throw e.result=JSON.stringify(n),e}if(n.error){const e=new Error(n.error.message||"unknown error");throw n.error.code&&(e.code=n.error.code),n.error.data&&(e.data=n.error.data),e}return n.result}function oM(n){if(n==="pending")throw new Error("pending not supported");return n==="latest"?n:parseInt(n.substring(2),16)}function lx(n,e,t){if(n==="call"&&e.code===ce.errors.SERVER_ERROR){const i=e.error;if(i&&(i.message.match(/reverted/i)||i.message.match(/VM execution error/i))){let s=i.data;if(s&&(s="0x"+s.replace(/^.*0x/i,"")),bt(s))return s;gA.throwError("missing revert data in call exception",ce.errors.CALL_EXCEPTION,{error:e,data:"0x"})}}let r=e.message;throw e.code===ce.errors.SERVER_ERROR&&(e.error&&typeof e.error.message=="string"?r=e.error.message:typeof e.body=="string"?r=e.body:typeof e.responseText=="string"&&(r=e.responseText)),r=(r||"").toLowerCase(),r.match(/insufficient funds/)&&gA.throwError("insufficient funds for intrinsic transaction cost",ce.errors.INSUFFICIENT_FUNDS,{error:e,method:n,transaction:t}),r.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&gA.throwError("nonce has already been used",ce.errors.NONCE_EXPIRED,{error:e,method:n,transaction:t}),r.match(/another transaction with same nonce/)&&gA.throwError("replacement fee too low",ce.errors.REPLACEMENT_UNDERPRICED,{error:e,method:n,transaction:t}),r.match(/execution failed due to an exception|execution reverted/)&&gA.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",ce.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:n,transaction:t}),e}class D6 extends qU{constructor(e,t){super(e),Ie(this,"baseUrl",this.getBaseUrl()),Ie(this,"apiKey",t||null)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"matic":return"https://api.polygonscan.com";case"maticmum":return"https://api-testnet.polygonscan.com";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}return gA.throwArgumentError("unsupported network","network",this.network.name)}getUrl(e,t){const r=Object.keys(t).reduce((s,o)=>{const a=t[o];return a!=null&&(s+=`&${o}=${a}`),s},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${e}${r}${i}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(e,t){return t.module=e,t.apikey=this.apiKey,t}fetch(e,t,r){return L0(this,void 0,void 0,function*(){const i=r?this.getPostUrl():this.getUrl(e,t),s=r?this.getPostData(e,t):null,o=e==="proxy"?sM:N6;this.emit("debug",{action:"request",request:i,provider:this});const a={url:i,throttleSlotInterval:1e3,throttleCallback:(c,u)=>(this.isCommunityResource()&&UC(),Promise.resolve(!0))};let l=null;s&&(a.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},l=Object.keys(s).map(c=>`${c}=${s[c]}`).join("&"));const A=yield xC(a,l,o||sM);return this.emit("debug",{action:"response",request:i,response:as(A),provider:this}),A})}detectNetwork(){return L0(this,void 0,void 0,function*(){return this.network})}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return L0(this,void 0,void 0,function*(){switch(e){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch(i=>lx("sendTransaction",i,t.signedTransaction));case"getBlock":if(t.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.transactionHash});case"call":{if(t.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const i=iM(t.transaction);i.module="proxy",i.action="eth_call";try{return yield this.fetch("proxy",i,!0)}catch(s){return lx("call",s,t.transaction)}}case"estimateGas":{const i=iM(t.transaction);i.module="proxy",i.action="eth_estimateGas";try{return yield this.fetch("proxy",i,!0)}catch(s){return lx("estimateGas",s,t.transaction)}}case"getLogs":{const i={action:"getLogs"};if(t.filter.fromBlock&&(i.fromBlock=oM(t.filter.fromBlock)),t.filter.toBlock&&(i.toBlock=oM(t.filter.toBlock)),t.filter.address&&(i.address=t.filter.address),t.filter.topics&&t.filter.topics.length>0&&(t.filter.topics.length>1&&gA.throwError("unsupported topic count",ce.errors.UNSUPPORTED_OPERATION,{topics:t.filter.topics}),t.filter.topics.length===1)){const a=t.filter.topics[0];(typeof a!="string"||a.length!==66)&&gA.throwError("unsupported topic format",ce.errors.UNSUPPORTED_OPERATION,{topic0:a}),i.topic0=a}const s=yield this.fetch("logs",i);let o={};for(let a=0;a{["contractAddress","to"].forEach(function(l){o[l]==""&&delete o[l]}),o.creates==null&&o.contractAddress!=null&&(o.creates=o.contractAddress);const a=this.formatter.transactionResponse(o);return o.timeStamp&&(a.timestamp=parseInt(o.timeStamp)),a})})}isCommunityResource(){return this.apiKey==null}}function k6(n){n=n.slice();for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}var TB=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})};const Vc=new ce(ti);function P0(){return new Date().getTime()}function aM(n){let e=null;for(let t=0;te?null:(r+i)/2}function sd(n){if(n===null)return"null";if(typeof n=="number"||typeof n=="boolean")return JSON.stringify(n);if(typeof n=="string")return n;if(De.isBigNumber(n))return n.toString();if(Array.isArray(n))return JSON.stringify(n.map(e=>sd(e)));if(typeof n=="object"){const e=Object.keys(n);return e.sort(),"{"+e.map(t=>{let r=n[t];return typeof r=="function"?r="[function]":r=sd(r),JSON.stringify(t)+":"+r}).join(",")+"}"}throw new Error("unknown value type: "+typeof n)}let V6=1;function AM(n){let e=null,t=null,r=new Promise(o=>{e=function(){t&&(clearTimeout(t),t=null),o()},t=setTimeout(e,n)});const i=o=>(r=r.then(o),r);function s(){return r}return{cancel:e,getPromise:s,wait:i}}const L6=[ce.errors.CALL_EXCEPTION,ce.errors.INSUFFICIENT_FUNDS,ce.errors.NONCE_EXPIRED,ce.errors.REPLACEMENT_UNDERPRICED,ce.errors.UNPREDICTABLE_GAS_LIMIT],P6=["address","args","errorArgs","errorSignature","method","transaction"];function W0(n,e){const t={weight:n.weight};return Object.defineProperty(t,"provider",{get:()=>n.provider}),n.start&&(t.start=n.start),e&&(t.duration=e-n.start),n.done&&(n.error?t.error=n.error:t.result=n.result||null),t}function W6(n,e){return function(t){const r={};t.forEach(s=>{const o=n(s.result);r[o]||(r[o]={count:0,result:s.result}),r[o].count++});const i=Object.keys(r);for(let s=0;s=e)return o.result}}}function O6(n,e,t){let r=sd;switch(e){case"getBlockNumber":return function(i){const s=i.map(a=>a.result);let o=lM(i.map(a=>a.result),2);if(o!=null)return o=Math.ceil(o),s.indexOf(o+1)>=0&&o++,o>=n._highestBlockNumber&&(n._highestBlockNumber=o),n._highestBlockNumber};case"getGasPrice":return function(i){const s=i.map(o=>o.result);return s.sort(),s[Math.floor(s.length/2)]};case"getEtherPrice":return function(i){return lM(i.map(s=>s.result))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":r=function(i){return i==null?null:(i=xn(i),i.confirmations=-1,sd(i))};break;case"getBlock":t.includeTransactions?r=function(i){return i==null?null:(i=xn(i),i.transactions=i.transactions.map(s=>(s=xn(s),s.confirmations=-1,s)),sd(i))}:r=function(i){return i==null?null:sd(i)};break;default:throw new Error("unknown method: "+e)}return W6(r,n.quorum)}function hp(n,e){return TB(this,void 0,void 0,function*(){const t=n.provider;return t.blockNumber!=null&&t.blockNumber>=e||e===-1?t:id(()=>new Promise((r,i)=>{setTimeout(function(){return t.blockNumber>=e?r(t):n.cancelled?r(null):r(void 0)},0)}),{oncePoll:t})})}function G6(n,e,t,r){return TB(this,void 0,void 0,function*(){let i=n.provider;switch(t){case"getBlockNumber":case"getGasPrice":return i[t]();case"getEtherPrice":if(i.getEtherPrice)return i.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return r.blockTag&&bt(r.blockTag)&&(i=yield hp(n,e)),i[t](r.address,r.blockTag||"latest");case"getStorageAt":return r.blockTag&&bt(r.blockTag)&&(i=yield hp(n,e)),i.getStorageAt(r.address,r.position,r.blockTag||"latest");case"getBlock":return r.blockTag&&bt(r.blockTag)&&(i=yield hp(n,e)),i[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return r.blockTag&&bt(r.blockTag)&&(i=yield hp(n,e)),t==="call"&&r.blockTag?i[t](r.transaction,r.blockTag):i[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return i[t](r.transactionHash);case"getLogs":{let s=r.filter;return(s.fromBlock&&bt(s.fromBlock)||s.toBlock&&bt(s.toBlock))&&(i=yield hp(n,e)),i.getLogs(s)}}return Vc.throwError("unknown method error",ce.errors.UNKNOWN_ERROR,{method:t,params:r})})}class Z6 extends qU{constructor(e,t){e.length===0&&Vc.throwArgumentError("missing providers","providers",e);const r=e.map((o,a)=>{if(qm.isProvider(o)){const c=HR(o)?2e3:750;return Object.freeze({provider:o,weight:1,stallTimeout:c,priority:1})}const l=xn(o);l.priority==null&&(l.priority=1),l.stallTimeout==null&&(l.stallTimeout=HR(o)?2e3:750),l.weight==null&&(l.weight=1);const A=l.weight;return(A%1||A>512||A<1)&&Vc.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${a}].weight`,A),Object.freeze(l)}),i=r.reduce((o,a)=>o+a.weight,0);t==null?t=i/2:t>i&&Vc.throwArgumentError("quorum will always fail; larger than total weight","quorum",t);let s=aM(r.map(o=>o.provider.network));s==null&&(s=new Promise((o,a)=>{setTimeout(()=>{this.detectNetwork().then(o,a)},0)})),super(s),Ie(this,"providerConfigs",Object.freeze(r)),Ie(this,"quorum",t),this._highestBlockNumber=-1}detectNetwork(){return TB(this,void 0,void 0,function*(){const e=yield Promise.all(this.providerConfigs.map(t=>t.provider.getNetwork()));return aM(e)})}perform(e,t){return TB(this,void 0,void 0,function*(){if(e==="sendTransaction"){const l=yield Promise.all(this.providerConfigs.map(A=>A.provider.sendTransaction(t.signedTransaction).then(c=>c.hash,c=>c)));for(let A=0;Al.priority-A.priority);const s=this._highestBlockNumber;let o=0,a=!0;for(;;){const l=P0();let A=i.filter(d=>d.runner&&l-d.startd+h.weight,0);for(;A{d.staller=null}),d.runner=G6(d,s,e,t).then(p=>{d.done=!0,d.result=p,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:h,backend:W0(d,P0()),request:{method:e,params:as(t)},provider:this})},p=>{d.done=!0,d.error=p,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:h,backend:W0(d,P0()),request:{method:e,params:as(t)},provider:this})}),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:h,backend:W0(d,null),request:{method:e,params:as(t)},provider:this}),A+=d.weight}const c=[];i.forEach(d=>{d.done||!d.runner||(c.push(d.runner),d.staller&&c.push(d.staller.getPromise()))}),c.length&&(yield Promise.race(c));const u=i.filter(d=>d.done&&d.error==null);if(u.length>=this.quorum){const d=r(u);if(d!==void 0)return i.forEach(h=>{h.staller&&h.staller.cancel(),h.cancelled=!0}),d;a||(yield AM(100).getPromise()),a=!1}const f=i.reduce((d,h)=>{if(!h.done||h.error==null)return d;const p=h.error.code;return L6.indexOf(p)>=0&&(d[p]||(d[p]={error:h.error,weight:0}),d[p].weight+=h.weight),d},{});if(Object.keys(f).forEach(d=>{const h=f[d];if(h.weight{g.staller&&g.staller.cancel(),g.cancelled=!0});const p=h.error,m={};P6.forEach(g=>{p[g]!=null&&(m[g]=p[g])}),Vc.throwError(p.reason||p.message,d,m)}),i.filter(d=>!d.done).length===0)break}return i.forEach(l=>{l.staller&&l.staller.cancel(),l.cancelled=!0}),Vc.throwError("failed to meet quorum",ce.errors.SERVER_ERROR,{method:e,params:t,results:i.map(l=>W0(l)),provider:this})})}}const J6=null,Oy=new ce(ti),ig="84842078b09946638c03157f83405213";class H6 extends tS{constructor(e,t){const r=new PP(e,t),i=r.connection;i.password&&Oy.throwError("INFURA WebSocket project secrets unsupported",ce.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});const s=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(s,e),Ie(this,"apiKey",r.projectId),Ie(this,"projectId",r.projectId),Ie(this,"projectSecret",r.projectSecret)}isCommunityResource(){return this.projectId===ig}}class PP extends lc{static getWebSocketProvider(e,t){return new H6(e,t)}static getApiKey(e){const t={apiKey:ig,projectId:ig,projectSecret:null};return e==null||(typeof e=="string"?t.projectId=e:e.projectSecret!=null?(Oy.assertArgument(typeof e.projectId=="string","projectSecret requires a projectId","projectId",e.projectId),Oy.assertArgument(typeof e.projectSecret=="string","invalid projectSecret","projectSecret","[REDACTED]"),t.projectId=e.projectId,t.projectSecret=e.projectSecret):e.projectId&&(t.projectId=e.projectId),t.apiKey=t.projectId),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"homestead":r="mainnet.infura.io";break;case"goerli":r="goerli.infura.io";break;case"sepolia":r="sepolia.infura.io";break;case"matic":r="polygon-mainnet.infura.io";break;case"maticmum":r="polygon-mumbai.infura.io";break;case"optimism":r="optimism-mainnet.infura.io";break;case"optimism-goerli":r="optimism-goerli.infura.io";break;case"arbitrum":r="arbitrum-mainnet.infura.io";break;case"arbitrum-goerli":r="arbitrum-goerli.infura.io";break;default:Oy.throwError("unsupported network",ce.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const i={allowGzip:!0,url:"https://"+r+"/v3/"+t.projectId,throttleCallback:(s,o)=>(t.projectId===ig&&UC(),Promise.resolve(!0))};return t.projectSecret!=null&&(i.user="",i.password=t.projectSecret),i}isCommunityResource(){return this.projectId===ig}}const Ax=new ce(ti),z6="ETHERS_JS_SHARED";class Y6 extends lc{static getApiKey(e){return e&&typeof e!="string"&&Ax.throwArgumentError("invalid apiKey","apiKey",e),e||z6}static getUrl(e,t){Ax.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let r=null;switch(e.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:Ax.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+t}}const cM=new ce(ti),uM="62e1ad51b37b8e00394bda3b";class X6 extends lc{static getApiKey(e){const t={applicationId:null,loadBalancer:!0,applicationSecretKey:null};return e==null?t.applicationId=uM:typeof e=="string"?t.applicationId=e:e.applicationSecretKey!=null?(t.applicationId=e.applicationId,t.applicationSecretKey=e.applicationSecretKey):e.applicationId?t.applicationId=e.applicationId:cM.throwArgumentError("unsupported PocketProvider apiKey","apiKey",e),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"goerli":r="eth-goerli.gateway.pokt.network";break;case"homestead":r="eth-mainnet.gateway.pokt.network";break;case"kovan":r="poa-kovan.gateway.pokt.network";break;case"matic":r="poly-mainnet.gateway.pokt.network";break;case"maticmum":r="polygon-mumbai-rpc.gateway.pokt.network";break;case"rinkeby":r="eth-rinkeby.gateway.pokt.network";break;case"ropsten":r="eth-ropsten.gateway.pokt.network";break;default:cM.throwError("unsupported network",ce.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const i=`https://${r}/v1/lb/${t.applicationId}`,s={headers:{},url:i};return t.applicationSecretKey!=null&&(s.user="",s.password=t.applicationSecretKey),s}isCommunityResource(){return this.applicationId===uM}}const fM=new ce(ti);let K6=1;function dM(n,e){const t="Web3LegacyFetcher";return function(r,i){const s={method:r,params:i,id:K6++,jsonrpc:"2.0"};return new Promise((o,a)=>{this.emit("debug",{action:"request",fetcher:t,request:as(s),provider:this}),e(s,(l,A)=>{if(l)return this.emit("debug",{action:"response",fetcher:t,error:l,request:s,provider:this}),a(l);if(this.emit("debug",{action:"response",fetcher:t,request:s,response:A,provider:this}),A.error){const c=new Error(A.error.message);return c.code=A.error.code,c.data=A.error.data,a(c)}o(A.result)})})}}function j6(n){return function(e,t){t==null&&(t=[]);const r={method:e,params:t};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:as(r),provider:this}),n.request(r).then(i=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:r,response:i,provider:this}),i),i=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:r,error:i,provider:this}),i})}}class nS extends qg{constructor(e,t){e==null&&fM.throwArgumentError("missing provider","provider",e);let r=null,i=null,s=null;typeof e=="function"?(r="unknown:",i=e):(r=e.host||e.path||"",!r&&e.isMetaMask&&(r="metamask"),s=e,e.request?(r===""&&(r="eip-1193:"),i=j6(e)):e.sendAsync?i=dM(e,e.sendAsync.bind(e)):e.send?i=dM(e,e.send.bind(e)):fM.throwArgumentError("unsupported provider","provider",e),r||(r="unknown:")),super(r,t),Ie(this,"jsonRpcFetchFunc",i),Ie(this,"provider",s)}send(e,t){return this.jsonRpcFetchFunc(e,t)}}const hM=new ce(ti);function $6(n,e){if(n==null&&(n="homestead"),typeof n=="string"){const r=n.match(/^(ws|http)s?:/i);if(r)switch(r[1].toLowerCase()){case"http":case"https":return new qg(n);case"ws":case"wss":return new tS(n);default:hM.throwArgumentError("unsupported URL scheme","network",n)}}const t=V3(n);return(!t||!t._defaultProvider)&&hM.throwError("unsupported getDefaultProvider network",ce.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:n}),t._defaultProvider({FallbackProvider:Z6,AlchemyProvider:LP,AnkrProvider:R6,CloudflareProvider:T6,EtherscanProvider:D6,InfuraProvider:PP,JsonRpcProvider:qg,NodesmithProvider:Y6,PocketProvider:X6,Web3Provider:nS,IpcProvider:J6},e)}var q6=!0,cx="Invariant failed";function gl(n,e){if(!n){if(q6)throw new Error(cx);var t=typeof e=="function"?e():e,r=t?"".concat(cx,": ").concat(t):cx;throw new Error(r)}}var Uo;(function(n){n.Update="Web3ReactUpdate",n.Error="Web3ReactError",n.Deactivate="Web3ReactDeactivate"})(Uo||(Uo={}));function em(){return em=Object.assign||function(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Gy(n,e,t){return eK()?Gy=Reflect.construct:Gy=function(i,s,o){var a=[null];a.push.apply(a,s);var l=Function.bind.apply(i,a),A=new l;return o&&tm(A,o.prototype),A},Gy.apply(null,arguments)}function tK(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function NB(n){var e=typeof Map=="function"?new Map:void 0;return NB=function(r){if(r===null||!tK(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return Gy(r,arguments,rF(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),tm(i,r)},NB(n)}typeof Symbol<"u"&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")));typeof Symbol<"u"&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));function pM(n,e){try{var t=n()}catch(r){return e(r)}return t&&t.then?t.then(void 0,e):t}function OP(n){if(typeof n=="string"){n=n.replace(/^Ox/,"0x");var e=Number.parseInt(n,n.trim().substring(0,2)==="0x"?16:10);return Number.isNaN(e)&&gl(!1),e}else return Number.isInteger(n)||gl(!1),n}function GP(n){typeof n=="string"&&n.match(/^(0x)?[0-9a-fA-F]{40}$/)||gl(!1);for(var e=n.substring(0,2)==="0x"?n:"0x"+n,t=e.toLowerCase().substring(2).split(""),r=new Uint8Array(40),i=0;i<40;i++)r[i]=t[i].charCodeAt(0);for(var s=lt(nr(r)),o=0;o<40;o+=2)s[o>>1]>>4>=8&&(t[o]=t[o].toUpperCase()),(s[o>>1]&15)>=8&&(t[o+1]=t[o+1].toUpperCase());var a="0x"+t.join("");return e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==a&&gl(!1),a}var gM=function(e,t){try{var r=function(o){return Promise.resolve(Promise.all([t.chainId===void 0?e.getChainId():t.chainId,t.account===void 0?e.getAccount():t.account])).then(function(a){var l=a[0],A=a[1],c=OP(l);if(e.supportedChainIds&&!e.supportedChainIds.includes(c))throw new ZP(c,e.supportedChainIds);var u=A===null?A:GP(A);return{provider:o,chainId:c,account:u}})},i=t.provider===void 0;return Promise.resolve(i?Promise.resolve(e.getProvider()).then(r):r(t.provider))}catch(s){return Promise.reject(s)}},O0=function(n){WP(e,n);function e(){var t;return t=n.call(this)||this,t.name=t.constructor.name,t}return e}(NB(Error)),ZP=function(n){WP(e,n);function e(t,r){var i;return i=n.call(this)||this,i.name=i.constructor.name,i.message="Unsupported chain id: "+t+". Supported chain ids are: "+r+".",i}return e}(NB(Error)),yr;(function(n){n[n.ACTIVATE_CONNECTOR=0]="ACTIVATE_CONNECTOR",n[n.UPDATE=1]="UPDATE",n[n.UPDATE_FROM_ERROR=2]="UPDATE_FROM_ERROR",n[n.ERROR=3]="ERROR",n[n.ERROR_FROM_ACTIVATION=4]="ERROR_FROM_ACTIVATION",n[n.DEACTIVATE_CONNECTOR=5]="DEACTIVATE_CONNECTOR"})(yr||(yr={}));function nK(n,e){var t=e.type,r=e.payload;switch(t){case yr.ACTIVATE_CONNECTOR:{var i=r.connector,s=r.provider,o=r.chainId,a=r.account,l=r.onError;return{connector:i,provider:s,chainId:o,account:a,onError:l}}case yr.UPDATE:{var A=r.provider,c=r.chainId,u=r.account;return em({},n,A===void 0?{}:{provider:A},c===void 0?{}:{chainId:c},u===void 0?{}:{account:u})}case yr.UPDATE_FROM_ERROR:{var f=r.provider,d=r.chainId,h=r.account;return em({},n,f===void 0?{}:{provider:f},d===void 0?{}:{chainId:d},h===void 0?{}:{account:h},{error:void 0})}case yr.ERROR:{var p=r.error,m=n.connector,g=n.onError;return{connector:m,error:p,onError:g}}case yr.ERROR_FROM_ACTIVATION:{var v=r.connector,y=r.error;return{connector:v,error:y}}case yr.DEACTIVATE_CONNECTOR:return{}}}function rK(){var n=me.useReducer(nK,{}),e=n[0],t=n[1],r=e.connector,i=e.provider,s=e.chainId,o=e.account,a=e.onError,l=e.error,A=me.useRef(-1);A.current+=1;var c=me.useCallback(function(m,g,v){v===void 0&&(v=!1);try{var y=A.current,w=!1;return Promise.resolve(pM(function(){return Promise.resolve(m.activate().then(function(C){return w=!0,C})).then(function(C){return Promise.resolve(gM(m,C)).then(function(b){if(A.current>y)throw new O0;t({type:yr.ACTIVATE_CONNECTOR,payload:em({connector:m},b,{onError:g})})})})},function(C){if(C instanceof O0)w&&m.deactivate();else{if(v)throw w&&m.deactivate(),C;g?(w&&m.deactivate(),g(C)):t({type:yr.ERROR_FROM_ACTIVATION,payload:{connector:m,error:C}})}}))}catch(C){return Promise.reject(C)}},[]),u=me.useCallback(function(m){t({type:yr.ERROR,payload:{error:m}})},[]),f=me.useCallback(function(){t({type:yr.DEACTIVATE_CONNECTOR})},[]),d=me.useCallback(function(m){try{if(!r)throw Error("This should never happen, it's just so Typescript stops complaining");var g=A.current;return Promise.resolve(function(){if(l)return pM(function(){return Promise.resolve(gM(r,m)).then(function(C){if(A.current>g)throw new O0;t({type:yr.UPDATE_FROM_ERROR,payload:C})})},function(C){C instanceof O0||(a?a(C):t({type:yr.ERROR,payload:{error:C}}))});var v=m.chainId===void 0?void 0:OP(m.chainId);if(v!==void 0&&r.supportedChainIds&&!r.supportedChainIds.includes(v)){var y=new ZP(v,r.supportedChainIds);a?a(y):t({type:yr.ERROR,payload:{error:y}})}else{var w=typeof m.account=="string"?GP(m.account):m.account;t({type:yr.UPDATE,payload:{provider:m.provider,chainId:v,account:w}})}}())}catch(v){return Promise.reject(v)}},[r,l,a]),h=me.useCallback(function(m){a?a(m):t({type:yr.ERROR,payload:{error:m}})},[a]),p=me.useCallback(function(){t({type:yr.DEACTIVATE_CONNECTOR})},[]);return me.useEffect(function(){return function(){r&&r.deactivate()}},[r]),me.useEffect(function(){return r&&r.on(Uo.Update,d).on(Uo.Error,h).on(Uo.Deactivate,p),function(){r&&r.off(Uo.Update,d).off(Uo.Error,h).off(Uo.Deactivate,p)}},[r,d,h,p]),{connector:r,provider:i,chainId:s,account:o,activate:c,setError:u,deactivate:f,error:l}}var JP="primary",od={};function iK(n){od[n]&&gl(!1),od[n]=me.createContext({activate:function(){try{return gl(!1),Promise.resolve()}catch(t){return Promise.reject(t)}},setError:function(){gl(!1)},deactivate:function(){gl(!1)},active:!1}),od[n].displayName="Web3ReactContext - "+n;var e=od[n].Provider;return function(r){var i=r.getLibrary,s=r.children,o=rK(),a=o.connector,l=o.provider,A=o.chainId,c=o.account,u=o.activate,f=o.setError,d=o.deactivate,h=o.error,p=a!==void 0&&A!==void 0&&c!==void 0&&!h,m=me.useMemo(function(){return p&&A!==void 0&&Number.isInteger(A)&&a?i(l,a):void 0},[p,i,l,a,A]),g={connector:a,library:m,chainId:A,account:c,activate:u,setError:f,deactivate:d,active:p,error:h};return Y.createElement(e,{value:g},s)}}var sK=iK(JP);function oK(n){return n===void 0&&(n=JP),Object.keys(od).includes(n)||gl(!1),od[n]}function aK(n){return me.useContext(oK(n))}var iF={},HP={exports:{}},vs={},zP={exports:{}},YP={};/** * @license React * scheduler.production.min.js * @@ -29,7 +29,7 @@ var mz=Object.defineProperty;var vz=(n,e,t)=>e in n?mz(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(n){function e(T,V){var O=T.length;T.push(V);e:for(;0>>1,U=T[L];if(0>>1;Li(N,O))ji(oe,N)?(T[L]=oe,T[j]=O,L=j):(T[L]=N,T[Ae]=O,L=Ae);else if(ji(oe,O))T[L]=oe,T[j]=O,L=j;else break e}}return V}function i(T,V){var O=T.sortIndex-V.sortIndex;return O!==0?O:T.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var l=[],A=[],c=1,u=null,f=3,d=!1,h=!1,p=!1,m=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(T){for(var V=t(A);V!==null;){if(V.callback===null)r(A);else if(V.startTime<=T)r(A),V.sortIndex=V.expirationTime,e(l,V);else break;V=t(A)}}function w(T){if(p=!1,y(T),!h)if(t(l)!==null)h=!0,R(C);else{var V=t(A);V!==null&&k(w,V.startTime-T)}}function C(T,V){h=!1,p&&(p=!1,g(x),x=-1),d=!0;var O=f;try{for(y(V),u=t(l);u!==null&&(!(u.expirationTime>V)||T&&!Z());){var L=u.callback;if(typeof L=="function"){u.callback=null,f=u.priorityLevel;var U=L(u.expirationTime<=V);V=n.unstable_now(),typeof U=="function"?u.callback=U:u===t(l)&&r(l),y(V)}else r(l);u=t(l)}if(u!==null)var H=!0;else{var Ae=t(A);Ae!==null&&k(w,Ae.startTime-V),H=!1}return H}finally{u=null,f=O,d=!1}}var b=!1,E=null,x=-1,S=5,M=-1;function Z(){return!(n.unstable_now()-MT||125L?(T.sortIndex=O,e(A,T),t(l)===null&&T===t(A)&&(p?(g(x),x=-1):p=!0,k(w,O-L))):(T.sortIndex=U,e(l,T),h||d||(h=!0,R(C))),T},n.unstable_shouldYield=Z,n.unstable_wrapCallback=function(T){var V=f;return function(){var O=f;f=V;try{return T.apply(this,arguments)}finally{f=O}}}})(YP);zP.exports=YP;var lK=zP.exports;/** + */(function(n){function e(T,V){var O=T.length;T.push(V);e:for(;0>>1,U=T[L];if(0>>1;Li(N,O))ji(oe,N)?(T[L]=oe,T[j]=O,L=j):(T[L]=N,T[le]=O,L=le);else if(ji(oe,O))T[L]=oe,T[j]=O,L=j;else break e}}return V}function i(T,V){var O=T.sortIndex-V.sortIndex;return O!==0?O:T.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var l=[],A=[],c=1,u=null,f=3,d=!1,h=!1,p=!1,m=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(T){for(var V=t(A);V!==null;){if(V.callback===null)r(A);else if(V.startTime<=T)r(A),V.sortIndex=V.expirationTime,e(l,V);else break;V=t(A)}}function w(T){if(p=!1,y(T),!h)if(t(l)!==null)h=!0,R(C);else{var V=t(A);V!==null&&k(w,V.startTime-T)}}function C(T,V){h=!1,p&&(p=!1,g(x),x=-1),d=!0;var O=f;try{for(y(V),u=t(l);u!==null&&(!(u.expirationTime>V)||T&&!Z());){var L=u.callback;if(typeof L=="function"){u.callback=null,f=u.priorityLevel;var U=L(u.expirationTime<=V);V=n.unstable_now(),typeof U=="function"?u.callback=U:u===t(l)&&r(l),y(V)}else r(l);u=t(l)}if(u!==null)var H=!0;else{var le=t(A);le!==null&&k(w,le.startTime-V),H=!1}return H}finally{u=null,f=O,d=!1}}var b=!1,E=null,x=-1,S=5,M=-1;function Z(){return!(n.unstable_now()-MT||125L?(T.sortIndex=O,e(A,T),t(l)===null&&T===t(A)&&(p?(g(x),x=-1):p=!0,k(w,O-L))):(T.sortIndex=U,e(l,T),h||d||(h=!0,R(C))),T},n.unstable_shouldYield=Z,n.unstable_wrapCallback=function(T){var V=f;return function(){var O=f;f=V;try{return T.apply(this,arguments)}finally{f=O}}}})(YP);zP.exports=YP;var lK=zP.exports;/** * @license React * react-dom.production.min.js * @@ -60,11 +60,11 @@ Error generating stack: `+s.message+` * Subject to the terms at https://greensock.com/standard-license or for * Club GreenSock members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com -*/var _2,xA,Ld,s_,Zc,Q2,o_,l7=function(){return typeof window<"u"},Tl={},Mc=180/Math.PI,Pd=Math.PI/180,zu=Math.atan2,R2=1e8,a_=/([A-Z])/g,A7=/(left|right|width|margin|padding|x)/i,c7=/[\s,\(]\S/,yl={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},lE=function(e,t){return t.set(t.t,t.p,Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},u7=function(e,t){return t.set(t.t,t.p,e===1?t.e:Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},f7=function(e,t){return t.set(t.t,t.p,e?Math.round((t.s+t.c*e)*1e4)/1e4+t.u:t.b,t)},d7=function(e,t){var r=t.s+t.c*e;t.set(t.t,t.p,~~(r+(r<0?-.5:.5))+t.u,t)},DG=function(e,t){return t.set(t.t,t.p,e?t.e:t.b,t)},kG=function(e,t){return t.set(t.t,t.p,e!==1?t.b:t.e,t)},h7=function(e,t,r){return e.style[t]=r},p7=function(e,t,r){return e.style.setProperty(t,r)},g7=function(e,t,r){return e._gsap[t]=r},m7=function(e,t,r){return e._gsap.scaleX=e._gsap.scaleY=r},v7=function(e,t,r,i,s){var o=e._gsap;o.scaleX=o.scaleY=r,o.renderTransform(s,o)},y7=function(e,t,r,i,s){var o=e._gsap;o[t]=r,o.renderTransform(s,o)},_n="transform",To=_n+"Origin",B7=function(e,t){var r=this,i=this.target,s=i.style;if(e in Tl){if(this.tfm=this.tfm||{},e!=="transform"&&(e=yl[e]||e,~e.indexOf(",")?e.split(",").forEach(function(o){return r.tfm[o]=dl(i,o)}):this.tfm[e]=i._gsap.x?i._gsap[e]:dl(i,e)),this.props.indexOf(_n)>=0)return;i._gsap.svg&&(this.svgo=i.getAttribute("data-svg-origin"),this.props.push(To,t,"")),e=_n}(s||t)&&this.props.push(e,t,s[e])},VG=function(e){e.translate&&(e.removeProperty("translate"),e.removeProperty("scale"),e.removeProperty("rotate"))},w7=function(){var e=this.props,t=this.target,r=t.style,i=t._gsap,s,o;for(s=0;s=0?M2[o]:"")+e},cE=function(){l7()&&window.document&&(_2=window,xA=_2.document,Ld=xA.documentElement,Zc=AE("div")||{style:{}},AE("div"),_n=ph(_n),To=_n+"Origin",Zc.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",PG=!!ph("perspective"),o_=ds.core.reverting,s_=1)},Gx=function n(e){var t=AE("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),r=this.parentNode,i=this.nextSibling,s=this.style.cssText,o;if(Ld.appendChild(t),t.appendChild(this),this.style.display="block",e)try{o=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=n}catch{}else this._gsapBBox&&(o=this._gsapBBox());return r&&(i?r.insertBefore(this,i):r.appendChild(this)),Ld.removeChild(t),this.style.cssText=s,o},T2=function(e,t){for(var r=t.length;r--;)if(e.hasAttribute(t[r]))return e.getAttribute(t[r])},WG=function(e){var t;try{t=e.getBBox()}catch{t=Gx.call(e,!0)}return t&&(t.width||t.height)||e.getBBox===Gx||(t=Gx.call(e,!0)),t&&!t.width&&!t.x&&!t.y?{x:+T2(e,["x","cx","x1"])||0,y:+T2(e,["y","cy","y1"])||0,width:0,height:0}:t},OG=function(e){return!!(e.getCTM&&(!e.parentNode||e.ownerSVGElement)&&WG(e))},Cm=function(e,t){if(t){var r=e.style;t in Tl&&t!==To&&(t=_n),r.removeProperty?((t.substr(0,2)==="ms"||t.substr(0,6)==="webkit")&&(t="-"+t),r.removeProperty(t.replace(a_,"-$1").toLowerCase())):r.removeAttribute(t)}},IA=function(e,t,r,i,s,o){var a=new ki(e._pt,t,r,0,1,o?kG:DG);return e._pt=a,a.b=i,a.e=s,e._props.push(r),a},N2={deg:1,rad:1,turn:1},C7={grid:1,flex:1},jA=function n(e,t,r,i){var s=parseFloat(r)||0,o=(r+"").trim().substr((s+"").length)||"px",a=Zc.style,l=A7.test(t),A=e.tagName.toLowerCase()==="svg",c=(A?"client":"offset")+(l?"Width":"Height"),u=100,f=i==="px",d=i==="%",h,p,m,g;return i===o||!s||N2[i]||N2[o]?s:(o!=="px"&&!f&&(s=n(e,t,r,"px")),g=e.getCTM&&OG(e),(d||o==="%")&&(Tl[t]||~t.indexOf("adius"))?(h=g?e.getBBox()[l?"width":"height"]:e[c],Jn(d?s/h*u:s/100*h)):(a[l?"width":"height"]=u+(f?o:i),p=~t.indexOf("adius")||i==="em"&&e.appendChild&&!A?e:e.parentNode,g&&(p=(e.ownerSVGElement||{}).parentNode),(!p||p===xA||!p.appendChild)&&(p=xA.body),m=p._gsap,m&&d&&m.width&&l&&m.time===ts.time&&!m.uncache?Jn(s/m.width*u):((d||o==="%")&&!C7[Ca(p,"display")]&&(a.position=Ca(e,"position")),p===e&&(a.position="static"),p.appendChild(Zc),h=Zc[c],p.removeChild(Zc),a.position="absolute",l&&d&&(m=eu(p),m.time=ts.time,m.width=p[c]),Jn(f?h*s/u:h&&s?u/h*s:0))))},dl=function(e,t,r,i){var s;return s_||cE(),t in yl&&t!=="transform"&&(t=yl[t],~t.indexOf(",")&&(t=t.split(",")[0])),Tl[t]&&t!=="transform"?(s=xm(e,i),s=t!=="transformOrigin"?s[t]:s.svg?s.origin:dw(Ca(e,To))+" "+s.zOrigin+"px"):(s=e.style[t],(!s||s==="auto"||i||~(s+"").indexOf("calc("))&&(s=fw[t]&&fw[t](e,t,r)||Ca(e,t)||oG(e,t)||(t==="opacity"?1:0))),r&&!~(s+"").trim().indexOf(" ")?jA(e,t,s,r)+r:s},b7=function(e,t,r,i){if(!r||r==="none"){var s=ph(t,e,1),o=s&&Ca(e,s,1);o&&o!==r?(t=s,r=o):t==="borderColor"&&(r=Ca(e,"borderTopColor"))}var a=new ki(this._pt,e.style,t,0,1,MG),l=0,A=0,c,u,f,d,h,p,m,g,v,y,w,C;if(a.b=r,a.e=i,r+="",i+="",i==="auto"&&(e.style[t]=i,i=Ca(e,t)||i,e.style[t]=r),c=[r,i],bG(c),r=c[0],i=c[1],f=r.match(yd)||[],C=i.match(yd)||[],C.length){for(;u=yd.exec(i);)m=u[0],v=i.substring(l,u.index),h?h=(h+1)%5:(v.substr(-5)==="rgba("||v.substr(-5)==="hsla(")&&(h=1),m!==(p=f[A++]||"")&&(d=parseFloat(p)||0,w=p.substr((d+"").length),m.charAt(1)==="="&&(m=Vd(d,m)+w),g=parseFloat(m),y=m.substr((g+"").length),l=yd.lastIndex-y.length,y||(y=y||As.units[t]||w,l===i.length&&(i+=y,a.e+=y)),w!==y&&(d=jA(e,t,p,y)||0),a._pt={_next:a._pt,p:v||A===1?v:",",s:d,c:g-d,m:h&&h<4||t==="zIndex"?Math.round:0});a.c=l-1;)a=s[A],Tl[a]&&(l=1,a=a==="transformOrigin"?To:_n),Cm(r,a);l&&(Cm(r,_n),o&&(o.svg&&r.removeAttribute("transform"),xm(r,1),o.uncache=1,VG(i)))}},fw={clearProps:function(e,t,r,i,s){if(s.data!=="isFromStart"){var o=e._pt=new ki(e._pt,t,r,0,0,I7);return o.u=i,o.pr=-10,o.tween=s,e._props.push(r),1}}},bm=[1,0,0,1,0,0],GG={},ZG=function(e){return e==="matrix(1, 0, 0, 1, 0, 0)"||e==="none"||!e},k2=function(e){var t=Ca(e,_n);return ZG(t)?bm:t.substr(7).match(qO).map(Jn)},l_=function(e,t){var r=e._gsap||eu(e),i=e.style,s=k2(e),o,a,l,A;return r.svg&&e.getAttribute("transform")?(l=e.transform.baseVal.consolidate().matrix,s=[l.a,l.b,l.c,l.d,l.e,l.f],s.join(",")==="1,0,0,1,0,0"?bm:s):(s===bm&&!e.offsetParent&&e!==Ld&&!r.svg&&(l=i.display,i.display="block",o=e.parentNode,(!o||!e.offsetParent)&&(A=1,a=e.nextElementSibling,Ld.appendChild(e)),s=k2(e),l?i.display=l:Cm(e,"display"),A&&(a?o.insertBefore(e,a):o?o.appendChild(e):Ld.removeChild(e))),t&&s.length>6?[s[0],s[1],s[4],s[5],s[12],s[13]]:s)},uE=function(e,t,r,i,s,o){var a=e._gsap,l=s||l_(e,!0),A=a.xOrigin||0,c=a.yOrigin||0,u=a.xOffset||0,f=a.yOffset||0,d=l[0],h=l[1],p=l[2],m=l[3],g=l[4],v=l[5],y=t.split(" "),w=parseFloat(y[0])||0,C=parseFloat(y[1])||0,b,E,x,S;r?l!==bm&&(E=d*m-h*p)&&(x=w*(m/E)+C*(-p/E)+(p*v-m*g)/E,S=w*(-h/E)+C*(d/E)-(d*v-h*g)/E,w=x,C=S):(b=WG(e),w=b.x+(~y[0].indexOf("%")?w/100*b.width:w),C=b.y+(~(y[1]||y[0]).indexOf("%")?C/100*b.height:C)),i||i!==!1&&a.smooth?(g=w-A,v=C-c,a.xOffset=u+(g*d+v*p)-g,a.yOffset=f+(g*h+v*m)-v):a.xOffset=a.yOffset=0,a.xOrigin=w,a.yOrigin=C,a.smooth=!!i,a.origin=t,a.originIsAbsolute=!!r,e.style[To]="0px 0px",o&&(IA(o,a,"xOrigin",A,w),IA(o,a,"yOrigin",c,C),IA(o,a,"xOffset",u,a.xOffset),IA(o,a,"yOffset",f,a.yOffset)),e.setAttribute("data-svg-origin",w+" "+C)},xm=function(e,t){var r=e._gsap||new EG(e);if("x"in r&&!t&&!r.uncache)return r;var i=e.style,s=r.scaleX<0,o="px",a="deg",l=getComputedStyle(e),A=Ca(e,To)||"0",c,u,f,d,h,p,m,g,v,y,w,C,b,E,x,S,M,Z,K,_,B,F,R,k,T,V,O,L,U,H,Ae,N;return c=u=f=p=m=g=v=y=w=0,d=h=1,r.svg=!!(e.getCTM&&OG(e)),l.translate&&((l.translate!=="none"||l.scale!=="none"||l.rotate!=="none")&&(i[_n]=(l.translate!=="none"?"translate3d("+(l.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(l.rotate!=="none"?"rotate("+l.rotate+") ":"")+(l.scale!=="none"?"scale("+l.scale.split(" ").join(",")+") ":"")+(l[_n]!=="none"?l[_n]:"")),i.scale=i.rotate=i.translate="none"),E=l_(e,r.svg),r.svg&&(r.uncache?(T=e.getBBox(),A=r.xOrigin-T.x+"px "+(r.yOrigin-T.y)+"px",k=""):k=!t&&e.getAttribute("data-svg-origin"),uE(e,k||A,!!k||r.originIsAbsolute,r.smooth!==!1,E)),C=r.xOrigin||0,b=r.yOrigin||0,E!==bm&&(Z=E[0],K=E[1],_=E[2],B=E[3],c=F=E[4],u=R=E[5],E.length===6?(d=Math.sqrt(Z*Z+K*K),h=Math.sqrt(B*B+_*_),p=Z||K?zu(K,Z)*Mc:0,v=_||B?zu(_,B)*Mc+p:0,v&&(h*=Math.abs(Math.cos(v*Pd))),r.svg&&(c-=C-(C*Z+b*_),u-=b-(C*K+b*B))):(N=E[6],H=E[7],O=E[8],L=E[9],U=E[10],Ae=E[11],c=E[12],u=E[13],f=E[14],x=zu(N,U),m=x*Mc,x&&(S=Math.cos(-x),M=Math.sin(-x),k=F*S+O*M,T=R*S+L*M,V=N*S+U*M,O=F*-M+O*S,L=R*-M+L*S,U=N*-M+U*S,Ae=H*-M+Ae*S,F=k,R=T,N=V),x=zu(-_,U),g=x*Mc,x&&(S=Math.cos(-x),M=Math.sin(-x),k=Z*S-O*M,T=K*S-L*M,V=_*S-U*M,Ae=B*M+Ae*S,Z=k,K=T,_=V),x=zu(K,Z),p=x*Mc,x&&(S=Math.cos(x),M=Math.sin(x),k=Z*S+K*M,T=F*S+R*M,K=K*S-Z*M,R=R*S-F*M,Z=k,F=T),m&&Math.abs(m)+Math.abs(p)>359.9&&(m=p=0,g=180-g),d=Jn(Math.sqrt(Z*Z+K*K+_*_)),h=Jn(Math.sqrt(R*R+N*N)),x=zu(F,R),v=Math.abs(x)>2e-4?x*Mc:0,w=Ae?1/(Ae<0?-Ae:Ae):0),r.svg&&(k=e.getAttribute("transform"),r.forceCSS=e.setAttribute("transform","")||!ZG(Ca(e,_n)),k&&e.setAttribute("transform",k))),Math.abs(v)>90&&Math.abs(v)<270&&(s?(d*=-1,v+=p<=0?180:-180,p+=p<=0?180:-180):(h*=-1,v+=v<=0?180:-180)),t=t||r.uncache,r.x=c-((r.xPercent=c&&(!t&&r.xPercent||(Math.round(e.offsetWidth/2)===Math.round(-c)?-50:0)))?e.offsetWidth*r.xPercent/100:0)+o,r.y=u-((r.yPercent=u&&(!t&&r.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-u)?-50:0)))?e.offsetHeight*r.yPercent/100:0)+o,r.z=f+o,r.scaleX=Jn(d),r.scaleY=Jn(h),r.rotation=Jn(p)+a,r.rotationX=Jn(m)+a,r.rotationY=Jn(g)+a,r.skewX=v+a,r.skewY=y+a,r.transformPerspective=w+o,(r.zOrigin=parseFloat(A.split(" ")[2])||0)&&(i[To]=dw(A)),r.xOffset=r.yOffset=0,r.force3D=As.force3D,r.renderTransform=r.svg?E7:PG?JG:F7,r.uncache=0,r},dw=function(e){return(e=e.split(" "))[0]+" "+e[1]},Zx=function(e,t,r){var i=Xr(t);return Jn(parseFloat(t)+parseFloat(jA(e,"x",r+"px",i)))+i},F7=function(e,t){t.z="0px",t.rotationY=t.rotationX="0deg",t.force3D=0,JG(e,t)},yc="0deg",bp="0px",Bc=") ",JG=function(e,t){var r=t||this,i=r.xPercent,s=r.yPercent,o=r.x,a=r.y,l=r.z,A=r.rotation,c=r.rotationY,u=r.rotationX,f=r.skewX,d=r.skewY,h=r.scaleX,p=r.scaleY,m=r.transformPerspective,g=r.force3D,v=r.target,y=r.zOrigin,w="",C=g==="auto"&&e&&e!==1||g===!0;if(y&&(u!==yc||c!==yc)){var b=parseFloat(c)*Pd,E=Math.sin(b),x=Math.cos(b),S;b=parseFloat(u)*Pd,S=Math.cos(b),o=Zx(v,o,E*S*-y),a=Zx(v,a,-Math.sin(b)*-y),l=Zx(v,l,x*S*-y+y)}m!==bp&&(w+="perspective("+m+Bc),(i||s)&&(w+="translate("+i+"%, "+s+"%) "),(C||o!==bp||a!==bp||l!==bp)&&(w+=l!==bp||C?"translate3d("+o+", "+a+", "+l+") ":"translate("+o+", "+a+Bc),A!==yc&&(w+="rotate("+A+Bc),c!==yc&&(w+="rotateY("+c+Bc),u!==yc&&(w+="rotateX("+u+Bc),(f!==yc||d!==yc)&&(w+="skew("+f+", "+d+Bc),(h!==1||p!==1)&&(w+="scale("+h+", "+p+Bc),v.style[_n]=w||"translate(0, 0)"},E7=function(e,t){var r=t||this,i=r.xPercent,s=r.yPercent,o=r.x,a=r.y,l=r.rotation,A=r.skewX,c=r.skewY,u=r.scaleX,f=r.scaleY,d=r.target,h=r.xOrigin,p=r.yOrigin,m=r.xOffset,g=r.yOffset,v=r.forceCSS,y=parseFloat(o),w=parseFloat(a),C,b,E,x,S;l=parseFloat(l),A=parseFloat(A),c=parseFloat(c),c&&(c=parseFloat(c),A+=c,l+=c),l||A?(l*=Pd,A*=Pd,C=Math.cos(l)*u,b=Math.sin(l)*u,E=Math.sin(l-A)*-f,x=Math.cos(l-A)*f,A&&(c*=Pd,S=Math.tan(A-c),S=Math.sqrt(1+S*S),E*=S,x*=S,c&&(S=Math.tan(c),S=Math.sqrt(1+S*S),C*=S,b*=S)),C=Jn(C),b=Jn(b),E=Jn(E),x=Jn(x)):(C=u,x=f,b=E=0),(y&&!~(o+"").indexOf("px")||w&&!~(a+"").indexOf("px"))&&(y=jA(d,"x",o,"px"),w=jA(d,"y",a,"px")),(h||p||m||g)&&(y=Jn(y+h-(h*C+p*E)+m),w=Jn(w+p-(h*b+p*x)+g)),(i||s)&&(S=d.getBBox(),y=Jn(y+i/100*S.width),w=Jn(w+s/100*S.height)),S="matrix("+C+","+b+","+E+","+x+","+y+","+w+")",d.setAttribute("transform",S),v&&(d.style[_n]=S)},U7=function(e,t,r,i,s){var o=360,a=Fr(s),l=parseFloat(s)*(a&&~s.indexOf("rad")?Mc:1),A=l-i,c=i+A+"deg",u,f;return a&&(u=s.split("_")[1],u==="short"&&(A%=o,A!==A%(o/2)&&(A+=A<0?o:-o)),u==="cw"&&A<0?A=(A+o*R2)%o-~~(A/o)*o:u==="ccw"&&A>0&&(A=(A-o*R2)%o-~~(A/o)*o)),e._pt=f=new ki(e._pt,t,r,i,A,u7),f.e=c,f.u="deg",e._props.push(r),f},V2=function(e,t){for(var r in t)e[r]=t[r];return e},S7=function(e,t,r){var i=V2({},r._gsap),s="perspective,force3D,transformOrigin,svgOrigin",o=r.style,a,l,A,c,u,f,d,h;i.svg?(A=r.getAttribute("transform"),r.setAttribute("transform",""),o[_n]=t,a=xm(r,1),Cm(r,_n),r.setAttribute("transform",A)):(A=getComputedStyle(r)[_n],o[_n]=t,a=xm(r,1),o[_n]=A);for(l in Tl)A=i[l],c=a[l],A!==c&&s.indexOf(l)<0&&(d=Xr(A),h=Xr(c),u=d!==h?jA(r,l,A,h):parseFloat(A),f=parseFloat(c),e._pt=new ki(e._pt,a,l,u,f-u,lE),e._pt.u=h||0,e._props.push(l));V2(a,i)};Di("padding,margin,Width,Radius",function(n,e){var t="Top",r="Right",i="Bottom",s="Left",o=(e<3?[t,r,i,s]:[t+s,t+r,i+r,i+s]).map(function(a){return e<2?n+a:"border"+a+n});fw[e>1?"border"+n:n]=function(a,l,A,c,u){var f,d;if(arguments.length<4)return f=o.map(function(h){return dl(a,h,A)}),d=f.join(" "),d.split(f[0]).length===5?f[0]:d;f=(c+"").split(" "),d={},o.forEach(function(h,p){return d[h]=f[p]=f[p]||f[(p-1)/2|0]}),a.init(l,d,u)}});var HG={name:"css",register:cE,targetTest:function(e){return e.style&&e.nodeType},init:function(e,t,r,i,s){var o=this._props,a=e.style,l=r.vars.startAt,A,c,u,f,d,h,p,m,g,v,y,w,C,b,E,x;s_||cE(),this.styles=this.styles||LG(e),x=this.styles.props,this.tween=r;for(p in t)if(p!=="autoRound"&&(c=t[p],!(es[p]&&UG(p,t,r,i,e,s)))){if(d=typeof c,h=fw[p],d==="function"&&(c=c.call(r,i,e,s),d=typeof c),d==="string"&&~c.indexOf("random(")&&(c=Bm(c)),h)h(this,e,p,c,r)&&(E=1);else if(p.substr(0,2)==="--")A=(getComputedStyle(e).getPropertyValue(p)+"").trim(),c+="",PA.lastIndex=0,PA.test(A)||(m=Xr(A),g=Xr(c)),g?m!==g&&(A=jA(e,p,A,g)+g):m&&(c+=m),this.add(a,"setProperty",A,c,i,s,0,0,p),o.push(p),x.push(p,0,a[p]);else if(d!=="undefined"){if(l&&p in l?(A=typeof l[p]=="function"?l[p].call(r,i,e,s):l[p],Fr(A)&&~A.indexOf("random(")&&(A=Bm(A)),Xr(A+"")||(A+=As.units[p]||Xr(dl(e,p))||""),(A+"").charAt(1)==="="&&(A=dl(e,p))):A=dl(e,p),f=parseFloat(A),v=d==="string"&&c.charAt(1)==="="&&c.substr(0,2),v&&(c=c.substr(2)),u=parseFloat(c),p in yl&&(p==="autoAlpha"&&(f===1&&dl(e,"visibility")==="hidden"&&u&&(f=0),x.push("visibility",0,a.visibility),IA(this,a,"visibility",f?"inherit":"hidden",u?"inherit":"hidden",!u)),p!=="scale"&&p!=="transform"&&(p=yl[p],~p.indexOf(",")&&(p=p.split(",")[0]))),y=p in Tl,y){if(this.styles.save(p),w||(C=e._gsap,C.renderTransform&&!t.parseTransform||xm(e,t.parseTransform),b=t.smoothOrigin!==!1&&C.smooth,w=this._pt=new ki(this._pt,a,_n,0,1,C.renderTransform,C,0,-1),w.dep=1),p==="scale")this._pt=new ki(this._pt,C,"scaleY",C.scaleY,(v?Vd(C.scaleY,v+u):u)-C.scaleY||0,lE),this._pt.u=0,o.push("scaleY",p),p+="X";else if(p==="transformOrigin"){x.push(To,0,a[To]),c=x7(c),C.svg?uE(e,c,0,b,0,this):(g=parseFloat(c.split(" ")[2])||0,g!==C.zOrigin&&IA(this,C,"zOrigin",C.zOrigin,g),IA(this,a,p,dw(A),dw(c)));continue}else if(p==="svgOrigin"){uE(e,c,1,b,0,this);continue}else if(p in GG){U7(this,C,p,f,v?Vd(f,v+c):c);continue}else if(p==="smoothOrigin"){IA(this,C,"smooth",C.smooth,c);continue}else if(p==="force3D"){C[p]=c;continue}else if(p==="transform"){S7(this,c,e);continue}}else p in a||(p=ph(p)||p);if(y||(u||u===0)&&(f||f===0)&&!c7.test(c)&&p in a)m=(A+"").substr((f+"").length),u||(u=0),g=Xr(c)||(p in As.units?As.units[p]:m),m!==g&&(f=jA(e,p,A,g)),this._pt=new ki(this._pt,y?C:a,p,f,(v?Vd(f,v+u):u)-f,!y&&(g==="px"||p==="zIndex")&&t.autoRound!==!1?d7:lE),this._pt.u=g||0,m!==g&&g!=="%"&&(this._pt.b=A,this._pt.r=f7);else if(p in a)b7.call(this,e,p,A,v?v+c:c);else if(p in e)this.add(e,p,A||e[p],v?v+c:c,i,s);else if(p!=="parseTransform"){KS(p,c);continue}y||(p in a?x.push(p,0,a[p]):x.push(p,1,A||e[p])),o.push(p)}}E&&TG(this)},render:function(e,t){if(t.tween._time||!o_())for(var r=t._pt;r;)r.r(e,r.d),r=r._next;else t.styles.revert()},get:dl,aliases:yl,getSetter:function(e,t,r){var i=yl[t];return i&&i.indexOf(",")<0&&(t=i),t in Tl&&t!==To&&(e._gsap.x||dl(e,"x"))?r&&Q2===r?t==="scale"?m7:g7:(Q2=r||{})&&(t==="scale"?v7:y7):e.style&&!YS(e.style[t])?h7:~t.indexOf("-")?p7:r_(e,t)},core:{_removeProperty:Cm,_getMatrix:l_}};ds.utils.checkPrefix=ph;ds.core.getStyleSaver=LG;(function(n,e,t,r){var i=Di(n+","+e+","+t,function(s){Tl[s]=1});Di(e,function(s){As.units[s]="deg",GG[s]=1}),yl[i[13]]=n+","+e,Di(r,function(s){var o=s.split(":");yl[o[1]]=i[o[0]]})})("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");Di("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(n){As.units[n]="px"});ds.registerPlugin(HG);var fE=ds.registerPlugin(HG)||ds;fE.core.Tween;function Nh(){localStorage&&Object.keys(localStorage).map(n=>{this.setItem(n,localStorage[n],!1)}),Object.defineProperty(this,"length",{get:function(){return Object.keys(this).length},enumerable:!1})}Nh.prototype.key=function(n){return Object.keys(this)[n]};Nh.prototype.getItem=function(n){try{return JSON.parse(this[n])}catch{}return this[n]};Nh.prototype.setItem=function(n,e,t=!0){const r=typeof e=="string"?e:JSON.stringify(e);return t&&localStorage.setItem(n,r),this[n]=r};Nh.prototype.removeItem=function(n){delete this[n]};Nh.prototype.clear=function(){Object.keys(this).forEach(n=>delete this[n])};let _7=new Nh;const Q7=n=>({get(e,t){return n.getItem(String(t))},set(e,t,r){return n.setItem(String(t),r),!0}}),R7=(n=_7)=>new Proxy({},Q7(n)),et=R7();/** +*/var _2,xA,Ld,s_,Zc,Q2,o_,l7=function(){return typeof window<"u"},Tl={},Mc=180/Math.PI,Pd=Math.PI/180,zu=Math.atan2,R2=1e8,a_=/([A-Z])/g,A7=/(left|right|width|margin|padding|x)/i,c7=/[\s,\(]\S/,yl={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},lE=function(e,t){return t.set(t.t,t.p,Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},u7=function(e,t){return t.set(t.t,t.p,e===1?t.e:Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},f7=function(e,t){return t.set(t.t,t.p,e?Math.round((t.s+t.c*e)*1e4)/1e4+t.u:t.b,t)},d7=function(e,t){var r=t.s+t.c*e;t.set(t.t,t.p,~~(r+(r<0?-.5:.5))+t.u,t)},DG=function(e,t){return t.set(t.t,t.p,e?t.e:t.b,t)},kG=function(e,t){return t.set(t.t,t.p,e!==1?t.b:t.e,t)},h7=function(e,t,r){return e.style[t]=r},p7=function(e,t,r){return e.style.setProperty(t,r)},g7=function(e,t,r){return e._gsap[t]=r},m7=function(e,t,r){return e._gsap.scaleX=e._gsap.scaleY=r},v7=function(e,t,r,i,s){var o=e._gsap;o.scaleX=o.scaleY=r,o.renderTransform(s,o)},y7=function(e,t,r,i,s){var o=e._gsap;o[t]=r,o.renderTransform(s,o)},_n="transform",To=_n+"Origin",B7=function(e,t){var r=this,i=this.target,s=i.style;if(e in Tl){if(this.tfm=this.tfm||{},e!=="transform"&&(e=yl[e]||e,~e.indexOf(",")?e.split(",").forEach(function(o){return r.tfm[o]=dl(i,o)}):this.tfm[e]=i._gsap.x?i._gsap[e]:dl(i,e)),this.props.indexOf(_n)>=0)return;i._gsap.svg&&(this.svgo=i.getAttribute("data-svg-origin"),this.props.push(To,t,"")),e=_n}(s||t)&&this.props.push(e,t,s[e])},VG=function(e){e.translate&&(e.removeProperty("translate"),e.removeProperty("scale"),e.removeProperty("rotate"))},w7=function(){var e=this.props,t=this.target,r=t.style,i=t._gsap,s,o;for(s=0;s=0?M2[o]:"")+e},cE=function(){l7()&&window.document&&(_2=window,xA=_2.document,Ld=xA.documentElement,Zc=AE("div")||{style:{}},AE("div"),_n=ph(_n),To=_n+"Origin",Zc.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",PG=!!ph("perspective"),o_=ds.core.reverting,s_=1)},Gx=function n(e){var t=AE("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),r=this.parentNode,i=this.nextSibling,s=this.style.cssText,o;if(Ld.appendChild(t),t.appendChild(this),this.style.display="block",e)try{o=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=n}catch{}else this._gsapBBox&&(o=this._gsapBBox());return r&&(i?r.insertBefore(this,i):r.appendChild(this)),Ld.removeChild(t),this.style.cssText=s,o},T2=function(e,t){for(var r=t.length;r--;)if(e.hasAttribute(t[r]))return e.getAttribute(t[r])},WG=function(e){var t;try{t=e.getBBox()}catch{t=Gx.call(e,!0)}return t&&(t.width||t.height)||e.getBBox===Gx||(t=Gx.call(e,!0)),t&&!t.width&&!t.x&&!t.y?{x:+T2(e,["x","cx","x1"])||0,y:+T2(e,["y","cy","y1"])||0,width:0,height:0}:t},OG=function(e){return!!(e.getCTM&&(!e.parentNode||e.ownerSVGElement)&&WG(e))},Cm=function(e,t){if(t){var r=e.style;t in Tl&&t!==To&&(t=_n),r.removeProperty?((t.substr(0,2)==="ms"||t.substr(0,6)==="webkit")&&(t="-"+t),r.removeProperty(t.replace(a_,"-$1").toLowerCase())):r.removeAttribute(t)}},IA=function(e,t,r,i,s,o){var a=new ki(e._pt,t,r,0,1,o?kG:DG);return e._pt=a,a.b=i,a.e=s,e._props.push(r),a},N2={deg:1,rad:1,turn:1},C7={grid:1,flex:1},jA=function n(e,t,r,i){var s=parseFloat(r)||0,o=(r+"").trim().substr((s+"").length)||"px",a=Zc.style,l=A7.test(t),A=e.tagName.toLowerCase()==="svg",c=(A?"client":"offset")+(l?"Width":"Height"),u=100,f=i==="px",d=i==="%",h,p,m,g;return i===o||!s||N2[i]||N2[o]?s:(o!=="px"&&!f&&(s=n(e,t,r,"px")),g=e.getCTM&&OG(e),(d||o==="%")&&(Tl[t]||~t.indexOf("adius"))?(h=g?e.getBBox()[l?"width":"height"]:e[c],Jn(d?s/h*u:s/100*h)):(a[l?"width":"height"]=u+(f?o:i),p=~t.indexOf("adius")||i==="em"&&e.appendChild&&!A?e:e.parentNode,g&&(p=(e.ownerSVGElement||{}).parentNode),(!p||p===xA||!p.appendChild)&&(p=xA.body),m=p._gsap,m&&d&&m.width&&l&&m.time===ts.time&&!m.uncache?Jn(s/m.width*u):((d||o==="%")&&!C7[Ca(p,"display")]&&(a.position=Ca(e,"position")),p===e&&(a.position="static"),p.appendChild(Zc),h=Zc[c],p.removeChild(Zc),a.position="absolute",l&&d&&(m=eu(p),m.time=ts.time,m.width=p[c]),Jn(f?h*s/u:h&&s?u/h*s:0))))},dl=function(e,t,r,i){var s;return s_||cE(),t in yl&&t!=="transform"&&(t=yl[t],~t.indexOf(",")&&(t=t.split(",")[0])),Tl[t]&&t!=="transform"?(s=xm(e,i),s=t!=="transformOrigin"?s[t]:s.svg?s.origin:dw(Ca(e,To))+" "+s.zOrigin+"px"):(s=e.style[t],(!s||s==="auto"||i||~(s+"").indexOf("calc("))&&(s=fw[t]&&fw[t](e,t,r)||Ca(e,t)||oG(e,t)||(t==="opacity"?1:0))),r&&!~(s+"").trim().indexOf(" ")?jA(e,t,s,r)+r:s},b7=function(e,t,r,i){if(!r||r==="none"){var s=ph(t,e,1),o=s&&Ca(e,s,1);o&&o!==r?(t=s,r=o):t==="borderColor"&&(r=Ca(e,"borderTopColor"))}var a=new ki(this._pt,e.style,t,0,1,MG),l=0,A=0,c,u,f,d,h,p,m,g,v,y,w,C;if(a.b=r,a.e=i,r+="",i+="",i==="auto"&&(e.style[t]=i,i=Ca(e,t)||i,e.style[t]=r),c=[r,i],bG(c),r=c[0],i=c[1],f=r.match(yd)||[],C=i.match(yd)||[],C.length){for(;u=yd.exec(i);)m=u[0],v=i.substring(l,u.index),h?h=(h+1)%5:(v.substr(-5)==="rgba("||v.substr(-5)==="hsla(")&&(h=1),m!==(p=f[A++]||"")&&(d=parseFloat(p)||0,w=p.substr((d+"").length),m.charAt(1)==="="&&(m=Vd(d,m)+w),g=parseFloat(m),y=m.substr((g+"").length),l=yd.lastIndex-y.length,y||(y=y||As.units[t]||w,l===i.length&&(i+=y,a.e+=y)),w!==y&&(d=jA(e,t,p,y)||0),a._pt={_next:a._pt,p:v||A===1?v:",",s:d,c:g-d,m:h&&h<4||t==="zIndex"?Math.round:0});a.c=l-1;)a=s[A],Tl[a]&&(l=1,a=a==="transformOrigin"?To:_n),Cm(r,a);l&&(Cm(r,_n),o&&(o.svg&&r.removeAttribute("transform"),xm(r,1),o.uncache=1,VG(i)))}},fw={clearProps:function(e,t,r,i,s){if(s.data!=="isFromStart"){var o=e._pt=new ki(e._pt,t,r,0,0,I7);return o.u=i,o.pr=-10,o.tween=s,e._props.push(r),1}}},bm=[1,0,0,1,0,0],GG={},ZG=function(e){return e==="matrix(1, 0, 0, 1, 0, 0)"||e==="none"||!e},k2=function(e){var t=Ca(e,_n);return ZG(t)?bm:t.substr(7).match(qO).map(Jn)},l_=function(e,t){var r=e._gsap||eu(e),i=e.style,s=k2(e),o,a,l,A;return r.svg&&e.getAttribute("transform")?(l=e.transform.baseVal.consolidate().matrix,s=[l.a,l.b,l.c,l.d,l.e,l.f],s.join(",")==="1,0,0,1,0,0"?bm:s):(s===bm&&!e.offsetParent&&e!==Ld&&!r.svg&&(l=i.display,i.display="block",o=e.parentNode,(!o||!e.offsetParent)&&(A=1,a=e.nextElementSibling,Ld.appendChild(e)),s=k2(e),l?i.display=l:Cm(e,"display"),A&&(a?o.insertBefore(e,a):o?o.appendChild(e):Ld.removeChild(e))),t&&s.length>6?[s[0],s[1],s[4],s[5],s[12],s[13]]:s)},uE=function(e,t,r,i,s,o){var a=e._gsap,l=s||l_(e,!0),A=a.xOrigin||0,c=a.yOrigin||0,u=a.xOffset||0,f=a.yOffset||0,d=l[0],h=l[1],p=l[2],m=l[3],g=l[4],v=l[5],y=t.split(" "),w=parseFloat(y[0])||0,C=parseFloat(y[1])||0,b,E,x,S;r?l!==bm&&(E=d*m-h*p)&&(x=w*(m/E)+C*(-p/E)+(p*v-m*g)/E,S=w*(-h/E)+C*(d/E)-(d*v-h*g)/E,w=x,C=S):(b=WG(e),w=b.x+(~y[0].indexOf("%")?w/100*b.width:w),C=b.y+(~(y[1]||y[0]).indexOf("%")?C/100*b.height:C)),i||i!==!1&&a.smooth?(g=w-A,v=C-c,a.xOffset=u+(g*d+v*p)-g,a.yOffset=f+(g*h+v*m)-v):a.xOffset=a.yOffset=0,a.xOrigin=w,a.yOrigin=C,a.smooth=!!i,a.origin=t,a.originIsAbsolute=!!r,e.style[To]="0px 0px",o&&(IA(o,a,"xOrigin",A,w),IA(o,a,"yOrigin",c,C),IA(o,a,"xOffset",u,a.xOffset),IA(o,a,"yOffset",f,a.yOffset)),e.setAttribute("data-svg-origin",w+" "+C)},xm=function(e,t){var r=e._gsap||new EG(e);if("x"in r&&!t&&!r.uncache)return r;var i=e.style,s=r.scaleX<0,o="px",a="deg",l=getComputedStyle(e),A=Ca(e,To)||"0",c,u,f,d,h,p,m,g,v,y,w,C,b,E,x,S,M,Z,K,_,B,F,R,k,T,V,O,L,U,H,le,N;return c=u=f=p=m=g=v=y=w=0,d=h=1,r.svg=!!(e.getCTM&&OG(e)),l.translate&&((l.translate!=="none"||l.scale!=="none"||l.rotate!=="none")&&(i[_n]=(l.translate!=="none"?"translate3d("+(l.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(l.rotate!=="none"?"rotate("+l.rotate+") ":"")+(l.scale!=="none"?"scale("+l.scale.split(" ").join(",")+") ":"")+(l[_n]!=="none"?l[_n]:"")),i.scale=i.rotate=i.translate="none"),E=l_(e,r.svg),r.svg&&(r.uncache?(T=e.getBBox(),A=r.xOrigin-T.x+"px "+(r.yOrigin-T.y)+"px",k=""):k=!t&&e.getAttribute("data-svg-origin"),uE(e,k||A,!!k||r.originIsAbsolute,r.smooth!==!1,E)),C=r.xOrigin||0,b=r.yOrigin||0,E!==bm&&(Z=E[0],K=E[1],_=E[2],B=E[3],c=F=E[4],u=R=E[5],E.length===6?(d=Math.sqrt(Z*Z+K*K),h=Math.sqrt(B*B+_*_),p=Z||K?zu(K,Z)*Mc:0,v=_||B?zu(_,B)*Mc+p:0,v&&(h*=Math.abs(Math.cos(v*Pd))),r.svg&&(c-=C-(C*Z+b*_),u-=b-(C*K+b*B))):(N=E[6],H=E[7],O=E[8],L=E[9],U=E[10],le=E[11],c=E[12],u=E[13],f=E[14],x=zu(N,U),m=x*Mc,x&&(S=Math.cos(-x),M=Math.sin(-x),k=F*S+O*M,T=R*S+L*M,V=N*S+U*M,O=F*-M+O*S,L=R*-M+L*S,U=N*-M+U*S,le=H*-M+le*S,F=k,R=T,N=V),x=zu(-_,U),g=x*Mc,x&&(S=Math.cos(-x),M=Math.sin(-x),k=Z*S-O*M,T=K*S-L*M,V=_*S-U*M,le=B*M+le*S,Z=k,K=T,_=V),x=zu(K,Z),p=x*Mc,x&&(S=Math.cos(x),M=Math.sin(x),k=Z*S+K*M,T=F*S+R*M,K=K*S-Z*M,R=R*S-F*M,Z=k,F=T),m&&Math.abs(m)+Math.abs(p)>359.9&&(m=p=0,g=180-g),d=Jn(Math.sqrt(Z*Z+K*K+_*_)),h=Jn(Math.sqrt(R*R+N*N)),x=zu(F,R),v=Math.abs(x)>2e-4?x*Mc:0,w=le?1/(le<0?-le:le):0),r.svg&&(k=e.getAttribute("transform"),r.forceCSS=e.setAttribute("transform","")||!ZG(Ca(e,_n)),k&&e.setAttribute("transform",k))),Math.abs(v)>90&&Math.abs(v)<270&&(s?(d*=-1,v+=p<=0?180:-180,p+=p<=0?180:-180):(h*=-1,v+=v<=0?180:-180)),t=t||r.uncache,r.x=c-((r.xPercent=c&&(!t&&r.xPercent||(Math.round(e.offsetWidth/2)===Math.round(-c)?-50:0)))?e.offsetWidth*r.xPercent/100:0)+o,r.y=u-((r.yPercent=u&&(!t&&r.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-u)?-50:0)))?e.offsetHeight*r.yPercent/100:0)+o,r.z=f+o,r.scaleX=Jn(d),r.scaleY=Jn(h),r.rotation=Jn(p)+a,r.rotationX=Jn(m)+a,r.rotationY=Jn(g)+a,r.skewX=v+a,r.skewY=y+a,r.transformPerspective=w+o,(r.zOrigin=parseFloat(A.split(" ")[2])||0)&&(i[To]=dw(A)),r.xOffset=r.yOffset=0,r.force3D=As.force3D,r.renderTransform=r.svg?E7:PG?JG:F7,r.uncache=0,r},dw=function(e){return(e=e.split(" "))[0]+" "+e[1]},Zx=function(e,t,r){var i=Xr(t);return Jn(parseFloat(t)+parseFloat(jA(e,"x",r+"px",i)))+i},F7=function(e,t){t.z="0px",t.rotationY=t.rotationX="0deg",t.force3D=0,JG(e,t)},yc="0deg",bp="0px",Bc=") ",JG=function(e,t){var r=t||this,i=r.xPercent,s=r.yPercent,o=r.x,a=r.y,l=r.z,A=r.rotation,c=r.rotationY,u=r.rotationX,f=r.skewX,d=r.skewY,h=r.scaleX,p=r.scaleY,m=r.transformPerspective,g=r.force3D,v=r.target,y=r.zOrigin,w="",C=g==="auto"&&e&&e!==1||g===!0;if(y&&(u!==yc||c!==yc)){var b=parseFloat(c)*Pd,E=Math.sin(b),x=Math.cos(b),S;b=parseFloat(u)*Pd,S=Math.cos(b),o=Zx(v,o,E*S*-y),a=Zx(v,a,-Math.sin(b)*-y),l=Zx(v,l,x*S*-y+y)}m!==bp&&(w+="perspective("+m+Bc),(i||s)&&(w+="translate("+i+"%, "+s+"%) "),(C||o!==bp||a!==bp||l!==bp)&&(w+=l!==bp||C?"translate3d("+o+", "+a+", "+l+") ":"translate("+o+", "+a+Bc),A!==yc&&(w+="rotate("+A+Bc),c!==yc&&(w+="rotateY("+c+Bc),u!==yc&&(w+="rotateX("+u+Bc),(f!==yc||d!==yc)&&(w+="skew("+f+", "+d+Bc),(h!==1||p!==1)&&(w+="scale("+h+", "+p+Bc),v.style[_n]=w||"translate(0, 0)"},E7=function(e,t){var r=t||this,i=r.xPercent,s=r.yPercent,o=r.x,a=r.y,l=r.rotation,A=r.skewX,c=r.skewY,u=r.scaleX,f=r.scaleY,d=r.target,h=r.xOrigin,p=r.yOrigin,m=r.xOffset,g=r.yOffset,v=r.forceCSS,y=parseFloat(o),w=parseFloat(a),C,b,E,x,S;l=parseFloat(l),A=parseFloat(A),c=parseFloat(c),c&&(c=parseFloat(c),A+=c,l+=c),l||A?(l*=Pd,A*=Pd,C=Math.cos(l)*u,b=Math.sin(l)*u,E=Math.sin(l-A)*-f,x=Math.cos(l-A)*f,A&&(c*=Pd,S=Math.tan(A-c),S=Math.sqrt(1+S*S),E*=S,x*=S,c&&(S=Math.tan(c),S=Math.sqrt(1+S*S),C*=S,b*=S)),C=Jn(C),b=Jn(b),E=Jn(E),x=Jn(x)):(C=u,x=f,b=E=0),(y&&!~(o+"").indexOf("px")||w&&!~(a+"").indexOf("px"))&&(y=jA(d,"x",o,"px"),w=jA(d,"y",a,"px")),(h||p||m||g)&&(y=Jn(y+h-(h*C+p*E)+m),w=Jn(w+p-(h*b+p*x)+g)),(i||s)&&(S=d.getBBox(),y=Jn(y+i/100*S.width),w=Jn(w+s/100*S.height)),S="matrix("+C+","+b+","+E+","+x+","+y+","+w+")",d.setAttribute("transform",S),v&&(d.style[_n]=S)},U7=function(e,t,r,i,s){var o=360,a=Fr(s),l=parseFloat(s)*(a&&~s.indexOf("rad")?Mc:1),A=l-i,c=i+A+"deg",u,f;return a&&(u=s.split("_")[1],u==="short"&&(A%=o,A!==A%(o/2)&&(A+=A<0?o:-o)),u==="cw"&&A<0?A=(A+o*R2)%o-~~(A/o)*o:u==="ccw"&&A>0&&(A=(A-o*R2)%o-~~(A/o)*o)),e._pt=f=new ki(e._pt,t,r,i,A,u7),f.e=c,f.u="deg",e._props.push(r),f},V2=function(e,t){for(var r in t)e[r]=t[r];return e},S7=function(e,t,r){var i=V2({},r._gsap),s="perspective,force3D,transformOrigin,svgOrigin",o=r.style,a,l,A,c,u,f,d,h;i.svg?(A=r.getAttribute("transform"),r.setAttribute("transform",""),o[_n]=t,a=xm(r,1),Cm(r,_n),r.setAttribute("transform",A)):(A=getComputedStyle(r)[_n],o[_n]=t,a=xm(r,1),o[_n]=A);for(l in Tl)A=i[l],c=a[l],A!==c&&s.indexOf(l)<0&&(d=Xr(A),h=Xr(c),u=d!==h?jA(r,l,A,h):parseFloat(A),f=parseFloat(c),e._pt=new ki(e._pt,a,l,u,f-u,lE),e._pt.u=h||0,e._props.push(l));V2(a,i)};Di("padding,margin,Width,Radius",function(n,e){var t="Top",r="Right",i="Bottom",s="Left",o=(e<3?[t,r,i,s]:[t+s,t+r,i+r,i+s]).map(function(a){return e<2?n+a:"border"+a+n});fw[e>1?"border"+n:n]=function(a,l,A,c,u){var f,d;if(arguments.length<4)return f=o.map(function(h){return dl(a,h,A)}),d=f.join(" "),d.split(f[0]).length===5?f[0]:d;f=(c+"").split(" "),d={},o.forEach(function(h,p){return d[h]=f[p]=f[p]||f[(p-1)/2|0]}),a.init(l,d,u)}});var HG={name:"css",register:cE,targetTest:function(e){return e.style&&e.nodeType},init:function(e,t,r,i,s){var o=this._props,a=e.style,l=r.vars.startAt,A,c,u,f,d,h,p,m,g,v,y,w,C,b,E,x;s_||cE(),this.styles=this.styles||LG(e),x=this.styles.props,this.tween=r;for(p in t)if(p!=="autoRound"&&(c=t[p],!(es[p]&&UG(p,t,r,i,e,s)))){if(d=typeof c,h=fw[p],d==="function"&&(c=c.call(r,i,e,s),d=typeof c),d==="string"&&~c.indexOf("random(")&&(c=Bm(c)),h)h(this,e,p,c,r)&&(E=1);else if(p.substr(0,2)==="--")A=(getComputedStyle(e).getPropertyValue(p)+"").trim(),c+="",PA.lastIndex=0,PA.test(A)||(m=Xr(A),g=Xr(c)),g?m!==g&&(A=jA(e,p,A,g)+g):m&&(c+=m),this.add(a,"setProperty",A,c,i,s,0,0,p),o.push(p),x.push(p,0,a[p]);else if(d!=="undefined"){if(l&&p in l?(A=typeof l[p]=="function"?l[p].call(r,i,e,s):l[p],Fr(A)&&~A.indexOf("random(")&&(A=Bm(A)),Xr(A+"")||(A+=As.units[p]||Xr(dl(e,p))||""),(A+"").charAt(1)==="="&&(A=dl(e,p))):A=dl(e,p),f=parseFloat(A),v=d==="string"&&c.charAt(1)==="="&&c.substr(0,2),v&&(c=c.substr(2)),u=parseFloat(c),p in yl&&(p==="autoAlpha"&&(f===1&&dl(e,"visibility")==="hidden"&&u&&(f=0),x.push("visibility",0,a.visibility),IA(this,a,"visibility",f?"inherit":"hidden",u?"inherit":"hidden",!u)),p!=="scale"&&p!=="transform"&&(p=yl[p],~p.indexOf(",")&&(p=p.split(",")[0]))),y=p in Tl,y){if(this.styles.save(p),w||(C=e._gsap,C.renderTransform&&!t.parseTransform||xm(e,t.parseTransform),b=t.smoothOrigin!==!1&&C.smooth,w=this._pt=new ki(this._pt,a,_n,0,1,C.renderTransform,C,0,-1),w.dep=1),p==="scale")this._pt=new ki(this._pt,C,"scaleY",C.scaleY,(v?Vd(C.scaleY,v+u):u)-C.scaleY||0,lE),this._pt.u=0,o.push("scaleY",p),p+="X";else if(p==="transformOrigin"){x.push(To,0,a[To]),c=x7(c),C.svg?uE(e,c,0,b,0,this):(g=parseFloat(c.split(" ")[2])||0,g!==C.zOrigin&&IA(this,C,"zOrigin",C.zOrigin,g),IA(this,a,p,dw(A),dw(c)));continue}else if(p==="svgOrigin"){uE(e,c,1,b,0,this);continue}else if(p in GG){U7(this,C,p,f,v?Vd(f,v+c):c);continue}else if(p==="smoothOrigin"){IA(this,C,"smooth",C.smooth,c);continue}else if(p==="force3D"){C[p]=c;continue}else if(p==="transform"){S7(this,c,e);continue}}else p in a||(p=ph(p)||p);if(y||(u||u===0)&&(f||f===0)&&!c7.test(c)&&p in a)m=(A+"").substr((f+"").length),u||(u=0),g=Xr(c)||(p in As.units?As.units[p]:m),m!==g&&(f=jA(e,p,A,g)),this._pt=new ki(this._pt,y?C:a,p,f,(v?Vd(f,v+u):u)-f,!y&&(g==="px"||p==="zIndex")&&t.autoRound!==!1?d7:lE),this._pt.u=g||0,m!==g&&g!=="%"&&(this._pt.b=A,this._pt.r=f7);else if(p in a)b7.call(this,e,p,A,v?v+c:c);else if(p in e)this.add(e,p,A||e[p],v?v+c:c,i,s);else if(p!=="parseTransform"){KS(p,c);continue}y||(p in a?x.push(p,0,a[p]):x.push(p,1,A||e[p])),o.push(p)}}E&&TG(this)},render:function(e,t){if(t.tween._time||!o_())for(var r=t._pt;r;)r.r(e,r.d),r=r._next;else t.styles.revert()},get:dl,aliases:yl,getSetter:function(e,t,r){var i=yl[t];return i&&i.indexOf(",")<0&&(t=i),t in Tl&&t!==To&&(e._gsap.x||dl(e,"x"))?r&&Q2===r?t==="scale"?m7:g7:(Q2=r||{})&&(t==="scale"?v7:y7):e.style&&!YS(e.style[t])?h7:~t.indexOf("-")?p7:r_(e,t)},core:{_removeProperty:Cm,_getMatrix:l_}};ds.utils.checkPrefix=ph;ds.core.getStyleSaver=LG;(function(n,e,t,r){var i=Di(n+","+e+","+t,function(s){Tl[s]=1});Di(e,function(s){As.units[s]="deg",GG[s]=1}),yl[i[13]]=n+","+e,Di(r,function(s){var o=s.split(":");yl[o[1]]=i[o[0]]})})("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");Di("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(n){As.units[n]="px"});ds.registerPlugin(HG);var fE=ds.registerPlugin(HG)||ds;fE.core.Tween;function Nh(){localStorage&&Object.keys(localStorage).map(n=>{this.setItem(n,localStorage[n],!1)}),Object.defineProperty(this,"length",{get:function(){return Object.keys(this).length},enumerable:!1})}Nh.prototype.key=function(n){return Object.keys(this)[n]};Nh.prototype.getItem=function(n){try{return JSON.parse(this[n])}catch{}return this[n]};Nh.prototype.setItem=function(n,e,t=!0){const r=typeof e=="string"?e:JSON.stringify(e);return t&&localStorage.setItem(n,r),this[n]=r};Nh.prototype.removeItem=function(n){delete this[n]};Nh.prototype.clear=function(){Object.keys(this).forEach(n=>delete this[n])};let _7=new Nh;const Q7=n=>({get(e,t){return n.getItem(String(t))},set(e,t,r){return n.setItem(String(t),r),!0}}),R7=(n=_7)=>new Proxy({},Q7(n)),et=R7();/** * @license * Copyright 2010-2022 Three.js Authors * SPDX-License-Identifier: MIT - */const Ps="146",Yu={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Xu={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},M7=0,L2=1,T7=2,zG=1,N7=2,ug=3,Vo=0,mi=1,pi=2,WA=0,Wd=1,pu=2,P2=3,W2=4,D7=5,Rf=100,k7=101,V7=102,O2=103,G2=104,L7=200,P7=201,W7=202,O7=203,YG=204,XG=205,G7=206,Z7=207,J7=208,H7=209,z7=210,Y7=0,X7=1,K7=2,dE=3,j7=4,$7=5,q7=6,e$=7,zC=0,t$=1,n$=2,xl=0,r$=1,i$=2,s$=3,o$=4,a$=5,KG=300,gh=301,mh=302,hw=303,hE=304,YC=306,hs=1e3,di=1001,Im=1002,er=1003,pw=1004,gw=1005,Ai=1006,A_=1007,Su=1008,$A=1009,l$=1010,A$=1011,jG=1012,c$=1013,Jc=1014,FA=1015,Fm=1016,u$=1017,f$=1018,Od=1020,d$=1021,$G=1022,br=1023,h$=1024,p$=1025,ru=1026,vh=1027,g$=1028,m$=1029,v$=1030,y$=1031,B$=1033,Jx=33776,Hx=33777,zx=33778,Yx=33779,Z2=35840,J2=35841,H2=35842,z2=35843,w$=36196,Y2=37492,X2=37496,K2=37808,j2=37809,$2=37810,q2=37811,eT=37812,tT=37813,nT=37814,rT=37815,iT=37816,sT=37817,oT=37818,aT=37819,lT=37820,AT=37821,cT=36492,C$=2200,b$=2201,x$=2202,yh=2300,gu=2301,Xx=2302,wd=2400,Cd=2401,mw=2402,c_=2500,I$=2501,F$=1,qG=2,ps=3e3,ht=3001,E$=3200,U$=3201,_u=0,S$=1,Al="srgb",Hc="srgb-linear",Kx=7680,_$=519,pE=35044,Q$=35048,uT="300 es",gE=1035;class dc{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,o=i.length;s>8&255]+Zr[n>>16&255]+Zr[n>>24&255]+"-"+Zr[e&255]+Zr[e>>8&255]+"-"+Zr[e>>16&15|64]+Zr[e>>24&255]+"-"+Zr[t&63|128]+Zr[t>>8&255]+"-"+Zr[t>>16&255]+Zr[t>>24&255]+Zr[r&255]+Zr[r>>8&255]+Zr[r>>16&255]+Zr[r>>24&255]).toLowerCase()}function fr(n,e,t){return Math.max(e,Math.min(t,n))}function u_(n,e){return(n%e+e)%e}function R$(n,e,t,r,i){return r+(n-e)*(i-r)/(t-e)}function M$(n,e,t){return n!==e?(t-n)/(e-n):0}function Gg(n,e,t){return(1-t)*n+t*e}function T$(n,e,t,r){return Gg(n,e,1-Math.exp(-t*r))}function N$(n,e=1){return e-Math.abs(u_(n,e*2)-e)}function D$(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function k$(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function V$(n,e){return n+Math.floor(Math.random()*(e-n+1))}function L$(n,e){return n+Math.random()*(e-n)}function P$(n){return n*(.5-Math.random())}function W$(n){n!==void 0&&(fT=n);let e=fT+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function O$(n){return n*Og}function G$(n){return n*Em}function mE(n){return(n&n-1)===0&&n!==0}function eZ(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function vw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Z$(n,e,t,r,i){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),A=s((e+r)/2),c=o((e+r)/2),u=s((e-r)/2),f=o((e-r)/2),d=s((r-e)/2),h=o((r-e)/2);switch(i){case"XYX":n.set(a*c,l*u,l*f,a*A);break;case"YZY":n.set(l*f,a*c,l*u,a*A);break;case"ZXZ":n.set(l*u,l*f,a*c,a*A);break;case"XZX":n.set(a*c,l*h,l*d,a*A);break;case"YXY":n.set(l*d,a*c,l*h,a*A);break;case"ZYZ":n.set(l*h,l*d,a*c,a*A);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Bl(n,e){switch(e.constructor){case Float32Array:return n;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function an(n,e){switch(e.constructor){case Float32Array:return n;case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}var Wt=Object.freeze({__proto__:null,DEG2RAD:Og,RAD2DEG:Em,generateUUID:No,clamp:fr,euclideanModulo:u_,mapLinear:R$,inverseLerp:M$,lerp:Gg,damp:T$,pingpong:N$,smoothstep:D$,smootherstep:k$,randInt:V$,randFloat:L$,randFloatSpread:P$,seededRandom:W$,degToRad:O$,radToDeg:G$,isPowerOfTwo:mE,ceilPowerOfTwo:eZ,floorPowerOfTwo:vw,setQuaternionFromProperEuler:Z$,normalize:an,denormalize:Bl});class We{constructor(e=0,t=0){We.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const r=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class kn{constructor(){kn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,r,i,s,o,a,l,A){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=s,c[5]=l,c[6]=r,c[7]=o,c[8]=A,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[3],l=r[6],A=r[1],c=r[4],u=r[7],f=r[2],d=r[5],h=r[8],p=i[0],m=i[3],g=i[6],v=i[1],y=i[4],w=i[7],C=i[2],b=i[5],E=i[8];return s[0]=o*p+a*v+l*C,s[3]=o*m+a*y+l*b,s[6]=o*g+a*w+l*E,s[1]=A*p+c*v+u*C,s[4]=A*m+c*y+u*b,s[7]=A*g+c*w+u*E,s[2]=f*p+d*v+h*C,s[5]=f*m+d*y+h*b,s[8]=f*g+d*w+h*E,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],A=e[7],c=e[8];return t*o*c-t*a*A-r*s*c+r*a*l+i*s*A-i*o*l}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],A=e[7],c=e[8],u=c*o-a*A,f=a*l-c*s,d=A*s-o*l,h=t*u+r*f+i*d;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);const p=1/h;return e[0]=u*p,e[1]=(i*A-c*r)*p,e[2]=(a*r-i*o)*p,e[3]=f*p,e[4]=(c*t-i*l)*p,e[5]=(i*s-a*t)*p,e[6]=d*p,e[7]=(r*l-A*t)*p,e[8]=(o*t-r*s)*p,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,r,i,s,o,a){const l=Math.cos(s),A=Math.sin(s);return this.set(r*l,r*A,-r*(l*o+A*a)+o+e,-i*A,i*l,-i*(-A*o+l*a)+a+t,0,0,1),this}scale(e,t){const r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=t,r[4]*=t,r[7]*=t,this}rotate(e){const t=Math.cos(e),r=Math.sin(e),i=this.elements,s=i[0],o=i[3],a=i[6],l=i[1],A=i[4],c=i[7];return i[0]=t*s+r*l,i[3]=t*o+r*A,i[6]=t*a+r*c,i[1]=-r*s+t*l,i[4]=-r*o+t*A,i[7]=-r*a+t*c,this}translate(e,t){const r=this.elements;return r[0]+=e*r[2],r[3]+=e*r[5],r[6]+=e*r[8],r[1]+=t*r[2],r[4]+=t*r[5],r[7]+=t*r[8],this}equals(e){const t=this.elements,r=e.elements;for(let i=0;i<9;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}function tZ(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Um(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function iu(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function rB(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}const jx={[Al]:{[Hc]:iu},[Hc]:{[Al]:rB}},go={legacyMode:!0,get workingColorSpace(){return Hc},set workingColorSpace(n){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(n,e,t){if(this.legacyMode||e===t||!e||!t)return n;if(jx[e]&&jx[e][t]!==void 0){const r=jx[e][t];return n.r=r(n.r),n.g=r(n.g),n.b=r(n.b),n}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(n,e){return this.convert(n,this.workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this.workingColorSpace)}},nZ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},lr={r:0,g:0,b:0},mo={h:0,s:0,l:0},ov={h:0,s:0,l:0};function $x(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function av(n,e){return e.r=n.r,e.g=n.g,e.b=n.b,e}class Re{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&r===void 0?this.set(e):this.setRGB(e,t,r)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Al){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,go.toWorkingColorSpace(this,t),this}setRGB(e,t,r,i=Hc){return this.r=e,this.g=t,this.b=r,go.toWorkingColorSpace(this,i),this}setHSL(e,t,r,i=Hc){if(e=u_(e,1),t=fr(t,0,1),r=fr(r,0,1),t===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+t):r+t-r*t,o=2*r-s;this.r=$x(o,s,e+1/3),this.g=$x(o,s,e),this.b=$x(o,s,e-1/3)}return go.toWorkingColorSpace(this,i),this}setStyle(e,t=Al){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,go.toWorkingColorSpace(this,t),r(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,go.toWorkingColorSpace(this,t),r(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){const l=parseFloat(s[1])/360,A=parseFloat(s[2])/100,c=parseFloat(s[3])/100;return r(s[4]),this.setHSL(l,A,c,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,go.toWorkingColorSpace(this,t),this;if(o===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,go.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Al){const r=nZ[e.toLowerCase()];return r!==void 0?this.setHex(r,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=iu(e.r),this.g=iu(e.g),this.b=iu(e.b),this}copyLinearToSRGB(e){return this.r=rB(e.r),this.g=rB(e.g),this.b=rB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Al){return go.fromWorkingColorSpace(av(this,lr),e),fr(lr.r*255,0,255)<<16^fr(lr.g*255,0,255)<<8^fr(lr.b*255,0,255)<<0}getHexString(e=Al){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Hc){go.fromWorkingColorSpace(av(this,lr),t);const r=lr.r,i=lr.g,s=lr.b,o=Math.max(r,i,s),a=Math.min(r,i,s);let l,A;const c=(a+o)/2;if(a===o)l=0,A=0;else{const u=o-a;switch(A=c<=.5?u/(o+a):u/(2-o-a),o){case r:l=(i-s)/u+(i"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ku===void 0&&(Ku=Um("canvas")),Ku.width=e.width,Ku.height=e.height;const r=Ku.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),t=Ku}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Um("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o1)switch(this.wrapS){case hs:e.x=e.x-Math.floor(e.x);break;case di:e.x=e.x<0?0:1;break;case Im:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case hs:e.y=e.y-Math.floor(e.y);break;case di:e.y=e.y<0?0:1;break;case Im:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}ir.DEFAULT_IMAGE=null;ir.DEFAULT_MAPPING=KG;class Tt{constructor(e=0,t=0,r=0,i=1){Tt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*r+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,i,s;const l=e.elements,A=l[0],c=l[4],u=l[8],f=l[1],d=l[5],h=l[9],p=l[2],m=l[6],g=l[10];if(Math.abs(c-f)<.01&&Math.abs(u-p)<.01&&Math.abs(h-m)<.01){if(Math.abs(c+f)<.1&&Math.abs(u+p)<.1&&Math.abs(h+m)<.1&&Math.abs(A+d+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const y=(A+1)/2,w=(d+1)/2,C=(g+1)/2,b=(c+f)/4,E=(u+p)/4,x=(h+m)/4;return y>w&&y>C?y<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(y),i=b/r,s=E/r):w>C?w<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(w),r=b/i,s=x/i):C<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(C),r=E/s,i=x/s),this.set(r,i,s,t),this}let v=Math.sqrt((m-h)*(m-h)+(u-p)*(u-p)+(f-c)*(f-c));return Math.abs(v)<.001&&(v=1),this.x=(m-h)/v,this.y=(u-p)/v,this.z=(f-c)/v,this.w=Math.acos((A+d+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class _a extends dc{constructor(e=1,t=1,r={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Tt(0,0,e,t),this.scissorTest=!1,this.viewport=new Tt(0,0,e,t);const i={width:e,height:t,depth:1};this.texture=new ir(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.internalFormat=r.internalFormat!==void 0?r.internalFormat:null,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:Ai,this.depthBuffer=r.depthBuffer!==void 0?r.depthBuffer:!0,this.stencilBuffer=r.stencilBuffer!==void 0?r.stencilBuffer:!1,this.depthTexture=r.depthTexture!==void 0?r.depthTexture:null,this.samples=r.samples!==void 0?r.samples:0}setSize(e,t,r=1){(this.width!==e||this.height!==t||this.depth!==r)&&(this.width=e,this.height=t,this.depth=r,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new f_(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class iZ extends ir{constructor(e=null,t=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=er,this.minFilter=er,this.wrapR=di,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class H$ extends ir{constructor(e=null,t=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=er,this.minFilter=er,this.wrapR=di,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class tt{constructor(e=0,t=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=i}static slerpFlat(e,t,r,i,s,o,a){let l=r[i+0],A=r[i+1],c=r[i+2],u=r[i+3];const f=s[o+0],d=s[o+1],h=s[o+2],p=s[o+3];if(a===0){e[t+0]=l,e[t+1]=A,e[t+2]=c,e[t+3]=u;return}if(a===1){e[t+0]=f,e[t+1]=d,e[t+2]=h,e[t+3]=p;return}if(u!==p||l!==f||A!==d||c!==h){let m=1-a;const g=l*f+A*d+c*h+u*p,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){const C=Math.sqrt(y),b=Math.atan2(C,g*v);m=Math.sin(m*b)/C,a=Math.sin(a*b)/C}const w=a*v;if(l=l*m+f*w,A=A*m+d*w,c=c*m+h*w,u=u*m+p*w,m===1-a){const C=1/Math.sqrt(l*l+A*A+c*c+u*u);l*=C,A*=C,c*=C,u*=C}}e[t]=l,e[t+1]=A,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,r,i,s,o){const a=r[i],l=r[i+1],A=r[i+2],c=r[i+3],u=s[o],f=s[o+1],d=s[o+2],h=s[o+3];return e[t]=a*h+c*u+l*d-A*f,e[t+1]=l*h+c*f+A*u-a*d,e[t+2]=A*h+c*d+a*f-l*u,e[t+3]=c*h-a*u-l*f-A*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const r=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,A=a(r/2),c=a(i/2),u=a(s/2),f=l(r/2),d=l(i/2),h=l(s/2);switch(o){case"XYZ":this._x=f*c*u+A*d*h,this._y=A*d*u-f*c*h,this._z=A*c*h+f*d*u,this._w=A*c*u-f*d*h;break;case"YXZ":this._x=f*c*u+A*d*h,this._y=A*d*u-f*c*h,this._z=A*c*h-f*d*u,this._w=A*c*u+f*d*h;break;case"ZXY":this._x=f*c*u-A*d*h,this._y=A*d*u+f*c*h,this._z=A*c*h+f*d*u,this._w=A*c*u-f*d*h;break;case"ZYX":this._x=f*c*u-A*d*h,this._y=A*d*u+f*c*h,this._z=A*c*h-f*d*u,this._w=A*c*u+f*d*h;break;case"YZX":this._x=f*c*u+A*d*h,this._y=A*d*u+f*c*h,this._z=A*c*h-f*d*u,this._w=A*c*u-f*d*h;break;case"XZY":this._x=f*c*u-A*d*h,this._y=A*d*u-f*c*h,this._z=A*c*h+f*d*u,this._w=A*c*u+f*d*h;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],A=t[2],c=t[6],u=t[10],f=r+a+u;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(c-l)*d,this._y=(s-A)*d,this._z=(o-i)*d}else if(r>a&&r>u){const d=2*Math.sqrt(1+r-a-u);this._w=(c-l)/d,this._x=.25*d,this._y=(i+o)/d,this._z=(s+A)/d}else if(a>u){const d=2*Math.sqrt(1+a-r-u);this._w=(s-A)/d,this._x=(i+o)/d,this._y=.25*d,this._z=(l+c)/d}else{const d=2*Math.sqrt(1+u-r-a);this._w=(o-i)/d,this._x=(s+A)/d,this._y=(l+c)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return rMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(fr(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,t/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const r=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,A=t._z,c=t._w;return this._x=r*c+o*a+i*A-s*l,this._y=i*c+o*l+s*a-r*A,this._z=s*c+o*A+r*l-i*a,this._w=o*c-r*a-i*l-s*A,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,o=this._w;let a=o*e._w+r*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const d=1-t;return this._w=d*o+t*this._w,this._x=d*r+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const A=Math.sqrt(l),c=Math.atan2(A,a),u=Math.sin((1-t)*c)/A,f=Math.sin(t*c)/A;return this._w=o*u+this._w*f,this._x=r*u+this._x*f,this._y=i*u+this._y*f,this._z=s*u+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=Math.random(),t=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),r*Math.sin(s),r*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class z{constructor(e=0,t=0,r=0){z.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return r===void 0&&(r=this.z),this.x=e,this.y=t,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(dT.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(dT.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6]*i,this.y=s[1]*t+s[4]*r+s[7]*i,this.z=s[2]*t+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const t=this.x,r=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,A=l*t+o*i-a*r,c=l*r+a*t-s*i,u=l*i+s*r-o*t,f=-s*t-o*r-a*i;return this.x=A*l+f*-s+c*-a-u*-o,this.y=c*l+f*-o+u*-s-A*-a,this.z=u*l+f*-a+A*-o-c*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i,this.y=s[1]*t+s[5]*r+s[9]*i,this.z=s[2]*t+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return eI.copy(this).projectOnVector(e),this.sub(eI)}reflect(e){return this.sub(eI.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(fr(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,r){const i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(t),this.y=r*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const eI=new z,dT=new tt;class ws{constructor(e=new z(1/0,1/0,1/0),t=new z(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,A=e.length;ls&&(s=c),u>o&&(o=u),f>a&&(a=f)}return this.min.set(t,r,i),this.max.set(s,o,a),this}setFromBufferAttribute(e){let t=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,A=e.count;ls&&(s=c),u>o&&(o=u),f>a&&(a=f)}return this.min.set(t,r,i),this.max.set(s,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,wc),wc.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(xp),lv.subVectors(this.max,xp),ju.subVectors(e.a,xp),$u.subVectors(e.b,xp),qu.subVectors(e.c,xp),Xl.subVectors($u,ju),Kl.subVectors(qu,$u),Cc.subVectors(ju,qu);let t=[0,-Xl.z,Xl.y,0,-Kl.z,Kl.y,0,-Cc.z,Cc.y,Xl.z,0,-Xl.x,Kl.z,0,-Kl.x,Cc.z,0,-Cc.x,-Xl.y,Xl.x,0,-Kl.y,Kl.x,0,-Cc.y,Cc.x,0];return!nI(t,ju,$u,qu,lv)||(t=[1,0,0,0,1,0,0,0,1],!nI(t,ju,$u,qu,lv))?!1:(Av.crossVectors(Xl,Kl),t=[Av.x,Av.y,Av.z],nI(t,ju,$u,qu,lv))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return wc.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(wc).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ga[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ga[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ga[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ga[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ga[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ga[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ga[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ga[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ga),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ga=[new z,new z,new z,new z,new z,new z,new z,new z],wc=new z,tI=new ws,ju=new z,$u=new z,qu=new z,Xl=new z,Kl=new z,Cc=new z,xp=new z,lv=new z,Av=new z,bc=new z;function nI(n,e,t,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){bc.fromArray(n,s);const a=i.x*Math.abs(bc.x)+i.y*Math.abs(bc.y)+i.z*Math.abs(bc.z),l=e.dot(bc),A=t.dot(bc),c=r.dot(bc);if(Math.max(-Math.max(l,A,c),Math.min(l,A,c))>a)return!1}return!0}const z$=new ws,Ip=new z,rI=new z;class Qu{constructor(e=new z,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const r=this.center;t!==void 0?r.copy(t):z$.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ip.subVectors(e,this.center);const t=Ip.lengthSq();if(t>this.radius*this.radius){const r=Math.sqrt(t),i=(r-this.radius)*.5;this.center.addScaledVector(Ip,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(rI.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ip.copy(e.center).add(rI)),this.expandByPoint(Ip.copy(e.center).sub(rI))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Za=new z,iI=new z,cv=new z,jl=new z,sI=new z,uv=new z,oI=new z;class l0{constructor(e=new z,t=new z(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Za)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Za.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Za.copy(this.direction).multiplyScalar(t).add(this.origin),Za.distanceToSquared(e))}distanceSqToSegment(e,t,r,i){iI.copy(e).add(t).multiplyScalar(.5),cv.copy(t).sub(e).normalize(),jl.copy(this.origin).sub(iI);const s=e.distanceTo(t)*.5,o=-this.direction.dot(cv),a=jl.dot(this.direction),l=-jl.dot(cv),A=jl.lengthSq(),c=Math.abs(1-o*o);let u,f,d,h;if(c>0)if(u=o*l-a,f=o*a-l,h=s*c,u>=0)if(f>=-h)if(f<=h){const p=1/c;u*=p,f*=p,d=u*(u+o*f+2*a)+f*(o*u+f+2*l)+A}else f=s,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+A;else f=-s,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+A;else f<=-h?(u=Math.max(0,-(-o*s+a)),f=u>0?-s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+A):f<=h?(u=0,f=Math.min(Math.max(-s,-l),s),d=f*(f+2*l)+A):(u=Math.max(0,-(o*s+a)),f=u>0?s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+A);else f=o>0?-s:s,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+A;return r&&r.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(cv).multiplyScalar(f).add(iI),d}intersectSphere(e,t){Za.subVectors(e.center,this.origin);const r=Za.dot(this.direction),i=Za.dot(Za)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=r-o,l=r+o;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return r===null?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,s,o,a,l;const A=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,f=this.origin;return A>=0?(r=(e.min.x-f.x)*A,i=(e.max.x-f.x)*A):(r=(e.max.x-f.x)*A,i=(e.min.x-f.x)*A),c>=0?(s=(e.min.y-f.y)*c,o=(e.max.y-f.y)*c):(s=(e.max.y-f.y)*c,o=(e.min.y-f.y)*c),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o=0?(a=(e.min.z-f.z)*u,l=(e.max.z-f.z)*u):(a=(e.max.z-f.z)*u,l=(e.min.z-f.z)*u),r>l||a>i)||((a>r||r!==r)&&(r=a),(l=0?r:i,t)}intersectsBox(e){return this.intersectBox(e,Za)!==null}intersectTriangle(e,t,r,i,s){sI.subVectors(t,e),uv.subVectors(r,e),oI.crossVectors(sI,uv);let o=this.direction.dot(oI),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;jl.subVectors(this.origin,e);const l=a*this.direction.dot(uv.crossVectors(jl,uv));if(l<0)return null;const A=a*this.direction.dot(sI.cross(jl));if(A<0||l+A>o)return null;const c=-a*jl.dot(oI);return c<0?null:this.at(c/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Le{constructor(){Le.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,r,i,s,o,a,l,A,c,u,f,d,h,p,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=r,g[12]=i,g[1]=s,g[5]=o,g[9]=a,g[13]=l,g[2]=A,g[6]=c,g[10]=u,g[14]=f,g[3]=d,g[7]=h,g[11]=p,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Le().fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,i=1/ef.setFromMatrixColumn(e,0).length(),s=1/ef.setFromMatrixColumn(e,1).length(),o=1/ef.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*s,t[5]=r[5]*s,t[6]=r[6]*s,t[7]=0,t[8]=r[8]*o,t[9]=r[9]*o,t[10]=r[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,i=e.y,s=e.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),A=Math.sin(i),c=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const f=o*c,d=o*u,h=a*c,p=a*u;t[0]=l*c,t[4]=-l*u,t[8]=A,t[1]=d+h*A,t[5]=f-p*A,t[9]=-a*l,t[2]=p-f*A,t[6]=h+d*A,t[10]=o*l}else if(e.order==="YXZ"){const f=l*c,d=l*u,h=A*c,p=A*u;t[0]=f+p*a,t[4]=h*a-d,t[8]=o*A,t[1]=o*u,t[5]=o*c,t[9]=-a,t[2]=d*a-h,t[6]=p+f*a,t[10]=o*l}else if(e.order==="ZXY"){const f=l*c,d=l*u,h=A*c,p=A*u;t[0]=f-p*a,t[4]=-o*u,t[8]=h+d*a,t[1]=d+h*a,t[5]=o*c,t[9]=p-f*a,t[2]=-o*A,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const f=o*c,d=o*u,h=a*c,p=a*u;t[0]=l*c,t[4]=h*A-d,t[8]=f*A+p,t[1]=l*u,t[5]=p*A+f,t[9]=d*A-h,t[2]=-A,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const f=o*l,d=o*A,h=a*l,p=a*A;t[0]=l*c,t[4]=p-f*u,t[8]=h*u+d,t[1]=u,t[5]=o*c,t[9]=-a*c,t[2]=-A*c,t[6]=d*u+h,t[10]=f-p*u}else if(e.order==="XZY"){const f=o*l,d=o*A,h=a*l,p=a*A;t[0]=l*c,t[4]=-u,t[8]=A*c,t[1]=f*u+p,t[5]=o*c,t[9]=d*u-h,t[2]=h*u-d,t[6]=a*c,t[10]=p*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Y$,e,X$)}lookAt(e,t,r){const i=this.elements;return Oi.subVectors(e,t),Oi.lengthSq()===0&&(Oi.z=1),Oi.normalize(),$l.crossVectors(r,Oi),$l.lengthSq()===0&&(Math.abs(r.z)===1?Oi.x+=1e-4:Oi.z+=1e-4,Oi.normalize(),$l.crossVectors(r,Oi)),$l.normalize(),fv.crossVectors(Oi,$l),i[0]=$l.x,i[4]=fv.x,i[8]=Oi.x,i[1]=$l.y,i[5]=fv.y,i[9]=Oi.y,i[2]=$l.z,i[6]=fv.z,i[10]=Oi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[4],l=r[8],A=r[12],c=r[1],u=r[5],f=r[9],d=r[13],h=r[2],p=r[6],m=r[10],g=r[14],v=r[3],y=r[7],w=r[11],C=r[15],b=i[0],E=i[4],x=i[8],S=i[12],M=i[1],Z=i[5],K=i[9],_=i[13],B=i[2],F=i[6],R=i[10],k=i[14],T=i[3],V=i[7],O=i[11],L=i[15];return s[0]=o*b+a*M+l*B+A*T,s[4]=o*E+a*Z+l*F+A*V,s[8]=o*x+a*K+l*R+A*O,s[12]=o*S+a*_+l*k+A*L,s[1]=c*b+u*M+f*B+d*T,s[5]=c*E+u*Z+f*F+d*V,s[9]=c*x+u*K+f*R+d*O,s[13]=c*S+u*_+f*k+d*L,s[2]=h*b+p*M+m*B+g*T,s[6]=h*E+p*Z+m*F+g*V,s[10]=h*x+p*K+m*R+g*O,s[14]=h*S+p*_+m*k+g*L,s[3]=v*b+y*M+w*B+C*T,s[7]=v*E+y*Z+w*F+C*V,s[11]=v*x+y*K+w*R+C*O,s[15]=v*S+y*_+w*k+C*L,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],A=e[13],c=e[2],u=e[6],f=e[10],d=e[14],h=e[3],p=e[7],m=e[11],g=e[15];return h*(+s*l*u-i*A*u-s*a*f+r*A*f+i*a*d-r*l*d)+p*(+t*l*d-t*A*f+s*o*f-i*o*d+i*A*c-s*l*c)+m*(+t*A*u-t*a*d-s*o*u+r*o*d+s*a*c-r*A*c)+g*(-i*a*c-t*l*u+t*a*f+i*o*u-r*o*f+r*l*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],A=e[7],c=e[8],u=e[9],f=e[10],d=e[11],h=e[12],p=e[13],m=e[14],g=e[15],v=u*m*A-p*f*A+p*l*d-a*m*d-u*l*g+a*f*g,y=h*f*A-c*m*A-h*l*d+o*m*d+c*l*g-o*f*g,w=c*p*A-h*u*A+h*a*d-o*p*d-c*a*g+o*u*g,C=h*u*l-c*p*l-h*a*f+o*p*f+c*a*m-o*u*m,b=t*v+r*y+i*w+s*C;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/b;return e[0]=v*E,e[1]=(p*f*s-u*m*s-p*i*d+r*m*d+u*i*g-r*f*g)*E,e[2]=(a*m*s-p*l*s+p*i*A-r*m*A-a*i*g+r*l*g)*E,e[3]=(u*l*s-a*f*s-u*i*A+r*f*A+a*i*d-r*l*d)*E,e[4]=y*E,e[5]=(c*m*s-h*f*s+h*i*d-t*m*d-c*i*g+t*f*g)*E,e[6]=(h*l*s-o*m*s-h*i*A+t*m*A+o*i*g-t*l*g)*E,e[7]=(o*f*s-c*l*s+c*i*A-t*f*A-o*i*d+t*l*d)*E,e[8]=w*E,e[9]=(h*u*s-c*p*s-h*r*d+t*p*d+c*r*g-t*u*g)*E,e[10]=(o*p*s-h*a*s+h*r*A-t*p*A-o*r*g+t*a*g)*E,e[11]=(c*a*s-o*u*s-c*r*A+t*u*A+o*r*d-t*a*d)*E,e[12]=C*E,e[13]=(c*p*i-h*u*i+h*r*f-t*p*f-c*r*m+t*u*m)*E,e[14]=(h*a*i-o*p*i-h*r*l+t*p*l+o*r*m-t*a*m)*E,e[15]=(o*u*i-c*a*i+c*r*l-t*u*l-o*r*f+t*a*f)*E,this}scale(e){const t=this.elements,r=e.x,i=e.y,s=e.z;return t[0]*=r,t[4]*=i,t[8]*=s,t[1]*=r,t[5]*=i,t[9]*=s,t[2]*=r,t[6]*=i,t[10]*=s,t[3]*=r,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,i))}makeTranslation(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),i=Math.sin(t),s=1-r,o=e.x,a=e.y,l=e.z,A=s*o,c=s*a;return this.set(A*o+r,A*a-i*l,A*l+i*a,0,A*a+i*l,c*a+r,c*l-i*o,0,A*l-i*a,c*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){const i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,A=s+s,c=o+o,u=a+a,f=s*A,d=s*c,h=s*u,p=o*c,m=o*u,g=a*u,v=l*A,y=l*c,w=l*u,C=r.x,b=r.y,E=r.z;return i[0]=(1-(p+g))*C,i[1]=(d+w)*C,i[2]=(h-y)*C,i[3]=0,i[4]=(d-w)*b,i[5]=(1-(f+g))*b,i[6]=(m+v)*b,i[7]=0,i[8]=(h+y)*E,i[9]=(m-v)*E,i[10]=(1-(f+p))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){const i=this.elements;let s=ef.set(i[0],i[1],i[2]).length();const o=ef.set(i[4],i[5],i[6]).length(),a=ef.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],vo.copy(this);const A=1/s,c=1/o,u=1/a;return vo.elements[0]*=A,vo.elements[1]*=A,vo.elements[2]*=A,vo.elements[4]*=c,vo.elements[5]*=c,vo.elements[6]*=c,vo.elements[8]*=u,vo.elements[9]*=u,vo.elements[10]*=u,t.setFromRotationMatrix(vo),r.x=s,r.y=o,r.z=a,this}makePerspective(e,t,r,i,s,o){const a=this.elements,l=2*s/(t-e),A=2*s/(r-i),c=(t+e)/(t-e),u=(r+i)/(r-i),f=-(o+s)/(o-s),d=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=A,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=f,a[14]=d,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,r,i,s,o){const a=this.elements,l=1/(t-e),A=1/(r-i),c=1/(o-s),u=(t+e)*l,f=(r+i)*A,d=(o+s)*c;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*A,a[9]=0,a[13]=-f,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-d,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let i=0;i<16;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const ef=new z,vo=new Le,Y$=new z(0,0,0),X$=new z(1,1,1),$l=new z,fv=new z,Oi=new z,hT=new Le,pT=new tt;class Kr{constructor(e=0,t=0,r=0,i=Kr.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,r,i=this._order){return this._x=e,this._y=t,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,r=!0){const i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],A=i[5],c=i[9],u=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(fr(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,A),this._z=0);break;case"YXZ":this._x=Math.asin(-fr(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(l,A)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(fr(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-o,A)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-fr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,A));break;case"YZX":this._z=Math.asin(fr(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,A),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-fr(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,A),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return hT.makeRotationFromQuaternion(e),this.setFromRotationMatrix(hT,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return pT.setFromEuler(this),this.setFromQuaternion(pT,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}Kr.DefaultOrder="XYZ";Kr.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class d_{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let r=0;r0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(r.geometries=a),l.length>0&&(r.materials=l),A.length>0&&(r.textures=A),c.length>0&&(r.images=c),u.length>0&&(r.shapes=u),f.length>0&&(r.skeletons=f),d.length>0&&(r.animations=d),h.length>0&&(r.nodes=h)}return r.object=i,r;function o(a){const l=[];for(const A in a){const c=a[A];delete c.metadata,l.push(c)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let r=0;r0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,r,i,s){yo.subVectors(i,t),Ha.subVectors(r,t),aI.subVectors(e,t);const o=yo.dot(yo),a=yo.dot(Ha),l=yo.dot(aI),A=Ha.dot(Ha),c=Ha.dot(aI),u=o*A-a*a;if(u===0)return s.set(-2,-1,-1);const f=1/u,d=(A*l-a*c)*f,h=(o*c-a*l)*f;return s.set(1-d-h,h,d)}static containsPoint(e,t,r,i){return this.getBarycoord(e,t,r,i,za),za.x>=0&&za.y>=0&&za.x+za.y<=1}static getUV(e,t,r,i,s,o,a,l){return this.getBarycoord(e,t,r,i,za),l.set(0,0),l.addScaledVector(s,za.x),l.addScaledVector(o,za.y),l.addScaledVector(a,za.z),l}static isFrontFacing(e,t,r,i){return yo.subVectors(r,t),Ha.subVectors(e,t),yo.cross(Ha).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return yo.subVectors(this.c,this.b),Ha.subVectors(this.a,this.b),yo.cross(Ha).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ns.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ns.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,r,i,s){return ns.getUV(e,this.a,this.b,this.c,t,r,i,s)}containsPoint(e){return ns.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ns.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,i=this.b,s=this.c;let o,a;nf.subVectors(i,r),rf.subVectors(s,r),lI.subVectors(e,r);const l=nf.dot(lI),A=rf.dot(lI);if(l<=0&&A<=0)return t.copy(r);AI.subVectors(e,i);const c=nf.dot(AI),u=rf.dot(AI);if(c>=0&&u<=c)return t.copy(i);const f=l*u-c*A;if(f<=0&&l>=0&&c<=0)return o=l/(l-c),t.copy(r).addScaledVector(nf,o);cI.subVectors(e,s);const d=nf.dot(cI),h=rf.dot(cI);if(h>=0&&d<=h)return t.copy(s);const p=d*A-l*h;if(p<=0&&A>=0&&h<=0)return a=A/(A-h),t.copy(r).addScaledVector(rf,a);const m=c*h-d*u;if(m<=0&&u-c>=0&&d-h>=0)return wT.subVectors(s,i),a=(u-c)/(u-c+(d-h)),t.copy(i).addScaledVector(wT,a);const g=1/(m+p+f);return o=p*g,a=f*g,t.copy(r).addScaledVector(nf,o).addScaledVector(rf,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let eq=0,cs=class extends dc{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eq++}),this.uuid=No(),this.name="",this.type="Material",this.blending=Wd,this.side=Vo,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=YG,this.blendDst=XG,this.blendEquation=Rf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=dE,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=_$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Kx,this.stencilZFail=Kx,this.stencilZPass=Kx,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const r=e[t];if(r===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}const i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Wd&&(r.blending=this.blending),this.side!==Vo&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(r.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=this.flatShading),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let r=null;if(t!==null){const i=t.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=t[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};class Qi extends cs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Re(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=zC,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Yn=new z,hv=new We;class At{constructor(e,t,r){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=r===!0,this.usage=pE,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,r){e*=this.itemSize,r*=t.itemSize;for(let i=0,s=this.itemSize;i0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const A in l)l[A]!==void 0&&(e[A]=l[A]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const r=this.attributes;for(const l in r){const A=r[l];e.data.attributes[l]=A.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const A=this.morphAttributes[l],c=[];for(let u=0,f=A.length;u0&&(i[l]=c,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(t));const i=e.attributes;for(const A in i){const c=i[A];this.setAttribute(A,c.clone(t))}const s=e.morphAttributes;for(const A in s){const c=[],u=s[A];for(let f=0,d=u.length;f0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;st.far?null:{distance:A,point:wv.clone(),object:n}}function Cv(n,e,t,r,i,s,o,a,l,A,c,u){ql.fromBufferAttribute(i,A),eA.fromBufferAttribute(i,c),tA.fromBufferAttribute(i,u);const f=n.morphTargetInfluences;if(s&&f){pv.set(0,0,0),gv.set(0,0,0),mv.set(0,0,0);for(let h=0,p=s.length;h0?1:-1,c.push(V.x,V.y,V.z),u.push(U/E),u.push(1-O/x),k+=1}}for(let O=0;O>8&255]+Zr[n>>16&255]+Zr[n>>24&255]+"-"+Zr[e&255]+Zr[e>>8&255]+"-"+Zr[e>>16&15|64]+Zr[e>>24&255]+"-"+Zr[t&63|128]+Zr[t>>8&255]+"-"+Zr[t>>16&255]+Zr[t>>24&255]+Zr[r&255]+Zr[r>>8&255]+Zr[r>>16&255]+Zr[r>>24&255]).toLowerCase()}function fr(n,e,t){return Math.max(e,Math.min(t,n))}function u_(n,e){return(n%e+e)%e}function R$(n,e,t,r,i){return r+(n-e)*(i-r)/(t-e)}function M$(n,e,t){return n!==e?(t-n)/(e-n):0}function Gg(n,e,t){return(1-t)*n+t*e}function T$(n,e,t,r){return Gg(n,e,1-Math.exp(-t*r))}function N$(n,e=1){return e-Math.abs(u_(n,e*2)-e)}function D$(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function k$(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function V$(n,e){return n+Math.floor(Math.random()*(e-n+1))}function L$(n,e){return n+Math.random()*(e-n)}function P$(n){return n*(.5-Math.random())}function W$(n){n!==void 0&&(fT=n);let e=fT+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function O$(n){return n*Og}function G$(n){return n*Em}function mE(n){return(n&n-1)===0&&n!==0}function eZ(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function vw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Z$(n,e,t,r,i){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),A=s((e+r)/2),c=o((e+r)/2),u=s((e-r)/2),f=o((e-r)/2),d=s((r-e)/2),h=o((r-e)/2);switch(i){case"XYX":n.set(a*c,l*u,l*f,a*A);break;case"YZY":n.set(l*f,a*c,l*u,a*A);break;case"ZXZ":n.set(l*u,l*f,a*c,a*A);break;case"XZX":n.set(a*c,l*h,l*d,a*A);break;case"YXY":n.set(l*d,a*c,l*h,a*A);break;case"ZYZ":n.set(l*h,l*d,a*c,a*A);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Bl(n,e){switch(e.constructor){case Float32Array:return n;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function an(n,e){switch(e.constructor){case Float32Array:return n;case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}var Wt=Object.freeze({__proto__:null,DEG2RAD:Og,RAD2DEG:Em,generateUUID:No,clamp:fr,euclideanModulo:u_,mapLinear:R$,inverseLerp:M$,lerp:Gg,damp:T$,pingpong:N$,smoothstep:D$,smootherstep:k$,randInt:V$,randFloat:L$,randFloatSpread:P$,seededRandom:W$,degToRad:O$,radToDeg:G$,isPowerOfTwo:mE,ceilPowerOfTwo:eZ,floorPowerOfTwo:vw,setQuaternionFromProperEuler:Z$,normalize:an,denormalize:Bl});class We{constructor(e=0,t=0){We.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const r=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class kn{constructor(){kn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,r,i,s,o,a,l,A){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=s,c[5]=l,c[6]=r,c[7]=o,c[8]=A,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[3],l=r[6],A=r[1],c=r[4],u=r[7],f=r[2],d=r[5],h=r[8],p=i[0],m=i[3],g=i[6],v=i[1],y=i[4],w=i[7],C=i[2],b=i[5],E=i[8];return s[0]=o*p+a*v+l*C,s[3]=o*m+a*y+l*b,s[6]=o*g+a*w+l*E,s[1]=A*p+c*v+u*C,s[4]=A*m+c*y+u*b,s[7]=A*g+c*w+u*E,s[2]=f*p+d*v+h*C,s[5]=f*m+d*y+h*b,s[8]=f*g+d*w+h*E,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],A=e[7],c=e[8];return t*o*c-t*a*A-r*s*c+r*a*l+i*s*A-i*o*l}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],A=e[7],c=e[8],u=c*o-a*A,f=a*l-c*s,d=A*s-o*l,h=t*u+r*f+i*d;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);const p=1/h;return e[0]=u*p,e[1]=(i*A-c*r)*p,e[2]=(a*r-i*o)*p,e[3]=f*p,e[4]=(c*t-i*l)*p,e[5]=(i*s-a*t)*p,e[6]=d*p,e[7]=(r*l-A*t)*p,e[8]=(o*t-r*s)*p,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,r,i,s,o,a){const l=Math.cos(s),A=Math.sin(s);return this.set(r*l,r*A,-r*(l*o+A*a)+o+e,-i*A,i*l,-i*(-A*o+l*a)+a+t,0,0,1),this}scale(e,t){const r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=t,r[4]*=t,r[7]*=t,this}rotate(e){const t=Math.cos(e),r=Math.sin(e),i=this.elements,s=i[0],o=i[3],a=i[6],l=i[1],A=i[4],c=i[7];return i[0]=t*s+r*l,i[3]=t*o+r*A,i[6]=t*a+r*c,i[1]=-r*s+t*l,i[4]=-r*o+t*A,i[7]=-r*a+t*c,this}translate(e,t){const r=this.elements;return r[0]+=e*r[2],r[3]+=e*r[5],r[6]+=e*r[8],r[1]+=t*r[2],r[4]+=t*r[5],r[7]+=t*r[8],this}equals(e){const t=this.elements,r=e.elements;for(let i=0;i<9;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}function tZ(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Um(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function iu(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function rB(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}const jx={[Al]:{[Hc]:iu},[Hc]:{[Al]:rB}},go={legacyMode:!0,get workingColorSpace(){return Hc},set workingColorSpace(n){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(n,e,t){if(this.legacyMode||e===t||!e||!t)return n;if(jx[e]&&jx[e][t]!==void 0){const r=jx[e][t];return n.r=r(n.r),n.g=r(n.g),n.b=r(n.b),n}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(n,e){return this.convert(n,this.workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this.workingColorSpace)}},nZ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},lr={r:0,g:0,b:0},mo={h:0,s:0,l:0},ov={h:0,s:0,l:0};function $x(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function av(n,e){return e.r=n.r,e.g=n.g,e.b=n.b,e}class Re{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&r===void 0?this.set(e):this.setRGB(e,t,r)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Al){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,go.toWorkingColorSpace(this,t),this}setRGB(e,t,r,i=Hc){return this.r=e,this.g=t,this.b=r,go.toWorkingColorSpace(this,i),this}setHSL(e,t,r,i=Hc){if(e=u_(e,1),t=fr(t,0,1),r=fr(r,0,1),t===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+t):r+t-r*t,o=2*r-s;this.r=$x(o,s,e+1/3),this.g=$x(o,s,e),this.b=$x(o,s,e-1/3)}return go.toWorkingColorSpace(this,i),this}setStyle(e,t=Al){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,go.toWorkingColorSpace(this,t),r(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,go.toWorkingColorSpace(this,t),r(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){const l=parseFloat(s[1])/360,A=parseFloat(s[2])/100,c=parseFloat(s[3])/100;return r(s[4]),this.setHSL(l,A,c,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,go.toWorkingColorSpace(this,t),this;if(o===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,go.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Al){const r=nZ[e.toLowerCase()];return r!==void 0?this.setHex(r,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=iu(e.r),this.g=iu(e.g),this.b=iu(e.b),this}copyLinearToSRGB(e){return this.r=rB(e.r),this.g=rB(e.g),this.b=rB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Al){return go.fromWorkingColorSpace(av(this,lr),e),fr(lr.r*255,0,255)<<16^fr(lr.g*255,0,255)<<8^fr(lr.b*255,0,255)<<0}getHexString(e=Al){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Hc){go.fromWorkingColorSpace(av(this,lr),t);const r=lr.r,i=lr.g,s=lr.b,o=Math.max(r,i,s),a=Math.min(r,i,s);let l,A;const c=(a+o)/2;if(a===o)l=0,A=0;else{const u=o-a;switch(A=c<=.5?u/(o+a):u/(2-o-a),o){case r:l=(i-s)/u+(i"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ku===void 0&&(Ku=Um("canvas")),Ku.width=e.width,Ku.height=e.height;const r=Ku.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),t=Ku}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Um("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o1)switch(this.wrapS){case hs:e.x=e.x-Math.floor(e.x);break;case di:e.x=e.x<0?0:1;break;case Im:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case hs:e.y=e.y-Math.floor(e.y);break;case di:e.y=e.y<0?0:1;break;case Im:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}ir.DEFAULT_IMAGE=null;ir.DEFAULT_MAPPING=KG;class Tt{constructor(e=0,t=0,r=0,i=1){Tt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*r+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,i,s;const l=e.elements,A=l[0],c=l[4],u=l[8],f=l[1],d=l[5],h=l[9],p=l[2],m=l[6],g=l[10];if(Math.abs(c-f)<.01&&Math.abs(u-p)<.01&&Math.abs(h-m)<.01){if(Math.abs(c+f)<.1&&Math.abs(u+p)<.1&&Math.abs(h+m)<.1&&Math.abs(A+d+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const y=(A+1)/2,w=(d+1)/2,C=(g+1)/2,b=(c+f)/4,E=(u+p)/4,x=(h+m)/4;return y>w&&y>C?y<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(y),i=b/r,s=E/r):w>C?w<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(w),r=b/i,s=x/i):C<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(C),r=E/s,i=x/s),this.set(r,i,s,t),this}let v=Math.sqrt((m-h)*(m-h)+(u-p)*(u-p)+(f-c)*(f-c));return Math.abs(v)<.001&&(v=1),this.x=(m-h)/v,this.y=(u-p)/v,this.z=(f-c)/v,this.w=Math.acos((A+d+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class _a extends dc{constructor(e=1,t=1,r={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Tt(0,0,e,t),this.scissorTest=!1,this.viewport=new Tt(0,0,e,t);const i={width:e,height:t,depth:1};this.texture=new ir(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.internalFormat=r.internalFormat!==void 0?r.internalFormat:null,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:Ai,this.depthBuffer=r.depthBuffer!==void 0?r.depthBuffer:!0,this.stencilBuffer=r.stencilBuffer!==void 0?r.stencilBuffer:!1,this.depthTexture=r.depthTexture!==void 0?r.depthTexture:null,this.samples=r.samples!==void 0?r.samples:0}setSize(e,t,r=1){(this.width!==e||this.height!==t||this.depth!==r)&&(this.width=e,this.height=t,this.depth=r,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new f_(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class iZ extends ir{constructor(e=null,t=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=er,this.minFilter=er,this.wrapR=di,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class H$ extends ir{constructor(e=null,t=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=er,this.minFilter=er,this.wrapR=di,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class tt{constructor(e=0,t=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=i}static slerpFlat(e,t,r,i,s,o,a){let l=r[i+0],A=r[i+1],c=r[i+2],u=r[i+3];const f=s[o+0],d=s[o+1],h=s[o+2],p=s[o+3];if(a===0){e[t+0]=l,e[t+1]=A,e[t+2]=c,e[t+3]=u;return}if(a===1){e[t+0]=f,e[t+1]=d,e[t+2]=h,e[t+3]=p;return}if(u!==p||l!==f||A!==d||c!==h){let m=1-a;const g=l*f+A*d+c*h+u*p,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){const C=Math.sqrt(y),b=Math.atan2(C,g*v);m=Math.sin(m*b)/C,a=Math.sin(a*b)/C}const w=a*v;if(l=l*m+f*w,A=A*m+d*w,c=c*m+h*w,u=u*m+p*w,m===1-a){const C=1/Math.sqrt(l*l+A*A+c*c+u*u);l*=C,A*=C,c*=C,u*=C}}e[t]=l,e[t+1]=A,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,r,i,s,o){const a=r[i],l=r[i+1],A=r[i+2],c=r[i+3],u=s[o],f=s[o+1],d=s[o+2],h=s[o+3];return e[t]=a*h+c*u+l*d-A*f,e[t+1]=l*h+c*f+A*u-a*d,e[t+2]=A*h+c*d+a*f-l*u,e[t+3]=c*h-a*u-l*f-A*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const r=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,A=a(r/2),c=a(i/2),u=a(s/2),f=l(r/2),d=l(i/2),h=l(s/2);switch(o){case"XYZ":this._x=f*c*u+A*d*h,this._y=A*d*u-f*c*h,this._z=A*c*h+f*d*u,this._w=A*c*u-f*d*h;break;case"YXZ":this._x=f*c*u+A*d*h,this._y=A*d*u-f*c*h,this._z=A*c*h-f*d*u,this._w=A*c*u+f*d*h;break;case"ZXY":this._x=f*c*u-A*d*h,this._y=A*d*u+f*c*h,this._z=A*c*h+f*d*u,this._w=A*c*u-f*d*h;break;case"ZYX":this._x=f*c*u-A*d*h,this._y=A*d*u+f*c*h,this._z=A*c*h-f*d*u,this._w=A*c*u+f*d*h;break;case"YZX":this._x=f*c*u+A*d*h,this._y=A*d*u+f*c*h,this._z=A*c*h-f*d*u,this._w=A*c*u-f*d*h;break;case"XZY":this._x=f*c*u-A*d*h,this._y=A*d*u-f*c*h,this._z=A*c*h+f*d*u,this._w=A*c*u+f*d*h;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],A=t[2],c=t[6],u=t[10],f=r+a+u;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(c-l)*d,this._y=(s-A)*d,this._z=(o-i)*d}else if(r>a&&r>u){const d=2*Math.sqrt(1+r-a-u);this._w=(c-l)/d,this._x=.25*d,this._y=(i+o)/d,this._z=(s+A)/d}else if(a>u){const d=2*Math.sqrt(1+a-r-u);this._w=(s-A)/d,this._x=(i+o)/d,this._y=.25*d,this._z=(l+c)/d}else{const d=2*Math.sqrt(1+u-r-a);this._w=(o-i)/d,this._x=(s+A)/d,this._y=(l+c)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return rMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(fr(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,t/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const r=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,A=t._z,c=t._w;return this._x=r*c+o*a+i*A-s*l,this._y=i*c+o*l+s*a-r*A,this._z=s*c+o*A+r*l-i*a,this._w=o*c-r*a-i*l-s*A,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,o=this._w;let a=o*e._w+r*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const d=1-t;return this._w=d*o+t*this._w,this._x=d*r+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const A=Math.sqrt(l),c=Math.atan2(A,a),u=Math.sin((1-t)*c)/A,f=Math.sin(t*c)/A;return this._w=o*u+this._w*f,this._x=r*u+this._x*f,this._y=i*u+this._y*f,this._z=s*u+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=Math.random(),t=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),r*Math.sin(s),r*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class z{constructor(e=0,t=0,r=0){z.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return r===void 0&&(r=this.z),this.x=e,this.y=t,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(dT.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(dT.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6]*i,this.y=s[1]*t+s[4]*r+s[7]*i,this.z=s[2]*t+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const t=this.x,r=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,A=l*t+o*i-a*r,c=l*r+a*t-s*i,u=l*i+s*r-o*t,f=-s*t-o*r-a*i;return this.x=A*l+f*-s+c*-a-u*-o,this.y=c*l+f*-o+u*-s-A*-a,this.z=u*l+f*-a+A*-o-c*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i,this.y=s[1]*t+s[5]*r+s[9]*i,this.z=s[2]*t+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return eI.copy(this).projectOnVector(e),this.sub(eI)}reflect(e){return this.sub(eI.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(fr(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,r){const i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(t),this.y=r*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const eI=new z,dT=new tt;class ws{constructor(e=new z(1/0,1/0,1/0),t=new z(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,A=e.length;ls&&(s=c),u>o&&(o=u),f>a&&(a=f)}return this.min.set(t,r,i),this.max.set(s,o,a),this}setFromBufferAttribute(e){let t=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,A=e.count;ls&&(s=c),u>o&&(o=u),f>a&&(a=f)}return this.min.set(t,r,i),this.max.set(s,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,wc),wc.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(xp),lv.subVectors(this.max,xp),ju.subVectors(e.a,xp),$u.subVectors(e.b,xp),qu.subVectors(e.c,xp),Xl.subVectors($u,ju),Kl.subVectors(qu,$u),Cc.subVectors(ju,qu);let t=[0,-Xl.z,Xl.y,0,-Kl.z,Kl.y,0,-Cc.z,Cc.y,Xl.z,0,-Xl.x,Kl.z,0,-Kl.x,Cc.z,0,-Cc.x,-Xl.y,Xl.x,0,-Kl.y,Kl.x,0,-Cc.y,Cc.x,0];return!nI(t,ju,$u,qu,lv)||(t=[1,0,0,0,1,0,0,0,1],!nI(t,ju,$u,qu,lv))?!1:(Av.crossVectors(Xl,Kl),t=[Av.x,Av.y,Av.z],nI(t,ju,$u,qu,lv))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return wc.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(wc).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ga[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ga[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ga[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ga[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ga[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ga[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ga[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ga[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ga),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ga=[new z,new z,new z,new z,new z,new z,new z,new z],wc=new z,tI=new ws,ju=new z,$u=new z,qu=new z,Xl=new z,Kl=new z,Cc=new z,xp=new z,lv=new z,Av=new z,bc=new z;function nI(n,e,t,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){bc.fromArray(n,s);const a=i.x*Math.abs(bc.x)+i.y*Math.abs(bc.y)+i.z*Math.abs(bc.z),l=e.dot(bc),A=t.dot(bc),c=r.dot(bc);if(Math.max(-Math.max(l,A,c),Math.min(l,A,c))>a)return!1}return!0}const z$=new ws,Ip=new z,rI=new z;class Qu{constructor(e=new z,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const r=this.center;t!==void 0?r.copy(t):z$.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ip.subVectors(e,this.center);const t=Ip.lengthSq();if(t>this.radius*this.radius){const r=Math.sqrt(t),i=(r-this.radius)*.5;this.center.addScaledVector(Ip,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(rI.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ip.copy(e.center).add(rI)),this.expandByPoint(Ip.copy(e.center).sub(rI))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Za=new z,iI=new z,cv=new z,jl=new z,sI=new z,uv=new z,oI=new z;class l0{constructor(e=new z,t=new z(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Za)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Za.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Za.copy(this.direction).multiplyScalar(t).add(this.origin),Za.distanceToSquared(e))}distanceSqToSegment(e,t,r,i){iI.copy(e).add(t).multiplyScalar(.5),cv.copy(t).sub(e).normalize(),jl.copy(this.origin).sub(iI);const s=e.distanceTo(t)*.5,o=-this.direction.dot(cv),a=jl.dot(this.direction),l=-jl.dot(cv),A=jl.lengthSq(),c=Math.abs(1-o*o);let u,f,d,h;if(c>0)if(u=o*l-a,f=o*a-l,h=s*c,u>=0)if(f>=-h)if(f<=h){const p=1/c;u*=p,f*=p,d=u*(u+o*f+2*a)+f*(o*u+f+2*l)+A}else f=s,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+A;else f=-s,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+A;else f<=-h?(u=Math.max(0,-(-o*s+a)),f=u>0?-s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+A):f<=h?(u=0,f=Math.min(Math.max(-s,-l),s),d=f*(f+2*l)+A):(u=Math.max(0,-(o*s+a)),f=u>0?s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+A);else f=o>0?-s:s,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+A;return r&&r.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(cv).multiplyScalar(f).add(iI),d}intersectSphere(e,t){Za.subVectors(e.center,this.origin);const r=Za.dot(this.direction),i=Za.dot(Za)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=r-o,l=r+o;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return r===null?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,s,o,a,l;const A=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,f=this.origin;return A>=0?(r=(e.min.x-f.x)*A,i=(e.max.x-f.x)*A):(r=(e.max.x-f.x)*A,i=(e.min.x-f.x)*A),c>=0?(s=(e.min.y-f.y)*c,o=(e.max.y-f.y)*c):(s=(e.max.y-f.y)*c,o=(e.min.y-f.y)*c),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o=0?(a=(e.min.z-f.z)*u,l=(e.max.z-f.z)*u):(a=(e.max.z-f.z)*u,l=(e.min.z-f.z)*u),r>l||a>i)||((a>r||r!==r)&&(r=a),(l=0?r:i,t)}intersectsBox(e){return this.intersectBox(e,Za)!==null}intersectTriangle(e,t,r,i,s){sI.subVectors(t,e),uv.subVectors(r,e),oI.crossVectors(sI,uv);let o=this.direction.dot(oI),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;jl.subVectors(this.origin,e);const l=a*this.direction.dot(uv.crossVectors(jl,uv));if(l<0)return null;const A=a*this.direction.dot(sI.cross(jl));if(A<0||l+A>o)return null;const c=-a*jl.dot(oI);return c<0?null:this.at(c/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Le{constructor(){Le.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,r,i,s,o,a,l,A,c,u,f,d,h,p,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=r,g[12]=i,g[1]=s,g[5]=o,g[9]=a,g[13]=l,g[2]=A,g[6]=c,g[10]=u,g[14]=f,g[3]=d,g[7]=h,g[11]=p,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Le().fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,i=1/ef.setFromMatrixColumn(e,0).length(),s=1/ef.setFromMatrixColumn(e,1).length(),o=1/ef.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*s,t[5]=r[5]*s,t[6]=r[6]*s,t[7]=0,t[8]=r[8]*o,t[9]=r[9]*o,t[10]=r[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,i=e.y,s=e.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),A=Math.sin(i),c=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const f=o*c,d=o*u,h=a*c,p=a*u;t[0]=l*c,t[4]=-l*u,t[8]=A,t[1]=d+h*A,t[5]=f-p*A,t[9]=-a*l,t[2]=p-f*A,t[6]=h+d*A,t[10]=o*l}else if(e.order==="YXZ"){const f=l*c,d=l*u,h=A*c,p=A*u;t[0]=f+p*a,t[4]=h*a-d,t[8]=o*A,t[1]=o*u,t[5]=o*c,t[9]=-a,t[2]=d*a-h,t[6]=p+f*a,t[10]=o*l}else if(e.order==="ZXY"){const f=l*c,d=l*u,h=A*c,p=A*u;t[0]=f-p*a,t[4]=-o*u,t[8]=h+d*a,t[1]=d+h*a,t[5]=o*c,t[9]=p-f*a,t[2]=-o*A,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const f=o*c,d=o*u,h=a*c,p=a*u;t[0]=l*c,t[4]=h*A-d,t[8]=f*A+p,t[1]=l*u,t[5]=p*A+f,t[9]=d*A-h,t[2]=-A,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const f=o*l,d=o*A,h=a*l,p=a*A;t[0]=l*c,t[4]=p-f*u,t[8]=h*u+d,t[1]=u,t[5]=o*c,t[9]=-a*c,t[2]=-A*c,t[6]=d*u+h,t[10]=f-p*u}else if(e.order==="XZY"){const f=o*l,d=o*A,h=a*l,p=a*A;t[0]=l*c,t[4]=-u,t[8]=A*c,t[1]=f*u+p,t[5]=o*c,t[9]=d*u-h,t[2]=h*u-d,t[6]=a*c,t[10]=p*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Y$,e,X$)}lookAt(e,t,r){const i=this.elements;return Oi.subVectors(e,t),Oi.lengthSq()===0&&(Oi.z=1),Oi.normalize(),$l.crossVectors(r,Oi),$l.lengthSq()===0&&(Math.abs(r.z)===1?Oi.x+=1e-4:Oi.z+=1e-4,Oi.normalize(),$l.crossVectors(r,Oi)),$l.normalize(),fv.crossVectors(Oi,$l),i[0]=$l.x,i[4]=fv.x,i[8]=Oi.x,i[1]=$l.y,i[5]=fv.y,i[9]=Oi.y,i[2]=$l.z,i[6]=fv.z,i[10]=Oi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[4],l=r[8],A=r[12],c=r[1],u=r[5],f=r[9],d=r[13],h=r[2],p=r[6],m=r[10],g=r[14],v=r[3],y=r[7],w=r[11],C=r[15],b=i[0],E=i[4],x=i[8],S=i[12],M=i[1],Z=i[5],K=i[9],_=i[13],B=i[2],F=i[6],R=i[10],k=i[14],T=i[3],V=i[7],O=i[11],L=i[15];return s[0]=o*b+a*M+l*B+A*T,s[4]=o*E+a*Z+l*F+A*V,s[8]=o*x+a*K+l*R+A*O,s[12]=o*S+a*_+l*k+A*L,s[1]=c*b+u*M+f*B+d*T,s[5]=c*E+u*Z+f*F+d*V,s[9]=c*x+u*K+f*R+d*O,s[13]=c*S+u*_+f*k+d*L,s[2]=h*b+p*M+m*B+g*T,s[6]=h*E+p*Z+m*F+g*V,s[10]=h*x+p*K+m*R+g*O,s[14]=h*S+p*_+m*k+g*L,s[3]=v*b+y*M+w*B+C*T,s[7]=v*E+y*Z+w*F+C*V,s[11]=v*x+y*K+w*R+C*O,s[15]=v*S+y*_+w*k+C*L,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],A=e[13],c=e[2],u=e[6],f=e[10],d=e[14],h=e[3],p=e[7],m=e[11],g=e[15];return h*(+s*l*u-i*A*u-s*a*f+r*A*f+i*a*d-r*l*d)+p*(+t*l*d-t*A*f+s*o*f-i*o*d+i*A*c-s*l*c)+m*(+t*A*u-t*a*d-s*o*u+r*o*d+s*a*c-r*A*c)+g*(-i*a*c-t*l*u+t*a*f+i*o*u-r*o*f+r*l*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],A=e[7],c=e[8],u=e[9],f=e[10],d=e[11],h=e[12],p=e[13],m=e[14],g=e[15],v=u*m*A-p*f*A+p*l*d-a*m*d-u*l*g+a*f*g,y=h*f*A-c*m*A-h*l*d+o*m*d+c*l*g-o*f*g,w=c*p*A-h*u*A+h*a*d-o*p*d-c*a*g+o*u*g,C=h*u*l-c*p*l-h*a*f+o*p*f+c*a*m-o*u*m,b=t*v+r*y+i*w+s*C;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/b;return e[0]=v*E,e[1]=(p*f*s-u*m*s-p*i*d+r*m*d+u*i*g-r*f*g)*E,e[2]=(a*m*s-p*l*s+p*i*A-r*m*A-a*i*g+r*l*g)*E,e[3]=(u*l*s-a*f*s-u*i*A+r*f*A+a*i*d-r*l*d)*E,e[4]=y*E,e[5]=(c*m*s-h*f*s+h*i*d-t*m*d-c*i*g+t*f*g)*E,e[6]=(h*l*s-o*m*s-h*i*A+t*m*A+o*i*g-t*l*g)*E,e[7]=(o*f*s-c*l*s+c*i*A-t*f*A-o*i*d+t*l*d)*E,e[8]=w*E,e[9]=(h*u*s-c*p*s-h*r*d+t*p*d+c*r*g-t*u*g)*E,e[10]=(o*p*s-h*a*s+h*r*A-t*p*A-o*r*g+t*a*g)*E,e[11]=(c*a*s-o*u*s-c*r*A+t*u*A+o*r*d-t*a*d)*E,e[12]=C*E,e[13]=(c*p*i-h*u*i+h*r*f-t*p*f-c*r*m+t*u*m)*E,e[14]=(h*a*i-o*p*i-h*r*l+t*p*l+o*r*m-t*a*m)*E,e[15]=(o*u*i-c*a*i+c*r*l-t*u*l-o*r*f+t*a*f)*E,this}scale(e){const t=this.elements,r=e.x,i=e.y,s=e.z;return t[0]*=r,t[4]*=i,t[8]*=s,t[1]*=r,t[5]*=i,t[9]*=s,t[2]*=r,t[6]*=i,t[10]*=s,t[3]*=r,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,i))}makeTranslation(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),i=Math.sin(t),s=1-r,o=e.x,a=e.y,l=e.z,A=s*o,c=s*a;return this.set(A*o+r,A*a-i*l,A*l+i*a,0,A*a+i*l,c*a+r,c*l-i*o,0,A*l-i*a,c*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){const i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,A=s+s,c=o+o,u=a+a,f=s*A,d=s*c,h=s*u,p=o*c,m=o*u,g=a*u,v=l*A,y=l*c,w=l*u,C=r.x,b=r.y,E=r.z;return i[0]=(1-(p+g))*C,i[1]=(d+w)*C,i[2]=(h-y)*C,i[3]=0,i[4]=(d-w)*b,i[5]=(1-(f+g))*b,i[6]=(m+v)*b,i[7]=0,i[8]=(h+y)*E,i[9]=(m-v)*E,i[10]=(1-(f+p))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){const i=this.elements;let s=ef.set(i[0],i[1],i[2]).length();const o=ef.set(i[4],i[5],i[6]).length(),a=ef.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],vo.copy(this);const A=1/s,c=1/o,u=1/a;return vo.elements[0]*=A,vo.elements[1]*=A,vo.elements[2]*=A,vo.elements[4]*=c,vo.elements[5]*=c,vo.elements[6]*=c,vo.elements[8]*=u,vo.elements[9]*=u,vo.elements[10]*=u,t.setFromRotationMatrix(vo),r.x=s,r.y=o,r.z=a,this}makePerspective(e,t,r,i,s,o){const a=this.elements,l=2*s/(t-e),A=2*s/(r-i),c=(t+e)/(t-e),u=(r+i)/(r-i),f=-(o+s)/(o-s),d=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=A,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=f,a[14]=d,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,r,i,s,o){const a=this.elements,l=1/(t-e),A=1/(r-i),c=1/(o-s),u=(t+e)*l,f=(r+i)*A,d=(o+s)*c;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*A,a[9]=0,a[13]=-f,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-d,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let i=0;i<16;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const ef=new z,vo=new Le,Y$=new z(0,0,0),X$=new z(1,1,1),$l=new z,fv=new z,Oi=new z,hT=new Le,pT=new tt;class Kr{constructor(e=0,t=0,r=0,i=Kr.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,r,i=this._order){return this._x=e,this._y=t,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,r=!0){const i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],A=i[5],c=i[9],u=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(fr(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,A),this._z=0);break;case"YXZ":this._x=Math.asin(-fr(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(l,A)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(fr(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-o,A)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-fr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,A));break;case"YZX":this._z=Math.asin(fr(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,A),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-fr(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,A),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return hT.makeRotationFromQuaternion(e),this.setFromRotationMatrix(hT,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return pT.setFromEuler(this),this.setFromQuaternion(pT,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}Kr.DefaultOrder="XYZ";Kr.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class d_{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let r=0;r0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(r.geometries=a),l.length>0&&(r.materials=l),A.length>0&&(r.textures=A),c.length>0&&(r.images=c),u.length>0&&(r.shapes=u),f.length>0&&(r.skeletons=f),d.length>0&&(r.animations=d),h.length>0&&(r.nodes=h)}return r.object=i,r;function o(a){const l=[];for(const A in a){const c=a[A];delete c.metadata,l.push(c)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let r=0;r0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,r,i,s){yo.subVectors(i,t),Ha.subVectors(r,t),aI.subVectors(e,t);const o=yo.dot(yo),a=yo.dot(Ha),l=yo.dot(aI),A=Ha.dot(Ha),c=Ha.dot(aI),u=o*A-a*a;if(u===0)return s.set(-2,-1,-1);const f=1/u,d=(A*l-a*c)*f,h=(o*c-a*l)*f;return s.set(1-d-h,h,d)}static containsPoint(e,t,r,i){return this.getBarycoord(e,t,r,i,za),za.x>=0&&za.y>=0&&za.x+za.y<=1}static getUV(e,t,r,i,s,o,a,l){return this.getBarycoord(e,t,r,i,za),l.set(0,0),l.addScaledVector(s,za.x),l.addScaledVector(o,za.y),l.addScaledVector(a,za.z),l}static isFrontFacing(e,t,r,i){return yo.subVectors(r,t),Ha.subVectors(e,t),yo.cross(Ha).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return yo.subVectors(this.c,this.b),Ha.subVectors(this.a,this.b),yo.cross(Ha).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ns.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ns.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,r,i,s){return ns.getUV(e,this.a,this.b,this.c,t,r,i,s)}containsPoint(e){return ns.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ns.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,i=this.b,s=this.c;let o,a;nf.subVectors(i,r),rf.subVectors(s,r),lI.subVectors(e,r);const l=nf.dot(lI),A=rf.dot(lI);if(l<=0&&A<=0)return t.copy(r);AI.subVectors(e,i);const c=nf.dot(AI),u=rf.dot(AI);if(c>=0&&u<=c)return t.copy(i);const f=l*u-c*A;if(f<=0&&l>=0&&c<=0)return o=l/(l-c),t.copy(r).addScaledVector(nf,o);cI.subVectors(e,s);const d=nf.dot(cI),h=rf.dot(cI);if(h>=0&&d<=h)return t.copy(s);const p=d*A-l*h;if(p<=0&&A>=0&&h<=0)return a=A/(A-h),t.copy(r).addScaledVector(rf,a);const m=c*h-d*u;if(m<=0&&u-c>=0&&d-h>=0)return wT.subVectors(s,i),a=(u-c)/(u-c+(d-h)),t.copy(i).addScaledVector(wT,a);const g=1/(m+p+f);return o=p*g,a=f*g,t.copy(r).addScaledVector(nf,o).addScaledVector(rf,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let eq=0,cs=class extends dc{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eq++}),this.uuid=No(),this.name="",this.type="Material",this.blending=Wd,this.side=Vo,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=YG,this.blendDst=XG,this.blendEquation=Rf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=dE,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=_$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Kx,this.stencilZFail=Kx,this.stencilZPass=Kx,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const r=e[t];if(r===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}const i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Wd&&(r.blending=this.blending),this.side!==Vo&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(r.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=this.flatShading),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let r=null;if(t!==null){const i=t.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=t[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};class Qi extends cs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Re(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=zC,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Yn=new z,hv=new We;class At{constructor(e,t,r){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=r===!0,this.usage=pE,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,r){e*=this.itemSize,r*=t.itemSize;for(let i=0,s=this.itemSize;i0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const A in l)l[A]!==void 0&&(e[A]=l[A]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const r=this.attributes;for(const l in r){const A=r[l];e.data.attributes[l]=A.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const A=this.morphAttributes[l],c=[];for(let u=0,f=A.length;u0&&(i[l]=c,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(t));const i=e.attributes;for(const A in i){const c=i[A];this.setAttribute(A,c.clone(t))}const s=e.morphAttributes;for(const A in s){const c=[],u=s[A];for(let f=0,d=u.length;f0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;st.far?null:{distance:A,point:wv.clone(),object:n}}function Cv(n,e,t,r,i,s,o,a,l,A,c,u){ql.fromBufferAttribute(i,A),eA.fromBufferAttribute(i,c),tA.fromBufferAttribute(i,u);const f=n.morphTargetInfluences;if(s&&f){pv.set(0,0,0),gv.set(0,0,0),mv.set(0,0,0);for(let h=0,p=s.length;h0?1:-1,c.push(V.x,V.y,V.z),u.push(U/E),u.push(1-O/x),k+=1}}for(let O=0;O #include #include -}`,yt={alphamap_fragment:uq,alphamap_pars_fragment:fq,alphatest_fragment:dq,alphatest_pars_fragment:hq,aomap_fragment:pq,aomap_pars_fragment:gq,begin_vertex:mq,beginnormal_vertex:vq,bsdfs:yq,iridescence_fragment:Bq,bumpmap_pars_fragment:wq,clipping_planes_fragment:Cq,clipping_planes_pars_fragment:bq,clipping_planes_pars_vertex:xq,clipping_planes_vertex:Iq,color_fragment:Fq,color_pars_fragment:Eq,color_pars_vertex:Uq,color_vertex:Sq,common:_q,cube_uv_reflection_fragment:Qq,defaultnormal_vertex:Rq,displacementmap_pars_vertex:Mq,displacementmap_vertex:Tq,emissivemap_fragment:Nq,emissivemap_pars_fragment:Dq,encodings_fragment:kq,encodings_pars_fragment:Vq,envmap_fragment:Lq,envmap_common_pars_fragment:Pq,envmap_pars_fragment:Wq,envmap_pars_vertex:Oq,envmap_physical_pars_fragment:eee,envmap_vertex:Gq,fog_vertex:Zq,fog_pars_vertex:Jq,fog_fragment:Hq,fog_pars_fragment:zq,gradientmap_pars_fragment:Yq,lightmap_fragment:Xq,lightmap_pars_fragment:Kq,lights_lambert_fragment:jq,lights_lambert_pars_fragment:$q,lights_pars_begin:qq,lights_toon_fragment:tee,lights_toon_pars_fragment:nee,lights_phong_fragment:ree,lights_phong_pars_fragment:iee,lights_physical_fragment:see,lights_physical_pars_fragment:oee,lights_fragment_begin:aee,lights_fragment_maps:lee,lights_fragment_end:Aee,logdepthbuf_fragment:cee,logdepthbuf_pars_fragment:uee,logdepthbuf_pars_vertex:fee,logdepthbuf_vertex:dee,map_fragment:hee,map_pars_fragment:pee,map_particle_fragment:gee,map_particle_pars_fragment:mee,metalnessmap_fragment:vee,metalnessmap_pars_fragment:yee,morphcolor_vertex:Bee,morphnormal_vertex:wee,morphtarget_pars_vertex:Cee,morphtarget_vertex:bee,normal_fragment_begin:xee,normal_fragment_maps:Iee,normal_pars_fragment:Fee,normal_pars_vertex:Eee,normal_vertex:Uee,normalmap_pars_fragment:See,clearcoat_normal_fragment_begin:_ee,clearcoat_normal_fragment_maps:Qee,clearcoat_pars_fragment:Ree,iridescence_pars_fragment:Mee,output_fragment:Tee,packing:Nee,premultiplied_alpha_fragment:Dee,project_vertex:kee,dithering_fragment:Vee,dithering_pars_fragment:Lee,roughnessmap_fragment:Pee,roughnessmap_pars_fragment:Wee,shadowmap_pars_fragment:Oee,shadowmap_pars_vertex:Gee,shadowmap_vertex:Zee,shadowmask_pars_fragment:Jee,skinbase_vertex:Hee,skinning_pars_vertex:zee,skinning_vertex:Yee,skinnormal_vertex:Xee,specularmap_fragment:Kee,specularmap_pars_fragment:jee,tonemapping_fragment:$ee,tonemapping_pars_fragment:qee,transmission_fragment:ete,transmission_pars_fragment:tte,uv_pars_fragment:nte,uv_pars_vertex:rte,uv_vertex:ite,uv2_pars_fragment:ste,uv2_pars_vertex:ote,uv2_vertex:ate,worldpos_vertex:lte,background_vert:Ate,background_frag:cte,backgroundCube_vert:ute,backgroundCube_frag:fte,cube_vert:dte,cube_frag:hte,depth_vert:pte,depth_frag:gte,distanceRGBA_vert:mte,distanceRGBA_frag:vte,equirect_vert:yte,equirect_frag:Bte,linedashed_vert:wte,linedashed_frag:Cte,meshbasic_vert:bte,meshbasic_frag:xte,meshlambert_vert:Ite,meshlambert_frag:Fte,meshmatcap_vert:Ete,meshmatcap_frag:Ute,meshnormal_vert:Ste,meshnormal_frag:_te,meshphong_vert:Qte,meshphong_frag:Rte,meshphysical_vert:Mte,meshphysical_frag:Tte,meshtoon_vert:Nte,meshtoon_frag:Dte,points_vert:kte,points_frag:Vte,shadow_vert:Lte,shadow_frag:Pte,sprite_vert:Wte,sprite_frag:Ote},Me={common:{diffuse:{value:new Re(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new kn},uv2Transform:{value:new kn},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new We(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Re(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Re(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new kn}},sprite:{diffuse:{value:new Re(16777215)},opacity:{value:1},center:{value:new We(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new kn}}},oa={basic:{uniforms:ai([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.fog]),vertexShader:yt.meshbasic_vert,fragmentShader:yt.meshbasic_frag},lambert:{uniforms:ai([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new Re(0)}}]),vertexShader:yt.meshlambert_vert,fragmentShader:yt.meshlambert_frag},phong:{uniforms:ai([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new Re(0)},specular:{value:new Re(1118481)},shininess:{value:30}}]),vertexShader:yt.meshphong_vert,fragmentShader:yt.meshphong_frag},standard:{uniforms:ai([Me.common,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.roughnessmap,Me.metalnessmap,Me.fog,Me.lights,{emissive:{value:new Re(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag},toon:{uniforms:ai([Me.common,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.gradientmap,Me.fog,Me.lights,{emissive:{value:new Re(0)}}]),vertexShader:yt.meshtoon_vert,fragmentShader:yt.meshtoon_frag},matcap:{uniforms:ai([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,{matcap:{value:null}}]),vertexShader:yt.meshmatcap_vert,fragmentShader:yt.meshmatcap_frag},points:{uniforms:ai([Me.points,Me.fog]),vertexShader:yt.points_vert,fragmentShader:yt.points_frag},dashed:{uniforms:ai([Me.common,Me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yt.linedashed_vert,fragmentShader:yt.linedashed_frag},depth:{uniforms:ai([Me.common,Me.displacementmap]),vertexShader:yt.depth_vert,fragmentShader:yt.depth_frag},normal:{uniforms:ai([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,{opacity:{value:1}}]),vertexShader:yt.meshnormal_vert,fragmentShader:yt.meshnormal_frag},sprite:{uniforms:ai([Me.sprite,Me.fog]),vertexShader:yt.sprite_vert,fragmentShader:yt.sprite_frag},background:{uniforms:{uvTransform:{value:new kn},t2D:{value:null}},vertexShader:yt.background_vert,fragmentShader:yt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0}},vertexShader:yt.backgroundCube_vert,fragmentShader:yt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yt.cube_vert,fragmentShader:yt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yt.equirect_vert,fragmentShader:yt.equirect_frag},distanceRGBA:{uniforms:ai([Me.common,Me.displacementmap,{referencePosition:{value:new z},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yt.distanceRGBA_vert,fragmentShader:yt.distanceRGBA_frag},shadow:{uniforms:ai([Me.lights,Me.fog,{color:{value:new Re(0)},opacity:{value:1}}]),vertexShader:yt.shadow_vert,fragmentShader:yt.shadow_frag}};oa.physical={uniforms:ai([oa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new We(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Re(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new We},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Re(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Re(1,1,1)},specularColorMap:{value:null}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag};function Gte(n,e,t,r,i,s,o){const a=new Re(0);let l=s===!0?0:1,A,c,u=null,f=0,d=null;function h(m,g){let v=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=(g.backgroundBlurriness>0?t:e).get(y));const w=n.xr,C=w.getSession&&w.getSession();C&&C.environmentBlendMode==="additive"&&(y=null),y===null?p(a,l):y&&y.isColor&&(p(y,1),v=!0),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),y&&(y.isCubeTexture||y.mapping===YC)?(c===void 0&&(c=new In(new A0(1,1,1),new Er({name:"BackgroundCubeMaterial",uniforms:Bh(oa.backgroundCube.uniforms),vertexShader:oa.backgroundCube.vertexShader,fragmentShader:oa.backgroundCube.fragmentShader,side:mi,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(b,E,x){this.matrixWorld.copyPosition(x.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,(u!==y||f!==y.version||d!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,f=y.version,d=n.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(A===void 0&&(A=new In(new Ru(2,2),new Er({name:"BackgroundMaterial",uniforms:Bh(oa.background.uniforms),vertexShader:oa.background.vertexShader,fragmentShader:oa.background.fragmentShader,side:Vo,depthTest:!1,depthWrite:!1,fog:!1})),A.geometry.deleteAttribute("normal"),Object.defineProperty(A.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(A)),A.material.uniforms.t2D.value=y,y.matrixAutoUpdate===!0&&y.updateMatrix(),A.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||f!==y.version||d!==n.toneMapping)&&(A.material.needsUpdate=!0,u=y,f=y.version,d=n.toneMapping),A.layers.enableAll(),m.unshift(A,A.geometry,A.material,0,0,null))}function p(m,g){r.buffers.color.setClear(m.r,m.g,m.b,g,o)}return{getClearColor:function(){return a},setClearColor:function(m,g=1){a.set(m),l=g,p(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(m){l=m,p(a,l)},render:h}}function Zte(n,e,t,r){const i=n.getParameter(34921),s=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,a={},l=m(null);let A=l,c=!1;function u(B,F,R,k,T){let V=!1;if(o){const O=p(k,R,F);A!==O&&(A=O,d(A.object)),V=g(B,k,R,T),V&&v(B,k,R,T)}else{const O=F.wireframe===!0;(A.geometry!==k.id||A.program!==R.id||A.wireframe!==O)&&(A.geometry=k.id,A.program=R.id,A.wireframe=O,V=!0)}T!==null&&t.update(T,34963),(V||c)&&(c=!1,x(B,F,R,k),T!==null&&n.bindBuffer(34963,t.get(T).buffer))}function f(){return r.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function d(B){return r.isWebGL2?n.bindVertexArray(B):s.bindVertexArrayOES(B)}function h(B){return r.isWebGL2?n.deleteVertexArray(B):s.deleteVertexArrayOES(B)}function p(B,F,R){const k=R.wireframe===!0;let T=a[B.id];T===void 0&&(T={},a[B.id]=T);let V=T[F.id];V===void 0&&(V={},T[F.id]=V);let O=V[k];return O===void 0&&(O=m(f()),V[k]=O),O}function m(B){const F=[],R=[],k=[];for(let T=0;T=0){const Ae=T[U];let N=V[U];if(N===void 0&&(U==="instanceMatrix"&&B.instanceMatrix&&(N=B.instanceMatrix),U==="instanceColor"&&B.instanceColor&&(N=B.instanceColor)),Ae===void 0||Ae.attribute!==N||N&&Ae.data!==N.data)return!0;O++}return A.attributesNum!==O||A.index!==k}function v(B,F,R,k){const T={},V=F.attributes;let O=0;const L=R.getAttributes();for(const U in L)if(L[U].location>=0){let Ae=V[U];Ae===void 0&&(U==="instanceMatrix"&&B.instanceMatrix&&(Ae=B.instanceMatrix),U==="instanceColor"&&B.instanceColor&&(Ae=B.instanceColor));const N={};N.attribute=Ae,Ae&&Ae.data&&(N.data=Ae.data),T[U]=N,O++}A.attributes=T,A.attributesNum=O,A.index=k}function y(){const B=A.newAttributes;for(let F=0,R=B.length;F=0){let H=T[L];if(H===void 0&&(L==="instanceMatrix"&&B.instanceMatrix&&(H=B.instanceMatrix),L==="instanceColor"&&B.instanceColor&&(H=B.instanceColor)),H!==void 0){const Ae=H.normalized,N=H.itemSize,j=t.get(H);if(j===void 0)continue;const oe=j.buffer,ie=j.type,de=j.bytesPerElement;if(H.isInterleavedBufferAttribute){const X=H.data,ne=X.stride,ae=H.offset;if(X.isInstancedInterleavedBuffer){for(let Be=0;Be0&&n.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";E="mediump"}return E==="mediump"&&n.getShaderPrecisionFormat(35633,36337).precision>0&&n.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&n instanceof WebGL2ComputeRenderingContext;let a=t.precision!==void 0?t.precision:"highp";const l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const A=o||e.has("WEBGL_draw_buffers"),c=t.logarithmicDepthBuffer===!0,u=n.getParameter(34930),f=n.getParameter(35660),d=n.getParameter(3379),h=n.getParameter(34076),p=n.getParameter(34921),m=n.getParameter(36347),g=n.getParameter(36348),v=n.getParameter(36349),y=f>0,w=o||e.has("OES_texture_float"),C=y&&w,b=o?n.getParameter(36183):0;return{isWebGL2:o,drawBuffers:A,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:w,floatVertexTextures:C,maxSamples:b}}function zte(n){const e=this;let t=null,r=0,i=!1,s=!1;const o=new hl,a=new kn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,f,d){const h=u.length!==0||f||r!==0||i;return i=f,t=c(u,d,0),r=u.length,h},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1,A()},this.setState=function(u,f,d){const h=u.clippingPlanes,p=u.clipIntersection,m=u.clipShadows,g=n.get(u);if(!i||h===null||h.length===0||s&&!m)s?c(null):A();else{const v=s?0:r,y=v*4;let w=g.clippingState||null;l.value=w,w=c(h,f,y,d);for(let C=0;C!==y;++C)w[C]=t[C];g.clippingState=w,this.numIntersection=p?this.numPlanes:0,this.numPlanes+=v}};function A(){l.value!==t&&(l.value=t,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function c(u,f,d,h){const p=u!==null?u.length:0;let m=null;if(p!==0){if(m=l.value,h!==!0||m===null){const g=d+p*4,v=f.matrixWorldInverse;a.getNormalMatrix(v),(m===null||m.length0){const A=new aq(l.height/2);return A.fromEquirectangularTexture(n,o),e.set(o,A),o.addEventListener("dispose",i),t(A.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class Mu extends oZ{constructor(e=-1,t=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,o=r+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const A=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=A*this.view.offsetX,o=s+A*this.view.width,a-=c*this.view.offsetY,l=a-c*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const bd=4,bT=[.125,.215,.35,.446,.526,.582],Lc=20,vI=new Mu,xT=new Re;let yI=null;const Tc=(1+Math.sqrt(5))/2,cf=1/Tc,IT=[new z(1,1,1),new z(-1,1,1),new z(1,1,-1),new z(-1,1,-1),new z(0,Tc,cf),new z(0,Tc,-cf),new z(cf,0,Tc),new z(-cf,0,Tc),new z(Tc,cf,0),new z(-Tc,cf,0)];class FT{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,r=.1,i=100){yI=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,r,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ST(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=UT(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?y:0,y,y),c.setRenderTarget(i),p&&c.render(h,a),c.render(e,a)}h.geometry.dispose(),h.material.dispose(),c.toneMapping=f,c.autoClear=u,e.background=m}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===gh||e.mapping===mh;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=ST()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=UT());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new In(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;xv(t,0,0,3*l,2*l),r.setRenderTarget(t),r.render(o,vI)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;for(let i=1;iLc&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Lc}`);const g=[];let v=0;for(let E=0;Ey-bd?i-y+bd:0),b=4*(this._cubeSize-w);xv(t,C,b,3*w,2*w),l.setRenderTarget(t),l.render(u,vI)}}function Xte(n){const e=[],t=[],r=[];let i=n;const s=n-bd+1+bT.length;for(let o=0;on-bd?l=bT[o-n+bd-1]:o===0&&(l=0),r.push(l);const A=1/(a-2),c=-A,u=1+A,f=[c,c,u,c,u,u,c,c,u,u,c,u],d=6,h=6,p=3,m=2,g=1,v=new Float32Array(p*h*d),y=new Float32Array(m*h*d),w=new Float32Array(g*h*d);for(let b=0;b2?0:-1,S=[E,x,0,E+2/3,x,0,E+2/3,x+1,0,E,x,0,E+2/3,x+1,0,E,x+1,0];v.set(S,p*h*b),y.set(f,m*h*b);const M=[b,b,b,b,b,b];w.set(M,g*h*b)}const C=new Ht;C.setAttribute("position",new At(v,p)),C.setAttribute("uv",new At(y,m)),C.setAttribute("faceIndex",new At(w,g)),e.push(C),i>bd&&i--}return{lodPlanes:e,sizeLods:t,sigmas:r}}function ET(n,e,t){const r=new _a(n,e,t);return r.texture.mapping=YC,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function xv(n,e,t,r,i){n.viewport.set(e,t,r,i),n.scissor.set(e,t,r,i)}function Kte(n,e,t){const r=new Float32Array(Lc),i=new z(0,1,0);return new Er({name:"SphericalGaussianBlur",defines:{n:Lc,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:g_(),fragmentShader:` +}`,yt={alphamap_fragment:uq,alphamap_pars_fragment:fq,alphatest_fragment:dq,alphatest_pars_fragment:hq,aomap_fragment:pq,aomap_pars_fragment:gq,begin_vertex:mq,beginnormal_vertex:vq,bsdfs:yq,iridescence_fragment:Bq,bumpmap_pars_fragment:wq,clipping_planes_fragment:Cq,clipping_planes_pars_fragment:bq,clipping_planes_pars_vertex:xq,clipping_planes_vertex:Iq,color_fragment:Fq,color_pars_fragment:Eq,color_pars_vertex:Uq,color_vertex:Sq,common:_q,cube_uv_reflection_fragment:Qq,defaultnormal_vertex:Rq,displacementmap_pars_vertex:Mq,displacementmap_vertex:Tq,emissivemap_fragment:Nq,emissivemap_pars_fragment:Dq,encodings_fragment:kq,encodings_pars_fragment:Vq,envmap_fragment:Lq,envmap_common_pars_fragment:Pq,envmap_pars_fragment:Wq,envmap_pars_vertex:Oq,envmap_physical_pars_fragment:eee,envmap_vertex:Gq,fog_vertex:Zq,fog_pars_vertex:Jq,fog_fragment:Hq,fog_pars_fragment:zq,gradientmap_pars_fragment:Yq,lightmap_fragment:Xq,lightmap_pars_fragment:Kq,lights_lambert_fragment:jq,lights_lambert_pars_fragment:$q,lights_pars_begin:qq,lights_toon_fragment:tee,lights_toon_pars_fragment:nee,lights_phong_fragment:ree,lights_phong_pars_fragment:iee,lights_physical_fragment:see,lights_physical_pars_fragment:oee,lights_fragment_begin:aee,lights_fragment_maps:lee,lights_fragment_end:Aee,logdepthbuf_fragment:cee,logdepthbuf_pars_fragment:uee,logdepthbuf_pars_vertex:fee,logdepthbuf_vertex:dee,map_fragment:hee,map_pars_fragment:pee,map_particle_fragment:gee,map_particle_pars_fragment:mee,metalnessmap_fragment:vee,metalnessmap_pars_fragment:yee,morphcolor_vertex:Bee,morphnormal_vertex:wee,morphtarget_pars_vertex:Cee,morphtarget_vertex:bee,normal_fragment_begin:xee,normal_fragment_maps:Iee,normal_pars_fragment:Fee,normal_pars_vertex:Eee,normal_vertex:Uee,normalmap_pars_fragment:See,clearcoat_normal_fragment_begin:_ee,clearcoat_normal_fragment_maps:Qee,clearcoat_pars_fragment:Ree,iridescence_pars_fragment:Mee,output_fragment:Tee,packing:Nee,premultiplied_alpha_fragment:Dee,project_vertex:kee,dithering_fragment:Vee,dithering_pars_fragment:Lee,roughnessmap_fragment:Pee,roughnessmap_pars_fragment:Wee,shadowmap_pars_fragment:Oee,shadowmap_pars_vertex:Gee,shadowmap_vertex:Zee,shadowmask_pars_fragment:Jee,skinbase_vertex:Hee,skinning_pars_vertex:zee,skinning_vertex:Yee,skinnormal_vertex:Xee,specularmap_fragment:Kee,specularmap_pars_fragment:jee,tonemapping_fragment:$ee,tonemapping_pars_fragment:qee,transmission_fragment:ete,transmission_pars_fragment:tte,uv_pars_fragment:nte,uv_pars_vertex:rte,uv_vertex:ite,uv2_pars_fragment:ste,uv2_pars_vertex:ote,uv2_vertex:ate,worldpos_vertex:lte,background_vert:Ate,background_frag:cte,backgroundCube_vert:ute,backgroundCube_frag:fte,cube_vert:dte,cube_frag:hte,depth_vert:pte,depth_frag:gte,distanceRGBA_vert:mte,distanceRGBA_frag:vte,equirect_vert:yte,equirect_frag:Bte,linedashed_vert:wte,linedashed_frag:Cte,meshbasic_vert:bte,meshbasic_frag:xte,meshlambert_vert:Ite,meshlambert_frag:Fte,meshmatcap_vert:Ete,meshmatcap_frag:Ute,meshnormal_vert:Ste,meshnormal_frag:_te,meshphong_vert:Qte,meshphong_frag:Rte,meshphysical_vert:Mte,meshphysical_frag:Tte,meshtoon_vert:Nte,meshtoon_frag:Dte,points_vert:kte,points_frag:Vte,shadow_vert:Lte,shadow_frag:Pte,sprite_vert:Wte,sprite_frag:Ote},Me={common:{diffuse:{value:new Re(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new kn},uv2Transform:{value:new kn},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new We(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Re(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Re(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new kn}},sprite:{diffuse:{value:new Re(16777215)},opacity:{value:1},center:{value:new We(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new kn}}},oa={basic:{uniforms:ai([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.fog]),vertexShader:yt.meshbasic_vert,fragmentShader:yt.meshbasic_frag},lambert:{uniforms:ai([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new Re(0)}}]),vertexShader:yt.meshlambert_vert,fragmentShader:yt.meshlambert_frag},phong:{uniforms:ai([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new Re(0)},specular:{value:new Re(1118481)},shininess:{value:30}}]),vertexShader:yt.meshphong_vert,fragmentShader:yt.meshphong_frag},standard:{uniforms:ai([Me.common,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.roughnessmap,Me.metalnessmap,Me.fog,Me.lights,{emissive:{value:new Re(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag},toon:{uniforms:ai([Me.common,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.gradientmap,Me.fog,Me.lights,{emissive:{value:new Re(0)}}]),vertexShader:yt.meshtoon_vert,fragmentShader:yt.meshtoon_frag},matcap:{uniforms:ai([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,{matcap:{value:null}}]),vertexShader:yt.meshmatcap_vert,fragmentShader:yt.meshmatcap_frag},points:{uniforms:ai([Me.points,Me.fog]),vertexShader:yt.points_vert,fragmentShader:yt.points_frag},dashed:{uniforms:ai([Me.common,Me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yt.linedashed_vert,fragmentShader:yt.linedashed_frag},depth:{uniforms:ai([Me.common,Me.displacementmap]),vertexShader:yt.depth_vert,fragmentShader:yt.depth_frag},normal:{uniforms:ai([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,{opacity:{value:1}}]),vertexShader:yt.meshnormal_vert,fragmentShader:yt.meshnormal_frag},sprite:{uniforms:ai([Me.sprite,Me.fog]),vertexShader:yt.sprite_vert,fragmentShader:yt.sprite_frag},background:{uniforms:{uvTransform:{value:new kn},t2D:{value:null}},vertexShader:yt.background_vert,fragmentShader:yt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0}},vertexShader:yt.backgroundCube_vert,fragmentShader:yt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yt.cube_vert,fragmentShader:yt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yt.equirect_vert,fragmentShader:yt.equirect_frag},distanceRGBA:{uniforms:ai([Me.common,Me.displacementmap,{referencePosition:{value:new z},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yt.distanceRGBA_vert,fragmentShader:yt.distanceRGBA_frag},shadow:{uniforms:ai([Me.lights,Me.fog,{color:{value:new Re(0)},opacity:{value:1}}]),vertexShader:yt.shadow_vert,fragmentShader:yt.shadow_frag}};oa.physical={uniforms:ai([oa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new We(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Re(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new We},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Re(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Re(1,1,1)},specularColorMap:{value:null}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag};function Gte(n,e,t,r,i,s,o){const a=new Re(0);let l=s===!0?0:1,A,c,u=null,f=0,d=null;function h(m,g){let v=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=(g.backgroundBlurriness>0?t:e).get(y));const w=n.xr,C=w.getSession&&w.getSession();C&&C.environmentBlendMode==="additive"&&(y=null),y===null?p(a,l):y&&y.isColor&&(p(y,1),v=!0),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),y&&(y.isCubeTexture||y.mapping===YC)?(c===void 0&&(c=new In(new A0(1,1,1),new Er({name:"BackgroundCubeMaterial",uniforms:Bh(oa.backgroundCube.uniforms),vertexShader:oa.backgroundCube.vertexShader,fragmentShader:oa.backgroundCube.fragmentShader,side:mi,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(b,E,x){this.matrixWorld.copyPosition(x.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,(u!==y||f!==y.version||d!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,f=y.version,d=n.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(A===void 0&&(A=new In(new Ru(2,2),new Er({name:"BackgroundMaterial",uniforms:Bh(oa.background.uniforms),vertexShader:oa.background.vertexShader,fragmentShader:oa.background.fragmentShader,side:Vo,depthTest:!1,depthWrite:!1,fog:!1})),A.geometry.deleteAttribute("normal"),Object.defineProperty(A.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(A)),A.material.uniforms.t2D.value=y,y.matrixAutoUpdate===!0&&y.updateMatrix(),A.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||f!==y.version||d!==n.toneMapping)&&(A.material.needsUpdate=!0,u=y,f=y.version,d=n.toneMapping),A.layers.enableAll(),m.unshift(A,A.geometry,A.material,0,0,null))}function p(m,g){r.buffers.color.setClear(m.r,m.g,m.b,g,o)}return{getClearColor:function(){return a},setClearColor:function(m,g=1){a.set(m),l=g,p(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(m){l=m,p(a,l)},render:h}}function Zte(n,e,t,r){const i=n.getParameter(34921),s=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,a={},l=m(null);let A=l,c=!1;function u(B,F,R,k,T){let V=!1;if(o){const O=p(k,R,F);A!==O&&(A=O,d(A.object)),V=g(B,k,R,T),V&&v(B,k,R,T)}else{const O=F.wireframe===!0;(A.geometry!==k.id||A.program!==R.id||A.wireframe!==O)&&(A.geometry=k.id,A.program=R.id,A.wireframe=O,V=!0)}T!==null&&t.update(T,34963),(V||c)&&(c=!1,x(B,F,R,k),T!==null&&n.bindBuffer(34963,t.get(T).buffer))}function f(){return r.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function d(B){return r.isWebGL2?n.bindVertexArray(B):s.bindVertexArrayOES(B)}function h(B){return r.isWebGL2?n.deleteVertexArray(B):s.deleteVertexArrayOES(B)}function p(B,F,R){const k=R.wireframe===!0;let T=a[B.id];T===void 0&&(T={},a[B.id]=T);let V=T[F.id];V===void 0&&(V={},T[F.id]=V);let O=V[k];return O===void 0&&(O=m(f()),V[k]=O),O}function m(B){const F=[],R=[],k=[];for(let T=0;T=0){const le=T[U];let N=V[U];if(N===void 0&&(U==="instanceMatrix"&&B.instanceMatrix&&(N=B.instanceMatrix),U==="instanceColor"&&B.instanceColor&&(N=B.instanceColor)),le===void 0||le.attribute!==N||N&&le.data!==N.data)return!0;O++}return A.attributesNum!==O||A.index!==k}function v(B,F,R,k){const T={},V=F.attributes;let O=0;const L=R.getAttributes();for(const U in L)if(L[U].location>=0){let le=V[U];le===void 0&&(U==="instanceMatrix"&&B.instanceMatrix&&(le=B.instanceMatrix),U==="instanceColor"&&B.instanceColor&&(le=B.instanceColor));const N={};N.attribute=le,le&&le.data&&(N.data=le.data),T[U]=N,O++}A.attributes=T,A.attributesNum=O,A.index=k}function y(){const B=A.newAttributes;for(let F=0,R=B.length;F=0){let H=T[L];if(H===void 0&&(L==="instanceMatrix"&&B.instanceMatrix&&(H=B.instanceMatrix),L==="instanceColor"&&B.instanceColor&&(H=B.instanceColor)),H!==void 0){const le=H.normalized,N=H.itemSize,j=t.get(H);if(j===void 0)continue;const oe=j.buffer,ie=j.type,de=j.bytesPerElement;if(H.isInterleavedBufferAttribute){const X=H.data,ne=X.stride,ae=H.offset;if(X.isInstancedInterleavedBuffer){for(let Be=0;Be0&&n.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";E="mediump"}return E==="mediump"&&n.getShaderPrecisionFormat(35633,36337).precision>0&&n.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&n instanceof WebGL2ComputeRenderingContext;let a=t.precision!==void 0?t.precision:"highp";const l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const A=o||e.has("WEBGL_draw_buffers"),c=t.logarithmicDepthBuffer===!0,u=n.getParameter(34930),f=n.getParameter(35660),d=n.getParameter(3379),h=n.getParameter(34076),p=n.getParameter(34921),m=n.getParameter(36347),g=n.getParameter(36348),v=n.getParameter(36349),y=f>0,w=o||e.has("OES_texture_float"),C=y&&w,b=o?n.getParameter(36183):0;return{isWebGL2:o,drawBuffers:A,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:w,floatVertexTextures:C,maxSamples:b}}function zte(n){const e=this;let t=null,r=0,i=!1,s=!1;const o=new hl,a=new kn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,f,d){const h=u.length!==0||f||r!==0||i;return i=f,t=c(u,d,0),r=u.length,h},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1,A()},this.setState=function(u,f,d){const h=u.clippingPlanes,p=u.clipIntersection,m=u.clipShadows,g=n.get(u);if(!i||h===null||h.length===0||s&&!m)s?c(null):A();else{const v=s?0:r,y=v*4;let w=g.clippingState||null;l.value=w,w=c(h,f,y,d);for(let C=0;C!==y;++C)w[C]=t[C];g.clippingState=w,this.numIntersection=p?this.numPlanes:0,this.numPlanes+=v}};function A(){l.value!==t&&(l.value=t,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function c(u,f,d,h){const p=u!==null?u.length:0;let m=null;if(p!==0){if(m=l.value,h!==!0||m===null){const g=d+p*4,v=f.matrixWorldInverse;a.getNormalMatrix(v),(m===null||m.length0){const A=new aq(l.height/2);return A.fromEquirectangularTexture(n,o),e.set(o,A),o.addEventListener("dispose",i),t(A.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class Mu extends oZ{constructor(e=-1,t=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,o=r+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const A=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=A*this.view.offsetX,o=s+A*this.view.width,a-=c*this.view.offsetY,l=a-c*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const bd=4,bT=[.125,.215,.35,.446,.526,.582],Lc=20,vI=new Mu,xT=new Re;let yI=null;const Tc=(1+Math.sqrt(5))/2,cf=1/Tc,IT=[new z(1,1,1),new z(-1,1,1),new z(1,1,-1),new z(-1,1,-1),new z(0,Tc,cf),new z(0,Tc,-cf),new z(cf,0,Tc),new z(-cf,0,Tc),new z(Tc,cf,0),new z(-Tc,cf,0)];class FT{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,r=.1,i=100){yI=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,r,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ST(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=UT(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?y:0,y,y),c.setRenderTarget(i),p&&c.render(h,a),c.render(e,a)}h.geometry.dispose(),h.material.dispose(),c.toneMapping=f,c.autoClear=u,e.background=m}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===gh||e.mapping===mh;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=ST()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=UT());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new In(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;xv(t,0,0,3*l,2*l),r.setRenderTarget(t),r.render(o,vI)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;for(let i=1;iLc&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Lc}`);const g=[];let v=0;for(let E=0;Ey-bd?i-y+bd:0),b=4*(this._cubeSize-w);xv(t,C,b,3*w,2*w),l.setRenderTarget(t),l.render(u,vI)}}function Xte(n){const e=[],t=[],r=[];let i=n;const s=n-bd+1+bT.length;for(let o=0;on-bd?l=bT[o-n+bd-1]:o===0&&(l=0),r.push(l);const A=1/(a-2),c=-A,u=1+A,f=[c,c,u,c,u,u,c,c,u,u,c,u],d=6,h=6,p=3,m=2,g=1,v=new Float32Array(p*h*d),y=new Float32Array(m*h*d),w=new Float32Array(g*h*d);for(let b=0;b2?0:-1,S=[E,x,0,E+2/3,x,0,E+2/3,x+1,0,E,x,0,E+2/3,x+1,0,E,x+1,0];v.set(S,p*h*b),y.set(f,m*h*b);const M=[b,b,b,b,b,b];w.set(M,g*h*b)}const C=new Ht;C.setAttribute("position",new At(v,p)),C.setAttribute("uv",new At(y,m)),C.setAttribute("faceIndex",new At(w,g)),e.push(C),i>bd&&i--}return{lodPlanes:e,sizeLods:t,sigmas:r}}function ET(n,e,t){const r=new _a(n,e,t);return r.texture.mapping=YC,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function xv(n,e,t,r,i){n.viewport.set(e,t,r,i),n.scissor.set(e,t,r,i)}function Kte(n,e,t){const r=new Float32Array(Lc),i=new z(0,1,0);return new Er({name:"SphericalGaussianBlur",defines:{n:Lc,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:g_(),fragmentShader:` precision mediump float; precision mediump int; @@ -3173,7 +3173,7 @@ precision `+n.precision+" int;";return n.precision==="highp"?e+=` Program Info Log: `+S+` `+B+` -`+F)}else S!==""?console.warn("THREE.WebGLProgram: Program Info Log:",S):(M===""||Z==="")&&(_=!1);_&&(this.diagnostics={runnable:K,programLog:S,vertexShader:{log:M,prefix:m},fragmentShader:{log:Z,prefix:g}})}i.deleteShader(C),i.deleteShader(b);let E;this.getUniforms=function(){return E===void 0&&(E=new iB(i,p)),E};let x;return this.getAttributes=function(){return x===void 0&&(x=rre(i,p)),x},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(p),this.program=void 0},this.name=t.shaderName,this.id=Kne++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=C,this.fragmentShader=b,this}let hre=0;class pre{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const r of t)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let r=t.get(e);return r===void 0&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return r===void 0&&(r=new gre(e),t.set(e,r)),r}}class gre{constructor(e){this.id=hre++,this.code=e,this.usedTimes=0}}function mre(n,e,t,r,i,s,o){const a=new d_,l=new pre,A=[],c=i.isWebGL2,u=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const h={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(x,S,M,Z,K){const _=Z.fog,B=K.geometry,F=x.isMeshStandardMaterial?Z.environment:null,R=(x.isMeshStandardMaterial?t:e).get(x.envMap||F),k=R&&R.mapping===YC?R.image.height:null,T=h[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&console.warn("THREE.WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const V=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,O=V!==void 0?V.length:0;let L=0;B.morphAttributes.position!==void 0&&(L=1),B.morphAttributes.normal!==void 0&&(L=2),B.morphAttributes.color!==void 0&&(L=3);let U,H,Ae,N;if(T){const ne=oa[T];U=ne.vertexShader,H=ne.fragmentShader}else U=x.vertexShader,H=x.fragmentShader,l.update(x),Ae=l.getVertexShaderID(x),N=l.getFragmentShaderID(x);const j=n.getRenderTarget(),oe=x.alphaTest>0,ie=x.clearcoat>0,de=x.iridescence>0;return{isWebGL2:c,shaderID:T,shaderName:x.type,vertexShader:U,fragmentShader:H,defines:x.defines,customVertexShaderID:Ae,customFragmentShaderID:N,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,instancing:K.isInstancedMesh===!0,instancingColor:K.isInstancedMesh===!0&&K.instanceColor!==null,supportsVertexTextures:f,outputEncoding:j===null?n.outputEncoding:j.isXRRenderTarget===!0?j.texture.encoding:ps,map:!!x.map,matcap:!!x.matcap,envMap:!!R,envMapMode:R&&R.mapping,envMapCubeUVHeight:k,lightMap:!!x.lightMap,aoMap:!!x.aoMap,emissiveMap:!!x.emissiveMap,bumpMap:!!x.bumpMap,normalMap:!!x.normalMap,objectSpaceNormalMap:x.normalMapType===S$,tangentSpaceNormalMap:x.normalMapType===_u,decodeVideoTexture:!!x.map&&x.map.isVideoTexture===!0&&x.map.encoding===ht,clearcoat:ie,clearcoatMap:ie&&!!x.clearcoatMap,clearcoatRoughnessMap:ie&&!!x.clearcoatRoughnessMap,clearcoatNormalMap:ie&&!!x.clearcoatNormalMap,iridescence:de,iridescenceMap:de&&!!x.iridescenceMap,iridescenceThicknessMap:de&&!!x.iridescenceThicknessMap,displacementMap:!!x.displacementMap,roughnessMap:!!x.roughnessMap,metalnessMap:!!x.metalnessMap,specularMap:!!x.specularMap,specularIntensityMap:!!x.specularIntensityMap,specularColorMap:!!x.specularColorMap,opaque:x.transparent===!1&&x.blending===Wd,alphaMap:!!x.alphaMap,alphaTest:oe,gradientMap:!!x.gradientMap,sheen:x.sheen>0,sheenColorMap:!!x.sheenColorMap,sheenRoughnessMap:!!x.sheenRoughnessMap,transmission:x.transmission>0,transmissionMap:!!x.transmissionMap,thicknessMap:!!x.thicknessMap,combine:x.combine,vertexTangents:!!x.normalMap&&!!B.attributes.tangent,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,vertexUvs:!!x.map||!!x.bumpMap||!!x.normalMap||!!x.specularMap||!!x.alphaMap||!!x.emissiveMap||!!x.roughnessMap||!!x.metalnessMap||!!x.clearcoatMap||!!x.clearcoatRoughnessMap||!!x.clearcoatNormalMap||!!x.iridescenceMap||!!x.iridescenceThicknessMap||!!x.displacementMap||!!x.transmissionMap||!!x.thicknessMap||!!x.specularIntensityMap||!!x.specularColorMap||!!x.sheenColorMap||!!x.sheenRoughnessMap,uvsVertexOnly:!(x.map||x.bumpMap||x.normalMap||x.specularMap||x.alphaMap||x.emissiveMap||x.roughnessMap||x.metalnessMap||x.clearcoatNormalMap||x.iridescenceMap||x.iridescenceThicknessMap||x.transmission>0||x.transmissionMap||x.thicknessMap||x.specularIntensityMap||x.specularColorMap||x.sheen>0||x.sheenColorMap||x.sheenRoughnessMap)&&!!x.displacementMap,fog:!!_,useFog:x.fog===!0,fogExp2:_&&_.isFogExp2,flatShading:!!x.flatShading,sizeAttenuation:x.sizeAttenuation,logarithmicDepthBuffer:u,skinning:K.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:O,morphTextureStride:L,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:x.dithering,shadowMapEnabled:n.shadowMap.enabled&&M.length>0,shadowMapType:n.shadowMap.type,toneMapping:x.toneMapped?n.toneMapping:xl,physicallyCorrectLights:n.physicallyCorrectLights,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===pi,flipSided:x.side===mi,useDepthPacking:!!x.depthPacking,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionDerivatives:x.extensions&&x.extensions.derivatives,extensionFragDepth:x.extensions&&x.extensions.fragDepth,extensionDrawBuffers:x.extensions&&x.extensions.drawBuffers,extensionShaderTextureLOD:x.extensions&&x.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:x.customProgramCacheKey()}}function m(x){const S=[];if(x.shaderID?S.push(x.shaderID):(S.push(x.customVertexShaderID),S.push(x.customFragmentShaderID)),x.defines!==void 0)for(const M in x.defines)S.push(M),S.push(x.defines[M]);return x.isRawShaderMaterial===!1&&(g(S,x),v(S,x),S.push(n.outputEncoding)),S.push(x.customProgramCacheKey),S.join()}function g(x,S){x.push(S.precision),x.push(S.outputEncoding),x.push(S.envMapMode),x.push(S.envMapCubeUVHeight),x.push(S.combine),x.push(S.vertexUvs),x.push(S.fogExp2),x.push(S.sizeAttenuation),x.push(S.morphTargetsCount),x.push(S.morphAttributeCount),x.push(S.numDirLights),x.push(S.numPointLights),x.push(S.numSpotLights),x.push(S.numSpotLightMaps),x.push(S.numHemiLights),x.push(S.numRectAreaLights),x.push(S.numDirLightShadows),x.push(S.numPointLightShadows),x.push(S.numSpotLightShadows),x.push(S.numSpotLightShadowsWithMaps),x.push(S.shadowMapType),x.push(S.toneMapping),x.push(S.numClippingPlanes),x.push(S.numClipIntersection),x.push(S.depthPacking)}function v(x,S){a.disableAll(),S.isWebGL2&&a.enable(0),S.supportsVertexTextures&&a.enable(1),S.instancing&&a.enable(2),S.instancingColor&&a.enable(3),S.map&&a.enable(4),S.matcap&&a.enable(5),S.envMap&&a.enable(6),S.lightMap&&a.enable(7),S.aoMap&&a.enable(8),S.emissiveMap&&a.enable(9),S.bumpMap&&a.enable(10),S.normalMap&&a.enable(11),S.objectSpaceNormalMap&&a.enable(12),S.tangentSpaceNormalMap&&a.enable(13),S.clearcoat&&a.enable(14),S.clearcoatMap&&a.enable(15),S.clearcoatRoughnessMap&&a.enable(16),S.clearcoatNormalMap&&a.enable(17),S.iridescence&&a.enable(18),S.iridescenceMap&&a.enable(19),S.iridescenceThicknessMap&&a.enable(20),S.displacementMap&&a.enable(21),S.specularMap&&a.enable(22),S.roughnessMap&&a.enable(23),S.metalnessMap&&a.enable(24),S.gradientMap&&a.enable(25),S.alphaMap&&a.enable(26),S.alphaTest&&a.enable(27),S.vertexColors&&a.enable(28),S.vertexAlphas&&a.enable(29),S.vertexUvs&&a.enable(30),S.vertexTangents&&a.enable(31),S.uvsVertexOnly&&a.enable(32),x.push(a.mask),a.disableAll(),S.fog&&a.enable(0),S.useFog&&a.enable(1),S.flatShading&&a.enable(2),S.logarithmicDepthBuffer&&a.enable(3),S.skinning&&a.enable(4),S.morphTargets&&a.enable(5),S.morphNormals&&a.enable(6),S.morphColors&&a.enable(7),S.premultipliedAlpha&&a.enable(8),S.shadowMapEnabled&&a.enable(9),S.physicallyCorrectLights&&a.enable(10),S.doubleSided&&a.enable(11),S.flipSided&&a.enable(12),S.useDepthPacking&&a.enable(13),S.dithering&&a.enable(14),S.specularIntensityMap&&a.enable(15),S.specularColorMap&&a.enable(16),S.transmission&&a.enable(17),S.transmissionMap&&a.enable(18),S.thicknessMap&&a.enable(19),S.sheen&&a.enable(20),S.sheenColorMap&&a.enable(21),S.sheenRoughnessMap&&a.enable(22),S.decodeVideoTexture&&a.enable(23),S.opaque&&a.enable(24),x.push(a.mask)}function y(x){const S=h[x.type];let M;if(S){const Z=oa[S];M=h_.clone(Z.uniforms)}else M=x.uniforms;return M}function w(x,S){let M;for(let Z=0,K=A.length;Z0?r.push(g):d.transparent===!0?i.push(g):t.push(g)}function l(u,f,d,h,p,m){const g=o(u,f,d,h,p,m);d.transmission>0?r.unshift(g):d.transparent===!0?i.unshift(g):t.unshift(g)}function A(u,f){t.length>1&&t.sort(u||yre),r.length>1&&r.sort(f||OT),i.length>1&&i.sort(f||OT)}function c(){for(let u=e,f=n.length;u=s.length?(o=new GT,s.push(o)):o=s[i],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function wre(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new z,color:new Re};break;case"SpotLight":t={position:new z,direction:new z,color:new Re,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new z,color:new Re,distance:0,decay:0};break;case"HemisphereLight":t={direction:new z,skyColor:new Re,groundColor:new Re};break;case"RectAreaLight":t={color:new Re,position:new z,halfWidth:new z,halfHeight:new z};break}return n[e.id]=t,t}}}function Cre(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let bre=0;function xre(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Ire(n,e){const t=new wre,r=Cre(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let c=0;c<9;c++)i.probe.push(new z);const s=new z,o=new Le,a=new Le;function l(c,u){let f=0,d=0,h=0;for(let Z=0;Z<9;Z++)i.probe[Z].set(0,0,0);let p=0,m=0,g=0,v=0,y=0,w=0,C=0,b=0,E=0,x=0;c.sort(xre);const S=u!==!0?Math.PI:1;for(let Z=0,K=c.length;Z0&&(e.isWebGL2||n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Me.LTC_FLOAT_1,i.rectAreaLTC2=Me.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Me.LTC_HALF_1,i.rectAreaLTC2=Me.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=h;const M=i.hash;(M.directionalLength!==p||M.pointLength!==m||M.spotLength!==g||M.rectAreaLength!==v||M.hemiLength!==y||M.numDirectionalShadows!==w||M.numPointShadows!==C||M.numSpotShadows!==b||M.numSpotMaps!==E)&&(i.directional.length=p,i.spot.length=g,i.rectArea.length=v,i.point.length=m,i.hemi.length=y,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.pointShadow.length=C,i.pointShadowMap.length=C,i.spotShadow.length=b,i.spotShadowMap.length=b,i.directionalShadowMatrix.length=w,i.pointShadowMatrix.length=C,i.spotLightMatrix.length=b+E-x,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=x,M.directionalLength=p,M.pointLength=m,M.spotLength=g,M.rectAreaLength=v,M.hemiLength=y,M.numDirectionalShadows=w,M.numPointShadows=C,M.numSpotShadows=b,M.numSpotMaps=E,i.version=bre++)}function A(c,u){let f=0,d=0,h=0,p=0,m=0;const g=u.matrixWorldInverse;for(let v=0,y=c.length;v=a.length?(l=new ZT(n,e),a.push(l)):l=a[o],l}function i(){t=new WeakMap}return{get:r,dispose:i}}class Ere extends cs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=E$,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ure extends cs{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new z,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const Sre=`void main() { +`+F)}else S!==""?console.warn("THREE.WebGLProgram: Program Info Log:",S):(M===""||Z==="")&&(_=!1);_&&(this.diagnostics={runnable:K,programLog:S,vertexShader:{log:M,prefix:m},fragmentShader:{log:Z,prefix:g}})}i.deleteShader(C),i.deleteShader(b);let E;this.getUniforms=function(){return E===void 0&&(E=new iB(i,p)),E};let x;return this.getAttributes=function(){return x===void 0&&(x=rre(i,p)),x},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(p),this.program=void 0},this.name=t.shaderName,this.id=Kne++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=C,this.fragmentShader=b,this}let hre=0;class pre{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const r of t)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let r=t.get(e);return r===void 0&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return r===void 0&&(r=new gre(e),t.set(e,r)),r}}class gre{constructor(e){this.id=hre++,this.code=e,this.usedTimes=0}}function mre(n,e,t,r,i,s,o){const a=new d_,l=new pre,A=[],c=i.isWebGL2,u=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const h={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(x,S,M,Z,K){const _=Z.fog,B=K.geometry,F=x.isMeshStandardMaterial?Z.environment:null,R=(x.isMeshStandardMaterial?t:e).get(x.envMap||F),k=R&&R.mapping===YC?R.image.height:null,T=h[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&console.warn("THREE.WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const V=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,O=V!==void 0?V.length:0;let L=0;B.morphAttributes.position!==void 0&&(L=1),B.morphAttributes.normal!==void 0&&(L=2),B.morphAttributes.color!==void 0&&(L=3);let U,H,le,N;if(T){const ne=oa[T];U=ne.vertexShader,H=ne.fragmentShader}else U=x.vertexShader,H=x.fragmentShader,l.update(x),le=l.getVertexShaderID(x),N=l.getFragmentShaderID(x);const j=n.getRenderTarget(),oe=x.alphaTest>0,ie=x.clearcoat>0,de=x.iridescence>0;return{isWebGL2:c,shaderID:T,shaderName:x.type,vertexShader:U,fragmentShader:H,defines:x.defines,customVertexShaderID:le,customFragmentShaderID:N,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,instancing:K.isInstancedMesh===!0,instancingColor:K.isInstancedMesh===!0&&K.instanceColor!==null,supportsVertexTextures:f,outputEncoding:j===null?n.outputEncoding:j.isXRRenderTarget===!0?j.texture.encoding:ps,map:!!x.map,matcap:!!x.matcap,envMap:!!R,envMapMode:R&&R.mapping,envMapCubeUVHeight:k,lightMap:!!x.lightMap,aoMap:!!x.aoMap,emissiveMap:!!x.emissiveMap,bumpMap:!!x.bumpMap,normalMap:!!x.normalMap,objectSpaceNormalMap:x.normalMapType===S$,tangentSpaceNormalMap:x.normalMapType===_u,decodeVideoTexture:!!x.map&&x.map.isVideoTexture===!0&&x.map.encoding===ht,clearcoat:ie,clearcoatMap:ie&&!!x.clearcoatMap,clearcoatRoughnessMap:ie&&!!x.clearcoatRoughnessMap,clearcoatNormalMap:ie&&!!x.clearcoatNormalMap,iridescence:de,iridescenceMap:de&&!!x.iridescenceMap,iridescenceThicknessMap:de&&!!x.iridescenceThicknessMap,displacementMap:!!x.displacementMap,roughnessMap:!!x.roughnessMap,metalnessMap:!!x.metalnessMap,specularMap:!!x.specularMap,specularIntensityMap:!!x.specularIntensityMap,specularColorMap:!!x.specularColorMap,opaque:x.transparent===!1&&x.blending===Wd,alphaMap:!!x.alphaMap,alphaTest:oe,gradientMap:!!x.gradientMap,sheen:x.sheen>0,sheenColorMap:!!x.sheenColorMap,sheenRoughnessMap:!!x.sheenRoughnessMap,transmission:x.transmission>0,transmissionMap:!!x.transmissionMap,thicknessMap:!!x.thicknessMap,combine:x.combine,vertexTangents:!!x.normalMap&&!!B.attributes.tangent,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,vertexUvs:!!x.map||!!x.bumpMap||!!x.normalMap||!!x.specularMap||!!x.alphaMap||!!x.emissiveMap||!!x.roughnessMap||!!x.metalnessMap||!!x.clearcoatMap||!!x.clearcoatRoughnessMap||!!x.clearcoatNormalMap||!!x.iridescenceMap||!!x.iridescenceThicknessMap||!!x.displacementMap||!!x.transmissionMap||!!x.thicknessMap||!!x.specularIntensityMap||!!x.specularColorMap||!!x.sheenColorMap||!!x.sheenRoughnessMap,uvsVertexOnly:!(x.map||x.bumpMap||x.normalMap||x.specularMap||x.alphaMap||x.emissiveMap||x.roughnessMap||x.metalnessMap||x.clearcoatNormalMap||x.iridescenceMap||x.iridescenceThicknessMap||x.transmission>0||x.transmissionMap||x.thicknessMap||x.specularIntensityMap||x.specularColorMap||x.sheen>0||x.sheenColorMap||x.sheenRoughnessMap)&&!!x.displacementMap,fog:!!_,useFog:x.fog===!0,fogExp2:_&&_.isFogExp2,flatShading:!!x.flatShading,sizeAttenuation:x.sizeAttenuation,logarithmicDepthBuffer:u,skinning:K.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:O,morphTextureStride:L,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:x.dithering,shadowMapEnabled:n.shadowMap.enabled&&M.length>0,shadowMapType:n.shadowMap.type,toneMapping:x.toneMapped?n.toneMapping:xl,physicallyCorrectLights:n.physicallyCorrectLights,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===pi,flipSided:x.side===mi,useDepthPacking:!!x.depthPacking,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionDerivatives:x.extensions&&x.extensions.derivatives,extensionFragDepth:x.extensions&&x.extensions.fragDepth,extensionDrawBuffers:x.extensions&&x.extensions.drawBuffers,extensionShaderTextureLOD:x.extensions&&x.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:x.customProgramCacheKey()}}function m(x){const S=[];if(x.shaderID?S.push(x.shaderID):(S.push(x.customVertexShaderID),S.push(x.customFragmentShaderID)),x.defines!==void 0)for(const M in x.defines)S.push(M),S.push(x.defines[M]);return x.isRawShaderMaterial===!1&&(g(S,x),v(S,x),S.push(n.outputEncoding)),S.push(x.customProgramCacheKey),S.join()}function g(x,S){x.push(S.precision),x.push(S.outputEncoding),x.push(S.envMapMode),x.push(S.envMapCubeUVHeight),x.push(S.combine),x.push(S.vertexUvs),x.push(S.fogExp2),x.push(S.sizeAttenuation),x.push(S.morphTargetsCount),x.push(S.morphAttributeCount),x.push(S.numDirLights),x.push(S.numPointLights),x.push(S.numSpotLights),x.push(S.numSpotLightMaps),x.push(S.numHemiLights),x.push(S.numRectAreaLights),x.push(S.numDirLightShadows),x.push(S.numPointLightShadows),x.push(S.numSpotLightShadows),x.push(S.numSpotLightShadowsWithMaps),x.push(S.shadowMapType),x.push(S.toneMapping),x.push(S.numClippingPlanes),x.push(S.numClipIntersection),x.push(S.depthPacking)}function v(x,S){a.disableAll(),S.isWebGL2&&a.enable(0),S.supportsVertexTextures&&a.enable(1),S.instancing&&a.enable(2),S.instancingColor&&a.enable(3),S.map&&a.enable(4),S.matcap&&a.enable(5),S.envMap&&a.enable(6),S.lightMap&&a.enable(7),S.aoMap&&a.enable(8),S.emissiveMap&&a.enable(9),S.bumpMap&&a.enable(10),S.normalMap&&a.enable(11),S.objectSpaceNormalMap&&a.enable(12),S.tangentSpaceNormalMap&&a.enable(13),S.clearcoat&&a.enable(14),S.clearcoatMap&&a.enable(15),S.clearcoatRoughnessMap&&a.enable(16),S.clearcoatNormalMap&&a.enable(17),S.iridescence&&a.enable(18),S.iridescenceMap&&a.enable(19),S.iridescenceThicknessMap&&a.enable(20),S.displacementMap&&a.enable(21),S.specularMap&&a.enable(22),S.roughnessMap&&a.enable(23),S.metalnessMap&&a.enable(24),S.gradientMap&&a.enable(25),S.alphaMap&&a.enable(26),S.alphaTest&&a.enable(27),S.vertexColors&&a.enable(28),S.vertexAlphas&&a.enable(29),S.vertexUvs&&a.enable(30),S.vertexTangents&&a.enable(31),S.uvsVertexOnly&&a.enable(32),x.push(a.mask),a.disableAll(),S.fog&&a.enable(0),S.useFog&&a.enable(1),S.flatShading&&a.enable(2),S.logarithmicDepthBuffer&&a.enable(3),S.skinning&&a.enable(4),S.morphTargets&&a.enable(5),S.morphNormals&&a.enable(6),S.morphColors&&a.enable(7),S.premultipliedAlpha&&a.enable(8),S.shadowMapEnabled&&a.enable(9),S.physicallyCorrectLights&&a.enable(10),S.doubleSided&&a.enable(11),S.flipSided&&a.enable(12),S.useDepthPacking&&a.enable(13),S.dithering&&a.enable(14),S.specularIntensityMap&&a.enable(15),S.specularColorMap&&a.enable(16),S.transmission&&a.enable(17),S.transmissionMap&&a.enable(18),S.thicknessMap&&a.enable(19),S.sheen&&a.enable(20),S.sheenColorMap&&a.enable(21),S.sheenRoughnessMap&&a.enable(22),S.decodeVideoTexture&&a.enable(23),S.opaque&&a.enable(24),x.push(a.mask)}function y(x){const S=h[x.type];let M;if(S){const Z=oa[S];M=h_.clone(Z.uniforms)}else M=x.uniforms;return M}function w(x,S){let M;for(let Z=0,K=A.length;Z0?r.push(g):d.transparent===!0?i.push(g):t.push(g)}function l(u,f,d,h,p,m){const g=o(u,f,d,h,p,m);d.transmission>0?r.unshift(g):d.transparent===!0?i.unshift(g):t.unshift(g)}function A(u,f){t.length>1&&t.sort(u||yre),r.length>1&&r.sort(f||OT),i.length>1&&i.sort(f||OT)}function c(){for(let u=e,f=n.length;u=s.length?(o=new GT,s.push(o)):o=s[i],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function wre(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new z,color:new Re};break;case"SpotLight":t={position:new z,direction:new z,color:new Re,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new z,color:new Re,distance:0,decay:0};break;case"HemisphereLight":t={direction:new z,skyColor:new Re,groundColor:new Re};break;case"RectAreaLight":t={color:new Re,position:new z,halfWidth:new z,halfHeight:new z};break}return n[e.id]=t,t}}}function Cre(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let bre=0;function xre(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Ire(n,e){const t=new wre,r=Cre(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let c=0;c<9;c++)i.probe.push(new z);const s=new z,o=new Le,a=new Le;function l(c,u){let f=0,d=0,h=0;for(let Z=0;Z<9;Z++)i.probe[Z].set(0,0,0);let p=0,m=0,g=0,v=0,y=0,w=0,C=0,b=0,E=0,x=0;c.sort(xre);const S=u!==!0?Math.PI:1;for(let Z=0,K=c.length;Z0&&(e.isWebGL2||n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Me.LTC_FLOAT_1,i.rectAreaLTC2=Me.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Me.LTC_HALF_1,i.rectAreaLTC2=Me.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=h;const M=i.hash;(M.directionalLength!==p||M.pointLength!==m||M.spotLength!==g||M.rectAreaLength!==v||M.hemiLength!==y||M.numDirectionalShadows!==w||M.numPointShadows!==C||M.numSpotShadows!==b||M.numSpotMaps!==E)&&(i.directional.length=p,i.spot.length=g,i.rectArea.length=v,i.point.length=m,i.hemi.length=y,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.pointShadow.length=C,i.pointShadowMap.length=C,i.spotShadow.length=b,i.spotShadowMap.length=b,i.directionalShadowMatrix.length=w,i.pointShadowMatrix.length=C,i.spotLightMatrix.length=b+E-x,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=x,M.directionalLength=p,M.pointLength=m,M.spotLength=g,M.rectAreaLength=v,M.hemiLength=y,M.numDirectionalShadows=w,M.numPointShadows=C,M.numSpotShadows=b,M.numSpotMaps=E,i.version=bre++)}function A(c,u){let f=0,d=0,h=0,p=0,m=0;const g=u.matrixWorldInverse;for(let v=0,y=c.length;v=a.length?(l=new ZT(n,e),a.push(l)):l=a[o],l}function i(){t=new WeakMap}return{get:r,dispose:i}}class Ere extends cs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=E$,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ure extends cs{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new z,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const Sre=`void main() { gl_Position = vec4( position, 1.0 ); }`,_re=`uniform sampler2D shadow_pass; uniform vec2 resolution; @@ -3201,7 +3201,7 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function Qre(n,e,t){let r=new p_;const i=new We,s=new We,o=new Tt,a=new Ere({depthPacking:U$}),l=new Ure,A={},c=t.maxTextureSize,u={0:mi,1:Vo,2:pi},f=new Er({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new We},radius:{value:4}},vertexShader:Sre,fragmentShader:_re}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const h=new Ht;h.setAttribute("position",new At(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const p=new In(h,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=zG,this.render=function(w,C,b){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;const E=n.getRenderTarget(),x=n.getActiveCubeFace(),S=n.getActiveMipmapLevel(),M=n.state;M.setBlending(WA),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);for(let Z=0,K=w.length;Zc||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/F.x),i.x=s.x*F.x,B.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/F.y),i.y=s.y*F.y,B.mapSize.y=s.y)),B.map===null){const k=this.type!==ug?{minFilter:er,magFilter:er}:{};B.map=new _a(i.x,i.y,k),B.map.texture.name=_.name+".shadowMap",B.camera.updateProjectionMatrix()}n.setRenderTarget(B.map),n.clear();const R=B.getViewportCount();for(let k=0;k0){const K=M.uuid,_=C.uuid;let B=A[K];B===void 0&&(B={},A[K]=B);let F=B[_];F===void 0&&(F=M.clone(),B[_]=F),M=F}return M.visible=C.visible,M.wireframe=C.wireframe,S===ug?M.side=C.shadowSide!==null?C.shadowSide:C.side:M.side=C.shadowSide!==null?C.shadowSide:u[C.side],M.alphaMap=C.alphaMap,M.alphaTest=C.alphaTest,M.clipShadows=C.clipShadows,M.clippingPlanes=C.clippingPlanes,M.clipIntersection=C.clipIntersection,M.displacementMap=C.displacementMap,M.displacementScale=C.displacementScale,M.displacementBias=C.displacementBias,M.wireframeLinewidth=C.wireframeLinewidth,M.linewidth=C.linewidth,b.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(b.matrixWorld),M.nearDistance=E,M.farDistance=x),M}function y(w,C,b,E,x){if(w.visible===!1)return;if(w.layers.test(C.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&x===ug)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,w.matrixWorld);const Z=e.update(w),K=w.material;if(Array.isArray(K)){const _=Z.groups;for(let B=0,F=_.length;B=1):T.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(T)[1]),R=k>=2);let V=null,O={};const L=n.getParameter(3088),U=n.getParameter(2978),H=new Tt().fromArray(L),Ae=new Tt().fromArray(U);function N(re,ye,be){const Ue=new Uint8Array(4),Je=n.createTexture();n.bindTexture(re,Je),n.texParameteri(re,10241,9728),n.texParameteri(re,10240,9728);for(let qe=0;qe"u"?"":navigator.userAgent),h=new WeakMap;let p;const m=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(G,J){return g?new OffscreenCanvas(G,J):Um("canvas")}function y(G,J,se,fe){let ve=1;if((G.width>fe||G.height>fe)&&(ve=fe/Math.max(G.width,G.height)),ve<1||J===!0)if(typeof HTMLImageElement<"u"&&G instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&G instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&G instanceof ImageBitmap){const W=J?vw:Math.floor,Q=W(ve*G.width),I=W(ve*G.height);p===void 0&&(p=v(Q,I));const D=se?v(Q,I):p;return D.width=Q,D.height=I,D.getContext("2d").drawImage(G,0,0,Q,I),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+G.width+"x"+G.height+") to ("+Q+"x"+I+")."),D}else return"data"in G&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+G.width+"x"+G.height+")."),G;return G}function w(G){return mE(G.width)&&mE(G.height)}function C(G){return a?!1:G.wrapS!==di||G.wrapT!==di||G.minFilter!==er&&G.minFilter!==Ai}function b(G,J){return G.generateMipmaps&&J&&G.minFilter!==er&&G.minFilter!==Ai}function E(G){n.generateMipmap(G)}function x(G,J,se,fe,ve=!1){if(a===!1)return J;if(G!==null){if(n[G]!==void 0)return n[G];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+G+"'")}let W=J;return J===6403&&(se===5126&&(W=33326),se===5131&&(W=33325),se===5121&&(W=33321)),J===33319&&(se===5126&&(W=33328),se===5131&&(W=33327),se===5121&&(W=33323)),J===6408&&(se===5126&&(W=34836),se===5131&&(W=34842),se===5121&&(W=fe===ht&&ve===!1?35907:32856),se===32819&&(W=32854),se===32820&&(W=32855)),(W===33325||W===33326||W===33327||W===33328||W===34842||W===34836)&&e.get("EXT_color_buffer_float"),W}function S(G,J,se){return b(G,se)===!0||G.isFramebufferTexture&&G.minFilter!==er&&G.minFilter!==Ai?Math.log2(Math.max(J.width,J.height))+1:G.mipmaps!==void 0&&G.mipmaps.length>0?G.mipmaps.length:G.isCompressedTexture&&Array.isArray(G.image)?J.mipmaps.length:1}function M(G){return G===er||G===pw||G===gw?9728:9729}function Z(G){const J=G.target;J.removeEventListener("dispose",Z),_(J),J.isVideoTexture&&h.delete(J)}function K(G){const J=G.target;J.removeEventListener("dispose",K),F(J)}function _(G){const J=r.get(G);if(J.__webglInit===void 0)return;const se=G.source,fe=m.get(se);if(fe){const ve=fe[J.__cacheKey];ve.usedTimes--,ve.usedTimes===0&&B(G),Object.keys(fe).length===0&&m.delete(se)}r.remove(G)}function B(G){const J=r.get(G);n.deleteTexture(J.__webglTexture);const se=G.source,fe=m.get(se);delete fe[J.__cacheKey],o.memory.textures--}function F(G){const J=G.texture,se=r.get(G),fe=r.get(J);if(fe.__webglTexture!==void 0&&(n.deleteTexture(fe.__webglTexture),o.memory.textures--),G.depthTexture&&G.depthTexture.dispose(),G.isWebGLCubeRenderTarget)for(let ve=0;ve<6;ve++)n.deleteFramebuffer(se.__webglFramebuffer[ve]),se.__webglDepthbuffer&&n.deleteRenderbuffer(se.__webglDepthbuffer[ve]);else{if(n.deleteFramebuffer(se.__webglFramebuffer),se.__webglDepthbuffer&&n.deleteRenderbuffer(se.__webglDepthbuffer),se.__webglMultisampledFramebuffer&&n.deleteFramebuffer(se.__webglMultisampledFramebuffer),se.__webglColorRenderbuffer)for(let ve=0;ve=l&&console.warn("THREE.WebGLTextures: Trying to use "+G+" texture units while this GPU supports only "+l),R+=1,G}function V(G){const J=[];return J.push(G.wrapS),J.push(G.wrapT),J.push(G.wrapR||0),J.push(G.magFilter),J.push(G.minFilter),J.push(G.anisotropy),J.push(G.internalFormat),J.push(G.format),J.push(G.type),J.push(G.generateMipmaps),J.push(G.premultiplyAlpha),J.push(G.flipY),J.push(G.unpackAlignment),J.push(G.encoding),J.join()}function O(G,J){const se=r.get(G);if(G.isVideoTexture&&Ge(G),G.isRenderTargetTexture===!1&&G.version>0&&se.__version!==G.version){const fe=G.image;if(fe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(fe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(se,G,J);return}}t.bindTexture(3553,se.__webglTexture,33984+J)}function L(G,J){const se=r.get(G);if(G.version>0&&se.__version!==G.version){ie(se,G,J);return}t.bindTexture(35866,se.__webglTexture,33984+J)}function U(G,J){const se=r.get(G);if(G.version>0&&se.__version!==G.version){ie(se,G,J);return}t.bindTexture(32879,se.__webglTexture,33984+J)}function H(G,J){const se=r.get(G);if(G.version>0&&se.__version!==G.version){de(se,G,J);return}t.bindTexture(34067,se.__webglTexture,33984+J)}const Ae={[hs]:10497,[di]:33071,[Im]:33648},N={[er]:9728,[pw]:9984,[gw]:9986,[Ai]:9729,[A_]:9985,[Su]:9987};function j(G,J,se){if(se?(n.texParameteri(G,10242,Ae[J.wrapS]),n.texParameteri(G,10243,Ae[J.wrapT]),(G===32879||G===35866)&&n.texParameteri(G,32882,Ae[J.wrapR]),n.texParameteri(G,10240,N[J.magFilter]),n.texParameteri(G,10241,N[J.minFilter])):(n.texParameteri(G,10242,33071),n.texParameteri(G,10243,33071),(G===32879||G===35866)&&n.texParameteri(G,32882,33071),(J.wrapS!==di||J.wrapT!==di)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(G,10240,M(J.magFilter)),n.texParameteri(G,10241,M(J.minFilter)),J.minFilter!==er&&J.minFilter!==Ai&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const fe=e.get("EXT_texture_filter_anisotropic");if(J.type===FA&&e.has("OES_texture_float_linear")===!1||a===!1&&J.type===Fm&&e.has("OES_texture_half_float_linear")===!1)return;(J.anisotropy>1||r.get(J).__currentAnisotropy)&&(n.texParameterf(G,fe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(J.anisotropy,i.getMaxAnisotropy())),r.get(J).__currentAnisotropy=J.anisotropy)}}function oe(G,J){let se=!1;G.__webglInit===void 0&&(G.__webglInit=!0,J.addEventListener("dispose",Z));const fe=J.source;let ve=m.get(fe);ve===void 0&&(ve={},m.set(fe,ve));const W=V(J);if(W!==G.__cacheKey){ve[W]===void 0&&(ve[W]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,se=!0),ve[W].usedTimes++;const Q=ve[G.__cacheKey];Q!==void 0&&(ve[G.__cacheKey].usedTimes--,Q.usedTimes===0&&B(J)),G.__cacheKey=W,G.__webglTexture=ve[W].texture}return se}function ie(G,J,se){let fe=3553;(J.isDataArrayTexture||J.isCompressedArrayTexture)&&(fe=35866),J.isData3DTexture&&(fe=32879);const ve=oe(G,J),W=J.source;t.bindTexture(fe,G.__webglTexture,33984+se);const Q=r.get(W);if(W.version!==Q.__version||ve===!0){t.activeTexture(33984+se),n.pixelStorei(37440,J.flipY),n.pixelStorei(37441,J.premultiplyAlpha),n.pixelStorei(3317,J.unpackAlignment),n.pixelStorei(37443,0);const I=C(J)&&w(J.image)===!1;let D=y(J.image,I,!1,c);D=Xe(J,D);const $=w(D)||a,ee=s.convert(J.format,J.encoding);let te=s.convert(J.type),we=x(J.internalFormat,ee,te,J.encoding,J.isVideoTexture);j(fe,J,$);let Ce;const Ee=J.mipmaps,Ve=a&&J.isVideoTexture!==!0,_e=Q.__version===void 0||ve===!0,re=S(J,D,$);if(J.isDepthTexture)we=6402,a?J.type===FA?we=36012:J.type===Jc?we=33190:J.type===Od?we=35056:we=33189:J.type===FA&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),J.format===ru&&we===6402&&J.type!==jG&&J.type!==Jc&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),J.type=Jc,te=s.convert(J.type)),J.format===vh&&we===6402&&(we=34041,J.type!==Od&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),J.type=Od,te=s.convert(J.type))),_e&&(Ve?t.texStorage2D(3553,1,we,D.width,D.height):t.texImage2D(3553,0,we,D.width,D.height,0,ee,te,null));else if(J.isDataTexture)if(Ee.length>0&&$){Ve&&_e&&t.texStorage2D(3553,re,we,Ee[0].width,Ee[0].height);for(let ye=0,be=Ee.length;ye>=1,be>>=1}}else if(Ee.length>0&&$){Ve&&_e&&t.texStorage2D(3553,re,we,Ee[0].width,Ee[0].height);for(let ye=0,be=Ee.length;ye0&&_e++,t.texStorage2D(34067,_e,Ce,D[0].width,D[0].height));for(let ye=0;ye<6;ye++)if(I){Ee?t.texSubImage2D(34069+ye,0,0,0,D[ye].width,D[ye].height,te,we,D[ye].data):t.texImage2D(34069+ye,0,Ce,D[ye].width,D[ye].height,0,te,we,D[ye].data);for(let be=0;be=34069&&ve<=34074)&&n.framebufferTexture2D(36160,fe,ve,r.get(se).__webglTexture,0),t.bindFramebuffer(36160,null)}function ne(G,J,se){if(n.bindRenderbuffer(36161,G),J.depthBuffer&&!J.stencilBuffer){let fe=33189;if(se||Qe(J)){const ve=J.depthTexture;ve&&ve.isDepthTexture&&(ve.type===FA?fe=36012:ve.type===Jc&&(fe=33190));const W=ke(J);Qe(J)?f.renderbufferStorageMultisampleEXT(36161,W,fe,J.width,J.height):n.renderbufferStorageMultisample(36161,W,fe,J.width,J.height)}else n.renderbufferStorage(36161,fe,J.width,J.height);n.framebufferRenderbuffer(36160,36096,36161,G)}else if(J.depthBuffer&&J.stencilBuffer){const fe=ke(J);se&&Qe(J)===!1?n.renderbufferStorageMultisample(36161,fe,35056,J.width,J.height):Qe(J)?f.renderbufferStorageMultisampleEXT(36161,fe,35056,J.width,J.height):n.renderbufferStorage(36161,34041,J.width,J.height),n.framebufferRenderbuffer(36160,33306,36161,G)}else{const fe=J.isWebGLMultipleRenderTargets===!0?J.texture:[J.texture];for(let ve=0;ve0&&Qe(G)===!1){const I=W?J:[J];se.__webglMultisampledFramebuffer=n.createFramebuffer(),se.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,se.__webglMultisampledFramebuffer);for(let D=0;D0&&Qe(G)===!1){const J=G.isWebGLMultipleRenderTargets?G.texture:[G.texture],se=G.width,fe=G.height;let ve=16384;const W=[],Q=G.stencilBuffer?33306:36096,I=r.get(G),D=G.isWebGLMultipleRenderTargets===!0;if(D)for(let $=0;$0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&J.__useRenderToTexture!==!1}function Ge(G){const J=o.render.frame;h.get(G)!==J&&(h.set(G,J),G.update())}function Xe(G,J){const se=G.encoding,fe=G.format,ve=G.type;return G.isCompressedTexture===!0||G.isVideoTexture===!0||G.format===gE||se!==ps&&(se===ht?a===!1?e.has("EXT_sRGB")===!0&&fe===br?(G.format=gE,G.minFilter=Ai,G.generateMipmaps=!1):J=rZ.sRGBToLinear(J):(fe!==br||ve!==$A)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",se)),J}this.allocateTextureUnit=T,this.resetTextureUnits=k,this.setTexture2D=O,this.setTexture2DArray=L,this.setTexture3D=U,this.setTextureCube=H,this.rebindTextures=pe,this.setupRenderTarget=Fe,this.updateRenderTargetMipmap=rt,this.updateMultisampleRenderTarget=Oe,this.setupDepthRenderbuffer=Be,this.setupFrameBufferTexture=X,this.useMultisampledRTT=Qe}function Tre(n,e,t){const r=t.isWebGL2;function i(s,o=null){let a;if(s===$A)return 5121;if(s===u$)return 32819;if(s===f$)return 32820;if(s===l$)return 5120;if(s===A$)return 5122;if(s===jG)return 5123;if(s===c$)return 5124;if(s===Jc)return 5125;if(s===FA)return 5126;if(s===Fm)return r?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===d$)return 6406;if(s===br)return 6408;if(s===h$)return 6409;if(s===p$)return 6410;if(s===ru)return 6402;if(s===vh)return 34041;if(s===g$)return 6403;if(s===$G)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===gE)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===m$)return 36244;if(s===v$)return 33319;if(s===y$)return 33320;if(s===B$)return 36249;if(s===Jx||s===Hx||s===zx||s===Yx)if(o===ht)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Jx)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Hx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===zx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Yx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Jx)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Hx)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===zx)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Yx)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Z2||s===J2||s===H2||s===z2)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Z2)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===J2)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===H2)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===z2)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===w$)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Y2||s===X2)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Y2)return o===ht?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===X2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===K2||s===j2||s===$2||s===q2||s===eT||s===tT||s===nT||s===rT||s===iT||s===sT||s===oT||s===aT||s===lT||s===AT)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===K2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===j2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===$2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===q2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===eT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===tT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===nT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===rT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===iT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===sT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===oT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===aT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===lT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===AT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===cT)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===cT)return o===ht?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===Od?r?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:i}}class Nre extends Mr{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Tr extends kt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Dre={type:"move"};class wI{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Tr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Tr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new z,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new z),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Tr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new z,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new z),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,r){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,A=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(A&&e.hand){o=!0;for(const p of e.hand.values()){const m=t.getJointPose(p,r);if(A.joints[p.jointName]===void 0){const v=new Tr;v.matrixAutoUpdate=!1,v.visible=!1,A.joints[p.jointName]=v,A.add(v)}const g=A.joints[p.jointName];m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=m!==null}const c=A.joints["index-finger-tip"],u=A.joints["thumb-tip"],f=c.position.distanceTo(u.position),d=.02,h=.005;A.inputState.pinching&&f>d+h?(A.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!A.inputState.pinching&&f<=d-h&&(A.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Dre)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),A!==null&&(A.visible=o!==null),this}}class dZ extends ir{constructor(e,t,r,i,s,o,a,l,A,c){if(c=c!==void 0?c:ru,c!==ru&&c!==vh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&c===ru&&(r=Jc),r===void 0&&c===vh&&(r=Od),super(null,i,s,o,a,l,c,r,A),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:er,this.minFilter=l!==void 0?l:er,this.flipY=!1,this.generateMipmaps=!1}}class kre extends dc{constructor(e,t){super();const r=this;let i=null,s=1,o=null,a="local-floor",l=null,A=null,c=null,u=null,f=null,d=null;const h=t.getContextAttributes();let p=null,m=null;const g=[],v=[],y=new Mr;y.layers.enable(1),y.viewport=new Tt;const w=new Mr;w.layers.enable(2),w.viewport=new Tt;const C=[y,w],b=new Nre;b.layers.enable(1),b.layers.enable(2);let E=null,x=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(V){let O=g[V];return O===void 0&&(O=new wI,g[V]=O),O.getTargetRaySpace()},this.getControllerGrip=function(V){let O=g[V];return O===void 0&&(O=new wI,g[V]=O),O.getGripSpace()},this.getHand=function(V){let O=g[V];return O===void 0&&(O=new wI,g[V]=O),O.getHandSpace()};function S(V){const O=v.indexOf(V.inputSource);if(O===-1)return;const L=g[O];L!==void 0&&L.dispatchEvent({type:V.type,data:V.inputSource})}function M(){i.removeEventListener("select",S),i.removeEventListener("selectstart",S),i.removeEventListener("selectend",S),i.removeEventListener("squeeze",S),i.removeEventListener("squeezestart",S),i.removeEventListener("squeezeend",S),i.removeEventListener("end",M),i.removeEventListener("inputsourceschange",Z);for(let V=0;V=0&&(v[U]=null,g[U].dispatchEvent({type:"disconnected",data:L}))}for(let O=0;O=v.length){v.push(L),U=Ae;break}else if(v[Ae]===null){v[Ae]=L,U=Ae;break}if(U===-1)break}const H=g[U];H&&H.dispatchEvent({type:"connected",data:L})}}const K=new z,_=new z;function B(V,O,L){K.setFromMatrixPosition(O.matrixWorld),_.setFromMatrixPosition(L.matrixWorld);const U=K.distanceTo(_),H=O.projectionMatrix.elements,Ae=L.projectionMatrix.elements,N=H[14]/(H[10]-1),j=H[14]/(H[10]+1),oe=(H[9]+1)/H[5],ie=(H[9]-1)/H[5],de=(H[8]-1)/H[0],X=(Ae[8]+1)/Ae[0],ne=N*de,ae=N*X,Be=U/(-de+X),pe=Be*-de;O.matrixWorld.decompose(V.position,V.quaternion,V.scale),V.translateX(pe),V.translateZ(Be),V.matrixWorld.compose(V.position,V.quaternion,V.scale),V.matrixWorldInverse.copy(V.matrixWorld).invert();const Fe=N+Be,rt=j+Be,Oe=ne-pe,ke=ae+(U-pe),Qe=oe*j/rt*Fe,Ge=ie*j/rt*Fe;V.projectionMatrix.makePerspective(Oe,ke,Qe,Ge,Fe,rt)}function F(V,O){O===null?V.matrixWorld.copy(V.matrix):V.matrixWorld.multiplyMatrices(O.matrixWorld,V.matrix),V.matrixWorldInverse.copy(V.matrixWorld).invert()}this.updateCamera=function(V){if(i===null)return;b.near=w.near=y.near=V.near,b.far=w.far=y.far=V.far,(E!==b.near||x!==b.far)&&(i.updateRenderState({depthNear:b.near,depthFar:b.far}),E=b.near,x=b.far);const O=V.parent,L=b.cameras;F(b,O);for(let H=0;H0&&(p.alphaTest.value=m.alphaTest);const g=e.get(m).envMap;if(g&&(p.envMap.value=g,p.flipEnvMap.value=g.isCubeTexture&&g.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap){p.lightMap.value=m.lightMap;const w=n.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=m.lightMapIntensity*w}m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity);let v;m.map?v=m.map:m.specularMap?v=m.specularMap:m.displacementMap?v=m.displacementMap:m.normalMap?v=m.normalMap:m.bumpMap?v=m.bumpMap:m.roughnessMap?v=m.roughnessMap:m.metalnessMap?v=m.metalnessMap:m.alphaMap?v=m.alphaMap:m.emissiveMap?v=m.emissiveMap:m.clearcoatMap?v=m.clearcoatMap:m.clearcoatNormalMap?v=m.clearcoatNormalMap:m.clearcoatRoughnessMap?v=m.clearcoatRoughnessMap:m.iridescenceMap?v=m.iridescenceMap:m.iridescenceThicknessMap?v=m.iridescenceThicknessMap:m.specularIntensityMap?v=m.specularIntensityMap:m.specularColorMap?v=m.specularColorMap:m.transmissionMap?v=m.transmissionMap:m.thicknessMap?v=m.thicknessMap:m.sheenColorMap?v=m.sheenColorMap:m.sheenRoughnessMap&&(v=m.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let y;m.aoMap?y=m.aoMap:m.lightMap&&(y=m.lightMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uv2Transform.value.copy(y.matrix))}function s(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function a(p,m,g,v){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*g,p.scale.value=v*.5,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let y;m.map?y=m.map:m.alphaMap&&(y=m.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function l(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let g;m.map?g=m.map:m.alphaMap&&(g=m.alphaMap),g!==void 0&&(g.matrixAutoUpdate===!0&&g.updateMatrix(),p.uvTransform.value.copy(g.matrix))}function A(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function c(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function u(p,m){p.roughness.value=m.roughness,p.metalness.value=m.metalness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap),e.get(m).envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,g){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),p.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===mi&&p.clearcoatNormalScale.value.negate())),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=g.texture,p.transmissionSamplerSize.value.set(g.width,g.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap)}function d(p,m){m.matcap&&(p.matcap.value=m.matcap)}function h(p,m){p.referencePosition.value.copy(m.referencePosition),p.nearDistance.value=m.nearDistance,p.farDistance.value=m.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:r}}function Lre(n,e,t,r){let i={},s={},o=[];const a=t.isWebGL2?n.getParameter(35375):0;function l(v,y){const w=y.program;r.uniformBlockBinding(v,w)}function A(v,y){let w=i[v.id];w===void 0&&(h(v),w=c(v),i[v.id]=w,v.addEventListener("dispose",m));const C=y.program;r.updateUBOMapping(v,C);const b=e.render.frame;s[v.id]!==b&&(f(v),s[v.id]=b)}function c(v){const y=u();v.__bindingPointIndex=y;const w=n.createBuffer(),C=v.__size,b=v.usage;return n.bindBuffer(35345,w),n.bufferData(35345,C,b),n.bindBuffer(35345,null),n.bindBufferBase(35345,y,w),w}function u(){for(let v=0;v0){b=w%C;const Z=C-b;b!==0&&Z-M.boundary<0&&(w+=C-b,S.__offset=w)}w+=M.storage}return b=w%C,b>0&&(w+=C-b),v.__size=w,v.__cache={},this}function p(v){const y=v.value,w={boundary:0,storage:0};return typeof y=="number"?(w.boundary=4,w.storage=4):y.isVector2?(w.boundary=8,w.storage=8):y.isVector3||y.isColor?(w.boundary=16,w.storage=12):y.isVector4?(w.boundary=16,w.storage=16):y.isMatrix3?(w.boundary=48,w.storage=48):y.isMatrix4?(w.boundary=64,w.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),w}function m(v){const y=v.target;y.removeEventListener("dispose",m);const w=o.indexOf(y.__bindingPointIndex);o.splice(w,1),n.deleteBuffer(i[y.id]),delete i[y.id],delete s[y.id]}function g(){for(const v in i)n.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:A,dispose:g}}function Pre(){const n=Um("canvas");return n.style.display="block",n}function c0(n={}){this.isWebGLRenderer=!0;const e=n.canvas!==void 0?n.canvas:Pre(),t=n.context!==void 0?n.context:null,r=n.depth!==void 0?n.depth:!0,i=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,o=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,a=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",A=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1;let c;t!==null?c=t.getContextAttributes().alpha:c=n.alpha!==void 0?n.alpha:!1;let u=null,f=null;const d=[],h=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=ps,this.physicallyCorrectLights=!1,this.toneMapping=xl,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const p=this;let m=!1,g=0,v=0,y=null,w=-1,C=null;const b=new Tt,E=new Tt;let x=null,S=e.width,M=e.height,Z=1,K=null,_=null;const B=new Tt(0,0,S,M),F=new Tt(0,0,S,M);let R=!1;const k=new p_;let T=!1,V=!1,O=null;const L=new Le,U=new We,H=new z,Ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function N(){return y===null?Z:1}let j=t;function oe(q,le){for(let he=0;he0?f=h[h.length-1]:f=null,d.pop(),d.length>0?u=d[d.length-1]:u=null};function ct(q,le,he,ue){if(q.visible===!1)return;if(q.layers.test(le.layers)){if(q.isGroup)he=q.renderOrder;else if(q.isLOD)q.autoUpdate===!0&&q.update(le);else if(q.isLight)f.pushLight(q),q.castShadow&&f.pushShadow(q);else if(q.isSprite){if(!q.frustumCulled||k.intersectsSprite(q)){ue&&H.setFromMatrixPosition(q.matrixWorld).applyMatrix4(L);const at=ke.update(q),Ye=q.material;Ye.visible&&u.push(q,at,Ye,he,H.z,null)}}else if((q.isMesh||q.isLine||q.isPoints)&&(q.isSkinnedMesh&&q.skeleton.frame!==ne.render.frame&&(q.skeleton.update(),q.skeleton.frame=ne.render.frame),!q.frustumCulled||k.intersectsObject(q))){ue&&H.setFromMatrixPosition(q.matrixWorld).applyMatrix4(L);const at=ke.update(q),Ye=q.material;if(Array.isArray(Ye)){const He=at.groups;for(let vt=0,ft=He.length;vt0&&xt(ge,le,he),ue&&X.viewport(b.copy(ue)),ge.length>0&&st(ge,le,he),Ne.length>0&&st(Ne,le,he),at.length>0&&st(at,le,he),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function xt(q,le,he){const ue=de.isWebGL2;O===null&&(O=new _a(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?Fm:$A,minFilter:Su,samples:ue&&s===!0?4:0})),p.getDrawingBufferSize(U),ue?O.setSize(U.x,U.y):O.setSize(vw(U.x),vw(U.y));const ge=p.getRenderTarget();p.setRenderTarget(O),p.clear();const Ne=p.toneMapping;p.toneMapping=xl,st(q,le,he),p.toneMapping=Ne,Be.updateMultisampleRenderTarget(O),Be.updateRenderTargetMipmap(O),p.setRenderTarget(ge)}function st(q,le,he){const ue=le.isScene===!0?le.overrideMaterial:null;for(let ge=0,Ne=q.length;ge0&&Be.useMultisampledRTT(q)===!1?ge=ae.get(q).__webglMultisampledFramebuffer:ge=ft,b.copy(q.viewport),E.copy(q.scissor),x=q.scissorTest}else b.copy(B).multiplyScalar(Z).floor(),E.copy(F).multiplyScalar(Z).floor(),x=R;if(X.bindFramebuffer(36160,ge)&&de.drawBuffers&&ue&&X.drawBuffers(q,ge),X.viewport(b),X.scissor(E),X.setScissorTest(x),Ne){const He=ae.get(q.texture);j.framebufferTexture2D(36160,36064,34069+le,He.__webglTexture,he)}else if(at){const He=ae.get(q.texture),vt=le||0;j.framebufferTextureLayer(36160,36064,He.__webglTexture,he||0,vt)}w=-1},this.readRenderTargetPixels=function(q,le,he,ue,ge,Ne,at){if(!(q&&q.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ye=ae.get(q).__webglFramebuffer;if(q.isWebGLCubeRenderTarget&&at!==void 0&&(Ye=Ye[at]),Ye){X.bindFramebuffer(36160,Ye);try{const He=q.texture,vt=He.format,ft=He.type;if(vt!==br&&I.convert(vt)!==j.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const gt=ft===Fm&&(ie.has("EXT_color_buffer_half_float")||de.isWebGL2&&ie.has("EXT_color_buffer_float"));if(ft!==$A&&I.convert(ft)!==j.getParameter(35738)&&!(ft===FA&&(de.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!gt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}le>=0&&le<=q.width-ue&&he>=0&&he<=q.height-ge&&j.readPixels(le,he,ue,ge,I.convert(vt),I.convert(ft),Ne)}finally{const He=y!==null?ae.get(y).__webglFramebuffer:null;X.bindFramebuffer(36160,He)}}},this.copyFramebufferToTexture=function(q,le,he=0){const ue=Math.pow(2,-he),ge=Math.floor(le.image.width*ue),Ne=Math.floor(le.image.height*ue);Be.setTexture2D(le,0),j.copyTexSubImage2D(3553,he,0,0,q.x,q.y,ge,Ne),X.unbindTexture()},this.copyTextureToTexture=function(q,le,he,ue=0){const ge=le.image.width,Ne=le.image.height,at=I.convert(he.format),Ye=I.convert(he.type);Be.setTexture2D(he,0),j.pixelStorei(37440,he.flipY),j.pixelStorei(37441,he.premultiplyAlpha),j.pixelStorei(3317,he.unpackAlignment),le.isDataTexture?j.texSubImage2D(3553,ue,q.x,q.y,ge,Ne,at,Ye,le.image.data):le.isCompressedTexture?j.compressedTexSubImage2D(3553,ue,q.x,q.y,le.mipmaps[0].width,le.mipmaps[0].height,at,le.mipmaps[0].data):j.texSubImage2D(3553,ue,q.x,q.y,at,Ye,le.image),ue===0&&he.generateMipmaps&&j.generateMipmap(3553),X.unbindTexture()},this.copyTextureToTexture3D=function(q,le,he,ue,ge=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ne=q.max.x-q.min.x+1,at=q.max.y-q.min.y+1,Ye=q.max.z-q.min.z+1,He=I.convert(ue.format),vt=I.convert(ue.type);let ft;if(ue.isData3DTexture)Be.setTexture3D(ue,0),ft=32879;else if(ue.isDataArrayTexture)Be.setTexture2DArray(ue,0),ft=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}j.pixelStorei(37440,ue.flipY),j.pixelStorei(37441,ue.premultiplyAlpha),j.pixelStorei(3317,ue.unpackAlignment);const gt=j.getParameter(3314),zt=j.getParameter(32878),Pr=j.getParameter(3316),Oo=j.getParameter(3315),Go=j.getParameter(32877),wi=he.isCompressedTexture?he.mipmaps[0]:he.image;j.pixelStorei(3314,wi.width),j.pixelStorei(32878,wi.height),j.pixelStorei(3316,q.min.x),j.pixelStorei(3315,q.min.y),j.pixelStorei(32877,q.min.z),he.isDataTexture||he.isData3DTexture?j.texSubImage3D(ft,ge,le.x,le.y,le.z,Ne,at,Ye,He,vt,wi.data):he.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),j.compressedTexSubImage3D(ft,ge,le.x,le.y,le.z,Ne,at,Ye,He,wi.data)):j.texSubImage3D(ft,ge,le.x,le.y,le.z,Ne,at,Ye,He,vt,wi),j.pixelStorei(3314,gt),j.pixelStorei(32878,zt),j.pixelStorei(3316,Pr),j.pixelStorei(3315,Oo),j.pixelStorei(32877,Go),ge===0&&ue.generateMipmaps&&j.generateMipmap(ft),X.unbindTexture()},this.initTexture=function(q){q.isCubeTexture?Be.setTextureCube(q,0):q.isData3DTexture?Be.setTexture3D(q,0):q.isDataArrayTexture||q.isCompressedArrayTexture?Be.setTexture2DArray(q,0):Be.setTexture2D(q,0),X.unbindTexture()},this.resetState=function(){g=0,v=0,y=null,X.reset(),D.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Wre extends c0{}Wre.prototype.isWebGL1Renderer=!0;class yw extends kt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.backgroundBlurriness=this.backgroundBlurriness),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class Ore{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=pE,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=No()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,r){e*=this.stride,r*=t.stride;for(let i=0,s=this.stride;il)continue;f.applyMatrix4(this.matrixWorld);const x=e.ray.origin.distanceTo(f);xe.far||t.push({distance:x,point:u.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{const g=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let y=g,w=v-1;yl)continue;f.applyMatrix4(this.matrixWorld);const b=e.ray.origin.distanceTo(f);be.far||t.push({distance:b,point:u.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;si.far)return;s.push({distance:A,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class Yre{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const r=this.getUtoTmapping(e);return this.getPoint(r,t)}getPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}getSpacedPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let r,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)r=this.getPoint(o/e),s+=r.distanceTo(i),t.push(s),i=r;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const r=this.getLengths();let i=0;const s=r.length;let o;t?o=t:o=e*r[s-1];let a=0,l=s-1,A;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),A=r[i]-o,A<0)a=i+1;else if(A>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const c=r[i],f=r[i+1]-c,d=(o-c)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new We:new z);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const r=this.getUtoTmapping(e);return this.getTangent(r,t)}computeFrenetFrames(e,t){const r=new z,i=[],s=[],o=[],a=new z,l=new Le;for(let d=0;d<=e;d++){const h=d/e;i[d]=this.getTangentAt(h,new z)}s[0]=new z,o[0]=new z;let A=Number.MAX_VALUE;const c=Math.abs(i[0].x),u=Math.abs(i[0].y),f=Math.abs(i[0].z);c<=A&&(A=c,r.set(1,0,0)),u<=A&&(A=u,r.set(0,1,0)),f<=A&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();const h=Math.acos(fr(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(a,h))}o[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(fr(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let h=1;h<=e;h++)s[h].applyMatrix4(l.makeRotationAxis(i[h],d*h)),o[h].crossVectors(i[h],s[h])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class $C extends Ht{constructor(e=1,t=1,r=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const A=this;i=Math.floor(i),s=Math.floor(s);const c=[],u=[],f=[],d=[];let h=0;const p=[],m=r/2;let g=0;v(),o===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(c),this.setAttribute("position",new rn(u,3)),this.setAttribute("normal",new rn(f,3)),this.setAttribute("uv",new rn(d,2));function v(){const w=new z,C=new z;let b=0;const E=(t-e)/r;for(let x=0;x<=s;x++){const S=[],M=x/s,Z=M*(t-e)+e;for(let K=0;K<=i;K++){const _=K/i,B=_*l+a,F=Math.sin(B),R=Math.cos(B);C.x=Z*F,C.y=-M*r+m,C.z=Z*R,u.push(C.x,C.y,C.z),w.set(F,E,R).normalize(),f.push(w.x,w.y,w.z),d.push(_,1-M),S.push(h++)}p.push(S)}for(let x=0;x0)&&d.push(y,w,b),(g!==r-1||l0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class bI extends cs{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Re(16777215),this.specular=new Re(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Re(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_u,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=zC,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Xre extends cs{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_u,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Kre extends cs{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Re(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Re(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_u,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=zC,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function nA(n,e,t){return gZ(n)?new n.constructor(n.subarray(e,t!==void 0?t:n.length)):n.slice(e,t)}function Sv(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function gZ(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function jre(n){function e(i,s){return n[i]-n[s]}const t=n.length,r=new Array(t);for(let i=0;i!==t;++i)r[i]=i;return r.sort(e),r}function sN(n,e,t){const r=n.length,i=new n.constructor(r);for(let s=0,o=0;o!==r;++s){const a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=n[a+l]}return i}function mZ(n,e,t,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[i++];while(s!==void 0);else do o=s[r],o!==void 0&&(e.push(s.time),t.push(o)),s=n[i++];while(s!==void 0)}class f0{constructor(e,t,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let r=this._cachedIndex,i=t[r],s=t[r-1];e:{t:{let o;n:{r:if(!(e=s)){const a=t[1];e=s)break t}o=r,r=0;break n}break e}for(;r>>1;et;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=nA(r,s,o),this.values=nA(this.values,s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,i=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&gZ(i))for(let a=0,l=i.length;a!==l;++a){const A=i[a];if(isNaN(A)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,A),e=!1;break}}return e}optimize(){const e=nA(this.times),t=nA(this.values),r=this.getValueSize(),i=this.getInterpolation()===Xx,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*r,l=o*r,A=0;A!==r;++A)t[l+A]=t[a+A];++o}return o!==e.length?(this.times=nA(e,0,o),this.values=nA(t,0,o*r)):(this.times=e,this.values=t),this}clone(){const e=nA(this.times,0),t=nA(this.values,0),r=this.constructor,i=new r(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Da.prototype.TimeBufferType=Float32Array;Da.prototype.ValueBufferType=Float32Array;Da.prototype.DefaultInterpolation=gu;class Vh extends Da{}Vh.prototype.ValueTypeName="bool";Vh.prototype.ValueBufferType=Array;Vh.prototype.DefaultInterpolation=yh;Vh.prototype.InterpolantFactoryMethodLinear=void 0;Vh.prototype.InterpolantFactoryMethodSmooth=void 0;class yZ extends Da{}yZ.prototype.ValueTypeName="color";class wh extends Da{}wh.prototype.ValueTypeName="number";class eie extends f0{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-t)/(i-t);let A=e*a;for(let c=A+a;A!==c;A+=4)tt.slerpFlat(s,0,o,A-a,o,A,l);return s}}class Qa extends Da{InterpolantFactoryMethodLinear(e){return new eie(this.times,this.values,this.getValueSize(),e)}}Qa.prototype.ValueTypeName="quaternion";Qa.prototype.DefaultInterpolation=gu;Qa.prototype.InterpolantFactoryMethodSmooth=void 0;class Lh extends Da{}Lh.prototype.ValueTypeName="string";Lh.prototype.ValueBufferType=Array;Lh.prototype.DefaultInterpolation=yh;Lh.prototype.InterpolantFactoryMethodLinear=void 0;Lh.prototype.InterpolantFactoryMethodSmooth=void 0;class ec extends Da{}ec.prototype.ValueTypeName="vector";class vu{constructor(e,t=-1,r,i=c_){this.name=e,this.tracks=r,this.duration=t,this.blendMode=i,this.uuid=No(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],r=e.tracks,i=1/(e.fps||1);for(let o=0,a=r.length;o!==a;++o)t.push(nie(r[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],r=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=r.length;s!==o;++s)t.push(Da.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(e,t,r,i){const s=t.length,o=[];for(let a=0;a1){const u=c[1];let f=i[u];f||(i[u]=f=[]),f.push(A)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,r));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const r=function(u,f,d,h,p){if(d.length!==0){const m=[],g=[];mZ(d,m,g,h),m.length!==0&&p.push(new u(f,m,g))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const A=e.hierarchy||[];for(let u=0;u{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ya[e]!==void 0){Ya[e].push({onLoad:t,onProgress:r,onError:i});return}Ya[e]=[],Ya[e].push({onLoad:t,onProgress:r,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(A=>{if(A.status===200||A.status===0){if(A.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||A.body===void 0||A.body.getReader===void 0)return A;const c=Ya[e],u=A.body.getReader(),f=A.headers.get("Content-Length"),d=f?parseInt(f):0,h=d!==0;let p=0;const m=new ReadableStream({start(g){v();function v(){u.read().then(({done:y,value:w})=>{if(y)g.close();else{p+=w.byteLength;const C=new ProgressEvent("progress",{lengthComputable:h,loaded:p,total:d});for(let b=0,E=c.length;b{switch(l){case"arraybuffer":return A.arrayBuffer();case"blob":return A.blob();case"document":return A.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return A.json();default:if(a===void 0)return A.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return A.arrayBuffer().then(h=>d.decode(h))}}}).then(A=>{Ch.add(e,A);const c=Ya[e];delete Ya[e];for(let u=0,f=c.length;u{const c=Ya[e];if(c===void 0)throw this.manager.itemError(e),A;delete Ya[e];for(let u=0,f=c.length;u{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class wZ extends Ph{constructor(e){super(e)}load(e,t,r,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Ch.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=Um("img");function l(){c(),Ch.add(e,this),t&&t(this),s.manager.itemEnd(e)}function A(u){c(),i&&i(u),s.manager.itemError(e),s.manager.itemEnd(e)}function c(){a.removeEventListener("load",l,!1),a.removeEventListener("error",A,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",A,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class Nu extends Ph{constructor(e){super(e)}load(e,t,r,i){const s=new ir,o=new wZ(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},r,i),s}}class qC extends kt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Re(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const xI=new Le,oN=new z,aN=new z;class B_{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new We(512,512),this.map=null,this.mapPass=null,this.matrix=new Le,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new p_,this._frameExtents=new We(1,1),this._viewportCount=1,this._viewports=[new Tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;oN.setFromMatrixPosition(e.matrixWorld),t.position.copy(oN),aN.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(aN),t.updateMatrixWorld(),xI.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xI),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(xI)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class sie extends B_{constructor(){super(new Mr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,r=Em*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(r!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=r,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class CZ extends qC{constructor(e,t,r=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(kt.DefaultUp),this.updateMatrix(),this.target=new kt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new sie}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const lN=new Le,Sp=new z,II=new z;class oie extends B_{constructor(){super(new Mr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new We(4,2),this._viewportCount=6,this._viewports=[new Tt(2,1,1,1),new Tt(0,1,1,1),new Tt(3,1,1,1),new Tt(1,1,1,1),new Tt(3,0,1,1),new Tt(1,0,1,1)],this._cubeDirections=[new z(1,0,0),new z(-1,0,0),new z(0,0,1),new z(0,0,-1),new z(0,1,0),new z(0,-1,0)],this._cubeUps=[new z(0,1,0),new z(0,1,0),new z(0,1,0),new z(0,1,0),new z(0,0,1),new z(0,0,-1)]}updateMatrices(e,t=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Sp.setFromMatrixPosition(e.matrixWorld),r.position.copy(Sp),II.copy(r.position),II.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(II),r.updateMatrixWorld(),i.makeTranslation(-Sp.x,-Sp.y,-Sp.z),lN.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lN)}}class BE extends qC{constructor(e,t,r=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new oie}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class aie extends B_{constructor(){super(new Mu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class w_ extends qC{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(kt.DefaultUp),this.updateMatrix(),this.target=new kt,this.shadow=new aie}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class bZ extends qC{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class ba{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let r=0,i=e.length;r"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Ch.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){Ch.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}class xZ{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=AN(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=AN();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function AN(){return(typeof performance>"u"?Date:performance).now()}class Aie{constructor(e,t,r){this.binding=e,this.valueSize=r;let i,s,o;switch(t){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const r=this.buffer,i=this.valueSize,s=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)r[s+a]=r[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(r,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,r=this.valueSize,i=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,r),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,r=this.buffer,i=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(r,i,l,1-s,t)}o>0&&this._mixBufferRegionAdditive(r,i,this._addIndex*t,1,t);for(let l=t,A=t+t;l!==A;++l)if(r[l]!==r[l+t]){a.setValue(r,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,r=this.valueSize,i=r*this._origIndex;e.getValue(t,i);for(let s=r,o=i;s!==o;++s)t[s]=t[i+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let r=e;r=.5)for(let o=0;o!==s;++o)e[t+o]=e[r+o]}_slerp(e,t,r,i){tt.slerpFlat(e,t,e,t,e,r,i)}_slerpAdditive(e,t,r,i,s){const o=this._workIndex*s;tt.multiplyQuaternionsFlat(e,o,e,t,e,r),tt.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,r,i,s){const o=1-i;for(let a=0;a!==s;++a){const l=t+a;e[l]=e[l]*o+e[r+a]*i}}_lerpAdditive(e,t,r,i,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[r+o]*i}}}const C_="\\[\\]\\.:\\/",cie=new RegExp("["+C_+"]","g"),b_="[^"+C_+"]",uie="[^"+C_.replace("\\.","")+"]",fie=/((?:WC+[\/:])*)/.source.replace("WC",b_),die=/(WCOD+)?/.source.replace("WCOD",uie),hie=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",b_),pie=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",b_),gie=new RegExp("^"+fie+die+hie+pie+"$"),mie=["material","materials","bones","map"];class vie{constructor(e,t,r){const i=r||Bt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(e,t)}setValue(e,t){const r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}}class Bt{constructor(e,t,r){this.path=t,this.parsedPath=r||Bt.parseTrackName(t),this.node=Bt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new Bt.Composite(e,t,r):new Bt(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(cie,"")}static parseTrackName(e){const t=gie.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=r.nodeName.substring(i+1);mie.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(t);if(r!==void 0)return r}if(e.children){const r=function(s){for(let o=0;o0){const l=this._interpolants,A=this._propertyBindings;switch(this.blendMode){case I$:for(let c=0,u=l.length;c!==u;++c)l[c].evaluate(o),A[c].accumulateAdditive(a);break;case c_:default:for(let c=0,u=l.length;c!==u;++c)l[c].evaluate(o),A[c].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const r=this._weightInterpolant;if(r!==null){const i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const r=this._timeScaleInterpolant;if(r!==null){const i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,r=this.loop;let i=this.time+e,s=this._loopCount;const o=r===x$;if(e===0)return s===-1?i:o&&(s&1)===1?t-i:i;if(r===C$){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const A=e<0;this._setEndings(A,!A,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return t-i}return i}_setEndings(e,t,r){const i=this._interpolantSettings;r?(i.endingStart=Cd,i.endingEnd=Cd):(e?i.endingStart=this.zeroSlopeAtStart?Cd:wd:i.endingStart=mw,t?i.endingEnd=this.zeroSlopeAtEnd?Cd:wd:i.endingEnd=mw)}_scheduleFading(e,t,r){const i=this._mixer,s=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=r,this}}const Bie=new Float32Array(1);class wie extends dc{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const r=e._localRoot||this._root,i=e._clip.tracks,s=i.length,o=e._propertyBindings,a=e._interpolants,l=r.uuid,A=this._bindingsByRootAndName;let c=A[l];c===void 0&&(c={},A[l]=c);for(let u=0;u!==s;++u){const f=i[u],d=f.name;let h=c[d];if(h!==void 0)++h.referenceCount,o[u]=h;else{if(h=o[u],h!==void 0){h._cacheIndex===null&&(++h.referenceCount,this._addInactiveBinding(h,l,d));continue}const p=t&&t._propertyBindings[u].binding.parsedPath;h=new Aie(Bt.create(r,d,p),f.ValueTypeName,f.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,l,d),o[u]=h}a[u].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const r=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,r)}const t=e._propertyBindings;for(let r=0,i=t.length;r!==i;++r){const s=t[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let r=0,i=t.length;r!==i;++r){const s=t[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--r)e[r].stop();return this}update(e){e*=this.timeScale;const t=this._actions,r=this._nActiveActions,i=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let A=0;A!==r;++A)t[A]._update(i,e,s,o);const a=this._bindings,l=this._nActiveBindings;for(let A=0;A!==l;++A)a[A].apply(o);return this}setTime(e){this.time=0;for(let t=0;tMath.PI&&(Ve-=we),_e<-Math.PI?_e+=we:_e>Math.PI&&(_e-=we),Ve<=_e?a.theta=Math.max(Ve,Math.min(_e,a.theta)):a.theta=a.theta>(Ve+_e)/2?Math.max(Ve,a.theta):Math.min(_e,a.theta)),a.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,a.phi)),a.makeSafe(),a.radius*=A,a.radius=Math.max(r.minDistance,Math.min(r.maxDistance,a.radius)),r.enableDamping===!0?r.target.addScaledVector(c,r.dampingFactor):r.target.add(c),I.setFromSpherical(a),I.applyQuaternion($),Ee.copy(r.target).add(I),r.object.lookAt(r.target),r.enableDamping===!0?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,c.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),c.set(0,0,0)),A=1,u||ee.distanceToSquared(r.object.position)>o||8*(1-te.dot(r.object.quaternion))>o?(r.dispatchEvent(hN),ee.copy(r.object.position),te.copy(r.object.quaternion),u=!1,!0):!1}}(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",se),r.domElement.removeEventListener("pointerdown",pe),r.domElement.removeEventListener("pointercancel",Oe),r.domElement.removeEventListener("wheel",Ge),r.domElement.removeEventListener("pointermove",Fe),r.domElement.removeEventListener("pointerup",rt),r._domElementKeyEvents!==null&&r._domElementKeyEvents.removeEventListener("keydown",Xe)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const o=1e-6,a=new fN,l=new fN;let A=1;const c=new z;let u=!1;const f=new We,d=new We,h=new We,p=new We,m=new We,g=new We,v=new We,y=new We,w=new We,C=[],b={};function E(){return 2*Math.PI/60/60*r.autoRotateSpeed}function x(){return Math.pow(.95,r.zoomSpeed)}function S(I){l.theta-=I}function M(I){l.phi-=I}const Z=function(){const I=new z;return function($,ee){I.setFromMatrixColumn(ee,0),I.multiplyScalar(-$),c.add(I)}}(),K=function(){const I=new z;return function($,ee){r.screenSpacePanning===!0?I.setFromMatrixColumn(ee,1):(I.setFromMatrixColumn(ee,0),I.crossVectors(r.object.up,I)),I.multiplyScalar($),c.add(I)}}(),_=function(){const I=new z;return function($,ee){const te=r.domElement;if(r.object.isPerspectiveCamera){const we=r.object.position;I.copy(we).sub(r.target);let Ce=I.length();Ce*=Math.tan(r.object.fov/2*Math.PI/180),Z(2*$*Ce/te.clientHeight,r.object.matrix),K(2*ee*Ce/te.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(Z($*(r.object.right-r.object.left)/r.object.zoom/te.clientWidth,r.object.matrix),K(ee*(r.object.top-r.object.bottom)/r.object.zoom/te.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}}();function B(I){r.object.isPerspectiveCamera?A/=I:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom*I)),r.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function F(I){r.object.isPerspectiveCamera?A*=I:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/I)),r.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function R(I){f.set(I.clientX,I.clientY)}function k(I){v.set(I.clientX,I.clientY)}function T(I){p.set(I.clientX,I.clientY)}function V(I){d.set(I.clientX,I.clientY),h.subVectors(d,f).multiplyScalar(r.rotateSpeed);const D=r.domElement;S(2*Math.PI*h.x/D.clientHeight),M(2*Math.PI*h.y/D.clientHeight),f.copy(d),r.update()}function O(I){y.set(I.clientX,I.clientY),w.subVectors(y,v),w.y>0?B(x()):w.y<0&&F(x()),v.copy(y),r.update()}function L(I){m.set(I.clientX,I.clientY),g.subVectors(m,p).multiplyScalar(r.panSpeed),_(g.x,g.y),p.copy(m),r.update()}function U(I){I.deltaY<0?F(x()):I.deltaY>0&&B(x()),r.update()}function H(I){let D=!1;switch(I.code){case r.keys.UP:_(0,r.keyPanSpeed),D=!0;break;case r.keys.BOTTOM:_(0,-r.keyPanSpeed),D=!0;break;case r.keys.LEFT:_(r.keyPanSpeed,0),D=!0;break;case r.keys.RIGHT:_(-r.keyPanSpeed,0),D=!0;break}D&&(I.preventDefault(),r.update())}function Ae(){if(C.length===1)f.set(C[0].pageX,C[0].pageY);else{const I=.5*(C[0].pageX+C[1].pageX),D=.5*(C[0].pageY+C[1].pageY);f.set(I,D)}}function N(){if(C.length===1)p.set(C[0].pageX,C[0].pageY);else{const I=.5*(C[0].pageX+C[1].pageX),D=.5*(C[0].pageY+C[1].pageY);p.set(I,D)}}function j(){const I=C[0].pageX-C[1].pageX,D=C[0].pageY-C[1].pageY,$=Math.sqrt(I*I+D*D);v.set(0,$)}function oe(){r.enableZoom&&j(),r.enablePan&&N()}function ie(){r.enableZoom&&j(),r.enableRotate&&Ae()}function de(I){if(C.length==1)d.set(I.pageX,I.pageY);else{const $=Q(I),ee=.5*(I.pageX+$.x),te=.5*(I.pageY+$.y);d.set(ee,te)}h.subVectors(d,f).multiplyScalar(r.rotateSpeed);const D=r.domElement;S(2*Math.PI*h.x/D.clientHeight),M(2*Math.PI*h.y/D.clientHeight),f.copy(d)}function X(I){if(C.length===1)m.set(I.pageX,I.pageY);else{const D=Q(I),$=.5*(I.pageX+D.x),ee=.5*(I.pageY+D.y);m.set($,ee)}g.subVectors(m,p).multiplyScalar(r.panSpeed),_(g.x,g.y),p.copy(m)}function ne(I){const D=Q(I),$=I.pageX-D.x,ee=I.pageY-D.y,te=Math.sqrt($*$+ee*ee);y.set(0,te),w.set(0,Math.pow(y.y/v.y,r.zoomSpeed)),B(w.y),v.copy(y)}function ae(I){r.enableZoom&&ne(I),r.enablePan&&X(I)}function Be(I){r.enableZoom&&ne(I),r.enableRotate&&de(I)}function pe(I){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(I.pointerId),r.domElement.addEventListener("pointermove",Fe),r.domElement.addEventListener("pointerup",rt)),fe(I),I.pointerType==="touch"?G(I):ke(I))}function Fe(I){r.enabled!==!1&&(I.pointerType==="touch"?J(I):Qe(I))}function rt(I){ve(I),C.length===0&&(r.domElement.releasePointerCapture(I.pointerId),r.domElement.removeEventListener("pointermove",Fe),r.domElement.removeEventListener("pointerup",rt)),r.dispatchEvent(pN),s=i.NONE}function Oe(I){ve(I)}function ke(I){let D;switch(I.button){case 0:D=r.mouseButtons.LEFT;break;case 1:D=r.mouseButtons.MIDDLE;break;case 2:D=r.mouseButtons.RIGHT;break;default:D=-1}switch(D){case Yu.DOLLY:if(r.enableZoom===!1)return;k(I),s=i.DOLLY;break;case Yu.ROTATE:if(I.ctrlKey||I.metaKey||I.shiftKey){if(r.enablePan===!1)return;T(I),s=i.PAN}else{if(r.enableRotate===!1)return;R(I),s=i.ROTATE}break;case Yu.PAN:if(I.ctrlKey||I.metaKey||I.shiftKey){if(r.enableRotate===!1)return;R(I),s=i.ROTATE}else{if(r.enablePan===!1)return;T(I),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(FI)}function Qe(I){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;V(I);break;case i.DOLLY:if(r.enableZoom===!1)return;O(I);break;case i.PAN:if(r.enablePan===!1)return;L(I);break}}function Ge(I){r.enabled===!1||r.enableZoom===!1||s!==i.NONE||(I.preventDefault(),r.dispatchEvent(FI),U(I),r.dispatchEvent(pN))}function Xe(I){r.enabled===!1||r.enablePan===!1||H(I)}function G(I){switch(W(I),C.length){case 1:switch(r.touches.ONE){case Xu.ROTATE:if(r.enableRotate===!1)return;Ae(),s=i.TOUCH_ROTATE;break;case Xu.PAN:if(r.enablePan===!1)return;N(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case Xu.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;oe(),s=i.TOUCH_DOLLY_PAN;break;case Xu.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;ie(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(FI)}function J(I){switch(W(I),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;de(I),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;X(I),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;ae(I),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;Be(I),r.update();break;default:s=i.NONE}}function se(I){r.enabled!==!1&&I.preventDefault()}function fe(I){C.push(I)}function ve(I){delete b[I.pointerId];for(let D=0;D=2.0 are supported."));return}const l=new $ie(s,{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 A=0;A=0&&a[c]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+c+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(r,i)}parseAsync(e,t){const r=this;return new Promise(function(i,s){r.parse(e,t,i,s)})}}function xie(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const Ct={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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Iie{constructor(e){this.parser=e,this.name=Ct.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,i=t.length;r=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Die{constructor(e){this.parser=e,this.name=Ct.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,i=r.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=r.textureLoader;if(a.uri){const A=r.options.manager.getHandler(a.uri);A!==null&&(l=A)}return this.detectSupport().then(function(A){if(A)return r.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.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(t.height===1)}})),this.isSupported}}class kie{constructor(e){this.name=Ct.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const i=r.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.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 s.then(function(a){const l=i.byteOffset||0,A=i.byteLength||0,c=i.count,u=i.byteStride,f=new Uint8Array(a,l,A);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(c,u,f,i.mode,i.filter).then(function(d){return d.buffer}):o.ready.then(function(){const d=new ArrayBuffer(c*u);return o.decodeGltfBuffer(new Uint8Array(d),c,u,f,i.mode,i.filter),d})})}else return null}}class Vie{constructor(e){this.name=Ct.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const i=t.meshes[r.mesh];for(const A of i.primitives)if(A.mode!==Ns.TRIANGLES&&A.mode!==Ns.TRIANGLE_STRIP&&A.mode!==Ns.TRIANGLE_FAN&&A.mode!==void 0)return null;const o=r.extensions[this.name].attributes,a=[],l={};for(const A in o)a.push(this.parser.getDependency("accessor",o[A]).then(c=>(l[A]=c,l[A])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(A=>{const c=A.pop(),u=c.isGroup?c.children:[c],f=A[0].count,d=[];for(const h of u){const p=new Le,m=new z,g=new tt,v=new z(1,1,1),y=new jC(h.geometry,h.material,f);for(let w=0;wc||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/F.x),i.x=s.x*F.x,B.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/F.y),i.y=s.y*F.y,B.mapSize.y=s.y)),B.map===null){const k=this.type!==ug?{minFilter:er,magFilter:er}:{};B.map=new _a(i.x,i.y,k),B.map.texture.name=_.name+".shadowMap",B.camera.updateProjectionMatrix()}n.setRenderTarget(B.map),n.clear();const R=B.getViewportCount();for(let k=0;k0){const K=M.uuid,_=C.uuid;let B=A[K];B===void 0&&(B={},A[K]=B);let F=B[_];F===void 0&&(F=M.clone(),B[_]=F),M=F}return M.visible=C.visible,M.wireframe=C.wireframe,S===ug?M.side=C.shadowSide!==null?C.shadowSide:C.side:M.side=C.shadowSide!==null?C.shadowSide:u[C.side],M.alphaMap=C.alphaMap,M.alphaTest=C.alphaTest,M.clipShadows=C.clipShadows,M.clippingPlanes=C.clippingPlanes,M.clipIntersection=C.clipIntersection,M.displacementMap=C.displacementMap,M.displacementScale=C.displacementScale,M.displacementBias=C.displacementBias,M.wireframeLinewidth=C.wireframeLinewidth,M.linewidth=C.linewidth,b.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(b.matrixWorld),M.nearDistance=E,M.farDistance=x),M}function y(w,C,b,E,x){if(w.visible===!1)return;if(w.layers.test(C.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&x===ug)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,w.matrixWorld);const Z=e.update(w),K=w.material;if(Array.isArray(K)){const _=Z.groups;for(let B=0,F=_.length;B=1):T.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(T)[1]),R=k>=2);let V=null,O={};const L=n.getParameter(3088),U=n.getParameter(2978),H=new Tt().fromArray(L),le=new Tt().fromArray(U);function N(re,ye,be){const Ue=new Uint8Array(4),Je=n.createTexture();n.bindTexture(re,Je),n.texParameteri(re,10241,9728),n.texParameteri(re,10240,9728);for(let qe=0;qe"u"?"":navigator.userAgent),h=new WeakMap;let p;const m=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(G,J){return g?new OffscreenCanvas(G,J):Um("canvas")}function y(G,J,se,fe){let ve=1;if((G.width>fe||G.height>fe)&&(ve=fe/Math.max(G.width,G.height)),ve<1||J===!0)if(typeof HTMLImageElement<"u"&&G instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&G instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&G instanceof ImageBitmap){const W=J?vw:Math.floor,Q=W(ve*G.width),I=W(ve*G.height);p===void 0&&(p=v(Q,I));const D=se?v(Q,I):p;return D.width=Q,D.height=I,D.getContext("2d").drawImage(G,0,0,Q,I),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+G.width+"x"+G.height+") to ("+Q+"x"+I+")."),D}else return"data"in G&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+G.width+"x"+G.height+")."),G;return G}function w(G){return mE(G.width)&&mE(G.height)}function C(G){return a?!1:G.wrapS!==di||G.wrapT!==di||G.minFilter!==er&&G.minFilter!==Ai}function b(G,J){return G.generateMipmaps&&J&&G.minFilter!==er&&G.minFilter!==Ai}function E(G){n.generateMipmap(G)}function x(G,J,se,fe,ve=!1){if(a===!1)return J;if(G!==null){if(n[G]!==void 0)return n[G];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+G+"'")}let W=J;return J===6403&&(se===5126&&(W=33326),se===5131&&(W=33325),se===5121&&(W=33321)),J===33319&&(se===5126&&(W=33328),se===5131&&(W=33327),se===5121&&(W=33323)),J===6408&&(se===5126&&(W=34836),se===5131&&(W=34842),se===5121&&(W=fe===ht&&ve===!1?35907:32856),se===32819&&(W=32854),se===32820&&(W=32855)),(W===33325||W===33326||W===33327||W===33328||W===34842||W===34836)&&e.get("EXT_color_buffer_float"),W}function S(G,J,se){return b(G,se)===!0||G.isFramebufferTexture&&G.minFilter!==er&&G.minFilter!==Ai?Math.log2(Math.max(J.width,J.height))+1:G.mipmaps!==void 0&&G.mipmaps.length>0?G.mipmaps.length:G.isCompressedTexture&&Array.isArray(G.image)?J.mipmaps.length:1}function M(G){return G===er||G===pw||G===gw?9728:9729}function Z(G){const J=G.target;J.removeEventListener("dispose",Z),_(J),J.isVideoTexture&&h.delete(J)}function K(G){const J=G.target;J.removeEventListener("dispose",K),F(J)}function _(G){const J=r.get(G);if(J.__webglInit===void 0)return;const se=G.source,fe=m.get(se);if(fe){const ve=fe[J.__cacheKey];ve.usedTimes--,ve.usedTimes===0&&B(G),Object.keys(fe).length===0&&m.delete(se)}r.remove(G)}function B(G){const J=r.get(G);n.deleteTexture(J.__webglTexture);const se=G.source,fe=m.get(se);delete fe[J.__cacheKey],o.memory.textures--}function F(G){const J=G.texture,se=r.get(G),fe=r.get(J);if(fe.__webglTexture!==void 0&&(n.deleteTexture(fe.__webglTexture),o.memory.textures--),G.depthTexture&&G.depthTexture.dispose(),G.isWebGLCubeRenderTarget)for(let ve=0;ve<6;ve++)n.deleteFramebuffer(se.__webglFramebuffer[ve]),se.__webglDepthbuffer&&n.deleteRenderbuffer(se.__webglDepthbuffer[ve]);else{if(n.deleteFramebuffer(se.__webglFramebuffer),se.__webglDepthbuffer&&n.deleteRenderbuffer(se.__webglDepthbuffer),se.__webglMultisampledFramebuffer&&n.deleteFramebuffer(se.__webglMultisampledFramebuffer),se.__webglColorRenderbuffer)for(let ve=0;ve=l&&console.warn("THREE.WebGLTextures: Trying to use "+G+" texture units while this GPU supports only "+l),R+=1,G}function V(G){const J=[];return J.push(G.wrapS),J.push(G.wrapT),J.push(G.wrapR||0),J.push(G.magFilter),J.push(G.minFilter),J.push(G.anisotropy),J.push(G.internalFormat),J.push(G.format),J.push(G.type),J.push(G.generateMipmaps),J.push(G.premultiplyAlpha),J.push(G.flipY),J.push(G.unpackAlignment),J.push(G.encoding),J.join()}function O(G,J){const se=r.get(G);if(G.isVideoTexture&&Ge(G),G.isRenderTargetTexture===!1&&G.version>0&&se.__version!==G.version){const fe=G.image;if(fe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(fe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(se,G,J);return}}t.bindTexture(3553,se.__webglTexture,33984+J)}function L(G,J){const se=r.get(G);if(G.version>0&&se.__version!==G.version){ie(se,G,J);return}t.bindTexture(35866,se.__webglTexture,33984+J)}function U(G,J){const se=r.get(G);if(G.version>0&&se.__version!==G.version){ie(se,G,J);return}t.bindTexture(32879,se.__webglTexture,33984+J)}function H(G,J){const se=r.get(G);if(G.version>0&&se.__version!==G.version){de(se,G,J);return}t.bindTexture(34067,se.__webglTexture,33984+J)}const le={[hs]:10497,[di]:33071,[Im]:33648},N={[er]:9728,[pw]:9984,[gw]:9986,[Ai]:9729,[A_]:9985,[Su]:9987};function j(G,J,se){if(se?(n.texParameteri(G,10242,le[J.wrapS]),n.texParameteri(G,10243,le[J.wrapT]),(G===32879||G===35866)&&n.texParameteri(G,32882,le[J.wrapR]),n.texParameteri(G,10240,N[J.magFilter]),n.texParameteri(G,10241,N[J.minFilter])):(n.texParameteri(G,10242,33071),n.texParameteri(G,10243,33071),(G===32879||G===35866)&&n.texParameteri(G,32882,33071),(J.wrapS!==di||J.wrapT!==di)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(G,10240,M(J.magFilter)),n.texParameteri(G,10241,M(J.minFilter)),J.minFilter!==er&&J.minFilter!==Ai&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const fe=e.get("EXT_texture_filter_anisotropic");if(J.type===FA&&e.has("OES_texture_float_linear")===!1||a===!1&&J.type===Fm&&e.has("OES_texture_half_float_linear")===!1)return;(J.anisotropy>1||r.get(J).__currentAnisotropy)&&(n.texParameterf(G,fe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(J.anisotropy,i.getMaxAnisotropy())),r.get(J).__currentAnisotropy=J.anisotropy)}}function oe(G,J){let se=!1;G.__webglInit===void 0&&(G.__webglInit=!0,J.addEventListener("dispose",Z));const fe=J.source;let ve=m.get(fe);ve===void 0&&(ve={},m.set(fe,ve));const W=V(J);if(W!==G.__cacheKey){ve[W]===void 0&&(ve[W]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,se=!0),ve[W].usedTimes++;const Q=ve[G.__cacheKey];Q!==void 0&&(ve[G.__cacheKey].usedTimes--,Q.usedTimes===0&&B(J)),G.__cacheKey=W,G.__webglTexture=ve[W].texture}return se}function ie(G,J,se){let fe=3553;(J.isDataArrayTexture||J.isCompressedArrayTexture)&&(fe=35866),J.isData3DTexture&&(fe=32879);const ve=oe(G,J),W=J.source;t.bindTexture(fe,G.__webglTexture,33984+se);const Q=r.get(W);if(W.version!==Q.__version||ve===!0){t.activeTexture(33984+se),n.pixelStorei(37440,J.flipY),n.pixelStorei(37441,J.premultiplyAlpha),n.pixelStorei(3317,J.unpackAlignment),n.pixelStorei(37443,0);const I=C(J)&&w(J.image)===!1;let D=y(J.image,I,!1,c);D=Xe(J,D);const $=w(D)||a,ee=s.convert(J.format,J.encoding);let te=s.convert(J.type),we=x(J.internalFormat,ee,te,J.encoding,J.isVideoTexture);j(fe,J,$);let Ce;const Ee=J.mipmaps,Ve=a&&J.isVideoTexture!==!0,_e=Q.__version===void 0||ve===!0,re=S(J,D,$);if(J.isDepthTexture)we=6402,a?J.type===FA?we=36012:J.type===Jc?we=33190:J.type===Od?we=35056:we=33189:J.type===FA&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),J.format===ru&&we===6402&&J.type!==jG&&J.type!==Jc&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),J.type=Jc,te=s.convert(J.type)),J.format===vh&&we===6402&&(we=34041,J.type!==Od&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),J.type=Od,te=s.convert(J.type))),_e&&(Ve?t.texStorage2D(3553,1,we,D.width,D.height):t.texImage2D(3553,0,we,D.width,D.height,0,ee,te,null));else if(J.isDataTexture)if(Ee.length>0&&$){Ve&&_e&&t.texStorage2D(3553,re,we,Ee[0].width,Ee[0].height);for(let ye=0,be=Ee.length;ye>=1,be>>=1}}else if(Ee.length>0&&$){Ve&&_e&&t.texStorage2D(3553,re,we,Ee[0].width,Ee[0].height);for(let ye=0,be=Ee.length;ye0&&_e++,t.texStorage2D(34067,_e,Ce,D[0].width,D[0].height));for(let ye=0;ye<6;ye++)if(I){Ee?t.texSubImage2D(34069+ye,0,0,0,D[ye].width,D[ye].height,te,we,D[ye].data):t.texImage2D(34069+ye,0,Ce,D[ye].width,D[ye].height,0,te,we,D[ye].data);for(let be=0;be=34069&&ve<=34074)&&n.framebufferTexture2D(36160,fe,ve,r.get(se).__webglTexture,0),t.bindFramebuffer(36160,null)}function ne(G,J,se){if(n.bindRenderbuffer(36161,G),J.depthBuffer&&!J.stencilBuffer){let fe=33189;if(se||Qe(J)){const ve=J.depthTexture;ve&&ve.isDepthTexture&&(ve.type===FA?fe=36012:ve.type===Jc&&(fe=33190));const W=ke(J);Qe(J)?f.renderbufferStorageMultisampleEXT(36161,W,fe,J.width,J.height):n.renderbufferStorageMultisample(36161,W,fe,J.width,J.height)}else n.renderbufferStorage(36161,fe,J.width,J.height);n.framebufferRenderbuffer(36160,36096,36161,G)}else if(J.depthBuffer&&J.stencilBuffer){const fe=ke(J);se&&Qe(J)===!1?n.renderbufferStorageMultisample(36161,fe,35056,J.width,J.height):Qe(J)?f.renderbufferStorageMultisampleEXT(36161,fe,35056,J.width,J.height):n.renderbufferStorage(36161,34041,J.width,J.height),n.framebufferRenderbuffer(36160,33306,36161,G)}else{const fe=J.isWebGLMultipleRenderTargets===!0?J.texture:[J.texture];for(let ve=0;ve0&&Qe(G)===!1){const I=W?J:[J];se.__webglMultisampledFramebuffer=n.createFramebuffer(),se.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,se.__webglMultisampledFramebuffer);for(let D=0;D0&&Qe(G)===!1){const J=G.isWebGLMultipleRenderTargets?G.texture:[G.texture],se=G.width,fe=G.height;let ve=16384;const W=[],Q=G.stencilBuffer?33306:36096,I=r.get(G),D=G.isWebGLMultipleRenderTargets===!0;if(D)for(let $=0;$0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&J.__useRenderToTexture!==!1}function Ge(G){const J=o.render.frame;h.get(G)!==J&&(h.set(G,J),G.update())}function Xe(G,J){const se=G.encoding,fe=G.format,ve=G.type;return G.isCompressedTexture===!0||G.isVideoTexture===!0||G.format===gE||se!==ps&&(se===ht?a===!1?e.has("EXT_sRGB")===!0&&fe===br?(G.format=gE,G.minFilter=Ai,G.generateMipmaps=!1):J=rZ.sRGBToLinear(J):(fe!==br||ve!==$A)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",se)),J}this.allocateTextureUnit=T,this.resetTextureUnits=k,this.setTexture2D=O,this.setTexture2DArray=L,this.setTexture3D=U,this.setTextureCube=H,this.rebindTextures=pe,this.setupRenderTarget=Fe,this.updateRenderTargetMipmap=rt,this.updateMultisampleRenderTarget=Oe,this.setupDepthRenderbuffer=Be,this.setupFrameBufferTexture=X,this.useMultisampledRTT=Qe}function Tre(n,e,t){const r=t.isWebGL2;function i(s,o=null){let a;if(s===$A)return 5121;if(s===u$)return 32819;if(s===f$)return 32820;if(s===l$)return 5120;if(s===A$)return 5122;if(s===jG)return 5123;if(s===c$)return 5124;if(s===Jc)return 5125;if(s===FA)return 5126;if(s===Fm)return r?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===d$)return 6406;if(s===br)return 6408;if(s===h$)return 6409;if(s===p$)return 6410;if(s===ru)return 6402;if(s===vh)return 34041;if(s===g$)return 6403;if(s===$G)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===gE)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===m$)return 36244;if(s===v$)return 33319;if(s===y$)return 33320;if(s===B$)return 36249;if(s===Jx||s===Hx||s===zx||s===Yx)if(o===ht)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Jx)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Hx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===zx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Yx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Jx)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Hx)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===zx)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Yx)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Z2||s===J2||s===H2||s===z2)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Z2)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===J2)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===H2)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===z2)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===w$)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Y2||s===X2)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Y2)return o===ht?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===X2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===K2||s===j2||s===$2||s===q2||s===eT||s===tT||s===nT||s===rT||s===iT||s===sT||s===oT||s===aT||s===lT||s===AT)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===K2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===j2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===$2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===q2)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===eT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===tT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===nT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===rT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===iT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===sT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===oT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===aT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===lT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===AT)return o===ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===cT)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===cT)return o===ht?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===Od?r?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:i}}class Nre extends Mr{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Tr extends kt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Dre={type:"move"};class wI{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Tr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Tr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new z,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new z),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Tr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new z,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new z),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,r){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,A=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(A&&e.hand){o=!0;for(const p of e.hand.values()){const m=t.getJointPose(p,r);if(A.joints[p.jointName]===void 0){const v=new Tr;v.matrixAutoUpdate=!1,v.visible=!1,A.joints[p.jointName]=v,A.add(v)}const g=A.joints[p.jointName];m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=m!==null}const c=A.joints["index-finger-tip"],u=A.joints["thumb-tip"],f=c.position.distanceTo(u.position),d=.02,h=.005;A.inputState.pinching&&f>d+h?(A.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!A.inputState.pinching&&f<=d-h&&(A.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Dre)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),A!==null&&(A.visible=o!==null),this}}class dZ extends ir{constructor(e,t,r,i,s,o,a,l,A,c){if(c=c!==void 0?c:ru,c!==ru&&c!==vh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&c===ru&&(r=Jc),r===void 0&&c===vh&&(r=Od),super(null,i,s,o,a,l,c,r,A),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:er,this.minFilter=l!==void 0?l:er,this.flipY=!1,this.generateMipmaps=!1}}class kre extends dc{constructor(e,t){super();const r=this;let i=null,s=1,o=null,a="local-floor",l=null,A=null,c=null,u=null,f=null,d=null;const h=t.getContextAttributes();let p=null,m=null;const g=[],v=[],y=new Mr;y.layers.enable(1),y.viewport=new Tt;const w=new Mr;w.layers.enable(2),w.viewport=new Tt;const C=[y,w],b=new Nre;b.layers.enable(1),b.layers.enable(2);let E=null,x=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(V){let O=g[V];return O===void 0&&(O=new wI,g[V]=O),O.getTargetRaySpace()},this.getControllerGrip=function(V){let O=g[V];return O===void 0&&(O=new wI,g[V]=O),O.getGripSpace()},this.getHand=function(V){let O=g[V];return O===void 0&&(O=new wI,g[V]=O),O.getHandSpace()};function S(V){const O=v.indexOf(V.inputSource);if(O===-1)return;const L=g[O];L!==void 0&&L.dispatchEvent({type:V.type,data:V.inputSource})}function M(){i.removeEventListener("select",S),i.removeEventListener("selectstart",S),i.removeEventListener("selectend",S),i.removeEventListener("squeeze",S),i.removeEventListener("squeezestart",S),i.removeEventListener("squeezeend",S),i.removeEventListener("end",M),i.removeEventListener("inputsourceschange",Z);for(let V=0;V=0&&(v[U]=null,g[U].dispatchEvent({type:"disconnected",data:L}))}for(let O=0;O=v.length){v.push(L),U=le;break}else if(v[le]===null){v[le]=L,U=le;break}if(U===-1)break}const H=g[U];H&&H.dispatchEvent({type:"connected",data:L})}}const K=new z,_=new z;function B(V,O,L){K.setFromMatrixPosition(O.matrixWorld),_.setFromMatrixPosition(L.matrixWorld);const U=K.distanceTo(_),H=O.projectionMatrix.elements,le=L.projectionMatrix.elements,N=H[14]/(H[10]-1),j=H[14]/(H[10]+1),oe=(H[9]+1)/H[5],ie=(H[9]-1)/H[5],de=(H[8]-1)/H[0],X=(le[8]+1)/le[0],ne=N*de,ae=N*X,Be=U/(-de+X),pe=Be*-de;O.matrixWorld.decompose(V.position,V.quaternion,V.scale),V.translateX(pe),V.translateZ(Be),V.matrixWorld.compose(V.position,V.quaternion,V.scale),V.matrixWorldInverse.copy(V.matrixWorld).invert();const Fe=N+Be,rt=j+Be,Oe=ne-pe,ke=ae+(U-pe),Qe=oe*j/rt*Fe,Ge=ie*j/rt*Fe;V.projectionMatrix.makePerspective(Oe,ke,Qe,Ge,Fe,rt)}function F(V,O){O===null?V.matrixWorld.copy(V.matrix):V.matrixWorld.multiplyMatrices(O.matrixWorld,V.matrix),V.matrixWorldInverse.copy(V.matrixWorld).invert()}this.updateCamera=function(V){if(i===null)return;b.near=w.near=y.near=V.near,b.far=w.far=y.far=V.far,(E!==b.near||x!==b.far)&&(i.updateRenderState({depthNear:b.near,depthFar:b.far}),E=b.near,x=b.far);const O=V.parent,L=b.cameras;F(b,O);for(let H=0;H0&&(p.alphaTest.value=m.alphaTest);const g=e.get(m).envMap;if(g&&(p.envMap.value=g,p.flipEnvMap.value=g.isCubeTexture&&g.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap){p.lightMap.value=m.lightMap;const w=n.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=m.lightMapIntensity*w}m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity);let v;m.map?v=m.map:m.specularMap?v=m.specularMap:m.displacementMap?v=m.displacementMap:m.normalMap?v=m.normalMap:m.bumpMap?v=m.bumpMap:m.roughnessMap?v=m.roughnessMap:m.metalnessMap?v=m.metalnessMap:m.alphaMap?v=m.alphaMap:m.emissiveMap?v=m.emissiveMap:m.clearcoatMap?v=m.clearcoatMap:m.clearcoatNormalMap?v=m.clearcoatNormalMap:m.clearcoatRoughnessMap?v=m.clearcoatRoughnessMap:m.iridescenceMap?v=m.iridescenceMap:m.iridescenceThicknessMap?v=m.iridescenceThicknessMap:m.specularIntensityMap?v=m.specularIntensityMap:m.specularColorMap?v=m.specularColorMap:m.transmissionMap?v=m.transmissionMap:m.thicknessMap?v=m.thicknessMap:m.sheenColorMap?v=m.sheenColorMap:m.sheenRoughnessMap&&(v=m.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let y;m.aoMap?y=m.aoMap:m.lightMap&&(y=m.lightMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uv2Transform.value.copy(y.matrix))}function s(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function a(p,m,g,v){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*g,p.scale.value=v*.5,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let y;m.map?y=m.map:m.alphaMap&&(y=m.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function l(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let g;m.map?g=m.map:m.alphaMap&&(g=m.alphaMap),g!==void 0&&(g.matrixAutoUpdate===!0&&g.updateMatrix(),p.uvTransform.value.copy(g.matrix))}function A(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function c(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function u(p,m){p.roughness.value=m.roughness,p.metalness.value=m.metalness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap),e.get(m).envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,g){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),p.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===mi&&p.clearcoatNormalScale.value.negate())),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=g.texture,p.transmissionSamplerSize.value.set(g.width,g.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap)}function d(p,m){m.matcap&&(p.matcap.value=m.matcap)}function h(p,m){p.referencePosition.value.copy(m.referencePosition),p.nearDistance.value=m.nearDistance,p.farDistance.value=m.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:r}}function Lre(n,e,t,r){let i={},s={},o=[];const a=t.isWebGL2?n.getParameter(35375):0;function l(v,y){const w=y.program;r.uniformBlockBinding(v,w)}function A(v,y){let w=i[v.id];w===void 0&&(h(v),w=c(v),i[v.id]=w,v.addEventListener("dispose",m));const C=y.program;r.updateUBOMapping(v,C);const b=e.render.frame;s[v.id]!==b&&(f(v),s[v.id]=b)}function c(v){const y=u();v.__bindingPointIndex=y;const w=n.createBuffer(),C=v.__size,b=v.usage;return n.bindBuffer(35345,w),n.bufferData(35345,C,b),n.bindBuffer(35345,null),n.bindBufferBase(35345,y,w),w}function u(){for(let v=0;v0){b=w%C;const Z=C-b;b!==0&&Z-M.boundary<0&&(w+=C-b,S.__offset=w)}w+=M.storage}return b=w%C,b>0&&(w+=C-b),v.__size=w,v.__cache={},this}function p(v){const y=v.value,w={boundary:0,storage:0};return typeof y=="number"?(w.boundary=4,w.storage=4):y.isVector2?(w.boundary=8,w.storage=8):y.isVector3||y.isColor?(w.boundary=16,w.storage=12):y.isVector4?(w.boundary=16,w.storage=16):y.isMatrix3?(w.boundary=48,w.storage=48):y.isMatrix4?(w.boundary=64,w.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),w}function m(v){const y=v.target;y.removeEventListener("dispose",m);const w=o.indexOf(y.__bindingPointIndex);o.splice(w,1),n.deleteBuffer(i[y.id]),delete i[y.id],delete s[y.id]}function g(){for(const v in i)n.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:A,dispose:g}}function Pre(){const n=Um("canvas");return n.style.display="block",n}function c0(n={}){this.isWebGLRenderer=!0;const e=n.canvas!==void 0?n.canvas:Pre(),t=n.context!==void 0?n.context:null,r=n.depth!==void 0?n.depth:!0,i=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,o=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,a=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",A=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1;let c;t!==null?c=t.getContextAttributes().alpha:c=n.alpha!==void 0?n.alpha:!1;let u=null,f=null;const d=[],h=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=ps,this.physicallyCorrectLights=!1,this.toneMapping=xl,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const p=this;let m=!1,g=0,v=0,y=null,w=-1,C=null;const b=new Tt,E=new Tt;let x=null,S=e.width,M=e.height,Z=1,K=null,_=null;const B=new Tt(0,0,S,M),F=new Tt(0,0,S,M);let R=!1;const k=new p_;let T=!1,V=!1,O=null;const L=new Le,U=new We,H=new z,le={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function N(){return y===null?Z:1}let j=t;function oe(q,Ae){for(let he=0;he0?f=h[h.length-1]:f=null,d.pop(),d.length>0?u=d[d.length-1]:u=null};function ct(q,Ae,he,ue){if(q.visible===!1)return;if(q.layers.test(Ae.layers)){if(q.isGroup)he=q.renderOrder;else if(q.isLOD)q.autoUpdate===!0&&q.update(Ae);else if(q.isLight)f.pushLight(q),q.castShadow&&f.pushShadow(q);else if(q.isSprite){if(!q.frustumCulled||k.intersectsSprite(q)){ue&&H.setFromMatrixPosition(q.matrixWorld).applyMatrix4(L);const at=ke.update(q),Ye=q.material;Ye.visible&&u.push(q,at,Ye,he,H.z,null)}}else if((q.isMesh||q.isLine||q.isPoints)&&(q.isSkinnedMesh&&q.skeleton.frame!==ne.render.frame&&(q.skeleton.update(),q.skeleton.frame=ne.render.frame),!q.frustumCulled||k.intersectsObject(q))){ue&&H.setFromMatrixPosition(q.matrixWorld).applyMatrix4(L);const at=ke.update(q),Ye=q.material;if(Array.isArray(Ye)){const He=at.groups;for(let vt=0,ft=He.length;vt0&&xt(ge,Ae,he),ue&&X.viewport(b.copy(ue)),ge.length>0&&st(ge,Ae,he),Ne.length>0&&st(Ne,Ae,he),at.length>0&&st(at,Ae,he),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function xt(q,Ae,he){const ue=de.isWebGL2;O===null&&(O=new _a(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?Fm:$A,minFilter:Su,samples:ue&&s===!0?4:0})),p.getDrawingBufferSize(U),ue?O.setSize(U.x,U.y):O.setSize(vw(U.x),vw(U.y));const ge=p.getRenderTarget();p.setRenderTarget(O),p.clear();const Ne=p.toneMapping;p.toneMapping=xl,st(q,Ae,he),p.toneMapping=Ne,Be.updateMultisampleRenderTarget(O),Be.updateRenderTargetMipmap(O),p.setRenderTarget(ge)}function st(q,Ae,he){const ue=Ae.isScene===!0?Ae.overrideMaterial:null;for(let ge=0,Ne=q.length;ge0&&Be.useMultisampledRTT(q)===!1?ge=ae.get(q).__webglMultisampledFramebuffer:ge=ft,b.copy(q.viewport),E.copy(q.scissor),x=q.scissorTest}else b.copy(B).multiplyScalar(Z).floor(),E.copy(F).multiplyScalar(Z).floor(),x=R;if(X.bindFramebuffer(36160,ge)&&de.drawBuffers&&ue&&X.drawBuffers(q,ge),X.viewport(b),X.scissor(E),X.setScissorTest(x),Ne){const He=ae.get(q.texture);j.framebufferTexture2D(36160,36064,34069+Ae,He.__webglTexture,he)}else if(at){const He=ae.get(q.texture),vt=Ae||0;j.framebufferTextureLayer(36160,36064,He.__webglTexture,he||0,vt)}w=-1},this.readRenderTargetPixels=function(q,Ae,he,ue,ge,Ne,at){if(!(q&&q.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ye=ae.get(q).__webglFramebuffer;if(q.isWebGLCubeRenderTarget&&at!==void 0&&(Ye=Ye[at]),Ye){X.bindFramebuffer(36160,Ye);try{const He=q.texture,vt=He.format,ft=He.type;if(vt!==br&&I.convert(vt)!==j.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const gt=ft===Fm&&(ie.has("EXT_color_buffer_half_float")||de.isWebGL2&&ie.has("EXT_color_buffer_float"));if(ft!==$A&&I.convert(ft)!==j.getParameter(35738)&&!(ft===FA&&(de.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!gt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ae>=0&&Ae<=q.width-ue&&he>=0&&he<=q.height-ge&&j.readPixels(Ae,he,ue,ge,I.convert(vt),I.convert(ft),Ne)}finally{const He=y!==null?ae.get(y).__webglFramebuffer:null;X.bindFramebuffer(36160,He)}}},this.copyFramebufferToTexture=function(q,Ae,he=0){const ue=Math.pow(2,-he),ge=Math.floor(Ae.image.width*ue),Ne=Math.floor(Ae.image.height*ue);Be.setTexture2D(Ae,0),j.copyTexSubImage2D(3553,he,0,0,q.x,q.y,ge,Ne),X.unbindTexture()},this.copyTextureToTexture=function(q,Ae,he,ue=0){const ge=Ae.image.width,Ne=Ae.image.height,at=I.convert(he.format),Ye=I.convert(he.type);Be.setTexture2D(he,0),j.pixelStorei(37440,he.flipY),j.pixelStorei(37441,he.premultiplyAlpha),j.pixelStorei(3317,he.unpackAlignment),Ae.isDataTexture?j.texSubImage2D(3553,ue,q.x,q.y,ge,Ne,at,Ye,Ae.image.data):Ae.isCompressedTexture?j.compressedTexSubImage2D(3553,ue,q.x,q.y,Ae.mipmaps[0].width,Ae.mipmaps[0].height,at,Ae.mipmaps[0].data):j.texSubImage2D(3553,ue,q.x,q.y,at,Ye,Ae.image),ue===0&&he.generateMipmaps&&j.generateMipmap(3553),X.unbindTexture()},this.copyTextureToTexture3D=function(q,Ae,he,ue,ge=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ne=q.max.x-q.min.x+1,at=q.max.y-q.min.y+1,Ye=q.max.z-q.min.z+1,He=I.convert(ue.format),vt=I.convert(ue.type);let ft;if(ue.isData3DTexture)Be.setTexture3D(ue,0),ft=32879;else if(ue.isDataArrayTexture)Be.setTexture2DArray(ue,0),ft=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}j.pixelStorei(37440,ue.flipY),j.pixelStorei(37441,ue.premultiplyAlpha),j.pixelStorei(3317,ue.unpackAlignment);const gt=j.getParameter(3314),zt=j.getParameter(32878),Pr=j.getParameter(3316),Oo=j.getParameter(3315),Go=j.getParameter(32877),wi=he.isCompressedTexture?he.mipmaps[0]:he.image;j.pixelStorei(3314,wi.width),j.pixelStorei(32878,wi.height),j.pixelStorei(3316,q.min.x),j.pixelStorei(3315,q.min.y),j.pixelStorei(32877,q.min.z),he.isDataTexture||he.isData3DTexture?j.texSubImage3D(ft,ge,Ae.x,Ae.y,Ae.z,Ne,at,Ye,He,vt,wi.data):he.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),j.compressedTexSubImage3D(ft,ge,Ae.x,Ae.y,Ae.z,Ne,at,Ye,He,wi.data)):j.texSubImage3D(ft,ge,Ae.x,Ae.y,Ae.z,Ne,at,Ye,He,vt,wi),j.pixelStorei(3314,gt),j.pixelStorei(32878,zt),j.pixelStorei(3316,Pr),j.pixelStorei(3315,Oo),j.pixelStorei(32877,Go),ge===0&&ue.generateMipmaps&&j.generateMipmap(ft),X.unbindTexture()},this.initTexture=function(q){q.isCubeTexture?Be.setTextureCube(q,0):q.isData3DTexture?Be.setTexture3D(q,0):q.isDataArrayTexture||q.isCompressedArrayTexture?Be.setTexture2DArray(q,0):Be.setTexture2D(q,0),X.unbindTexture()},this.resetState=function(){g=0,v=0,y=null,X.reset(),D.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Wre extends c0{}Wre.prototype.isWebGL1Renderer=!0;class yw extends kt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.backgroundBlurriness=this.backgroundBlurriness),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class Ore{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=pE,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=No()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,r){e*=this.stride,r*=t.stride;for(let i=0,s=this.stride;il)continue;f.applyMatrix4(this.matrixWorld);const x=e.ray.origin.distanceTo(f);xe.far||t.push({distance:x,point:u.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{const g=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let y=g,w=v-1;yl)continue;f.applyMatrix4(this.matrixWorld);const b=e.ray.origin.distanceTo(f);be.far||t.push({distance:b,point:u.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;si.far)return;s.push({distance:A,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class Yre{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const r=this.getUtoTmapping(e);return this.getPoint(r,t)}getPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}getSpacedPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let r,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)r=this.getPoint(o/e),s+=r.distanceTo(i),t.push(s),i=r;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const r=this.getLengths();let i=0;const s=r.length;let o;t?o=t:o=e*r[s-1];let a=0,l=s-1,A;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),A=r[i]-o,A<0)a=i+1;else if(A>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const c=r[i],f=r[i+1]-c,d=(o-c)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new We:new z);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const r=this.getUtoTmapping(e);return this.getTangent(r,t)}computeFrenetFrames(e,t){const r=new z,i=[],s=[],o=[],a=new z,l=new Le;for(let d=0;d<=e;d++){const h=d/e;i[d]=this.getTangentAt(h,new z)}s[0]=new z,o[0]=new z;let A=Number.MAX_VALUE;const c=Math.abs(i[0].x),u=Math.abs(i[0].y),f=Math.abs(i[0].z);c<=A&&(A=c,r.set(1,0,0)),u<=A&&(A=u,r.set(0,1,0)),f<=A&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();const h=Math.acos(fr(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(a,h))}o[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(fr(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let h=1;h<=e;h++)s[h].applyMatrix4(l.makeRotationAxis(i[h],d*h)),o[h].crossVectors(i[h],s[h])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class $C extends Ht{constructor(e=1,t=1,r=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const A=this;i=Math.floor(i),s=Math.floor(s);const c=[],u=[],f=[],d=[];let h=0;const p=[],m=r/2;let g=0;v(),o===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(c),this.setAttribute("position",new rn(u,3)),this.setAttribute("normal",new rn(f,3)),this.setAttribute("uv",new rn(d,2));function v(){const w=new z,C=new z;let b=0;const E=(t-e)/r;for(let x=0;x<=s;x++){const S=[],M=x/s,Z=M*(t-e)+e;for(let K=0;K<=i;K++){const _=K/i,B=_*l+a,F=Math.sin(B),R=Math.cos(B);C.x=Z*F,C.y=-M*r+m,C.z=Z*R,u.push(C.x,C.y,C.z),w.set(F,E,R).normalize(),f.push(w.x,w.y,w.z),d.push(_,1-M),S.push(h++)}p.push(S)}for(let x=0;x0)&&d.push(y,w,b),(g!==r-1||l0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class bI extends cs{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Re(16777215),this.specular=new Re(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Re(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_u,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=zC,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Xre extends cs{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_u,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Kre extends cs{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Re(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Re(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_u,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=zC,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function nA(n,e,t){return gZ(n)?new n.constructor(n.subarray(e,t!==void 0?t:n.length)):n.slice(e,t)}function Sv(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function gZ(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function jre(n){function e(i,s){return n[i]-n[s]}const t=n.length,r=new Array(t);for(let i=0;i!==t;++i)r[i]=i;return r.sort(e),r}function sN(n,e,t){const r=n.length,i=new n.constructor(r);for(let s=0,o=0;o!==r;++s){const a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=n[a+l]}return i}function mZ(n,e,t,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[i++];while(s!==void 0);else do o=s[r],o!==void 0&&(e.push(s.time),t.push(o)),s=n[i++];while(s!==void 0)}class f0{constructor(e,t,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let r=this._cachedIndex,i=t[r],s=t[r-1];e:{t:{let o;n:{r:if(!(e=s)){const a=t[1];e=s)break t}o=r,r=0;break n}break e}for(;r>>1;et;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=nA(r,s,o),this.values=nA(this.values,s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,i=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&gZ(i))for(let a=0,l=i.length;a!==l;++a){const A=i[a];if(isNaN(A)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,A),e=!1;break}}return e}optimize(){const e=nA(this.times),t=nA(this.values),r=this.getValueSize(),i=this.getInterpolation()===Xx,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*r,l=o*r,A=0;A!==r;++A)t[l+A]=t[a+A];++o}return o!==e.length?(this.times=nA(e,0,o),this.values=nA(t,0,o*r)):(this.times=e,this.values=t),this}clone(){const e=nA(this.times,0),t=nA(this.values,0),r=this.constructor,i=new r(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Da.prototype.TimeBufferType=Float32Array;Da.prototype.ValueBufferType=Float32Array;Da.prototype.DefaultInterpolation=gu;class Vh extends Da{}Vh.prototype.ValueTypeName="bool";Vh.prototype.ValueBufferType=Array;Vh.prototype.DefaultInterpolation=yh;Vh.prototype.InterpolantFactoryMethodLinear=void 0;Vh.prototype.InterpolantFactoryMethodSmooth=void 0;class yZ extends Da{}yZ.prototype.ValueTypeName="color";class wh extends Da{}wh.prototype.ValueTypeName="number";class eie extends f0{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-t)/(i-t);let A=e*a;for(let c=A+a;A!==c;A+=4)tt.slerpFlat(s,0,o,A-a,o,A,l);return s}}class Qa extends Da{InterpolantFactoryMethodLinear(e){return new eie(this.times,this.values,this.getValueSize(),e)}}Qa.prototype.ValueTypeName="quaternion";Qa.prototype.DefaultInterpolation=gu;Qa.prototype.InterpolantFactoryMethodSmooth=void 0;class Lh extends Da{}Lh.prototype.ValueTypeName="string";Lh.prototype.ValueBufferType=Array;Lh.prototype.DefaultInterpolation=yh;Lh.prototype.InterpolantFactoryMethodLinear=void 0;Lh.prototype.InterpolantFactoryMethodSmooth=void 0;class ec extends Da{}ec.prototype.ValueTypeName="vector";class vu{constructor(e,t=-1,r,i=c_){this.name=e,this.tracks=r,this.duration=t,this.blendMode=i,this.uuid=No(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],r=e.tracks,i=1/(e.fps||1);for(let o=0,a=r.length;o!==a;++o)t.push(nie(r[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],r=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=r.length;s!==o;++s)t.push(Da.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(e,t,r,i){const s=t.length,o=[];for(let a=0;a1){const u=c[1];let f=i[u];f||(i[u]=f=[]),f.push(A)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,r));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const r=function(u,f,d,h,p){if(d.length!==0){const m=[],g=[];mZ(d,m,g,h),m.length!==0&&p.push(new u(f,m,g))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const A=e.hierarchy||[];for(let u=0;u{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ya[e]!==void 0){Ya[e].push({onLoad:t,onProgress:r,onError:i});return}Ya[e]=[],Ya[e].push({onLoad:t,onProgress:r,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(A=>{if(A.status===200||A.status===0){if(A.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||A.body===void 0||A.body.getReader===void 0)return A;const c=Ya[e],u=A.body.getReader(),f=A.headers.get("Content-Length"),d=f?parseInt(f):0,h=d!==0;let p=0;const m=new ReadableStream({start(g){v();function v(){u.read().then(({done:y,value:w})=>{if(y)g.close();else{p+=w.byteLength;const C=new ProgressEvent("progress",{lengthComputable:h,loaded:p,total:d});for(let b=0,E=c.length;b{switch(l){case"arraybuffer":return A.arrayBuffer();case"blob":return A.blob();case"document":return A.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return A.json();default:if(a===void 0)return A.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return A.arrayBuffer().then(h=>d.decode(h))}}}).then(A=>{Ch.add(e,A);const c=Ya[e];delete Ya[e];for(let u=0,f=c.length;u{const c=Ya[e];if(c===void 0)throw this.manager.itemError(e),A;delete Ya[e];for(let u=0,f=c.length;u{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class wZ extends Ph{constructor(e){super(e)}load(e,t,r,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Ch.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=Um("img");function l(){c(),Ch.add(e,this),t&&t(this),s.manager.itemEnd(e)}function A(u){c(),i&&i(u),s.manager.itemError(e),s.manager.itemEnd(e)}function c(){a.removeEventListener("load",l,!1),a.removeEventListener("error",A,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",A,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class Nu extends Ph{constructor(e){super(e)}load(e,t,r,i){const s=new ir,o=new wZ(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},r,i),s}}class qC extends kt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Re(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const xI=new Le,oN=new z,aN=new z;class B_{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new We(512,512),this.map=null,this.mapPass=null,this.matrix=new Le,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new p_,this._frameExtents=new We(1,1),this._viewportCount=1,this._viewports=[new Tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;oN.setFromMatrixPosition(e.matrixWorld),t.position.copy(oN),aN.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(aN),t.updateMatrixWorld(),xI.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xI),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(xI)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class sie extends B_{constructor(){super(new Mr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,r=Em*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(r!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=r,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class CZ extends qC{constructor(e,t,r=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(kt.DefaultUp),this.updateMatrix(),this.target=new kt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new sie}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const lN=new Le,Sp=new z,II=new z;class oie extends B_{constructor(){super(new Mr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new We(4,2),this._viewportCount=6,this._viewports=[new Tt(2,1,1,1),new Tt(0,1,1,1),new Tt(3,1,1,1),new Tt(1,1,1,1),new Tt(3,0,1,1),new Tt(1,0,1,1)],this._cubeDirections=[new z(1,0,0),new z(-1,0,0),new z(0,0,1),new z(0,0,-1),new z(0,1,0),new z(0,-1,0)],this._cubeUps=[new z(0,1,0),new z(0,1,0),new z(0,1,0),new z(0,1,0),new z(0,0,1),new z(0,0,-1)]}updateMatrices(e,t=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Sp.setFromMatrixPosition(e.matrixWorld),r.position.copy(Sp),II.copy(r.position),II.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(II),r.updateMatrixWorld(),i.makeTranslation(-Sp.x,-Sp.y,-Sp.z),lN.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lN)}}class BE extends qC{constructor(e,t,r=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new oie}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class aie extends B_{constructor(){super(new Mu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class w_ extends qC{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(kt.DefaultUp),this.updateMatrix(),this.target=new kt,this.shadow=new aie}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class bZ extends qC{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class ba{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let r=0,i=e.length;r"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Ch.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){Ch.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}class xZ{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=AN(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=AN();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function AN(){return(typeof performance>"u"?Date:performance).now()}class Aie{constructor(e,t,r){this.binding=e,this.valueSize=r;let i,s,o;switch(t){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const r=this.buffer,i=this.valueSize,s=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)r[s+a]=r[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(r,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,r=this.valueSize,i=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,r),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,r=this.buffer,i=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(r,i,l,1-s,t)}o>0&&this._mixBufferRegionAdditive(r,i,this._addIndex*t,1,t);for(let l=t,A=t+t;l!==A;++l)if(r[l]!==r[l+t]){a.setValue(r,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,r=this.valueSize,i=r*this._origIndex;e.getValue(t,i);for(let s=r,o=i;s!==o;++s)t[s]=t[i+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let r=e;r=.5)for(let o=0;o!==s;++o)e[t+o]=e[r+o]}_slerp(e,t,r,i){tt.slerpFlat(e,t,e,t,e,r,i)}_slerpAdditive(e,t,r,i,s){const o=this._workIndex*s;tt.multiplyQuaternionsFlat(e,o,e,t,e,r),tt.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,r,i,s){const o=1-i;for(let a=0;a!==s;++a){const l=t+a;e[l]=e[l]*o+e[r+a]*i}}_lerpAdditive(e,t,r,i,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[r+o]*i}}}const C_="\\[\\]\\.:\\/",cie=new RegExp("["+C_+"]","g"),b_="[^"+C_+"]",uie="[^"+C_.replace("\\.","")+"]",fie=/((?:WC+[\/:])*)/.source.replace("WC",b_),die=/(WCOD+)?/.source.replace("WCOD",uie),hie=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",b_),pie=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",b_),gie=new RegExp("^"+fie+die+hie+pie+"$"),mie=["material","materials","bones","map"];class vie{constructor(e,t,r){const i=r||Bt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(e,t)}setValue(e,t){const r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}}class Bt{constructor(e,t,r){this.path=t,this.parsedPath=r||Bt.parseTrackName(t),this.node=Bt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new Bt.Composite(e,t,r):new Bt(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(cie,"")}static parseTrackName(e){const t=gie.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=r.nodeName.substring(i+1);mie.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(t);if(r!==void 0)return r}if(e.children){const r=function(s){for(let o=0;o0){const l=this._interpolants,A=this._propertyBindings;switch(this.blendMode){case I$:for(let c=0,u=l.length;c!==u;++c)l[c].evaluate(o),A[c].accumulateAdditive(a);break;case c_:default:for(let c=0,u=l.length;c!==u;++c)l[c].evaluate(o),A[c].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const r=this._weightInterpolant;if(r!==null){const i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const r=this._timeScaleInterpolant;if(r!==null){const i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,r=this.loop;let i=this.time+e,s=this._loopCount;const o=r===x$;if(e===0)return s===-1?i:o&&(s&1)===1?t-i:i;if(r===C$){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const A=e<0;this._setEndings(A,!A,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return t-i}return i}_setEndings(e,t,r){const i=this._interpolantSettings;r?(i.endingStart=Cd,i.endingEnd=Cd):(e?i.endingStart=this.zeroSlopeAtStart?Cd:wd:i.endingStart=mw,t?i.endingEnd=this.zeroSlopeAtEnd?Cd:wd:i.endingEnd=mw)}_scheduleFading(e,t,r){const i=this._mixer,s=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=r,this}}const Bie=new Float32Array(1);class wie extends dc{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const r=e._localRoot||this._root,i=e._clip.tracks,s=i.length,o=e._propertyBindings,a=e._interpolants,l=r.uuid,A=this._bindingsByRootAndName;let c=A[l];c===void 0&&(c={},A[l]=c);for(let u=0;u!==s;++u){const f=i[u],d=f.name;let h=c[d];if(h!==void 0)++h.referenceCount,o[u]=h;else{if(h=o[u],h!==void 0){h._cacheIndex===null&&(++h.referenceCount,this._addInactiveBinding(h,l,d));continue}const p=t&&t._propertyBindings[u].binding.parsedPath;h=new Aie(Bt.create(r,d,p),f.ValueTypeName,f.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,l,d),o[u]=h}a[u].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const r=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,r)}const t=e._propertyBindings;for(let r=0,i=t.length;r!==i;++r){const s=t[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let r=0,i=t.length;r!==i;++r){const s=t[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--r)e[r].stop();return this}update(e){e*=this.timeScale;const t=this._actions,r=this._nActiveActions,i=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let A=0;A!==r;++A)t[A]._update(i,e,s,o);const a=this._bindings,l=this._nActiveBindings;for(let A=0;A!==l;++A)a[A].apply(o);return this}setTime(e){this.time=0;for(let t=0;tMath.PI&&(Ve-=we),_e<-Math.PI?_e+=we:_e>Math.PI&&(_e-=we),Ve<=_e?a.theta=Math.max(Ve,Math.min(_e,a.theta)):a.theta=a.theta>(Ve+_e)/2?Math.max(Ve,a.theta):Math.min(_e,a.theta)),a.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,a.phi)),a.makeSafe(),a.radius*=A,a.radius=Math.max(r.minDistance,Math.min(r.maxDistance,a.radius)),r.enableDamping===!0?r.target.addScaledVector(c,r.dampingFactor):r.target.add(c),I.setFromSpherical(a),I.applyQuaternion($),Ee.copy(r.target).add(I),r.object.lookAt(r.target),r.enableDamping===!0?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,c.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),c.set(0,0,0)),A=1,u||ee.distanceToSquared(r.object.position)>o||8*(1-te.dot(r.object.quaternion))>o?(r.dispatchEvent(hN),ee.copy(r.object.position),te.copy(r.object.quaternion),u=!1,!0):!1}}(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",se),r.domElement.removeEventListener("pointerdown",pe),r.domElement.removeEventListener("pointercancel",Oe),r.domElement.removeEventListener("wheel",Ge),r.domElement.removeEventListener("pointermove",Fe),r.domElement.removeEventListener("pointerup",rt),r._domElementKeyEvents!==null&&r._domElementKeyEvents.removeEventListener("keydown",Xe)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const o=1e-6,a=new fN,l=new fN;let A=1;const c=new z;let u=!1;const f=new We,d=new We,h=new We,p=new We,m=new We,g=new We,v=new We,y=new We,w=new We,C=[],b={};function E(){return 2*Math.PI/60/60*r.autoRotateSpeed}function x(){return Math.pow(.95,r.zoomSpeed)}function S(I){l.theta-=I}function M(I){l.phi-=I}const Z=function(){const I=new z;return function($,ee){I.setFromMatrixColumn(ee,0),I.multiplyScalar(-$),c.add(I)}}(),K=function(){const I=new z;return function($,ee){r.screenSpacePanning===!0?I.setFromMatrixColumn(ee,1):(I.setFromMatrixColumn(ee,0),I.crossVectors(r.object.up,I)),I.multiplyScalar($),c.add(I)}}(),_=function(){const I=new z;return function($,ee){const te=r.domElement;if(r.object.isPerspectiveCamera){const we=r.object.position;I.copy(we).sub(r.target);let Ce=I.length();Ce*=Math.tan(r.object.fov/2*Math.PI/180),Z(2*$*Ce/te.clientHeight,r.object.matrix),K(2*ee*Ce/te.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(Z($*(r.object.right-r.object.left)/r.object.zoom/te.clientWidth,r.object.matrix),K(ee*(r.object.top-r.object.bottom)/r.object.zoom/te.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}}();function B(I){r.object.isPerspectiveCamera?A/=I:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom*I)),r.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function F(I){r.object.isPerspectiveCamera?A*=I:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/I)),r.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function R(I){f.set(I.clientX,I.clientY)}function k(I){v.set(I.clientX,I.clientY)}function T(I){p.set(I.clientX,I.clientY)}function V(I){d.set(I.clientX,I.clientY),h.subVectors(d,f).multiplyScalar(r.rotateSpeed);const D=r.domElement;S(2*Math.PI*h.x/D.clientHeight),M(2*Math.PI*h.y/D.clientHeight),f.copy(d),r.update()}function O(I){y.set(I.clientX,I.clientY),w.subVectors(y,v),w.y>0?B(x()):w.y<0&&F(x()),v.copy(y),r.update()}function L(I){m.set(I.clientX,I.clientY),g.subVectors(m,p).multiplyScalar(r.panSpeed),_(g.x,g.y),p.copy(m),r.update()}function U(I){I.deltaY<0?F(x()):I.deltaY>0&&B(x()),r.update()}function H(I){let D=!1;switch(I.code){case r.keys.UP:_(0,r.keyPanSpeed),D=!0;break;case r.keys.BOTTOM:_(0,-r.keyPanSpeed),D=!0;break;case r.keys.LEFT:_(r.keyPanSpeed,0),D=!0;break;case r.keys.RIGHT:_(-r.keyPanSpeed,0),D=!0;break}D&&(I.preventDefault(),r.update())}function le(){if(C.length===1)f.set(C[0].pageX,C[0].pageY);else{const I=.5*(C[0].pageX+C[1].pageX),D=.5*(C[0].pageY+C[1].pageY);f.set(I,D)}}function N(){if(C.length===1)p.set(C[0].pageX,C[0].pageY);else{const I=.5*(C[0].pageX+C[1].pageX),D=.5*(C[0].pageY+C[1].pageY);p.set(I,D)}}function j(){const I=C[0].pageX-C[1].pageX,D=C[0].pageY-C[1].pageY,$=Math.sqrt(I*I+D*D);v.set(0,$)}function oe(){r.enableZoom&&j(),r.enablePan&&N()}function ie(){r.enableZoom&&j(),r.enableRotate&&le()}function de(I){if(C.length==1)d.set(I.pageX,I.pageY);else{const $=Q(I),ee=.5*(I.pageX+$.x),te=.5*(I.pageY+$.y);d.set(ee,te)}h.subVectors(d,f).multiplyScalar(r.rotateSpeed);const D=r.domElement;S(2*Math.PI*h.x/D.clientHeight),M(2*Math.PI*h.y/D.clientHeight),f.copy(d)}function X(I){if(C.length===1)m.set(I.pageX,I.pageY);else{const D=Q(I),$=.5*(I.pageX+D.x),ee=.5*(I.pageY+D.y);m.set($,ee)}g.subVectors(m,p).multiplyScalar(r.panSpeed),_(g.x,g.y),p.copy(m)}function ne(I){const D=Q(I),$=I.pageX-D.x,ee=I.pageY-D.y,te=Math.sqrt($*$+ee*ee);y.set(0,te),w.set(0,Math.pow(y.y/v.y,r.zoomSpeed)),B(w.y),v.copy(y)}function ae(I){r.enableZoom&&ne(I),r.enablePan&&X(I)}function Be(I){r.enableZoom&&ne(I),r.enableRotate&&de(I)}function pe(I){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(I.pointerId),r.domElement.addEventListener("pointermove",Fe),r.domElement.addEventListener("pointerup",rt)),fe(I),I.pointerType==="touch"?G(I):ke(I))}function Fe(I){r.enabled!==!1&&(I.pointerType==="touch"?J(I):Qe(I))}function rt(I){ve(I),C.length===0&&(r.domElement.releasePointerCapture(I.pointerId),r.domElement.removeEventListener("pointermove",Fe),r.domElement.removeEventListener("pointerup",rt)),r.dispatchEvent(pN),s=i.NONE}function Oe(I){ve(I)}function ke(I){let D;switch(I.button){case 0:D=r.mouseButtons.LEFT;break;case 1:D=r.mouseButtons.MIDDLE;break;case 2:D=r.mouseButtons.RIGHT;break;default:D=-1}switch(D){case Yu.DOLLY:if(r.enableZoom===!1)return;k(I),s=i.DOLLY;break;case Yu.ROTATE:if(I.ctrlKey||I.metaKey||I.shiftKey){if(r.enablePan===!1)return;T(I),s=i.PAN}else{if(r.enableRotate===!1)return;R(I),s=i.ROTATE}break;case Yu.PAN:if(I.ctrlKey||I.metaKey||I.shiftKey){if(r.enableRotate===!1)return;R(I),s=i.ROTATE}else{if(r.enablePan===!1)return;T(I),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(FI)}function Qe(I){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;V(I);break;case i.DOLLY:if(r.enableZoom===!1)return;O(I);break;case i.PAN:if(r.enablePan===!1)return;L(I);break}}function Ge(I){r.enabled===!1||r.enableZoom===!1||s!==i.NONE||(I.preventDefault(),r.dispatchEvent(FI),U(I),r.dispatchEvent(pN))}function Xe(I){r.enabled===!1||r.enablePan===!1||H(I)}function G(I){switch(W(I),C.length){case 1:switch(r.touches.ONE){case Xu.ROTATE:if(r.enableRotate===!1)return;le(),s=i.TOUCH_ROTATE;break;case Xu.PAN:if(r.enablePan===!1)return;N(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case Xu.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;oe(),s=i.TOUCH_DOLLY_PAN;break;case Xu.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;ie(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(FI)}function J(I){switch(W(I),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;de(I),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;X(I),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;ae(I),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;Be(I),r.update();break;default:s=i.NONE}}function se(I){r.enabled!==!1&&I.preventDefault()}function fe(I){C.push(I)}function ve(I){delete b[I.pointerId];for(let D=0;D=2.0 are supported."));return}const l=new $ie(s,{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 A=0;A=0&&a[c]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+c+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(r,i)}parseAsync(e,t){const r=this;return new Promise(function(i,s){r.parse(e,t,i,s)})}}function xie(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const Ct={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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Iie{constructor(e){this.parser=e,this.name=Ct.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,i=t.length;r=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Die{constructor(e){this.parser=e,this.name=Ct.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,i=r.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=r.textureLoader;if(a.uri){const A=r.options.manager.getHandler(a.uri);A!==null&&(l=A)}return this.detectSupport().then(function(A){if(A)return r.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.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(t.height===1)}})),this.isSupported}}class kie{constructor(e){this.name=Ct.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const i=r.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.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 s.then(function(a){const l=i.byteOffset||0,A=i.byteLength||0,c=i.count,u=i.byteStride,f=new Uint8Array(a,l,A);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(c,u,f,i.mode,i.filter).then(function(d){return d.buffer}):o.ready.then(function(){const d=new ArrayBuffer(c*u);return o.decodeGltfBuffer(new Uint8Array(d),c,u,f,i.mode,i.filter),d})})}else return null}}class Vie{constructor(e){this.name=Ct.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const i=t.meshes[r.mesh];for(const A of i.primitives)if(A.mode!==Ns.TRIANGLES&&A.mode!==Ns.TRIANGLE_STRIP&&A.mode!==Ns.TRIANGLE_FAN&&A.mode!==void 0)return null;const o=r.extensions[this.name].attributes,a=[],l={};for(const A in o)a.push(this.parser.getDependency("accessor",o[A]).then(c=>(l[A]=c,l[A])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(A=>{const c=A.pop(),u=c.isGroup?c.children:[c],f=A[0].count,d=[];for(const h of u){const p=new Le,m=new z,g=new tt,v=new z(1,1,1),y=new jC(h.geometry,h.material,f);for(let w=0;w Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE version 0.6.9 -*/var bN={},IE=function(n){return URL.createObjectURL(new Blob([n],{type:"text/javascript"}))},SZ=function(n){return new Worker(n)};try{URL.revokeObjectURL(IE(""))}catch{IE=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},SZ=function(e){return new Worker(e,{type:"module"})}}var ese=function(n,e,t,r,i){var s=SZ(bN[e]||(bN[e]=IE(n)));return s.onerror=function(o){return i(o.error,null)},s.onmessage=function(o){return i(null,o.data)},s.postMessage(t,r),s},Ut=Uint8Array,xr=Uint16Array,Nl=Uint32Array,Wh=new Ut([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]),Oh=new Ut([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]),_m=new Ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_Z=function(n,e){for(var t=new xr(31),r=0;r<31;++r)t[r]=e+=1<>>1|(gn&21845)<<1;iA=(iA&52428)>>>2|(iA&13107)<<2,iA=(iA&61680)>>>4|(iA&3855)<<4,Qm[gn]=((iA&65280)>>>8|(iA&255)<<8)>>>1}var Ks=function(n,e,t){for(var r=n.length,i=0,s=new xr(e);i>>l]=A}else for(a=new xr(r),i=0;i>>15-n[i]);return a},Dl=new Ut(288);for(var gn=0;gn<144;++gn)Dl[gn]=8;for(var gn=144;gn<256;++gn)Dl[gn]=9;for(var gn=256;gn<280;++gn)Dl[gn]=7;for(var gn=280;gn<288;++gn)Dl[gn]=8;var bh=new Ut(32);for(var gn=0;gn<32;++gn)bh[gn]=5;var TZ=Ks(Dl,9,0),NZ=Ks(Dl,9,1),DZ=Ks(bh,5,0),kZ=Ks(bh,5,1),sB=function(n){for(var e=n[0],t=1;te&&(e=n[t]);return e},Qs=function(n,e,t){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(e&7)&t},oB=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},d0=function(n){return(n/8|0)+(n&7&&1)},js=function(n,e,t){(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof xr?xr:n instanceof Nl?Nl:Ut)(t-e);return r.set(n.subarray(e,t)),r},h0=function(n,e,t){var r=n.length;if(!r||t&&!t.l&&r<5)return e||new Ut(0);var i=!e||t,s=!t||t.i;t||(t={}),e||(e=new Ut(r*3));var o=function(j){var oe=e.length;if(j>oe){var ie=new Ut(Math.max(oe*2,j));ie.set(e),e=ie}},a=t.f||0,l=t.p||0,A=t.b||0,c=t.l,u=t.d,f=t.m,d=t.n,h=r*8;do{if(!c){t.f=a=Qs(n,l,1);var p=Qs(n,l+1,3);if(l+=3,p)if(p==1)c=NZ,u=kZ,f=9,d=5;else if(p==2){var y=Qs(n,l,31)+257,w=Qs(n,l+10,15)+4,C=y+Qs(n,l+5,31)+1;l+=14;for(var b=new Ut(C),E=new Ut(19),x=0;x>>4;if(m<16)b[x++]=m;else{var _=0,B=0;for(m==16?(B=3+Qs(n,l,3),l+=2,_=b[x-1]):m==17?(B=3+Qs(n,l,7),l+=3):m==18&&(B=11+Qs(n,l,127),l+=7);B--;)b[x++]=_}}var F=b.subarray(0,y),R=b.subarray(y);f=sB(F),d=sB(R),c=Ks(F,f,1),u=Ks(R,d,1)}else throw"invalid block type";else{var m=d0(l)+4,g=n[m-4]|n[m-3]<<8,v=m+g;if(v>r){if(s)throw"unexpected EOF";break}i&&o(A+g),e.set(n.subarray(m,v),A),t.b=A+=g,t.p=l=v*8;continue}if(l>h){if(s)throw"unexpected EOF";break}}i&&o(A+131072);for(var k=(1<>>4;if(l+=_&15,l>h){if(s)throw"unexpected EOF";break}if(!_)throw"invalid length/literal";if(O<256)e[A++]=O;else if(O==256){V=l,c=null;break}else{var L=O-254;if(O>264){var x=O-257,U=Wh[x];L=Qs(n,l,(1<>>4;if(!H)throw"invalid distance";l+=H&15;var R=MZ[Ae];if(Ae>3){var U=Oh[Ae];R+=oB(n,l)&(1<h){if(s)throw"unexpected EOF";break}i&&o(A+131072);for(var N=A+L;A>>8},Mf=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>>8,n[r+2]|=t>>>16},aB=function(n,e){for(var t=[],r=0;rf&&(f=s[r].s);var d=new xr(f+1),h=bw(t[c-1],d,0);if(h>e){var r=0,p=0,m=h-e,g=1<e)p+=g-(1<>>=m;p>0;){var y=s[r].s;d[y]=0&&p;--r){var w=s[r].s;d[w]==e&&(--d[w],++p)}h=e}return[new Ut(d),h]},bw=function(n,e,t){return n.s==-1?Math.max(bw(n.l,e,t+1),bw(n.r,e,t+1)):e[n.s]=t},EE=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new xr(++e),r=0,i=n[0],s=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(n[a]==i&&a!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=n[a]}return[t.subarray(0,r),e]},Tf=function(n,e){for(var t=0,r=0;r>>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var s=0;s4&&!M[_m[K-1]];--K);var _=A+5<<3,B=Tf(i,Dl)+Tf(s,bh)+o,F=Tf(i,f)+Tf(s,p)+o+14+3*K+Tf(E,M)+(2*E[16]+3*E[17]+7*E[18]);if(_<=B&&_<=F)return Zg(e,c,n.subarray(l,l+A));var R,k,T,V;if(ea(e,c,1+(F15&&(ea(e,c,H[x]>>>5&127),c+=H[x]>>>12)}}else R=TZ,k=Dl,T=DZ,V=bh;for(var x=0;x255){var Ae=r[x]>>>18&31;Mf(e,c,R[Ae+257]),c+=k[Ae+257],Ae>7&&(ea(e,c,r[x]>>>23&31),c+=Wh[Ae]);var N=r[x]&31;Mf(e,c,T[N]),c+=V[N],N>3&&(Mf(e,c,r[x]>>>5&8191),c+=Oh[N])}else Mf(e,c,R[r[x]]),c+=k[r[x]];return Mf(e,c,R[256]),c+k[256]},VZ=new Nl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),wl=new Ut(0),LZ=function(n,e,t,r,i,s){var o=n.length,a=new Ut(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),A=0;if(!e||o<8)for(var c=0;c<=o;c+=65535){var u=c+65535;u>>13,h=f&8191,p=(1<7e3||M>24576)&&R>423){A=UE(n,l,0,C,b,E,S,M,K,c-K,A),M=x=S=0,K=c;for(var k=0;k<286;++k)b[k]=0;for(var k=0;k<30;++k)E[k]=0}var T=2,V=0,O=h,L=B-F&32767;if(R>2&&_==w(c-L))for(var U=Math.min(d,R)-1,H=Math.min(32767,c),Ae=Math.min(258,R);L<=H&&--O&&B!=F;){if(n[c+T]==n[c+T-L]){for(var N=0;NT){if(T=N,V=L,N>U)break;for(var j=Math.min(L,N-2),oe=0,k=0;koe&&(oe=X,F=ie)}}}B=F,F=m[B],L+=B-F+32768&32767}if(V){C[M++]=268435456|Cw[T]<<18|FE[V];var ne=Cw[T]&31,ae=FE[V]&31;S+=Wh[ne]+Oh[ae],++b[257+ne],++E[ae],Z=c+T,++x}else C[M++]=n[c],++b[n[c]]}}A=UE(n,l,s,C,b,E,S,M,K,c-K,A),!s&&A&7&&(A=Zg(l,A+1,wl))}return js(a,0,r+d0(A)+i)},PZ=function(){for(var n=new Nl(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(t&1&&3988292384)^t>>>1;n[e]=t}return n}(),Gh=function(){var n=-1;return{p:function(e){for(var t=n,r=0;r>>8;n=t},d:function(){return~n}}},F_=function(){var n=1,e=0;return{p:function(t){for(var r=n,i=e,s=t.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o>16),i=(i&65535)+15*(i>>16)}n=r,e=i},d:function(){return n%=65521,e%=65521,(n&255)<<24|n>>>8<<16|(e&255)<<8|e>>>8}}},Du=function(n,e,t,r,i){return LZ(n,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):12+e.mem,t,r,!i)},p0=function(n,e){var t={};for(var r in n)t[r]=n[r];for(var r in e)t[r]=e[r];return t},xN=function(n,e,t){for(var r=n(),i=n.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o>>0},UI=function(n,e){return zn(n,e)+zn(n,e+4)*4294967296},$t=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8},U_=function(n,e){var t=e.filename;if(n[0]=31,n[1]=139,n[2]=8,n[8]=e.level<2?4:e.level==9?2:0,n[9]=3,e.mtime!=0&&$t(n,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){n[3]=8;for(var r=0;r<=t.length;++r)n[r+10]=t.charCodeAt(r)}},S_=function(n){if(n[0]!=31||n[1]!=139||n[2]!=8)throw"invalid gzip data";var e=n[3],t=10;e&4&&(t+=n[10]|(n[11]<<8)+2);for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!n[t++]);return t+(e&2)},HZ=function(n){var e=n.length;return(n[e-4]|n[e-3]<<8|n[e-2]<<16|n[e-1]<<24)>>>0},__=function(n){return 10+(n.filename&&n.filename.length+1||0)},Q_=function(n,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;n[0]=120,n[1]=r<<6|(r?32-2*r:1)},zZ=function(n){if((n[0]&15)!=8||n[0]>>>4>7||(n[0]<<8|n[1])%31)throw"invalid zlib data";if(n[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function R_(n,e){return!e&&typeof n=="function"&&(e=n,n={}),this.ondata=e,n}var Ra=function(){function n(e,t){!t&&typeof e=="function"&&(t=e,e={}),this.ondata=t,this.o=e||{}}return n.prototype.p=function(e,t){this.ondata(Du(e,this.o,0,0,!t),t)},n.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)},n}(),YZ=function(){function n(e,t){zh([Jh,function(){return[io,Ra]}],this,R_.call(this,e,t),function(r){var i=new Ra(r.data);onmessage=io(i)},6)}return n}();function XZ(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Jh],function(r){return pc(g0(r.data[0],r.data[1]))},0,t)}function g0(n,e){return Du(n,e||{},0,0)}var Vi=function(){function n(e){this.s={},this.p=new Ut(0),this.ondata=e}return n.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,r=new Ut(t+e.length);r.set(this.p),r.set(e,t),this.p=r},n.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,r=h0(this.p,this.o,this.s);this.ondata(js(r,t,this.s.b),this.d),this.o=js(r,this.s.b-32768),this.s.b=this.o.length,this.p=js(this.p,this.s.p/8|0),this.s.p&=7},n.prototype.push=function(e,t){this.e(e),this.c(t)},n}(),M_=function(){function n(e){this.ondata=e,zh([Zh,function(){return[io,Vi]}],this,0,function(){var t=new Vi;onmessage=io(t)},7)}return n}();function T_(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Zh],function(r){return pc(Yh(r.data[0],E_(r.data[1])))},1,t)}function Yh(n,e){return h0(n,e)}var xw=function(){function n(e,t){this.c=Gh(),this.l=0,this.v=1,Ra.call(this,e,t)}return n.prototype.push=function(e,t){Ra.prototype.push.call(this,e,t)},n.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var r=Du(e,this.o,this.v&&__(this.o),t&&8,!t);this.v&&(U_(r,this.o),this.v=0),t&&($t(r,r.length-8,this.c.d()),$t(r,r.length-4,this.l)),this.ondata(r,t)},n}(),IN=function(){function n(e,t){zh([Jh,OZ,function(){return[io,Ra,xw]}],this,R_.call(this,e,t),function(r){var i=new xw(r.data);onmessage=io(i)},8)}return n}();function FN(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Jh,OZ,function(){return[Iw]}],function(r){return pc(Iw(r.data[0],r.data[1]))},2,t)}function Iw(n,e){e||(e={});var t=Gh(),r=n.length;t.p(n);var i=Du(n,e,__(e),8),s=i.length;return U_(i,e),$t(i,s-8,t.d()),$t(i,s-4,r),i}var Fw=function(){function n(e){this.v=1,Vi.call(this,e)}return n.prototype.push=function(e,t){if(Vi.prototype.e.call(this,e),this.v){var r=this.p.length>3?S_(this.p):4;if(r>=this.p.length&&!t)return;this.p=this.p.subarray(r),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Vi.prototype.c.call(this,t)},n}(),KZ=function(){function n(e){this.ondata=e,zh([Zh,GZ,function(){return[io,Vi,Fw]}],this,0,function(){var t=new Fw;onmessage=io(t)},9)}return n}();function jZ(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Zh,GZ,function(){return[Ew]}],function(r){return pc(Ew(r.data[0]))},3,t)}function Ew(n,e){return h0(n.subarray(S_(n),-8),e||new Ut(HZ(n)))}var SE=function(){function n(e,t){this.c=F_(),this.v=1,Ra.call(this,e,t)}return n.prototype.push=function(e,t){Ra.prototype.push.call(this,e,t)},n.prototype.p=function(e,t){this.c.p(e);var r=Du(e,this.o,this.v&&2,t&&4,!t);this.v&&(Q_(r,this.o),this.v=0),t&&$t(r,r.length-4,this.c.d()),this.ondata(r,t)},n}(),nse=function(){function n(e,t){zh([Jh,ZZ,function(){return[io,Ra,SE]}],this,R_.call(this,e,t),function(r){var i=new SE(r.data);onmessage=io(i)},10)}return n}();function rse(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Jh,ZZ,function(){return[_E]}],function(r){return pc(_E(r.data[0],r.data[1]))},4,t)}function _E(n,e){e||(e={});var t=F_();t.p(n);var r=Du(n,e,2,4);return Q_(r,e),$t(r,r.length-4,t.d()),r}var Uw=function(){function n(e){this.v=1,Vi.call(this,e)}return n.prototype.push=function(e,t){if(Vi.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)}Vi.prototype.c.call(this,t)},n}(),$Z=function(){function n(e){this.ondata=e,zh([Zh,JZ,function(){return[io,Vi,Uw]}],this,0,function(){var t=new Uw;onmessage=io(t)},11)}return n}();function qZ(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Zh,JZ,function(){return[Rm]}],function(r){return pc(Rm(r.data[0],E_(r.data[1])))},5,t)}function Rm(n,e){return h0((zZ(n),n.subarray(2,-4)),e)}var eJ=function(){function n(e){this.G=Fw,this.I=Vi,this.Z=Uw,this.ondata=e}return n.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 r=new Ut(this.p.length+e.length);r.set(this.p),r.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=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(s):(this.p[0]&15)!=8||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}}},n}(),ise=function(){function n(e){this.G=KZ,this.I=M_,this.Z=$Z,this.ondata=e}return n.prototype.push=function(e,t){eJ.prototype.push.call(this,e,t)},n}();function sse(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return n[0]==31&&n[1]==139&&n[2]==8?jZ(n,e,t):(n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31?T_(n,e,t):qZ(n,e,t)}function ose(n,e){return n[0]==31&&n[1]==139&&n[2]==8?Ew(n,e):(n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31?Yh(n,e):Rm(n,e)}var N_=function(n,e,t,r){for(var i in n){var s=n[i],o=e+i;s instanceof Ut?t[o]=[s,r]:Array.isArray(s)?t[o]=[s[0],p0(r,s[1])]:N_(s,o+"/",t,r)}},EN=typeof TextEncoder<"u"&&new TextEncoder,QE=typeof TextDecoder<"u"&&new TextDecoder,tJ=0;try{QE.decode(wl,{stream:!0}),tJ=1}catch{}var nJ=function(n){for(var e="",t=0;;){var r=n[t++],i=(r>127)+(r>223)+(r>239);if(t+i>n.length)return[e,js(n,t-1)];i?i==3?(r=((r&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?e+=String.fromCharCode((r&31)<<6|n[t++]&63):e+=String.fromCharCode((r&15)<<12|(n[t++]&63)<<6|n[t++]&63):e+=String.fromCharCode(r)}},ase=function(){function n(e){this.ondata=e,tJ?this.t=new TextDecoder:this.p=wl}return n.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}return}if(!this.p)throw"stream finished";var r=new Ut(this.p.length+e.length);r.set(this.p),r.set(e,this.p.length);var i=nJ(r),s=i[0],o=i[1];if(t){if(o.length)throw"invalid utf-8 data";this.p=null}else this.p=o;this.ondata(s,t)},n}(),lse=function(){function n(e){this.ondata=e}return n.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(tc(e),this.d=t||!1)},n}();function tc(n,e){if(e){for(var t=new Ut(n.length),r=0;r>1)),o=0,a=function(c){s[o++]=c},r=0;rs.length){var l=new Ut(o+8+(i-r<<1));l.set(s),s=l}var A=n.charCodeAt(r);A<128||e?a(A):A<2048?(a(192|A>>6),a(128|A&63)):A>55295&&A<57344?(A=65536+(A&1047552)|n.charCodeAt(++r)&1023,a(240|A>>18),a(128|A>>12&63),a(128|A>>6&63),a(128|A&63)):(a(224|A>>12),a(128|A>>6&63),a(128|A&63))}return js(s,0,o)}function D_(n,e){if(e){for(var t="",r=0;r65535)throw"extra field too long";e+=r+4}return e},xh=function(n,e,t,r,i,s,o,a){var l=r.length,A=t.extra,c=a&&a.length,u=OA(A);$t(n,e,o!=null?33639248:67324752),e+=4,o!=null&&(n[e++]=20,n[e++]=t.os),n[e]=20,e+=2,n[e++]=t.flag<<1|(s==null&&8),n[e++]=i&&8,n[e++]=t.compression&255,n[e++]=t.compression>>8;var f=new Date(t.mtime==null?Date.now():t.mtime),d=f.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if($t(n,e,d<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>>1),e+=4,s!=null&&($t(n,e,t.crc),$t(n,e+4,s),$t(n,e+8,t.size)),$t(n,e+12,l),$t(n,e+14,u),e+=16,o!=null&&($t(n,e,c),$t(n,e+6,t.attrs),$t(n,e+10,o),e+=14),n.set(r,e),e+=l,u)for(var h in A){var p=A[h],m=p.length;$t(n,e,+h),$t(n,e+2,m),n.set(p,e+4),e+=4+m}return c&&(n.set(a,e),e+=c),e},k_=function(n,e,t,r,i){$t(n,e,101010256),$t(n,e+8,t),$t(n,e+10,t),$t(n,e+12,r),$t(n,e+16,i)},Mm=function(){function n(e){this.filename=e,this.c=Gh(),this.size=0,this.compression=0}return n.prototype.process=function(e,t){this.ondata(null,e,t)},n.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)},n}(),Ase=function(){function n(e,t){var r=this;t||(t={}),Mm.call(this,e),this.d=new Ra(t,function(i,s){r.ondata(null,i,s)}),this.compression=8,this.flag=rJ(t.level)}return n.prototype.process=function(e,t){try{this.d.push(e,t)}catch(r){this.ondata(r,null,t)}},n.prototype.push=function(e,t){Mm.prototype.push.call(this,e,t)},n}(),cse=function(){function n(e,t){var r=this;t||(t={}),Mm.call(this,e),this.d=new YZ(t,function(i,s,o){r.ondata(i,s,o)}),this.compression=8,this.flag=rJ(t.level),this.terminate=this.d.terminate}return n.prototype.process=function(e,t){this.d.push(e,t)},n.prototype.push=function(e,t){Mm.prototype.push.call(this,e,t)},n}(),use=function(){function n(e){this.ondata=e,this.u=[],this.d=1}return n.prototype.add=function(e){var t=this;if(this.d&2)throw"stream finished";var r=tc(e.filename),i=r.length,s=e.comment,o=s&&tc(s),a=i!=e.filename.length||o&&s.length!=o.length,l=i+OA(e.extra)+30;if(i>65535)throw"filename too long";var A=new Ut(l);xh(A,0,e,r,a);var c=[A],u=function(){for(var m=0,g=c;m65535&&_("filename too long",null),!K)_(null,v);else if(C<16e4)try{_(null,g0(v,y))}catch(B){_(B,null)}else c.push(XZ(v,y,_))},h=0;h65535)throw"filename too long";var g=c?g0(l,A):l,v=g.length,y=Gh();y.p(l),r.push(p0(A,{size:l.length,crc:y.d(),c:g,f:u,m:h,u:f!=o.length||h&&d.length!=p,o:i,compression:c})),i+=30+f+m+v,s+=76+2*(f+m)+(p||0)+v}for(var w=new Ut(s+22),C=i,b=s-i,E=0;E0){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),e.length)return this.push(e,t)}else{var o=0,a=0,l=void 0,A=void 0;this.p.length?e.length?(A=new Ut(this.p.length+e.length),A.set(this.p),A.set(e,this.p.length)):A=this.p:A=e;for(var c=A.length,u=this.c,f=u&&this.d,d=function(){var g,v=zn(A,a);if(v==67324752){o=1,l=a,h.d=null,h.c=0;var y=hi(A,a+6),w=hi(A,a+8),C=y&2048,b=y&8,E=hi(A,a+26),x=hi(A,a+28);if(c>a+30+E+x){var S=[];h.k.unshift(S),o=2;var M=zn(A,a+18),Z=zn(A,a+22),K=D_(A.subarray(a+30,a+=30+E),!C);M==4294967295?(g=b?[-2]:oJ(A,a),M=g[0],Z=g[1]):b&&(M=-1),a+=x,h.c=M;var _,B={name:K,compression:w,start:function(){if(!B.ondata)throw"no callback";if(!M)B.ondata(null,wl,!0);else{var F=r.o[w];if(!F)throw"unknown compression type "+w;_=M<0?new F(K):new F(K,M,Z),_.ondata=function(V,O,L){B.ondata(V,O,L)};for(var R=0,k=S;R=0&&(B.size=M,B.originalSize=Z),h.onfile(B)}return"break"}else if(u){if(v==134695760)return l=a+=12+(u==-2&&8),o=3,h.c=0,"break";if(v==33639248)return l=a-=4,o=3,h.c=0,"break"}},h=this;a65558){e("invalid zip file",null);return}var o=hi(n,s+8);o||e(null,{});var a=o,l=zn(n,s+16),A=l==4294967295;if(A){if(s=zn(n,s-12),zn(n,s)!=101075792){e("invalid zip file",null);return}a=o=zn(n,s+32),l=zn(n,s+48)}for(var c=function(f){var d=sJ(n,l,A),h=d[0],p=d[1],m=d[2],g=d[3],v=d[4],y=d[5],w=iJ(n,y);l=v;var C=function(E,x){E?(r(),e(E,null)):(i[g]=x,--o||e(null,i))};if(!h)C(null,js(n,w,w+p));else if(h==8){var b=n.subarray(w,w+p);if(p<32e4)try{C(null,Yh(b,new Ut(m)))}catch(E){C(E,null)}else t.push(T_(b,{size:m},C))}else C("unknown compression type "+h,null)},u=0;u65558)throw"invalid zip file";var r=hi(n,t+8);if(!r)return{};var i=zn(n,t+16),s=i==4294967295;if(s){if(t=zn(n,t-12),zn(n,t)!=101075792)throw"invalid zip file";r=zn(n,t+32),i=zn(n,t+48)}for(var o=0;o=t[r])return r-1;if(e<=t[n])return n;let i=n,s=r,o=Math.floor((i+s)/2);for(;e=t[o+1];)e=p&&(h[d][0]=h[f][0]/a[v+1][g],m=h[d][0]*a[g][v]);const y=g>=-1?1:-g,w=u-1<=v?p-1:t-u;for(let b=y;b<=w;++b)h[d][b]=(h[f][b]-h[f][b-1])/a[v+1][g+b],m+=h[d][b]*a[g+b][v];u<=v&&(h[d][p]=-h[f][p-1]/a[v+1][u],m+=h[d][p]*a[u][v]),o[p][u]=m;const C=f;f=d,d=C}}let c=t;for(let u=1;u<=r;++u){for(let f=0;f<=t;++f)o[u][f]*=c;c*=t-u}return o}function bse(n,e,t,r,i){const s=i0,l=typeof s.Content=="string"&&s.Content!=="";if(a||l){const A=this.parseImage(r[i]);t[s.RelativeFilename||s.Filename]=A}}}}for(const r in e){const i=e[r];t[i]!==void 0?e[r]=t[i]:e[r]=e[r].split("\\").pop()}return e}parseImage(e){const t=e.Content,r=e.RelativeFilename||e.Filename,i=r.slice(r.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":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",r),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const o=new Uint8Array(t);return window.URL.createObjectURL(new Blob([o],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in It.Objects){const r=It.Objects.Texture;for(const i in r){const s=this.parseTexture(r[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const r=this.loadTexture(e,t);r.ID=e.id,r.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,o=i!==void 0?i.value:0,a=s!==void 0?s.value:0;if(r.wrapS=o===0?hs:di,r.wrapT=a===0?hs:di,"Scaling"in e){const l=e.Scaling.value;r.repeat.x=l[0],r.repeat.y=l[1]}if("Translation"in e){const l=e.Translation.value;r.offset.x=l[0],r.offset.y=l[1]}return r}loadTexture(e,t){let r;const i=this.textureLoader.path,s=Gn.get(e.id).children;s!==void 0&&s.length>0&&t[s[0].ID]!==void 0&&(r=t[s[0].ID],(r.indexOf("blob:")===0||r.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let o;const a=e.FileName.slice(-3).toLowerCase();if(a==="tga"){const l=this.manager.getHandler(".tga");l===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),o=new ir):(l.setPath(this.textureLoader.path),o=l.load(r))}else a==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),o=new ir):o=this.textureLoader.load(r);return this.textureLoader.setPath(i),o}parseMaterials(e){const t=new Map;if("Material"in It.Objects){const r=It.Objects.Material;for(const i in r){const s=this.parseMaterial(r[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const r=e.id,i=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!Gn.has(r))return null;const o=this.parseParameters(e,t,r);let a;switch(s.toLowerCase()){case"phong":a=new bI;break;case"lambert":a=new Kre;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new bI;break}return a.setValues(o),a.name=i,a}parseParameters(e,t,r){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=new Re().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=new Re().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=new Re().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=new Re().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 Re().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=new Re().fromArray(e.SpecularColor.value));const s=this;return Gn.get(r).children.forEach(function(o){const a=o.relationship;switch(a){case"Bump":i.bumpMap=s.getTexture(t,o.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,o.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,o.ID),i.map!==void 0&&(i.map.encoding=ht);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,o.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,o.ID),i.emissiveMap!==void 0&&(i.emissiveMap.encoding=ht);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,o.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,o.ID),i.envMap!==void 0&&(i.envMap.mapping=hw,i.envMap.encoding=ht);break;case"SpecularColor":i.specularMap=s.getTexture(t,o.ID),i.specularMap!==void 0&&(i.specularMap.encoding=ht);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,o.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.",a);break}}),i}getTexture(e,t){return"LayeredTexture"in It.Objects&&t in It.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Gn.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in It.Objects){const r=It.Objects.Deformer;for(const i in r){const s=r[i],o=Gn.get(parseInt(i));if(s.attrType==="Skin"){const a=this.parseSkeleton(o,r);a.ID=i,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=o.parents[0].ID,e[i]=a}else if(s.attrType==="BlendShape"){const a={id:i};a.rawTargets=this.parseMorphTargets(o,r),a.id=i,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=a}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const r=[];return e.children.forEach(function(i){const s=t[i.ID];if(s.attrType!=="Cluster")return;const o={ID:i.ID,indices:[],weights:[],transformLink:new Le().fromArray(s.TransformLink.a)};"Indexes"in s&&(o.indices=s.Indexes.a,o.weights=s.Weights.a),r.push(o)}),{rawBones:r,bones:[]}}parseMorphTargets(e,t){const r=[];for(let i=0;i1?o=a:a.length>0?o=a[0]:(o=new bI({color:13421772}),a.push(o)),"color"in s.attributes&&a.forEach(function(l){l.vertexColors=!0}),s.FBX_Deformer?(i=new qA(s,o),i.normalizeSkinWeights()):i=new In(s,o),i}createCurve(e,t){const r=e.children.reduce(function(s,o){return t.has(o.ID)&&(s=t.get(o.ID)),s},null),i=new Wl({color:3342591,linewidth:1});return new kh(r,i)}getTransformData(e,t){const r={};"InheritType"in t&&(r.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?r.eulerOrder=uJ(t.RotationOrder.value):r.eulerOrder="ZYX","Lcl_Translation"in t&&(r.translation=t.Lcl_Translation.value),"PreRotation"in t&&(r.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(r.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(r.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(r.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(r.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(r.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(r.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(r.rotationPivot=t.RotationPivot.value),e.userData.transformData=r}setLookAtProperties(e,t){"LookAtProperty"in t&&Gn.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=It.Objects.Model[i.ID];if("Lcl_Translation"in s){const o=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),xi.add(e.target)):e.lookAt(new z().fromArray(o))}}})}bindSkeleton(e,t,r){const i=this.parsePoseNodes();for(const s in e){const o=e[s];Gn.get(parseInt(o.ID)).parents.forEach(function(l){if(t.has(l.ID)){const A=l.ID;Gn.get(A).parents.forEach(function(u){r.has(u.ID)&&r.get(u.ID).bind(new hc(o.bones),i[u.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in It.Objects){const t=It.Objects.Pose;for(const r in t)if(t[r].attrType==="BindPose"&&t[r].NbPoseNodes>0){const i=t[r].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new Le().fromArray(s.Matrix.a)}):e[i.Node]=new Le().fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in It&&"AmbientColor"in It.GlobalSettings){const e=It.GlobalSettings.AmbientColor.value,t=e[0],r=e[1],i=e[2];if(t!==0||r!==0||i!==0){const s=new Re(t,r,i);xi.add(new bZ(s,1))}}}}class Sse{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in It.Objects){const r=It.Objects.Geometry;for(const i in r){const s=Gn.get(parseInt(i)),o=this.parseGeometry(s,r[i],e);t.set(parseInt(i),o)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,r){const i=r.skeletons,s=[],o=e.parents.map(function(u){return It.Objects.Model[u.ID]});if(o.length===0)return;const a=e.children.reduce(function(u,f){return i[f.ID]!==void 0&&(u=i[f.ID]),u},null);e.children.forEach(function(u){r.morphTargets[u.ID]!==void 0&&s.push(r.morphTargets[u.ID])});const l=o[0],A={};"RotationOrder"in l&&(A.eulerOrder=uJ(l.RotationOrder.value)),"InheritType"in l&&(A.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(A.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(A.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(A.scale=l.GeometricScaling.value);const c=cJ(A);return this.genGeometry(t,a,s,c)}genGeometry(e,t,r,i){const s=new Ht;e.attrName&&(s.name=e.attrName);const o=this.parseGeoNode(e,t),a=this.genBuffers(o),l=new rn(a.vertex,3);if(l.applyMatrix4(i),s.setAttribute("position",l),a.colors.length>0&&s.setAttribute("color",new rn(a.colors,3)),t&&(s.setAttribute("skinIndex",new XC(a.weightsIndices,4)),s.setAttribute("skinWeight",new rn(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){const A=new kn().getNormalMatrix(i),c=new rn(a.normal,3);c.applyNormalMatrix(A),s.setAttribute("normal",c)}if(a.uvs.forEach(function(A,c){let u="uv"+(c+1).toString();c===0&&(u="uv"),s.setAttribute(u,new rn(a.uvs[c],2))}),o.material&&o.material.mappingType!=="AllSame"){let A=a.materialIndex[0],c=0;if(a.materialIndex.forEach(function(u,f){u!==A&&(s.addGroup(c,f-c,A),A=u,c=f)}),s.groups.length>0){const u=s.groups[s.groups.length-1],f=u.start+u.count;f!==a.materialIndex.length&&s.addGroup(f,a.materialIndex.length-f,A)}s.groups.length===0&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,r,i),s}parseGeoNode(e,t){const r={};if(r.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],r.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(r.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(r.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(r.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){r.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return r.weightTable={},t!==null&&(r.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(o,a){r.weightTable[o]===void 0&&(r.weightTable[o]=[]),r.weightTable[o].push({id:s,weight:i.weights[a]})})})),r}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let r=0,i=0,s=!1,o=[],a=[],l=[],A=[],c=[],u=[];const f=this;return e.vertexIndices.forEach(function(d,h){let p,m=!1;d<0&&(d=d^-1,m=!0);let g=[],v=[];if(o.push(d*3,d*3+1,d*3+2),e.color){const y=Rv(h,r,d,e.color);l.push(y[0],y[1],y[2])}if(e.skeleton){if(e.weightTable[d]!==void 0&&e.weightTable[d].forEach(function(y){v.push(y.weight),g.push(y.id)}),v.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const y=[0,0,0,0],w=[0,0,0,0];v.forEach(function(C,b){let E=C,x=g[b];w.forEach(function(S,M,Z){if(E>S){Z[M]=E,E=S;const K=y[M];y[M]=x,x=K}})}),g=y,v=w}for(;v.length<4;)v.push(0),g.push(0);for(let y=0;y<4;++y)c.push(v[y]),u.push(g[y])}if(e.normal){const y=Rv(h,r,d,e.normal);a.push(y[0],y[1],y[2])}e.material&&e.material.mappingType!=="AllSame"&&(p=Rv(h,r,d,e.material)[0],p<0&&(f.negativeMaterialIndices=!0,p=0)),e.uv&&e.uv.forEach(function(y,w){const C=Rv(h,r,d,y);A[w]===void 0&&(A[w]=[]),A[w].push(C[0]),A[w].push(C[1])}),i++,m&&(f.genFace(t,e,o,p,a,l,A,c,u,i),r++,i=0,o=[],a=[],l=[],A=[],c=[],u=[])}),t}genFace(e,t,r,i,s,o,a,l,A,c){for(let u=2;u1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const o=e.get(s[0].ID);r[i]={name:t[i].attrName,layer:o}}return r}addClip(e){let t=[];const r=this;return e.layer.forEach(function(i){t=t.concat(r.generateTracks(i))}),new vu(e.name,-1,t)}generateTracks(e){const t=[];let r=new z,i=new tt,s=new z;if(e.transform&&e.transform.decompose(r,i,s),r=r.toArray(),i=new Kr().setFromQuaternion(i,e.eulerOrder).toArray(),s=s.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.T.curves,r,"position");o!==void 0&&t.push(o)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const o=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);o!==void 0&&t.push(o)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");o!==void 0&&t.push(o)}if(e.DeformPercent!==void 0){const o=this.generateMorphTrack(e);o!==void 0&&t.push(o)}return t}generateVectorTrack(e,t,r,i){const s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,r);return new ec(e+"."+i,s,o)}generateRotationTrack(e,t,r,i,s,o){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Wt.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Wt.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Wt.degToRad));const a=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(a,t,r);i!==void 0&&(i=i.map(Wt.degToRad),i.push(o),i=new Kr().fromArray(i),i=new tt().setFromEuler(i)),s!==void 0&&(s=s.map(Wt.degToRad),s.push(o),s=new Kr().fromArray(s),s=new tt().setFromEuler(s).invert());const A=new tt,c=new Kr,u=[];for(let f=0;f1){let r=1,i=t[0];for(let s=1;s=180){const o=s/180,a=i/o;let l=r+a;const A=e.times[t-1],u=(e.times[t]-A)/o;let f=A+u;const d=[],h=[];for(;f1&&(r=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:r,type:i}}parseNodeProperty(e,t,r){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=r.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if(o.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){const l=s.split(",").slice(1),A=parseInt(l[0]),c=parseInt(l[1]);let u=s.split(",").slice(3);u=u.map(function(f){return f.trim().replace(/^"/,"")}),i="connections",s=[A,c],kse(s,u),o[i]===void 0&&(o[i]=[])}i==="Node"&&(o.id=s),i in o&&Array.isArray(o[i])?o[i].push(s):i!=="a"?o[i]=s:o.a=s,this.setCurrentProp(o,i),i==="a"&&s.slice(-1)!==","&&(o.a=_I(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=_I(t.a))}parseNodeSpecialProperty(e,t,r){const i=r.split('",').map(function(c){return c.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],o=i[1],a=i[2],l=i[3];let A=i[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":A=parseFloat(A);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":A=_I(A);break}this.getPrevNode()[s]={type:o,type2:a,flag:l,value:A},this.setCurrentProp(this.getPrevNode(),s)}}class Rse{parse(e){const t=new SN(e);t.skip(23);const r=t.getUint32();if(r<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+r);const i=new AJ;for(;!this.endOfContent(t);){const s=this.parseNode(t,r);s!==null&&i.add(s.name,s)}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 r={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const o=e.getUint8(),a=e.getString(o);if(i===0)return null;const l=[];for(let f=0;f0?l[0]:"",c=l.length>1?l[1]:"",u=l.length>2?l[2]:"";for(r.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){const f=this.parseNode(e,t);f!==null&&this.parseSubNode(a,r,f)}return r.propertyList=l,typeof A=="number"&&(r.id=A),c!==""&&(r.attrName=c),u!==""&&(r.attrType=u),a!==""&&(r.name=a),r}parseSubNode(e,t,r){if(r.singleProperty===!0){const i=r.propertyList[0];Array.isArray(i)?(t[r.name]=r,r.a=i):t[r.name]=i}else if(e==="Connections"&&r.name==="C"){const i=[];r.propertyList.forEach(function(s,o){o!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(r.name==="Properties70")Object.keys(r).forEach(function(s){t[s]=r[s]});else if(e==="Properties70"&&r.name==="P"){let i=r.propertyList[0],s=r.propertyList[1];const o=r.propertyList[2],a=r.propertyList[3];let l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?l=[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:l=r.propertyList[4],t[i]={type:s,type2:o,flag:a,value:l}}else t[r.name]===void 0?typeof r.id=="number"?(t[r.name]={},t[r.name][r.id]=r):t[r.name]=r:r.name==="PoseNode"?(Array.isArray(t[r.name])||(t[r.name]=[t[r.name]]),t[r.name].push(r)):t[r.name][r.id]===void 0&&(t[r.name][r.id]=r)}parseProperty(e){const t=e.getString(1);let r;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 r=e.getUint32(),e.getArrayBuffer(r);case"S":return r=e.getUint32(),e.getString(r);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),o=e.getUint32();if(s===0)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)}typeof yse>"u"&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=Rm(new Uint8Array(e.getArrayBuffer(o))),l=new SN(a.buffer);switch(t){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class SN{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let r=0;r=0&&(t=t.slice(0,r)),ba.decodeText(new Uint8Array(t))}}class AJ{add(e,t){this[e]=t}}function Mse(n){const e="Kaydara FBX Binary \0";return n.byteLength>=e.length&&e===fJ(n,0,e.length)}function Tse(n){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function r(i){const s=n[i-1];return n=n.slice(t+i),t++,s}for(let i=0;i4?o=n.array[i*n.itemSize+s]:s===0?o=n.getX(i):s===1?o=n.getY(i):s===2?o=n.getZ(i):s===3&&(o=n.getW(i)),r.min[s]=Math.min(r.min[s],o),r.max[s]=Math.max(r.max[s],o)}return r}function dJ(n){return Math.ceil(n/4)*4}function QI(n,e=0){const t=dJ(n.byteLength);if(t!==n.byteLength){const r=new Uint8Array(t);if(r.set(new Uint8Array(n)),e!==0)for(let i=n.byteLength;i"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function DN(n,e){if(n.toBlob!==void 0)return new Promise(r=>n.toBlob(r,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),n.convertToBlob({type:e,quality:t})}class Hse{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,r){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,s=i.buffers,o=i.json;r=i.options;const a=i.extensionsUsed,l=new Blob(s,{type:"application/octet-stream"}),A=Object.keys(a);if(A.length>0&&(o.extensionsUsed=A),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=l.size),r.binary===!0){const c=new FileReader;c.readAsArrayBuffer(l),c.onloadend=function(){const u=QI(c.result),f=new DataView(new ArrayBuffer(TN));f.setUint32(0,u.byteLength,!0),f.setUint32(4,Ose,!0);const d=QI(Gse(JSON.stringify(o)),32),h=new DataView(new ArrayBuffer(TN));h.setUint32(0,d.byteLength,!0),h.setUint32(4,Wse,!0);const p=new ArrayBuffer(MN),m=new DataView(p);m.setUint32(0,Lse,!0),m.setUint32(4,Pse,!0);const g=MN+h.byteLength+d.byteLength+f.byteLength+u.byteLength;m.setUint32(8,g,!0);const v=new Blob([p,h,d,f,u],{type:"application/octet-stream"}),y=new FileReader;y.readAsArrayBuffer(v),y.onloadend=function(){t(y.result)}}}else if(o.buffers&&o.buffers.length>0){const c=new FileReader;c.readAsDataURL(l),c.onloadend=function(){const u=c.result;o.buffers[0].uri=u,t(o)}}else t(o)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const r=this.options,i=this.extensionsUsed;try{const s=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&s.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const o in s.gltfExtensions)t.extensions[o]=s.gltfExtensions[o],i[o]=!0;delete s.gltfExtensions}Object.keys(s).length>0&&(t.extras=s)}catch(s){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+s.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const i=new Map;i.set(!0,this.uid++),i.set(!1,this.uid++),this.uids.set(e,i)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const r=new z;for(let i=0,s=e.count;i5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const r=e.clone(),i=new z;for(let s=0,o=r.count;s4?p=e.array[d*e.itemSize+h]:h===0?p=e.getX(d):h===1?p=e.getY(d):h===2?p=e.getZ(d):h===3&&(p=e.getW(d)),t===nn.FLOAT?A.setFloat32(c,p,!0):t===nn.UNSIGNED_INT?A.setUint32(c,p,!0):t===nn.UNSIGNED_SHORT?A.setUint16(c,p,!0):t===nn.UNSIGNED_BYTE&&A.setUint8(c,p),c+=a}const u={buffer:this.processBuffer(A.buffer),byteOffset:this.byteOffset,byteLength:l};return s!==void 0&&(u.target=s),s===nn.ARRAY_BUFFER&&(u.byteStride=e.itemSize*a),this.byteOffset+=l,o.bufferViews.push(u),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise(function(i){const s=new FileReader;s.readAsArrayBuffer(e),s.onloadend=function(){const o=QI(s.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,i(r.bufferViews.push(a)-1)}})}processAccessor(e,t,r,i){const s=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"};let a;if(e.array.constructor===Float32Array)a=nn.FLOAT;else if(e.array.constructor===Uint32Array)a=nn.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)a=nn.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)a=nn.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");if(r===void 0&&(r=0),i===void 0&&(i=e.count),i===0)return null;const l=Jse(e,r,i);let A;t!==void 0&&(A=e===t.index?nn.ELEMENT_ARRAY_BUFFER:nn.ARRAY_BUFFER);const c=this.processBufferView(e,a,r,i,A),u={bufferView:c.id,byteOffset:c.byteOffset,componentType:a,count:i,max:l.max,min:l.min,type:o[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(u)-1}processImage(e,t,r,i="image/png"){const s=this,o=s.cache,a=s.json,l=s.options,A=s.pending;o.images.has(e)||o.images.set(e,{});const c=o.images.get(e),u=i+":flipY/"+r.toString();if(c[u]!==void 0)return c[u];a.images||(a.images=[]);const f={mimeType:i},d=NN();d.width=Math.min(e.width,l.maxTextureSize),d.height=Math.min(e.height,l.maxTextureSize);const h=d.getContext("2d");if(r===!0&&(h.translate(0,d.height),h.scale(1,-1)),e.data!==void 0){t!==br&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const m=new Uint8ClampedArray(e.height*e.width*4);for(let g=0;gs.processBufferViewImage(m)).then(m=>{f.bufferView=m})):d.toDataURL!==void 0?f.uri=d.toDataURL(i):A.push(DN(d,i).then(m=>new FileReader().readAsDataURL(m)).then(m=>{f.uri=m}));const p=a.images.push(f)-1;return c[u]=p,p}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const r={magFilter:os[e.magFilter],minFilter:os[e.minFilter],wrapS:os[e.wrapS],wrapT:os[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){const t=this.cache,r=this.json;if(t.textures.has(e))return t.textures.get(e);r.textures||(r.textures=[]);let i=e.userData.mimeType;i==="image/webp"&&(i="image/png");const s={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(s.name=e.name),this._invokeAll(function(a){a.writeTexture&&a.writeTexture(e,s)});const o=r.textures.push(s)-1;return t.textures.set(e,o),o}processMaterial(e){const t=this.cache,r=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);const i={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const s=e.color.toArray().concat([e.opacity]);if(dg(s,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),l={index:this.processTexture(a)};this.applyTextureTransform(l,a),i.pbrMetallicRoughness.metallicRoughnessTexture=l}if(e.map){const a={index:this.processTexture(e.map)};this.applyTextureTransform(a,e.map),i.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive.clone().multiplyScalar(e.emissiveIntensity),l=Math.max(a.r,a.g,a.b);if(l>1&&(a.multiplyScalar(1/l),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),l>0&&(i.emissiveFactor=a.toArray()),e.emissiveMap){const A={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(A,e.emissiveMap),i.emissiveTexture=A}}if(e.normalMap){const a={index:this.processTexture(e.normalMap)};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),i.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:1};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),i.occlusionTexture=a}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===pi&&(i.doubleSided=!0),e.name!==""&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,i)});const o=r.materials.push(i)-1;return t.materials.set(e,o),o}processMesh(e){const t=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let y=0,w=e.material.length;y0){const y=[],w=[],C={};if(e.morphTargetDictionary!==void 0)for(const b in e.morphTargetDictionary)C[e.morphTargetDictionary[b]]=b;for(let b=0;b0&&(l.extras={},l.extras.targetNames=w)}const p=Array.isArray(e.material);if(p&&o.groups.length===0)return null;const m=p?e.material:[e.material],g=p?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let y=0,w=g.length;y0&&(C.targets=u),o.index!==null){let E=this.getUID(o.index);(g[y].start!==void 0||g[y].count!==void 0)&&(E+=":"+g[y].start+":"+g[y].count),t.attributes.has(E)?C.indices=t.attributes.get(E):(C.indices=this.processAccessor(o.index,o,g[y].start,g[y].count),t.attributes.set(E,C.indices)),C.indices===null&&delete C.indices}const b=this.processMaterial(m[g[y].materialIndex]);b!==null&&(C.material=b),c.push(C)}l.primitives=c,r.meshes||(r.meshes=[]),this._invokeAll(function(y){y.writeMesh&&y.writeMesh(e,l)});const v=r.meshes.push(l)-1;return t.meshes.set(s,v),v}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const r=e.isOrthographicCamera,i={type:r?"orthographic":"perspective"};return r?i.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:Wt.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const r=this.json,i=this.nodeMap;r.animations||(r.animations=[]),e=V_.Utils.mergeMorphTargetTracks(e.clone(),t);const s=e.tracks,o=[],a=[];for(let l=0;l0){const a=[];for(let l=0,A=e.children.length;l0&&(s.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,s)});const o=t.nodes.push(s)-1;return i.set(e,o),o}processScene(e){const t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};e.name!==""&&(i.name=e.name),t.scenes.push(i);const s=[];for(let o=0,a=e.children.length;o0&&(i.nodes=s),this.serializeUserData(e,i)}processObjects(e){const t=new yw;t.name="AuxScene";for(let r=0;r0&&this.processObjects(r);for(let i=0;i0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),s[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},s[this.name]=!0);const a=i.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}class Yse{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class Xse{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;const r=this.writer,i=r.extensionsUsed,s={};t.pbrMetallicRoughness.baseColorFactor&&(s.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);const o=[1,1,1];if(e.specular.toArray(o,0),s.specularFactor=o,s.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(s.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){const a={index:r.processTexture(e.specularMap)};r.applyTextureTransform(a,e.specularMap),s.specularGlossinessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class Kse{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial)return;const r=this.writer,i=r.extensionsUsed,s={};if(s.clearcoatFactor=e.clearcoat,e.clearcoatMap){const o={index:r.processTexture(e.clearcoatMap)};r.applyTextureTransform(o,e.clearcoatMap),s.clearcoatTexture=o}if(s.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const o={index:r.processTexture(e.clearcoatRoughnessMap)};r.applyTextureTransform(o,e.clearcoatRoughnessMap),s.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){const o={index:r.processTexture(e.clearcoatNormalMap)};r.applyTextureTransform(o,e.clearcoatNormalMap),s.clearcoatNormalTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class jse{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial)return;const r=this.writer,i=r.extensionsUsed,s={};if(s.iridescenceFactor=e.iridescence,e.iridescenceMap){const o={index:r.processTexture(e.iridescenceMap)};r.applyTextureTransform(o,e.iridescenceMap),s.iridescenceTexture=o}if(s.iridescenceIor=e.iridescenceIOR,s.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],s.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const o={index:r.processTexture(e.iridescenceThicknessMap)};r.applyTextureTransform(o,e.iridescenceThicknessMap),s.iridescenceThicknessTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class $se{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,i=r.extensionsUsed,s={};if(s.transmissionFactor=e.transmission,e.transmissionMap){const o={index:r.processTexture(e.transmissionMap)};r.applyTextureTransform(o,e.transmissionMap),s.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class qse{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,i=r.extensionsUsed,s={};if(s.thicknessFactor=e.thickness,e.thicknessMap){const o={index:r.processTexture(e.thicknessMap)};r.applyTextureTransform(o,e.thicknessMap),s.thicknessTexture=o}s.attenuationDistance=e.attenuationDistance,s.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}V_.Utils={insertKeyframe:function(n,e){const r=n.getValueSize(),i=new n.TimeBufferType(n.times.length+1),s=new n.ValueBufferType(n.values.length+r),o=n.createInterpolant(new n.ValueBufferType(r));let a;if(n.times.length===0){i[0]=e;for(let l=0;ln.times[n.times.length-1]){if(Math.abs(n.times[n.times.length-1]-e)<.001)return n.times.length-1;i[i.length-1]=e,i.set(n.times,0),s.set(n.values,0),s.set(o.evaluate(e),n.values.length),a=i.length-1}else for(let l=0;le){i.set(n.times.slice(0,l+1),0),i[l+1]=e,i.set(n.times.slice(l+1),l+2),s.set(n.values.slice(0,(l+1)*r),0),s.set(o.evaluate(e),(l+1)*r),s.set(n.values.slice((l+1)*r),(l+2)*r),a=l+1;break}}return n.times=i,n.values=s,a},mergeMorphTargetTracks:function(n,e){const t=[],r={},i=n.tracks;for(let s=0;s0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function noe(n){var e=pJ(n),t=e[0],r=e[1];return(t+r)*3/4-r}function roe(n,e,t){return(e+t)*3/4-t}function ioe(n){var e,t=pJ(n),r=t[0],i=t[1],s=new eoe(roe(n,r,i)),o=0,a=i>0?r-4:r,l;for(l=0;l>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Ds[n.charCodeAt(l)]<<2|Ds[n.charCodeAt(l+1)]>>4,s[o++]=e&255),i===1&&(e=Ds[n.charCodeAt(l)]<<10|Ds[n.charCodeAt(l+1)]<<4|Ds[n.charCodeAt(l+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function soe(n){return ca[n>>18&63]+ca[n>>12&63]+ca[n>>6&63]+ca[n&63]}function ooe(n,e,t){for(var r,i=[],s=e;sa?a:o+s));return r===1?(e=n[t-1],i.push(ca[e>>2]+ca[e<<4&63]+"==")):r===2&&(e=(n[t-2]<<8)+n[t-1],i.push(ca[e>>10]+ca[e>>4&63]+ca[e<<2&63]+"=")),i.join("")}var L_={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */L_.read=function(n,e,t,r,i){var s,o,a=i*8-r-1,l=(1<>1,c=-7,u=t?i-1:0,f=t?-1:1,d=n[e+u];for(u+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=s*256+n[e+u],u+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=o*256+n[e+u],u+=f,c-=8);if(s===0)s=1-A;else{if(s===l)return o?NaN:(d?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-A}return(d?-1:1)*o*Math.pow(2,s-r)};L_.write=function(n,e,t,r,i,s){var o,a,l,A=s*8-i-1,c=(1<>1,f=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,h=r?1:-1,p=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+u>=1?e+=f/l:e+=f*Math.pow(2,1-u),e*l>=2&&(o++,l/=2),o+u>=c?(a=0,o=c):o+u>=1?(a=(e*l-1)*Math.pow(2,i),o=o+u):(a=e*Math.pow(2,u-1)*Math.pow(2,i),o=0));i>=8;n[t+d]=a&255,d+=h,a/=256,i-=8);for(o=o<0;n[t+d]=o&255,d+=h,o/=256,A-=8);n[t+d-h]|=p*128};/*! +*/var bN={},IE=function(n){return URL.createObjectURL(new Blob([n],{type:"text/javascript"}))},SZ=function(n){return new Worker(n)};try{URL.revokeObjectURL(IE(""))}catch{IE=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},SZ=function(e){return new Worker(e,{type:"module"})}}var ese=function(n,e,t,r,i){var s=SZ(bN[e]||(bN[e]=IE(n)));return s.onerror=function(o){return i(o.error,null)},s.onmessage=function(o){return i(null,o.data)},s.postMessage(t,r),s},Ut=Uint8Array,xr=Uint16Array,Nl=Uint32Array,Wh=new Ut([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]),Oh=new Ut([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]),_m=new Ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_Z=function(n,e){for(var t=new xr(31),r=0;r<31;++r)t[r]=e+=1<>>1|(gn&21845)<<1;iA=(iA&52428)>>>2|(iA&13107)<<2,iA=(iA&61680)>>>4|(iA&3855)<<4,Qm[gn]=((iA&65280)>>>8|(iA&255)<<8)>>>1}var Ks=function(n,e,t){for(var r=n.length,i=0,s=new xr(e);i>>l]=A}else for(a=new xr(r),i=0;i>>15-n[i]);return a},Dl=new Ut(288);for(var gn=0;gn<144;++gn)Dl[gn]=8;for(var gn=144;gn<256;++gn)Dl[gn]=9;for(var gn=256;gn<280;++gn)Dl[gn]=7;for(var gn=280;gn<288;++gn)Dl[gn]=8;var bh=new Ut(32);for(var gn=0;gn<32;++gn)bh[gn]=5;var TZ=Ks(Dl,9,0),NZ=Ks(Dl,9,1),DZ=Ks(bh,5,0),kZ=Ks(bh,5,1),sB=function(n){for(var e=n[0],t=1;te&&(e=n[t]);return e},Qs=function(n,e,t){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(e&7)&t},oB=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},d0=function(n){return(n/8|0)+(n&7&&1)},js=function(n,e,t){(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof xr?xr:n instanceof Nl?Nl:Ut)(t-e);return r.set(n.subarray(e,t)),r},h0=function(n,e,t){var r=n.length;if(!r||t&&!t.l&&r<5)return e||new Ut(0);var i=!e||t,s=!t||t.i;t||(t={}),e||(e=new Ut(r*3));var o=function(j){var oe=e.length;if(j>oe){var ie=new Ut(Math.max(oe*2,j));ie.set(e),e=ie}},a=t.f||0,l=t.p||0,A=t.b||0,c=t.l,u=t.d,f=t.m,d=t.n,h=r*8;do{if(!c){t.f=a=Qs(n,l,1);var p=Qs(n,l+1,3);if(l+=3,p)if(p==1)c=NZ,u=kZ,f=9,d=5;else if(p==2){var y=Qs(n,l,31)+257,w=Qs(n,l+10,15)+4,C=y+Qs(n,l+5,31)+1;l+=14;for(var b=new Ut(C),E=new Ut(19),x=0;x>>4;if(m<16)b[x++]=m;else{var _=0,B=0;for(m==16?(B=3+Qs(n,l,3),l+=2,_=b[x-1]):m==17?(B=3+Qs(n,l,7),l+=3):m==18&&(B=11+Qs(n,l,127),l+=7);B--;)b[x++]=_}}var F=b.subarray(0,y),R=b.subarray(y);f=sB(F),d=sB(R),c=Ks(F,f,1),u=Ks(R,d,1)}else throw"invalid block type";else{var m=d0(l)+4,g=n[m-4]|n[m-3]<<8,v=m+g;if(v>r){if(s)throw"unexpected EOF";break}i&&o(A+g),e.set(n.subarray(m,v),A),t.b=A+=g,t.p=l=v*8;continue}if(l>h){if(s)throw"unexpected EOF";break}}i&&o(A+131072);for(var k=(1<>>4;if(l+=_&15,l>h){if(s)throw"unexpected EOF";break}if(!_)throw"invalid length/literal";if(O<256)e[A++]=O;else if(O==256){V=l,c=null;break}else{var L=O-254;if(O>264){var x=O-257,U=Wh[x];L=Qs(n,l,(1<>>4;if(!H)throw"invalid distance";l+=H&15;var R=MZ[le];if(le>3){var U=Oh[le];R+=oB(n,l)&(1<h){if(s)throw"unexpected EOF";break}i&&o(A+131072);for(var N=A+L;A>>8},Mf=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>>8,n[r+2]|=t>>>16},aB=function(n,e){for(var t=[],r=0;rf&&(f=s[r].s);var d=new xr(f+1),h=bw(t[c-1],d,0);if(h>e){var r=0,p=0,m=h-e,g=1<e)p+=g-(1<>>=m;p>0;){var y=s[r].s;d[y]=0&&p;--r){var w=s[r].s;d[w]==e&&(--d[w],++p)}h=e}return[new Ut(d),h]},bw=function(n,e,t){return n.s==-1?Math.max(bw(n.l,e,t+1),bw(n.r,e,t+1)):e[n.s]=t},EE=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new xr(++e),r=0,i=n[0],s=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(n[a]==i&&a!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=n[a]}return[t.subarray(0,r),e]},Tf=function(n,e){for(var t=0,r=0;r>>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var s=0;s4&&!M[_m[K-1]];--K);var _=A+5<<3,B=Tf(i,Dl)+Tf(s,bh)+o,F=Tf(i,f)+Tf(s,p)+o+14+3*K+Tf(E,M)+(2*E[16]+3*E[17]+7*E[18]);if(_<=B&&_<=F)return Zg(e,c,n.subarray(l,l+A));var R,k,T,V;if(ea(e,c,1+(F15&&(ea(e,c,H[x]>>>5&127),c+=H[x]>>>12)}}else R=TZ,k=Dl,T=DZ,V=bh;for(var x=0;x255){var le=r[x]>>>18&31;Mf(e,c,R[le+257]),c+=k[le+257],le>7&&(ea(e,c,r[x]>>>23&31),c+=Wh[le]);var N=r[x]&31;Mf(e,c,T[N]),c+=V[N],N>3&&(Mf(e,c,r[x]>>>5&8191),c+=Oh[N])}else Mf(e,c,R[r[x]]),c+=k[r[x]];return Mf(e,c,R[256]),c+k[256]},VZ=new Nl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),wl=new Ut(0),LZ=function(n,e,t,r,i,s){var o=n.length,a=new Ut(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),A=0;if(!e||o<8)for(var c=0;c<=o;c+=65535){var u=c+65535;u>>13,h=f&8191,p=(1<7e3||M>24576)&&R>423){A=UE(n,l,0,C,b,E,S,M,K,c-K,A),M=x=S=0,K=c;for(var k=0;k<286;++k)b[k]=0;for(var k=0;k<30;++k)E[k]=0}var T=2,V=0,O=h,L=B-F&32767;if(R>2&&_==w(c-L))for(var U=Math.min(d,R)-1,H=Math.min(32767,c),le=Math.min(258,R);L<=H&&--O&&B!=F;){if(n[c+T]==n[c+T-L]){for(var N=0;NT){if(T=N,V=L,N>U)break;for(var j=Math.min(L,N-2),oe=0,k=0;koe&&(oe=X,F=ie)}}}B=F,F=m[B],L+=B-F+32768&32767}if(V){C[M++]=268435456|Cw[T]<<18|FE[V];var ne=Cw[T]&31,ae=FE[V]&31;S+=Wh[ne]+Oh[ae],++b[257+ne],++E[ae],Z=c+T,++x}else C[M++]=n[c],++b[n[c]]}}A=UE(n,l,s,C,b,E,S,M,K,c-K,A),!s&&A&7&&(A=Zg(l,A+1,wl))}return js(a,0,r+d0(A)+i)},PZ=function(){for(var n=new Nl(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(t&1&&3988292384)^t>>>1;n[e]=t}return n}(),Gh=function(){var n=-1;return{p:function(e){for(var t=n,r=0;r>>8;n=t},d:function(){return~n}}},F_=function(){var n=1,e=0;return{p:function(t){for(var r=n,i=e,s=t.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o>16),i=(i&65535)+15*(i>>16)}n=r,e=i},d:function(){return n%=65521,e%=65521,(n&255)<<24|n>>>8<<16|(e&255)<<8|e>>>8}}},Du=function(n,e,t,r,i){return LZ(n,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):12+e.mem,t,r,!i)},p0=function(n,e){var t={};for(var r in n)t[r]=n[r];for(var r in e)t[r]=e[r];return t},xN=function(n,e,t){for(var r=n(),i=n.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o>>0},UI=function(n,e){return zn(n,e)+zn(n,e+4)*4294967296},$t=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8},U_=function(n,e){var t=e.filename;if(n[0]=31,n[1]=139,n[2]=8,n[8]=e.level<2?4:e.level==9?2:0,n[9]=3,e.mtime!=0&&$t(n,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){n[3]=8;for(var r=0;r<=t.length;++r)n[r+10]=t.charCodeAt(r)}},S_=function(n){if(n[0]!=31||n[1]!=139||n[2]!=8)throw"invalid gzip data";var e=n[3],t=10;e&4&&(t+=n[10]|(n[11]<<8)+2);for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!n[t++]);return t+(e&2)},HZ=function(n){var e=n.length;return(n[e-4]|n[e-3]<<8|n[e-2]<<16|n[e-1]<<24)>>>0},__=function(n){return 10+(n.filename&&n.filename.length+1||0)},Q_=function(n,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;n[0]=120,n[1]=r<<6|(r?32-2*r:1)},zZ=function(n){if((n[0]&15)!=8||n[0]>>>4>7||(n[0]<<8|n[1])%31)throw"invalid zlib data";if(n[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function R_(n,e){return!e&&typeof n=="function"&&(e=n,n={}),this.ondata=e,n}var Ra=function(){function n(e,t){!t&&typeof e=="function"&&(t=e,e={}),this.ondata=t,this.o=e||{}}return n.prototype.p=function(e,t){this.ondata(Du(e,this.o,0,0,!t),t)},n.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)},n}(),YZ=function(){function n(e,t){zh([Jh,function(){return[io,Ra]}],this,R_.call(this,e,t),function(r){var i=new Ra(r.data);onmessage=io(i)},6)}return n}();function XZ(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Jh],function(r){return pc(g0(r.data[0],r.data[1]))},0,t)}function g0(n,e){return Du(n,e||{},0,0)}var Vi=function(){function n(e){this.s={},this.p=new Ut(0),this.ondata=e}return n.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,r=new Ut(t+e.length);r.set(this.p),r.set(e,t),this.p=r},n.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,r=h0(this.p,this.o,this.s);this.ondata(js(r,t,this.s.b),this.d),this.o=js(r,this.s.b-32768),this.s.b=this.o.length,this.p=js(this.p,this.s.p/8|0),this.s.p&=7},n.prototype.push=function(e,t){this.e(e),this.c(t)},n}(),M_=function(){function n(e){this.ondata=e,zh([Zh,function(){return[io,Vi]}],this,0,function(){var t=new Vi;onmessage=io(t)},7)}return n}();function T_(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Zh],function(r){return pc(Yh(r.data[0],E_(r.data[1])))},1,t)}function Yh(n,e){return h0(n,e)}var xw=function(){function n(e,t){this.c=Gh(),this.l=0,this.v=1,Ra.call(this,e,t)}return n.prototype.push=function(e,t){Ra.prototype.push.call(this,e,t)},n.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var r=Du(e,this.o,this.v&&__(this.o),t&&8,!t);this.v&&(U_(r,this.o),this.v=0),t&&($t(r,r.length-8,this.c.d()),$t(r,r.length-4,this.l)),this.ondata(r,t)},n}(),IN=function(){function n(e,t){zh([Jh,OZ,function(){return[io,Ra,xw]}],this,R_.call(this,e,t),function(r){var i=new xw(r.data);onmessage=io(i)},8)}return n}();function FN(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Jh,OZ,function(){return[Iw]}],function(r){return pc(Iw(r.data[0],r.data[1]))},2,t)}function Iw(n,e){e||(e={});var t=Gh(),r=n.length;t.p(n);var i=Du(n,e,__(e),8),s=i.length;return U_(i,e),$t(i,s-8,t.d()),$t(i,s-4,r),i}var Fw=function(){function n(e){this.v=1,Vi.call(this,e)}return n.prototype.push=function(e,t){if(Vi.prototype.e.call(this,e),this.v){var r=this.p.length>3?S_(this.p):4;if(r>=this.p.length&&!t)return;this.p=this.p.subarray(r),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Vi.prototype.c.call(this,t)},n}(),KZ=function(){function n(e){this.ondata=e,zh([Zh,GZ,function(){return[io,Vi,Fw]}],this,0,function(){var t=new Fw;onmessage=io(t)},9)}return n}();function jZ(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Zh,GZ,function(){return[Ew]}],function(r){return pc(Ew(r.data[0]))},3,t)}function Ew(n,e){return h0(n.subarray(S_(n),-8),e||new Ut(HZ(n)))}var SE=function(){function n(e,t){this.c=F_(),this.v=1,Ra.call(this,e,t)}return n.prototype.push=function(e,t){Ra.prototype.push.call(this,e,t)},n.prototype.p=function(e,t){this.c.p(e);var r=Du(e,this.o,this.v&&2,t&&4,!t);this.v&&(Q_(r,this.o),this.v=0),t&&$t(r,r.length-4,this.c.d()),this.ondata(r,t)},n}(),nse=function(){function n(e,t){zh([Jh,ZZ,function(){return[io,Ra,SE]}],this,R_.call(this,e,t),function(r){var i=new SE(r.data);onmessage=io(i)},10)}return n}();function rse(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Jh,ZZ,function(){return[_E]}],function(r){return pc(_E(r.data[0],r.data[1]))},4,t)}function _E(n,e){e||(e={});var t=F_();t.p(n);var r=Du(n,e,2,4);return Q_(r,e),$t(r,r.length-4,t.d()),r}var Uw=function(){function n(e){this.v=1,Vi.call(this,e)}return n.prototype.push=function(e,t){if(Vi.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)}Vi.prototype.c.call(this,t)},n}(),$Z=function(){function n(e){this.ondata=e,zh([Zh,JZ,function(){return[io,Vi,Uw]}],this,0,function(){var t=new Uw;onmessage=io(t)},11)}return n}();function qZ(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Hh(n,e,[Zh,JZ,function(){return[Rm]}],function(r){return pc(Rm(r.data[0],E_(r.data[1])))},5,t)}function Rm(n,e){return h0((zZ(n),n.subarray(2,-4)),e)}var eJ=function(){function n(e){this.G=Fw,this.I=Vi,this.Z=Uw,this.ondata=e}return n.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 r=new Ut(this.p.length+e.length);r.set(this.p),r.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=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(s):(this.p[0]&15)!=8||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}}},n}(),ise=function(){function n(e){this.G=KZ,this.I=M_,this.Z=$Z,this.ondata=e}return n.prototype.push=function(e,t){eJ.prototype.push.call(this,e,t)},n}();function sse(n,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return n[0]==31&&n[1]==139&&n[2]==8?jZ(n,e,t):(n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31?T_(n,e,t):qZ(n,e,t)}function ose(n,e){return n[0]==31&&n[1]==139&&n[2]==8?Ew(n,e):(n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31?Yh(n,e):Rm(n,e)}var N_=function(n,e,t,r){for(var i in n){var s=n[i],o=e+i;s instanceof Ut?t[o]=[s,r]:Array.isArray(s)?t[o]=[s[0],p0(r,s[1])]:N_(s,o+"/",t,r)}},EN=typeof TextEncoder<"u"&&new TextEncoder,QE=typeof TextDecoder<"u"&&new TextDecoder,tJ=0;try{QE.decode(wl,{stream:!0}),tJ=1}catch{}var nJ=function(n){for(var e="",t=0;;){var r=n[t++],i=(r>127)+(r>223)+(r>239);if(t+i>n.length)return[e,js(n,t-1)];i?i==3?(r=((r&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?e+=String.fromCharCode((r&31)<<6|n[t++]&63):e+=String.fromCharCode((r&15)<<12|(n[t++]&63)<<6|n[t++]&63):e+=String.fromCharCode(r)}},ase=function(){function n(e){this.ondata=e,tJ?this.t=new TextDecoder:this.p=wl}return n.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}return}if(!this.p)throw"stream finished";var r=new Ut(this.p.length+e.length);r.set(this.p),r.set(e,this.p.length);var i=nJ(r),s=i[0],o=i[1];if(t){if(o.length)throw"invalid utf-8 data";this.p=null}else this.p=o;this.ondata(s,t)},n}(),lse=function(){function n(e){this.ondata=e}return n.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(tc(e),this.d=t||!1)},n}();function tc(n,e){if(e){for(var t=new Ut(n.length),r=0;r>1)),o=0,a=function(c){s[o++]=c},r=0;rs.length){var l=new Ut(o+8+(i-r<<1));l.set(s),s=l}var A=n.charCodeAt(r);A<128||e?a(A):A<2048?(a(192|A>>6),a(128|A&63)):A>55295&&A<57344?(A=65536+(A&1047552)|n.charCodeAt(++r)&1023,a(240|A>>18),a(128|A>>12&63),a(128|A>>6&63),a(128|A&63)):(a(224|A>>12),a(128|A>>6&63),a(128|A&63))}return js(s,0,o)}function D_(n,e){if(e){for(var t="",r=0;r65535)throw"extra field too long";e+=r+4}return e},xh=function(n,e,t,r,i,s,o,a){var l=r.length,A=t.extra,c=a&&a.length,u=OA(A);$t(n,e,o!=null?33639248:67324752),e+=4,o!=null&&(n[e++]=20,n[e++]=t.os),n[e]=20,e+=2,n[e++]=t.flag<<1|(s==null&&8),n[e++]=i&&8,n[e++]=t.compression&255,n[e++]=t.compression>>8;var f=new Date(t.mtime==null?Date.now():t.mtime),d=f.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if($t(n,e,d<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>>1),e+=4,s!=null&&($t(n,e,t.crc),$t(n,e+4,s),$t(n,e+8,t.size)),$t(n,e+12,l),$t(n,e+14,u),e+=16,o!=null&&($t(n,e,c),$t(n,e+6,t.attrs),$t(n,e+10,o),e+=14),n.set(r,e),e+=l,u)for(var h in A){var p=A[h],m=p.length;$t(n,e,+h),$t(n,e+2,m),n.set(p,e+4),e+=4+m}return c&&(n.set(a,e),e+=c),e},k_=function(n,e,t,r,i){$t(n,e,101010256),$t(n,e+8,t),$t(n,e+10,t),$t(n,e+12,r),$t(n,e+16,i)},Mm=function(){function n(e){this.filename=e,this.c=Gh(),this.size=0,this.compression=0}return n.prototype.process=function(e,t){this.ondata(null,e,t)},n.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)},n}(),Ase=function(){function n(e,t){var r=this;t||(t={}),Mm.call(this,e),this.d=new Ra(t,function(i,s){r.ondata(null,i,s)}),this.compression=8,this.flag=rJ(t.level)}return n.prototype.process=function(e,t){try{this.d.push(e,t)}catch(r){this.ondata(r,null,t)}},n.prototype.push=function(e,t){Mm.prototype.push.call(this,e,t)},n}(),cse=function(){function n(e,t){var r=this;t||(t={}),Mm.call(this,e),this.d=new YZ(t,function(i,s,o){r.ondata(i,s,o)}),this.compression=8,this.flag=rJ(t.level),this.terminate=this.d.terminate}return n.prototype.process=function(e,t){this.d.push(e,t)},n.prototype.push=function(e,t){Mm.prototype.push.call(this,e,t)},n}(),use=function(){function n(e){this.ondata=e,this.u=[],this.d=1}return n.prototype.add=function(e){var t=this;if(this.d&2)throw"stream finished";var r=tc(e.filename),i=r.length,s=e.comment,o=s&&tc(s),a=i!=e.filename.length||o&&s.length!=o.length,l=i+OA(e.extra)+30;if(i>65535)throw"filename too long";var A=new Ut(l);xh(A,0,e,r,a);var c=[A],u=function(){for(var m=0,g=c;m65535&&_("filename too long",null),!K)_(null,v);else if(C<16e4)try{_(null,g0(v,y))}catch(B){_(B,null)}else c.push(XZ(v,y,_))},h=0;h65535)throw"filename too long";var g=c?g0(l,A):l,v=g.length,y=Gh();y.p(l),r.push(p0(A,{size:l.length,crc:y.d(),c:g,f:u,m:h,u:f!=o.length||h&&d.length!=p,o:i,compression:c})),i+=30+f+m+v,s+=76+2*(f+m)+(p||0)+v}for(var w=new Ut(s+22),C=i,b=s-i,E=0;E0){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),e.length)return this.push(e,t)}else{var o=0,a=0,l=void 0,A=void 0;this.p.length?e.length?(A=new Ut(this.p.length+e.length),A.set(this.p),A.set(e,this.p.length)):A=this.p:A=e;for(var c=A.length,u=this.c,f=u&&this.d,d=function(){var g,v=zn(A,a);if(v==67324752){o=1,l=a,h.d=null,h.c=0;var y=hi(A,a+6),w=hi(A,a+8),C=y&2048,b=y&8,E=hi(A,a+26),x=hi(A,a+28);if(c>a+30+E+x){var S=[];h.k.unshift(S),o=2;var M=zn(A,a+18),Z=zn(A,a+22),K=D_(A.subarray(a+30,a+=30+E),!C);M==4294967295?(g=b?[-2]:oJ(A,a),M=g[0],Z=g[1]):b&&(M=-1),a+=x,h.c=M;var _,B={name:K,compression:w,start:function(){if(!B.ondata)throw"no callback";if(!M)B.ondata(null,wl,!0);else{var F=r.o[w];if(!F)throw"unknown compression type "+w;_=M<0?new F(K):new F(K,M,Z),_.ondata=function(V,O,L){B.ondata(V,O,L)};for(var R=0,k=S;R=0&&(B.size=M,B.originalSize=Z),h.onfile(B)}return"break"}else if(u){if(v==134695760)return l=a+=12+(u==-2&&8),o=3,h.c=0,"break";if(v==33639248)return l=a-=4,o=3,h.c=0,"break"}},h=this;a65558){e("invalid zip file",null);return}var o=hi(n,s+8);o||e(null,{});var a=o,l=zn(n,s+16),A=l==4294967295;if(A){if(s=zn(n,s-12),zn(n,s)!=101075792){e("invalid zip file",null);return}a=o=zn(n,s+32),l=zn(n,s+48)}for(var c=function(f){var d=sJ(n,l,A),h=d[0],p=d[1],m=d[2],g=d[3],v=d[4],y=d[5],w=iJ(n,y);l=v;var C=function(E,x){E?(r(),e(E,null)):(i[g]=x,--o||e(null,i))};if(!h)C(null,js(n,w,w+p));else if(h==8){var b=n.subarray(w,w+p);if(p<32e4)try{C(null,Yh(b,new Ut(m)))}catch(E){C(E,null)}else t.push(T_(b,{size:m},C))}else C("unknown compression type "+h,null)},u=0;u65558)throw"invalid zip file";var r=hi(n,t+8);if(!r)return{};var i=zn(n,t+16),s=i==4294967295;if(s){if(t=zn(n,t-12),zn(n,t)!=101075792)throw"invalid zip file";r=zn(n,t+32),i=zn(n,t+48)}for(var o=0;o=t[r])return r-1;if(e<=t[n])return n;let i=n,s=r,o=Math.floor((i+s)/2);for(;e=t[o+1];)e=p&&(h[d][0]=h[f][0]/a[v+1][g],m=h[d][0]*a[g][v]);const y=g>=-1?1:-g,w=u-1<=v?p-1:t-u;for(let b=y;b<=w;++b)h[d][b]=(h[f][b]-h[f][b-1])/a[v+1][g+b],m+=h[d][b]*a[g+b][v];u<=v&&(h[d][p]=-h[f][p-1]/a[v+1][u],m+=h[d][p]*a[u][v]),o[p][u]=m;const C=f;f=d,d=C}}let c=t;for(let u=1;u<=r;++u){for(let f=0;f<=t;++f)o[u][f]*=c;c*=t-u}return o}function bse(n,e,t,r,i){const s=i0,l=typeof s.Content=="string"&&s.Content!=="";if(a||l){const A=this.parseImage(r[i]);t[s.RelativeFilename||s.Filename]=A}}}}for(const r in e){const i=e[r];t[i]!==void 0?e[r]=t[i]:e[r]=e[r].split("\\").pop()}return e}parseImage(e){const t=e.Content,r=e.RelativeFilename||e.Filename,i=r.slice(r.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":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",r),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const o=new Uint8Array(t);return window.URL.createObjectURL(new Blob([o],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in It.Objects){const r=It.Objects.Texture;for(const i in r){const s=this.parseTexture(r[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const r=this.loadTexture(e,t);r.ID=e.id,r.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,o=i!==void 0?i.value:0,a=s!==void 0?s.value:0;if(r.wrapS=o===0?hs:di,r.wrapT=a===0?hs:di,"Scaling"in e){const l=e.Scaling.value;r.repeat.x=l[0],r.repeat.y=l[1]}if("Translation"in e){const l=e.Translation.value;r.offset.x=l[0],r.offset.y=l[1]}return r}loadTexture(e,t){let r;const i=this.textureLoader.path,s=Gn.get(e.id).children;s!==void 0&&s.length>0&&t[s[0].ID]!==void 0&&(r=t[s[0].ID],(r.indexOf("blob:")===0||r.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let o;const a=e.FileName.slice(-3).toLowerCase();if(a==="tga"){const l=this.manager.getHandler(".tga");l===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),o=new ir):(l.setPath(this.textureLoader.path),o=l.load(r))}else a==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),o=new ir):o=this.textureLoader.load(r);return this.textureLoader.setPath(i),o}parseMaterials(e){const t=new Map;if("Material"in It.Objects){const r=It.Objects.Material;for(const i in r){const s=this.parseMaterial(r[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const r=e.id,i=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!Gn.has(r))return null;const o=this.parseParameters(e,t,r);let a;switch(s.toLowerCase()){case"phong":a=new bI;break;case"lambert":a=new Kre;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new bI;break}return a.setValues(o),a.name=i,a}parseParameters(e,t,r){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=new Re().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=new Re().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=new Re().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=new Re().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 Re().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=new Re().fromArray(e.SpecularColor.value));const s=this;return Gn.get(r).children.forEach(function(o){const a=o.relationship;switch(a){case"Bump":i.bumpMap=s.getTexture(t,o.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,o.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,o.ID),i.map!==void 0&&(i.map.encoding=ht);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,o.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,o.ID),i.emissiveMap!==void 0&&(i.emissiveMap.encoding=ht);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,o.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,o.ID),i.envMap!==void 0&&(i.envMap.mapping=hw,i.envMap.encoding=ht);break;case"SpecularColor":i.specularMap=s.getTexture(t,o.ID),i.specularMap!==void 0&&(i.specularMap.encoding=ht);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,o.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.",a);break}}),i}getTexture(e,t){return"LayeredTexture"in It.Objects&&t in It.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Gn.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in It.Objects){const r=It.Objects.Deformer;for(const i in r){const s=r[i],o=Gn.get(parseInt(i));if(s.attrType==="Skin"){const a=this.parseSkeleton(o,r);a.ID=i,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=o.parents[0].ID,e[i]=a}else if(s.attrType==="BlendShape"){const a={id:i};a.rawTargets=this.parseMorphTargets(o,r),a.id=i,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=a}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const r=[];return e.children.forEach(function(i){const s=t[i.ID];if(s.attrType!=="Cluster")return;const o={ID:i.ID,indices:[],weights:[],transformLink:new Le().fromArray(s.TransformLink.a)};"Indexes"in s&&(o.indices=s.Indexes.a,o.weights=s.Weights.a),r.push(o)}),{rawBones:r,bones:[]}}parseMorphTargets(e,t){const r=[];for(let i=0;i1?o=a:a.length>0?o=a[0]:(o=new bI({color:13421772}),a.push(o)),"color"in s.attributes&&a.forEach(function(l){l.vertexColors=!0}),s.FBX_Deformer?(i=new qA(s,o),i.normalizeSkinWeights()):i=new In(s,o),i}createCurve(e,t){const r=e.children.reduce(function(s,o){return t.has(o.ID)&&(s=t.get(o.ID)),s},null),i=new Wl({color:3342591,linewidth:1});return new kh(r,i)}getTransformData(e,t){const r={};"InheritType"in t&&(r.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?r.eulerOrder=uJ(t.RotationOrder.value):r.eulerOrder="ZYX","Lcl_Translation"in t&&(r.translation=t.Lcl_Translation.value),"PreRotation"in t&&(r.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(r.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(r.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(r.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(r.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(r.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(r.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(r.rotationPivot=t.RotationPivot.value),e.userData.transformData=r}setLookAtProperties(e,t){"LookAtProperty"in t&&Gn.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=It.Objects.Model[i.ID];if("Lcl_Translation"in s){const o=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),xi.add(e.target)):e.lookAt(new z().fromArray(o))}}})}bindSkeleton(e,t,r){const i=this.parsePoseNodes();for(const s in e){const o=e[s];Gn.get(parseInt(o.ID)).parents.forEach(function(l){if(t.has(l.ID)){const A=l.ID;Gn.get(A).parents.forEach(function(u){r.has(u.ID)&&r.get(u.ID).bind(new hc(o.bones),i[u.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in It.Objects){const t=It.Objects.Pose;for(const r in t)if(t[r].attrType==="BindPose"&&t[r].NbPoseNodes>0){const i=t[r].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new Le().fromArray(s.Matrix.a)}):e[i.Node]=new Le().fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in It&&"AmbientColor"in It.GlobalSettings){const e=It.GlobalSettings.AmbientColor.value,t=e[0],r=e[1],i=e[2];if(t!==0||r!==0||i!==0){const s=new Re(t,r,i);xi.add(new bZ(s,1))}}}}class Sse{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in It.Objects){const r=It.Objects.Geometry;for(const i in r){const s=Gn.get(parseInt(i)),o=this.parseGeometry(s,r[i],e);t.set(parseInt(i),o)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,r){const i=r.skeletons,s=[],o=e.parents.map(function(u){return It.Objects.Model[u.ID]});if(o.length===0)return;const a=e.children.reduce(function(u,f){return i[f.ID]!==void 0&&(u=i[f.ID]),u},null);e.children.forEach(function(u){r.morphTargets[u.ID]!==void 0&&s.push(r.morphTargets[u.ID])});const l=o[0],A={};"RotationOrder"in l&&(A.eulerOrder=uJ(l.RotationOrder.value)),"InheritType"in l&&(A.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(A.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(A.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(A.scale=l.GeometricScaling.value);const c=cJ(A);return this.genGeometry(t,a,s,c)}genGeometry(e,t,r,i){const s=new Ht;e.attrName&&(s.name=e.attrName);const o=this.parseGeoNode(e,t),a=this.genBuffers(o),l=new rn(a.vertex,3);if(l.applyMatrix4(i),s.setAttribute("position",l),a.colors.length>0&&s.setAttribute("color",new rn(a.colors,3)),t&&(s.setAttribute("skinIndex",new XC(a.weightsIndices,4)),s.setAttribute("skinWeight",new rn(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){const A=new kn().getNormalMatrix(i),c=new rn(a.normal,3);c.applyNormalMatrix(A),s.setAttribute("normal",c)}if(a.uvs.forEach(function(A,c){let u="uv"+(c+1).toString();c===0&&(u="uv"),s.setAttribute(u,new rn(a.uvs[c],2))}),o.material&&o.material.mappingType!=="AllSame"){let A=a.materialIndex[0],c=0;if(a.materialIndex.forEach(function(u,f){u!==A&&(s.addGroup(c,f-c,A),A=u,c=f)}),s.groups.length>0){const u=s.groups[s.groups.length-1],f=u.start+u.count;f!==a.materialIndex.length&&s.addGroup(f,a.materialIndex.length-f,A)}s.groups.length===0&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,r,i),s}parseGeoNode(e,t){const r={};if(r.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],r.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(r.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(r.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(r.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){r.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return r.weightTable={},t!==null&&(r.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(o,a){r.weightTable[o]===void 0&&(r.weightTable[o]=[]),r.weightTable[o].push({id:s,weight:i.weights[a]})})})),r}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let r=0,i=0,s=!1,o=[],a=[],l=[],A=[],c=[],u=[];const f=this;return e.vertexIndices.forEach(function(d,h){let p,m=!1;d<0&&(d=d^-1,m=!0);let g=[],v=[];if(o.push(d*3,d*3+1,d*3+2),e.color){const y=Rv(h,r,d,e.color);l.push(y[0],y[1],y[2])}if(e.skeleton){if(e.weightTable[d]!==void 0&&e.weightTable[d].forEach(function(y){v.push(y.weight),g.push(y.id)}),v.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const y=[0,0,0,0],w=[0,0,0,0];v.forEach(function(C,b){let E=C,x=g[b];w.forEach(function(S,M,Z){if(E>S){Z[M]=E,E=S;const K=y[M];y[M]=x,x=K}})}),g=y,v=w}for(;v.length<4;)v.push(0),g.push(0);for(let y=0;y<4;++y)c.push(v[y]),u.push(g[y])}if(e.normal){const y=Rv(h,r,d,e.normal);a.push(y[0],y[1],y[2])}e.material&&e.material.mappingType!=="AllSame"&&(p=Rv(h,r,d,e.material)[0],p<0&&(f.negativeMaterialIndices=!0,p=0)),e.uv&&e.uv.forEach(function(y,w){const C=Rv(h,r,d,y);A[w]===void 0&&(A[w]=[]),A[w].push(C[0]),A[w].push(C[1])}),i++,m&&(f.genFace(t,e,o,p,a,l,A,c,u,i),r++,i=0,o=[],a=[],l=[],A=[],c=[],u=[])}),t}genFace(e,t,r,i,s,o,a,l,A,c){for(let u=2;u1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const o=e.get(s[0].ID);r[i]={name:t[i].attrName,layer:o}}return r}addClip(e){let t=[];const r=this;return e.layer.forEach(function(i){t=t.concat(r.generateTracks(i))}),new vu(e.name,-1,t)}generateTracks(e){const t=[];let r=new z,i=new tt,s=new z;if(e.transform&&e.transform.decompose(r,i,s),r=r.toArray(),i=new Kr().setFromQuaternion(i,e.eulerOrder).toArray(),s=s.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.T.curves,r,"position");o!==void 0&&t.push(o)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const o=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);o!==void 0&&t.push(o)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");o!==void 0&&t.push(o)}if(e.DeformPercent!==void 0){const o=this.generateMorphTrack(e);o!==void 0&&t.push(o)}return t}generateVectorTrack(e,t,r,i){const s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,r);return new ec(e+"."+i,s,o)}generateRotationTrack(e,t,r,i,s,o){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Wt.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Wt.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Wt.degToRad));const a=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(a,t,r);i!==void 0&&(i=i.map(Wt.degToRad),i.push(o),i=new Kr().fromArray(i),i=new tt().setFromEuler(i)),s!==void 0&&(s=s.map(Wt.degToRad),s.push(o),s=new Kr().fromArray(s),s=new tt().setFromEuler(s).invert());const A=new tt,c=new Kr,u=[];for(let f=0;f1){let r=1,i=t[0];for(let s=1;s=180){const o=s/180,a=i/o;let l=r+a;const A=e.times[t-1],u=(e.times[t]-A)/o;let f=A+u;const d=[],h=[];for(;f1&&(r=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:r,type:i}}parseNodeProperty(e,t,r){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=r.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if(o.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){const l=s.split(",").slice(1),A=parseInt(l[0]),c=parseInt(l[1]);let u=s.split(",").slice(3);u=u.map(function(f){return f.trim().replace(/^"/,"")}),i="connections",s=[A,c],kse(s,u),o[i]===void 0&&(o[i]=[])}i==="Node"&&(o.id=s),i in o&&Array.isArray(o[i])?o[i].push(s):i!=="a"?o[i]=s:o.a=s,this.setCurrentProp(o,i),i==="a"&&s.slice(-1)!==","&&(o.a=_I(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=_I(t.a))}parseNodeSpecialProperty(e,t,r){const i=r.split('",').map(function(c){return c.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],o=i[1],a=i[2],l=i[3];let A=i[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":A=parseFloat(A);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":A=_I(A);break}this.getPrevNode()[s]={type:o,type2:a,flag:l,value:A},this.setCurrentProp(this.getPrevNode(),s)}}class Rse{parse(e){const t=new SN(e);t.skip(23);const r=t.getUint32();if(r<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+r);const i=new AJ;for(;!this.endOfContent(t);){const s=this.parseNode(t,r);s!==null&&i.add(s.name,s)}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 r={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const o=e.getUint8(),a=e.getString(o);if(i===0)return null;const l=[];for(let f=0;f0?l[0]:"",c=l.length>1?l[1]:"",u=l.length>2?l[2]:"";for(r.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){const f=this.parseNode(e,t);f!==null&&this.parseSubNode(a,r,f)}return r.propertyList=l,typeof A=="number"&&(r.id=A),c!==""&&(r.attrName=c),u!==""&&(r.attrType=u),a!==""&&(r.name=a),r}parseSubNode(e,t,r){if(r.singleProperty===!0){const i=r.propertyList[0];Array.isArray(i)?(t[r.name]=r,r.a=i):t[r.name]=i}else if(e==="Connections"&&r.name==="C"){const i=[];r.propertyList.forEach(function(s,o){o!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(r.name==="Properties70")Object.keys(r).forEach(function(s){t[s]=r[s]});else if(e==="Properties70"&&r.name==="P"){let i=r.propertyList[0],s=r.propertyList[1];const o=r.propertyList[2],a=r.propertyList[3];let l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?l=[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:l=r.propertyList[4],t[i]={type:s,type2:o,flag:a,value:l}}else t[r.name]===void 0?typeof r.id=="number"?(t[r.name]={},t[r.name][r.id]=r):t[r.name]=r:r.name==="PoseNode"?(Array.isArray(t[r.name])||(t[r.name]=[t[r.name]]),t[r.name].push(r)):t[r.name][r.id]===void 0&&(t[r.name][r.id]=r)}parseProperty(e){const t=e.getString(1);let r;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 r=e.getUint32(),e.getArrayBuffer(r);case"S":return r=e.getUint32(),e.getString(r);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),o=e.getUint32();if(s===0)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)}typeof yse>"u"&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=Rm(new Uint8Array(e.getArrayBuffer(o))),l=new SN(a.buffer);switch(t){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class SN{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let r=0;r=0&&(t=t.slice(0,r)),ba.decodeText(new Uint8Array(t))}}class AJ{add(e,t){this[e]=t}}function Mse(n){const e="Kaydara FBX Binary \0";return n.byteLength>=e.length&&e===fJ(n,0,e.length)}function Tse(n){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function r(i){const s=n[i-1];return n=n.slice(t+i),t++,s}for(let i=0;i4?o=n.array[i*n.itemSize+s]:s===0?o=n.getX(i):s===1?o=n.getY(i):s===2?o=n.getZ(i):s===3&&(o=n.getW(i)),r.min[s]=Math.min(r.min[s],o),r.max[s]=Math.max(r.max[s],o)}return r}function dJ(n){return Math.ceil(n/4)*4}function QI(n,e=0){const t=dJ(n.byteLength);if(t!==n.byteLength){const r=new Uint8Array(t);if(r.set(new Uint8Array(n)),e!==0)for(let i=n.byteLength;i"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function DN(n,e){if(n.toBlob!==void 0)return new Promise(r=>n.toBlob(r,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),n.convertToBlob({type:e,quality:t})}class Hse{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,r){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,s=i.buffers,o=i.json;r=i.options;const a=i.extensionsUsed,l=new Blob(s,{type:"application/octet-stream"}),A=Object.keys(a);if(A.length>0&&(o.extensionsUsed=A),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=l.size),r.binary===!0){const c=new FileReader;c.readAsArrayBuffer(l),c.onloadend=function(){const u=QI(c.result),f=new DataView(new ArrayBuffer(TN));f.setUint32(0,u.byteLength,!0),f.setUint32(4,Ose,!0);const d=QI(Gse(JSON.stringify(o)),32),h=new DataView(new ArrayBuffer(TN));h.setUint32(0,d.byteLength,!0),h.setUint32(4,Wse,!0);const p=new ArrayBuffer(MN),m=new DataView(p);m.setUint32(0,Lse,!0),m.setUint32(4,Pse,!0);const g=MN+h.byteLength+d.byteLength+f.byteLength+u.byteLength;m.setUint32(8,g,!0);const v=new Blob([p,h,d,f,u],{type:"application/octet-stream"}),y=new FileReader;y.readAsArrayBuffer(v),y.onloadend=function(){t(y.result)}}}else if(o.buffers&&o.buffers.length>0){const c=new FileReader;c.readAsDataURL(l),c.onloadend=function(){const u=c.result;o.buffers[0].uri=u,t(o)}}else t(o)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const r=this.options,i=this.extensionsUsed;try{const s=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&s.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const o in s.gltfExtensions)t.extensions[o]=s.gltfExtensions[o],i[o]=!0;delete s.gltfExtensions}Object.keys(s).length>0&&(t.extras=s)}catch(s){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+s.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const i=new Map;i.set(!0,this.uid++),i.set(!1,this.uid++),this.uids.set(e,i)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const r=new z;for(let i=0,s=e.count;i5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const r=e.clone(),i=new z;for(let s=0,o=r.count;s4?p=e.array[d*e.itemSize+h]:h===0?p=e.getX(d):h===1?p=e.getY(d):h===2?p=e.getZ(d):h===3&&(p=e.getW(d)),t===nn.FLOAT?A.setFloat32(c,p,!0):t===nn.UNSIGNED_INT?A.setUint32(c,p,!0):t===nn.UNSIGNED_SHORT?A.setUint16(c,p,!0):t===nn.UNSIGNED_BYTE&&A.setUint8(c,p),c+=a}const u={buffer:this.processBuffer(A.buffer),byteOffset:this.byteOffset,byteLength:l};return s!==void 0&&(u.target=s),s===nn.ARRAY_BUFFER&&(u.byteStride=e.itemSize*a),this.byteOffset+=l,o.bufferViews.push(u),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise(function(i){const s=new FileReader;s.readAsArrayBuffer(e),s.onloadend=function(){const o=QI(s.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,i(r.bufferViews.push(a)-1)}})}processAccessor(e,t,r,i){const s=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"};let a;if(e.array.constructor===Float32Array)a=nn.FLOAT;else if(e.array.constructor===Uint32Array)a=nn.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)a=nn.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)a=nn.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");if(r===void 0&&(r=0),i===void 0&&(i=e.count),i===0)return null;const l=Jse(e,r,i);let A;t!==void 0&&(A=e===t.index?nn.ELEMENT_ARRAY_BUFFER:nn.ARRAY_BUFFER);const c=this.processBufferView(e,a,r,i,A),u={bufferView:c.id,byteOffset:c.byteOffset,componentType:a,count:i,max:l.max,min:l.min,type:o[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(u)-1}processImage(e,t,r,i="image/png"){const s=this,o=s.cache,a=s.json,l=s.options,A=s.pending;o.images.has(e)||o.images.set(e,{});const c=o.images.get(e),u=i+":flipY/"+r.toString();if(c[u]!==void 0)return c[u];a.images||(a.images=[]);const f={mimeType:i},d=NN();d.width=Math.min(e.width,l.maxTextureSize),d.height=Math.min(e.height,l.maxTextureSize);const h=d.getContext("2d");if(r===!0&&(h.translate(0,d.height),h.scale(1,-1)),e.data!==void 0){t!==br&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const m=new Uint8ClampedArray(e.height*e.width*4);for(let g=0;gs.processBufferViewImage(m)).then(m=>{f.bufferView=m})):d.toDataURL!==void 0?f.uri=d.toDataURL(i):A.push(DN(d,i).then(m=>new FileReader().readAsDataURL(m)).then(m=>{f.uri=m}));const p=a.images.push(f)-1;return c[u]=p,p}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const r={magFilter:os[e.magFilter],minFilter:os[e.minFilter],wrapS:os[e.wrapS],wrapT:os[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){const t=this.cache,r=this.json;if(t.textures.has(e))return t.textures.get(e);r.textures||(r.textures=[]);let i=e.userData.mimeType;i==="image/webp"&&(i="image/png");const s={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(s.name=e.name),this._invokeAll(function(a){a.writeTexture&&a.writeTexture(e,s)});const o=r.textures.push(s)-1;return t.textures.set(e,o),o}processMaterial(e){const t=this.cache,r=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);const i={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const s=e.color.toArray().concat([e.opacity]);if(dg(s,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),l={index:this.processTexture(a)};this.applyTextureTransform(l,a),i.pbrMetallicRoughness.metallicRoughnessTexture=l}if(e.map){const a={index:this.processTexture(e.map)};this.applyTextureTransform(a,e.map),i.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive.clone().multiplyScalar(e.emissiveIntensity),l=Math.max(a.r,a.g,a.b);if(l>1&&(a.multiplyScalar(1/l),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),l>0&&(i.emissiveFactor=a.toArray()),e.emissiveMap){const A={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(A,e.emissiveMap),i.emissiveTexture=A}}if(e.normalMap){const a={index:this.processTexture(e.normalMap)};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),i.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:1};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),i.occlusionTexture=a}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===pi&&(i.doubleSided=!0),e.name!==""&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,i)});const o=r.materials.push(i)-1;return t.materials.set(e,o),o}processMesh(e){const t=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let y=0,w=e.material.length;y0){const y=[],w=[],C={};if(e.morphTargetDictionary!==void 0)for(const b in e.morphTargetDictionary)C[e.morphTargetDictionary[b]]=b;for(let b=0;b0&&(l.extras={},l.extras.targetNames=w)}const p=Array.isArray(e.material);if(p&&o.groups.length===0)return null;const m=p?e.material:[e.material],g=p?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let y=0,w=g.length;y0&&(C.targets=u),o.index!==null){let E=this.getUID(o.index);(g[y].start!==void 0||g[y].count!==void 0)&&(E+=":"+g[y].start+":"+g[y].count),t.attributes.has(E)?C.indices=t.attributes.get(E):(C.indices=this.processAccessor(o.index,o,g[y].start,g[y].count),t.attributes.set(E,C.indices)),C.indices===null&&delete C.indices}const b=this.processMaterial(m[g[y].materialIndex]);b!==null&&(C.material=b),c.push(C)}l.primitives=c,r.meshes||(r.meshes=[]),this._invokeAll(function(y){y.writeMesh&&y.writeMesh(e,l)});const v=r.meshes.push(l)-1;return t.meshes.set(s,v),v}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const r=e.isOrthographicCamera,i={type:r?"orthographic":"perspective"};return r?i.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:Wt.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const r=this.json,i=this.nodeMap;r.animations||(r.animations=[]),e=V_.Utils.mergeMorphTargetTracks(e.clone(),t);const s=e.tracks,o=[],a=[];for(let l=0;l0){const a=[];for(let l=0,A=e.children.length;l0&&(s.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,s)});const o=t.nodes.push(s)-1;return i.set(e,o),o}processScene(e){const t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};e.name!==""&&(i.name=e.name),t.scenes.push(i);const s=[];for(let o=0,a=e.children.length;o0&&(i.nodes=s),this.serializeUserData(e,i)}processObjects(e){const t=new yw;t.name="AuxScene";for(let r=0;r0&&this.processObjects(r);for(let i=0;i0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),s[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},s[this.name]=!0);const a=i.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}class Yse{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class Xse{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;const r=this.writer,i=r.extensionsUsed,s={};t.pbrMetallicRoughness.baseColorFactor&&(s.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);const o=[1,1,1];if(e.specular.toArray(o,0),s.specularFactor=o,s.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(s.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){const a={index:r.processTexture(e.specularMap)};r.applyTextureTransform(a,e.specularMap),s.specularGlossinessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class Kse{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial)return;const r=this.writer,i=r.extensionsUsed,s={};if(s.clearcoatFactor=e.clearcoat,e.clearcoatMap){const o={index:r.processTexture(e.clearcoatMap)};r.applyTextureTransform(o,e.clearcoatMap),s.clearcoatTexture=o}if(s.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const o={index:r.processTexture(e.clearcoatRoughnessMap)};r.applyTextureTransform(o,e.clearcoatRoughnessMap),s.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){const o={index:r.processTexture(e.clearcoatNormalMap)};r.applyTextureTransform(o,e.clearcoatNormalMap),s.clearcoatNormalTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class jse{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial)return;const r=this.writer,i=r.extensionsUsed,s={};if(s.iridescenceFactor=e.iridescence,e.iridescenceMap){const o={index:r.processTexture(e.iridescenceMap)};r.applyTextureTransform(o,e.iridescenceMap),s.iridescenceTexture=o}if(s.iridescenceIor=e.iridescenceIOR,s.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],s.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const o={index:r.processTexture(e.iridescenceThicknessMap)};r.applyTextureTransform(o,e.iridescenceThicknessMap),s.iridescenceThicknessTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class $se{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,i=r.extensionsUsed,s={};if(s.transmissionFactor=e.transmission,e.transmissionMap){const o={index:r.processTexture(e.transmissionMap)};r.applyTextureTransform(o,e.transmissionMap),s.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class qse{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,i=r.extensionsUsed,s={};if(s.thicknessFactor=e.thickness,e.thicknessMap){const o={index:r.processTexture(e.thicknessMap)};r.applyTextureTransform(o,e.thicknessMap),s.thicknessTexture=o}s.attenuationDistance=e.attenuationDistance,s.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}V_.Utils={insertKeyframe:function(n,e){const r=n.getValueSize(),i=new n.TimeBufferType(n.times.length+1),s=new n.ValueBufferType(n.values.length+r),o=n.createInterpolant(new n.ValueBufferType(r));let a;if(n.times.length===0){i[0]=e;for(let l=0;ln.times[n.times.length-1]){if(Math.abs(n.times[n.times.length-1]-e)<.001)return n.times.length-1;i[i.length-1]=e,i.set(n.times,0),s.set(n.values,0),s.set(o.evaluate(e),n.values.length),a=i.length-1}else for(let l=0;le){i.set(n.times.slice(0,l+1),0),i[l+1]=e,i.set(n.times.slice(l+1),l+2),s.set(n.values.slice(0,(l+1)*r),0),s.set(o.evaluate(e),(l+1)*r),s.set(n.values.slice((l+1)*r),(l+2)*r),a=l+1;break}}return n.times=i,n.values=s,a},mergeMorphTargetTracks:function(n,e){const t=[],r={},i=n.tracks;for(let s=0;s0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function noe(n){var e=pJ(n),t=e[0],r=e[1];return(t+r)*3/4-r}function roe(n,e,t){return(e+t)*3/4-t}function ioe(n){var e,t=pJ(n),r=t[0],i=t[1],s=new eoe(roe(n,r,i)),o=0,a=i>0?r-4:r,l;for(l=0;l>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Ds[n.charCodeAt(l)]<<2|Ds[n.charCodeAt(l+1)]>>4,s[o++]=e&255),i===1&&(e=Ds[n.charCodeAt(l)]<<10|Ds[n.charCodeAt(l+1)]<<4|Ds[n.charCodeAt(l+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function soe(n){return ca[n>>18&63]+ca[n>>12&63]+ca[n>>6&63]+ca[n&63]}function ooe(n,e,t){for(var r,i=[],s=e;sa?a:o+s));return r===1?(e=n[t-1],i.push(ca[e>>2]+ca[e<<4&63]+"==")):r===2&&(e=(n[t-2]<<8)+n[t-1],i.push(ca[e>>10]+ca[e>>4&63]+ca[e<<2&63]+"=")),i.join("")}var L_={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */L_.read=function(n,e,t,r,i){var s,o,a=i*8-r-1,l=(1<>1,c=-7,u=t?i-1:0,f=t?-1:1,d=n[e+u];for(u+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=s*256+n[e+u],u+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=o*256+n[e+u],u+=f,c-=8);if(s===0)s=1-A;else{if(s===l)return o?NaN:(d?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-A}return(d?-1:1)*o*Math.pow(2,s-r)};L_.write=function(n,e,t,r,i,s){var o,a,l,A=s*8-i-1,c=(1<>1,f=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,h=r?1:-1,p=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+u>=1?e+=f/l:e+=f*Math.pow(2,1-u),e*l>=2&&(o++,l/=2),o+u>=c?(a=0,o=c):o+u>=1?(a=(e*l-1)*Math.pow(2,i),o=o+u):(a=e*Math.pow(2,u-1)*Math.pow(2,i),o=0));i>=8;n[t+d]=a&255,d+=h,a/=256,i-=8);for(o=o<0;n[t+d]=o&255,d+=h,o/=256,A-=8);n[t+d-h]|=p*128};/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT - */(function(n){const e=eb,t=L_,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=v,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=s(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{const W=new Uint8Array(1),Q={foo:function(){return 42}};return Object.setPrototypeOf(Q,Uint8Array.prototype),Object.setPrototypeOf(W,Q),W.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(W){if(W>i)throw new RangeError('The value "'+W+'" is invalid for option "size"');const Q=new Uint8Array(W);return Object.setPrototypeOf(Q,a.prototype),Q}function a(W,Q,I){if(typeof W=="number"){if(typeof Q=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return u(W)}return l(W,Q,I)}a.poolSize=8192;function l(W,Q,I){if(typeof W=="string")return f(W,Q);if(ArrayBuffer.isView(W))return h(W);if(W==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof W);if(G(W,ArrayBuffer)||W&&G(W.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(G(W,SharedArrayBuffer)||W&&G(W.buffer,SharedArrayBuffer)))return p(W,Q,I);if(typeof W=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const D=W.valueOf&&W.valueOf();if(D!=null&&D!==W)return a.from(D,Q,I);const $=m(W);if($)return $;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof W[Symbol.toPrimitive]=="function")return a.from(W[Symbol.toPrimitive]("string"),Q,I);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof W)}a.from=function(W,Q,I){return l(W,Q,I)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function A(W){if(typeof W!="number")throw new TypeError('"size" argument must be of type number');if(W<0)throw new RangeError('The value "'+W+'" is invalid for option "size"')}function c(W,Q,I){return A(W),W<=0?o(W):Q!==void 0?typeof I=="string"?o(W).fill(Q,I):o(W).fill(Q):o(W)}a.alloc=function(W,Q,I){return c(W,Q,I)};function u(W){return A(W),o(W<0?0:g(W)|0)}a.allocUnsafe=function(W){return u(W)},a.allocUnsafeSlow=function(W){return u(W)};function f(W,Q){if((typeof Q!="string"||Q==="")&&(Q="utf8"),!a.isEncoding(Q))throw new TypeError("Unknown encoding: "+Q);const I=y(W,Q)|0;let D=o(I);const $=D.write(W,Q);return $!==I&&(D=D.slice(0,$)),D}function d(W){const Q=W.length<0?0:g(W.length)|0,I=o(Q);for(let D=0;D=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return W|0}function v(W){return+W!=W&&(W=0),a.alloc(+W)}a.isBuffer=function(Q){return Q!=null&&Q._isBuffer===!0&&Q!==a.prototype},a.compare=function(Q,I){if(G(Q,Uint8Array)&&(Q=a.from(Q,Q.offset,Q.byteLength)),G(I,Uint8Array)&&(I=a.from(I,I.offset,I.byteLength)),!a.isBuffer(Q)||!a.isBuffer(I))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(Q===I)return 0;let D=Q.length,$=I.length;for(let ee=0,te=Math.min(D,$);ee$.length?(a.isBuffer(te)||(te=a.from(te)),te.copy($,ee)):Uint8Array.prototype.set.call($,te,ee);else if(a.isBuffer(te))te.copy($,ee);else throw new TypeError('"list" argument must be an Array of Buffers');ee+=te.length}return $};function y(W,Q){if(a.isBuffer(W))return W.length;if(ArrayBuffer.isView(W)||G(W,ArrayBuffer))return W.byteLength;if(typeof W!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof W);const I=W.length,D=arguments.length>2&&arguments[2]===!0;if(!D&&I===0)return 0;let $=!1;for(;;)switch(Q){case"ascii":case"latin1":case"binary":return I;case"utf8":case"utf-8":return Oe(W).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I*2;case"hex":return I>>>1;case"base64":return Ge(W).length;default:if($)return D?-1:Oe(W).length;Q=(""+Q).toLowerCase(),$=!0}}a.byteLength=y;function w(W,Q,I){let D=!1;if((Q===void 0||Q<0)&&(Q=0),Q>this.length||((I===void 0||I>this.length)&&(I=this.length),I<=0)||(I>>>=0,Q>>>=0,I<=Q))return"";for(W||(W="utf8");;)switch(W){case"hex":return V(this,Q,I);case"utf8":case"utf-8":return B(this,Q,I);case"ascii":return k(this,Q,I);case"latin1":case"binary":return T(this,Q,I);case"base64":return _(this,Q,I);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,Q,I);default:if(D)throw new TypeError("Unknown encoding: "+W);W=(W+"").toLowerCase(),D=!0}}a.prototype._isBuffer=!0;function C(W,Q,I){const D=W[Q];W[Q]=W[I],W[I]=D}a.prototype.swap16=function(){const Q=this.length;if(Q%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let I=0;II&&(Q+=" ... "),""},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(Q,I,D,$,ee){if(G(Q,Uint8Array)&&(Q=a.from(Q,Q.offset,Q.byteLength)),!a.isBuffer(Q))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof Q);if(I===void 0&&(I=0),D===void 0&&(D=Q?Q.length:0),$===void 0&&($=0),ee===void 0&&(ee=this.length),I<0||D>Q.length||$<0||ee>this.length)throw new RangeError("out of range index");if($>=ee&&I>=D)return 0;if($>=ee)return-1;if(I>=D)return 1;if(I>>>=0,D>>>=0,$>>>=0,ee>>>=0,this===Q)return 0;let te=ee-$,we=D-I;const Ce=Math.min(te,we),Ee=this.slice($,ee),Ve=Q.slice(I,D);for(let _e=0;_e2147483647?I=2147483647:I<-2147483648&&(I=-2147483648),I=+I,J(I)&&(I=$?0:W.length-1),I<0&&(I=W.length+I),I>=W.length){if($)return-1;I=W.length-1}else if(I<0)if($)I=0;else return-1;if(typeof Q=="string"&&(Q=a.from(Q,D)),a.isBuffer(Q))return Q.length===0?-1:E(W,Q,I,D,$);if(typeof Q=="number")return Q=Q&255,typeof Uint8Array.prototype.indexOf=="function"?$?Uint8Array.prototype.indexOf.call(W,Q,I):Uint8Array.prototype.lastIndexOf.call(W,Q,I):E(W,[Q],I,D,$);throw new TypeError("val must be string, number or Buffer")}function E(W,Q,I,D,$){let ee=1,te=W.length,we=Q.length;if(D!==void 0&&(D=String(D).toLowerCase(),D==="ucs2"||D==="ucs-2"||D==="utf16le"||D==="utf-16le")){if(W.length<2||Q.length<2)return-1;ee=2,te/=2,we/=2,I/=2}function Ce(Ve,_e){return ee===1?Ve[_e]:Ve.readUInt16BE(_e*ee)}let Ee;if($){let Ve=-1;for(Ee=I;Eete&&(I=te-we),Ee=I;Ee>=0;Ee--){let Ve=!0;for(let _e=0;_e$&&(D=$)):D=$;const ee=Q.length;D>ee/2&&(D=ee/2);let te;for(te=0;te>>0,isFinite(D)?(D=D>>>0,$===void 0&&($="utf8")):($=D,D=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ee=this.length-I;if((D===void 0||D>ee)&&(D=ee),Q.length>0&&(D<0||I<0)||I>this.length)throw new RangeError("Attempt to write outside buffer bounds");$||($="utf8");let te=!1;for(;;)switch($){case"hex":return x(this,Q,I,D);case"utf8":case"utf-8":return S(this,Q,I,D);case"ascii":case"latin1":case"binary":return M(this,Q,I,D);case"base64":return Z(this,Q,I,D);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,Q,I,D);default:if(te)throw new TypeError("Unknown encoding: "+$);$=(""+$).toLowerCase(),te=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function _(W,Q,I){return Q===0&&I===W.length?e.fromByteArray(W):e.fromByteArray(W.slice(Q,I))}function B(W,Q,I){I=Math.min(W.length,I);const D=[];let $=Q;for(;$239?4:ee>223?3:ee>191?2:1;if($+we<=I){let Ce,Ee,Ve,_e;switch(we){case 1:ee<128&&(te=ee);break;case 2:Ce=W[$+1],(Ce&192)===128&&(_e=(ee&31)<<6|Ce&63,_e>127&&(te=_e));break;case 3:Ce=W[$+1],Ee=W[$+2],(Ce&192)===128&&(Ee&192)===128&&(_e=(ee&15)<<12|(Ce&63)<<6|Ee&63,_e>2047&&(_e<55296||_e>57343)&&(te=_e));break;case 4:Ce=W[$+1],Ee=W[$+2],Ve=W[$+3],(Ce&192)===128&&(Ee&192)===128&&(Ve&192)===128&&(_e=(ee&15)<<18|(Ce&63)<<12|(Ee&63)<<6|Ve&63,_e>65535&&_e<1114112&&(te=_e))}}te===null?(te=65533,we=1):te>65535&&(te-=65536,D.push(te>>>10&1023|55296),te=56320|te&1023),D.push(te),$+=we}return R(D)}const F=4096;function R(W){const Q=W.length;if(Q<=F)return String.fromCharCode.apply(String,W);let I="",D=0;for(;DD)&&(I=D);let $="";for(let ee=Q;eeD&&(Q=D),I<0?(I+=D,I<0&&(I=0)):I>D&&(I=D),II)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(Q,I,D){Q=Q>>>0,I=I>>>0,D||L(Q,I,this.length);let $=this[Q],ee=1,te=0;for(;++te>>0,I=I>>>0,D||L(Q,I,this.length);let $=this[Q+--I],ee=1;for(;I>0&&(ee*=256);)$+=this[Q+--I]*ee;return $},a.prototype.readUint8=a.prototype.readUInt8=function(Q,I){return Q=Q>>>0,I||L(Q,1,this.length),this[Q]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(Q,I){return Q=Q>>>0,I||L(Q,2,this.length),this[Q]|this[Q+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(Q,I){return Q=Q>>>0,I||L(Q,2,this.length),this[Q]<<8|this[Q+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),(this[Q]|this[Q+1]<<8|this[Q+2]<<16)+this[Q+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),this[Q]*16777216+(this[Q+1]<<16|this[Q+2]<<8|this[Q+3])},a.prototype.readBigUInt64LE=fe(function(Q){Q=Q>>>0,Be(Q,"offset");const I=this[Q],D=this[Q+7];(I===void 0||D===void 0)&&pe(Q,this.length-8);const $=I+this[++Q]*2**8+this[++Q]*2**16+this[++Q]*2**24,ee=this[++Q]+this[++Q]*2**8+this[++Q]*2**16+D*2**24;return BigInt($)+(BigInt(ee)<>>0,Be(Q,"offset");const I=this[Q],D=this[Q+7];(I===void 0||D===void 0)&&pe(Q,this.length-8);const $=I*2**24+this[++Q]*2**16+this[++Q]*2**8+this[++Q],ee=this[++Q]*2**24+this[++Q]*2**16+this[++Q]*2**8+D;return(BigInt($)<>>0,I=I>>>0,D||L(Q,I,this.length);let $=this[Q],ee=1,te=0;for(;++te=ee&&($-=Math.pow(2,8*I)),$},a.prototype.readIntBE=function(Q,I,D){Q=Q>>>0,I=I>>>0,D||L(Q,I,this.length);let $=I,ee=1,te=this[Q+--$];for(;$>0&&(ee*=256);)te+=this[Q+--$]*ee;return ee*=128,te>=ee&&(te-=Math.pow(2,8*I)),te},a.prototype.readInt8=function(Q,I){return Q=Q>>>0,I||L(Q,1,this.length),this[Q]&128?(255-this[Q]+1)*-1:this[Q]},a.prototype.readInt16LE=function(Q,I){Q=Q>>>0,I||L(Q,2,this.length);const D=this[Q]|this[Q+1]<<8;return D&32768?D|4294901760:D},a.prototype.readInt16BE=function(Q,I){Q=Q>>>0,I||L(Q,2,this.length);const D=this[Q+1]|this[Q]<<8;return D&32768?D|4294901760:D},a.prototype.readInt32LE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),this[Q]|this[Q+1]<<8|this[Q+2]<<16|this[Q+3]<<24},a.prototype.readInt32BE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),this[Q]<<24|this[Q+1]<<16|this[Q+2]<<8|this[Q+3]},a.prototype.readBigInt64LE=fe(function(Q){Q=Q>>>0,Be(Q,"offset");const I=this[Q],D=this[Q+7];(I===void 0||D===void 0)&&pe(Q,this.length-8);const $=this[Q+4]+this[Q+5]*2**8+this[Q+6]*2**16+(D<<24);return(BigInt($)<>>0,Be(Q,"offset");const I=this[Q],D=this[Q+7];(I===void 0||D===void 0)&&pe(Q,this.length-8);const $=(I<<24)+this[++Q]*2**16+this[++Q]*2**8+this[++Q];return(BigInt($)<>>0,I||L(Q,4,this.length),t.read(this,Q,!0,23,4)},a.prototype.readFloatBE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),t.read(this,Q,!1,23,4)},a.prototype.readDoubleLE=function(Q,I){return Q=Q>>>0,I||L(Q,8,this.length),t.read(this,Q,!0,52,8)},a.prototype.readDoubleBE=function(Q,I){return Q=Q>>>0,I||L(Q,8,this.length),t.read(this,Q,!1,52,8)};function U(W,Q,I,D,$,ee){if(!a.isBuffer(W))throw new TypeError('"buffer" argument must be a Buffer instance');if(Q>$||QW.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(Q,I,D,$){if(Q=+Q,I=I>>>0,D=D>>>0,!$){const we=Math.pow(2,8*D)-1;U(this,Q,I,D,we,0)}let ee=1,te=0;for(this[I]=Q&255;++te>>0,D=D>>>0,!$){const we=Math.pow(2,8*D)-1;U(this,Q,I,D,we,0)}let ee=D-1,te=1;for(this[I+ee]=Q&255;--ee>=0&&(te*=256);)this[I+ee]=Q/te&255;return I+D},a.prototype.writeUint8=a.prototype.writeUInt8=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,1,255,0),this[I]=Q&255,I+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,2,65535,0),this[I]=Q&255,this[I+1]=Q>>>8,I+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,2,65535,0),this[I]=Q>>>8,this[I+1]=Q&255,I+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,4,4294967295,0),this[I+3]=Q>>>24,this[I+2]=Q>>>16,this[I+1]=Q>>>8,this[I]=Q&255,I+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,4,4294967295,0),this[I]=Q>>>24,this[I+1]=Q>>>16,this[I+2]=Q>>>8,this[I+3]=Q&255,I+4};function H(W,Q,I,D,$){ae(Q,D,$,W,I,7);let ee=Number(Q&BigInt(4294967295));W[I++]=ee,ee=ee>>8,W[I++]=ee,ee=ee>>8,W[I++]=ee,ee=ee>>8,W[I++]=ee;let te=Number(Q>>BigInt(32)&BigInt(4294967295));return W[I++]=te,te=te>>8,W[I++]=te,te=te>>8,W[I++]=te,te=te>>8,W[I++]=te,I}function Ae(W,Q,I,D,$){ae(Q,D,$,W,I,7);let ee=Number(Q&BigInt(4294967295));W[I+7]=ee,ee=ee>>8,W[I+6]=ee,ee=ee>>8,W[I+5]=ee,ee=ee>>8,W[I+4]=ee;let te=Number(Q>>BigInt(32)&BigInt(4294967295));return W[I+3]=te,te=te>>8,W[I+2]=te,te=te>>8,W[I+1]=te,te=te>>8,W[I]=te,I+8}a.prototype.writeBigUInt64LE=fe(function(Q,I=0){return H(this,Q,I,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=fe(function(Q,I=0){return Ae(this,Q,I,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(Q,I,D,$){if(Q=+Q,I=I>>>0,!$){const Ce=Math.pow(2,8*D-1);U(this,Q,I,D,Ce-1,-Ce)}let ee=0,te=1,we=0;for(this[I]=Q&255;++ee>0)-we&255;return I+D},a.prototype.writeIntBE=function(Q,I,D,$){if(Q=+Q,I=I>>>0,!$){const Ce=Math.pow(2,8*D-1);U(this,Q,I,D,Ce-1,-Ce)}let ee=D-1,te=1,we=0;for(this[I+ee]=Q&255;--ee>=0&&(te*=256);)Q<0&&we===0&&this[I+ee+1]!==0&&(we=1),this[I+ee]=(Q/te>>0)-we&255;return I+D},a.prototype.writeInt8=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,1,127,-128),Q<0&&(Q=255+Q+1),this[I]=Q&255,I+1},a.prototype.writeInt16LE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,2,32767,-32768),this[I]=Q&255,this[I+1]=Q>>>8,I+2},a.prototype.writeInt16BE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,2,32767,-32768),this[I]=Q>>>8,this[I+1]=Q&255,I+2},a.prototype.writeInt32LE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,4,2147483647,-2147483648),this[I]=Q&255,this[I+1]=Q>>>8,this[I+2]=Q>>>16,this[I+3]=Q>>>24,I+4},a.prototype.writeInt32BE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,4,2147483647,-2147483648),Q<0&&(Q=4294967295+Q+1),this[I]=Q>>>24,this[I+1]=Q>>>16,this[I+2]=Q>>>8,this[I+3]=Q&255,I+4},a.prototype.writeBigInt64LE=fe(function(Q,I=0){return H(this,Q,I,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=fe(function(Q,I=0){return Ae(this,Q,I,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function N(W,Q,I,D,$,ee){if(I+D>W.length)throw new RangeError("Index out of range");if(I<0)throw new RangeError("Index out of range")}function j(W,Q,I,D,$){return Q=+Q,I=I>>>0,$||N(W,Q,I,4),t.write(W,Q,I,D,23,4),I+4}a.prototype.writeFloatLE=function(Q,I,D){return j(this,Q,I,!0,D)},a.prototype.writeFloatBE=function(Q,I,D){return j(this,Q,I,!1,D)};function oe(W,Q,I,D,$){return Q=+Q,I=I>>>0,$||N(W,Q,I,8),t.write(W,Q,I,D,52,8),I+8}a.prototype.writeDoubleLE=function(Q,I,D){return oe(this,Q,I,!0,D)},a.prototype.writeDoubleBE=function(Q,I,D){return oe(this,Q,I,!1,D)},a.prototype.copy=function(Q,I,D,$){if(!a.isBuffer(Q))throw new TypeError("argument should be a Buffer");if(D||(D=0),!$&&$!==0&&($=this.length),I>=Q.length&&(I=Q.length),I||(I=0),$>0&&$=this.length)throw new RangeError("Index out of range");if($<0)throw new RangeError("sourceEnd out of bounds");$>this.length&&($=this.length),Q.length-I<$-D&&($=Q.length-I+D);const ee=$-D;return this===Q&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(I,D,$):Uint8Array.prototype.set.call(Q,this.subarray(D,$),I),ee},a.prototype.fill=function(Q,I,D,$){if(typeof Q=="string"){if(typeof I=="string"?($=I,I=0,D=this.length):typeof D=="string"&&($=D,D=this.length),$!==void 0&&typeof $!="string")throw new TypeError("encoding must be a string");if(typeof $=="string"&&!a.isEncoding($))throw new TypeError("Unknown encoding: "+$);if(Q.length===1){const te=Q.charCodeAt(0);($==="utf8"&&te<128||$==="latin1")&&(Q=te)}}else typeof Q=="number"?Q=Q&255:typeof Q=="boolean"&&(Q=Number(Q));if(I<0||this.length>>0,D=D===void 0?this.length:D>>>0,Q||(Q=0);let ee;if(typeof Q=="number")for(ee=I;ee2**32?$=X(String(I)):typeof I=="bigint"&&($=String(I),(I>BigInt(2)**BigInt(32)||I<-(BigInt(2)**BigInt(32)))&&($=X($)),$+="n"),D+=` It must be ${Q}. Received ${$}`,D},RangeError);function X(W){let Q="",I=W.length;const D=W[0]==="-"?1:0;for(;I>=D+4;I-=3)Q=`_${W.slice(I-3,I)}${Q}`;return`${W.slice(0,I)}${Q}`}function ne(W,Q,I){Be(Q,"offset"),(W[Q]===void 0||W[Q+I]===void 0)&&pe(Q,W.length-(I+1))}function ae(W,Q,I,D,$,ee){if(W>I||W3?Q===0||Q===BigInt(0)?we=`>= 0${te} and < 2${te} ** ${(ee+1)*8}${te}`:we=`>= -(2${te} ** ${(ee+1)*8-1}${te}) and < 2 ** ${(ee+1)*8-1}${te}`:we=`>= ${Q}${te} and <= ${I}${te}`,new ie.ERR_OUT_OF_RANGE("value",we,W)}ne(D,$,ee)}function Be(W,Q){if(typeof W!="number")throw new ie.ERR_INVALID_ARG_TYPE(Q,"number",W)}function pe(W,Q,I){throw Math.floor(W)!==W?(Be(W,I),new ie.ERR_OUT_OF_RANGE(I||"offset","an integer",W)):Q<0?new ie.ERR_BUFFER_OUT_OF_BOUNDS:new ie.ERR_OUT_OF_RANGE(I||"offset",`>= ${I?1:0} and <= ${Q}`,W)}const Fe=/[^+/0-9A-Za-z-_]/g;function rt(W){if(W=W.split("=")[0],W=W.trim().replace(Fe,""),W.length<2)return"";for(;W.length%4!==0;)W=W+"=";return W}function Oe(W,Q){Q=Q||1/0;let I;const D=W.length;let $=null;const ee=[];for(let te=0;te55295&&I<57344){if(!$){if(I>56319){(Q-=3)>-1&&ee.push(239,191,189);continue}else if(te+1===D){(Q-=3)>-1&&ee.push(239,191,189);continue}$=I;continue}if(I<56320){(Q-=3)>-1&&ee.push(239,191,189),$=I;continue}I=($-55296<<10|I-56320)+65536}else $&&(Q-=3)>-1&&ee.push(239,191,189);if($=null,I<128){if((Q-=1)<0)break;ee.push(I)}else if(I<2048){if((Q-=2)<0)break;ee.push(I>>6|192,I&63|128)}else if(I<65536){if((Q-=3)<0)break;ee.push(I>>12|224,I>>6&63|128,I&63|128)}else if(I<1114112){if((Q-=4)<0)break;ee.push(I>>18|240,I>>12&63|128,I>>6&63|128,I&63|128)}else throw new Error("Invalid code point")}return ee}function ke(W){const Q=[];for(let I=0;I>8,$=I%256,ee.push($),ee.push(D);return ee}function Ge(W){return e.toByteArray(rt(W))}function Xe(W,Q,I,D){let $;for($=0;$=Q.length||$>=W.length);++$)Q[$+I]=W[$];return $}function G(W,Q){return W instanceof Q||W!=null&&W.constructor!=null&&W.constructor.name!=null&&W.constructor.name===Q.name}function J(W){return W!==W}const se=function(){const W="0123456789abcdef",Q=new Array(256);for(let I=0;I<16;++I){const D=I*16;for(let $=0;$<16;++$)Q[D+$]=W[I]+W[$]}return Q}();function fe(W){return typeof BigInt>"u"?ve:W}function ve(){throw new Error("BigInt not supported")}})(hJ);/*! + */(function(n){const e=eb,t=L_,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=v,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=s(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{const W=new Uint8Array(1),Q={foo:function(){return 42}};return Object.setPrototypeOf(Q,Uint8Array.prototype),Object.setPrototypeOf(W,Q),W.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(W){if(W>i)throw new RangeError('The value "'+W+'" is invalid for option "size"');const Q=new Uint8Array(W);return Object.setPrototypeOf(Q,a.prototype),Q}function a(W,Q,I){if(typeof W=="number"){if(typeof Q=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return u(W)}return l(W,Q,I)}a.poolSize=8192;function l(W,Q,I){if(typeof W=="string")return f(W,Q);if(ArrayBuffer.isView(W))return h(W);if(W==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof W);if(G(W,ArrayBuffer)||W&&G(W.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(G(W,SharedArrayBuffer)||W&&G(W.buffer,SharedArrayBuffer)))return p(W,Q,I);if(typeof W=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const D=W.valueOf&&W.valueOf();if(D!=null&&D!==W)return a.from(D,Q,I);const $=m(W);if($)return $;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof W[Symbol.toPrimitive]=="function")return a.from(W[Symbol.toPrimitive]("string"),Q,I);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof W)}a.from=function(W,Q,I){return l(W,Q,I)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function A(W){if(typeof W!="number")throw new TypeError('"size" argument must be of type number');if(W<0)throw new RangeError('The value "'+W+'" is invalid for option "size"')}function c(W,Q,I){return A(W),W<=0?o(W):Q!==void 0?typeof I=="string"?o(W).fill(Q,I):o(W).fill(Q):o(W)}a.alloc=function(W,Q,I){return c(W,Q,I)};function u(W){return A(W),o(W<0?0:g(W)|0)}a.allocUnsafe=function(W){return u(W)},a.allocUnsafeSlow=function(W){return u(W)};function f(W,Q){if((typeof Q!="string"||Q==="")&&(Q="utf8"),!a.isEncoding(Q))throw new TypeError("Unknown encoding: "+Q);const I=y(W,Q)|0;let D=o(I);const $=D.write(W,Q);return $!==I&&(D=D.slice(0,$)),D}function d(W){const Q=W.length<0?0:g(W.length)|0,I=o(Q);for(let D=0;D=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return W|0}function v(W){return+W!=W&&(W=0),a.alloc(+W)}a.isBuffer=function(Q){return Q!=null&&Q._isBuffer===!0&&Q!==a.prototype},a.compare=function(Q,I){if(G(Q,Uint8Array)&&(Q=a.from(Q,Q.offset,Q.byteLength)),G(I,Uint8Array)&&(I=a.from(I,I.offset,I.byteLength)),!a.isBuffer(Q)||!a.isBuffer(I))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(Q===I)return 0;let D=Q.length,$=I.length;for(let ee=0,te=Math.min(D,$);ee$.length?(a.isBuffer(te)||(te=a.from(te)),te.copy($,ee)):Uint8Array.prototype.set.call($,te,ee);else if(a.isBuffer(te))te.copy($,ee);else throw new TypeError('"list" argument must be an Array of Buffers');ee+=te.length}return $};function y(W,Q){if(a.isBuffer(W))return W.length;if(ArrayBuffer.isView(W)||G(W,ArrayBuffer))return W.byteLength;if(typeof W!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof W);const I=W.length,D=arguments.length>2&&arguments[2]===!0;if(!D&&I===0)return 0;let $=!1;for(;;)switch(Q){case"ascii":case"latin1":case"binary":return I;case"utf8":case"utf-8":return Oe(W).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I*2;case"hex":return I>>>1;case"base64":return Ge(W).length;default:if($)return D?-1:Oe(W).length;Q=(""+Q).toLowerCase(),$=!0}}a.byteLength=y;function w(W,Q,I){let D=!1;if((Q===void 0||Q<0)&&(Q=0),Q>this.length||((I===void 0||I>this.length)&&(I=this.length),I<=0)||(I>>>=0,Q>>>=0,I<=Q))return"";for(W||(W="utf8");;)switch(W){case"hex":return V(this,Q,I);case"utf8":case"utf-8":return B(this,Q,I);case"ascii":return k(this,Q,I);case"latin1":case"binary":return T(this,Q,I);case"base64":return _(this,Q,I);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,Q,I);default:if(D)throw new TypeError("Unknown encoding: "+W);W=(W+"").toLowerCase(),D=!0}}a.prototype._isBuffer=!0;function C(W,Q,I){const D=W[Q];W[Q]=W[I],W[I]=D}a.prototype.swap16=function(){const Q=this.length;if(Q%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let I=0;II&&(Q+=" ... "),""},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(Q,I,D,$,ee){if(G(Q,Uint8Array)&&(Q=a.from(Q,Q.offset,Q.byteLength)),!a.isBuffer(Q))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof Q);if(I===void 0&&(I=0),D===void 0&&(D=Q?Q.length:0),$===void 0&&($=0),ee===void 0&&(ee=this.length),I<0||D>Q.length||$<0||ee>this.length)throw new RangeError("out of range index");if($>=ee&&I>=D)return 0;if($>=ee)return-1;if(I>=D)return 1;if(I>>>=0,D>>>=0,$>>>=0,ee>>>=0,this===Q)return 0;let te=ee-$,we=D-I;const Ce=Math.min(te,we),Ee=this.slice($,ee),Ve=Q.slice(I,D);for(let _e=0;_e2147483647?I=2147483647:I<-2147483648&&(I=-2147483648),I=+I,J(I)&&(I=$?0:W.length-1),I<0&&(I=W.length+I),I>=W.length){if($)return-1;I=W.length-1}else if(I<0)if($)I=0;else return-1;if(typeof Q=="string"&&(Q=a.from(Q,D)),a.isBuffer(Q))return Q.length===0?-1:E(W,Q,I,D,$);if(typeof Q=="number")return Q=Q&255,typeof Uint8Array.prototype.indexOf=="function"?$?Uint8Array.prototype.indexOf.call(W,Q,I):Uint8Array.prototype.lastIndexOf.call(W,Q,I):E(W,[Q],I,D,$);throw new TypeError("val must be string, number or Buffer")}function E(W,Q,I,D,$){let ee=1,te=W.length,we=Q.length;if(D!==void 0&&(D=String(D).toLowerCase(),D==="ucs2"||D==="ucs-2"||D==="utf16le"||D==="utf-16le")){if(W.length<2||Q.length<2)return-1;ee=2,te/=2,we/=2,I/=2}function Ce(Ve,_e){return ee===1?Ve[_e]:Ve.readUInt16BE(_e*ee)}let Ee;if($){let Ve=-1;for(Ee=I;Eete&&(I=te-we),Ee=I;Ee>=0;Ee--){let Ve=!0;for(let _e=0;_e$&&(D=$)):D=$;const ee=Q.length;D>ee/2&&(D=ee/2);let te;for(te=0;te>>0,isFinite(D)?(D=D>>>0,$===void 0&&($="utf8")):($=D,D=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ee=this.length-I;if((D===void 0||D>ee)&&(D=ee),Q.length>0&&(D<0||I<0)||I>this.length)throw new RangeError("Attempt to write outside buffer bounds");$||($="utf8");let te=!1;for(;;)switch($){case"hex":return x(this,Q,I,D);case"utf8":case"utf-8":return S(this,Q,I,D);case"ascii":case"latin1":case"binary":return M(this,Q,I,D);case"base64":return Z(this,Q,I,D);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,Q,I,D);default:if(te)throw new TypeError("Unknown encoding: "+$);$=(""+$).toLowerCase(),te=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function _(W,Q,I){return Q===0&&I===W.length?e.fromByteArray(W):e.fromByteArray(W.slice(Q,I))}function B(W,Q,I){I=Math.min(W.length,I);const D=[];let $=Q;for(;$239?4:ee>223?3:ee>191?2:1;if($+we<=I){let Ce,Ee,Ve,_e;switch(we){case 1:ee<128&&(te=ee);break;case 2:Ce=W[$+1],(Ce&192)===128&&(_e=(ee&31)<<6|Ce&63,_e>127&&(te=_e));break;case 3:Ce=W[$+1],Ee=W[$+2],(Ce&192)===128&&(Ee&192)===128&&(_e=(ee&15)<<12|(Ce&63)<<6|Ee&63,_e>2047&&(_e<55296||_e>57343)&&(te=_e));break;case 4:Ce=W[$+1],Ee=W[$+2],Ve=W[$+3],(Ce&192)===128&&(Ee&192)===128&&(Ve&192)===128&&(_e=(ee&15)<<18|(Ce&63)<<12|(Ee&63)<<6|Ve&63,_e>65535&&_e<1114112&&(te=_e))}}te===null?(te=65533,we=1):te>65535&&(te-=65536,D.push(te>>>10&1023|55296),te=56320|te&1023),D.push(te),$+=we}return R(D)}const F=4096;function R(W){const Q=W.length;if(Q<=F)return String.fromCharCode.apply(String,W);let I="",D=0;for(;DD)&&(I=D);let $="";for(let ee=Q;eeD&&(Q=D),I<0?(I+=D,I<0&&(I=0)):I>D&&(I=D),II)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(Q,I,D){Q=Q>>>0,I=I>>>0,D||L(Q,I,this.length);let $=this[Q],ee=1,te=0;for(;++te>>0,I=I>>>0,D||L(Q,I,this.length);let $=this[Q+--I],ee=1;for(;I>0&&(ee*=256);)$+=this[Q+--I]*ee;return $},a.prototype.readUint8=a.prototype.readUInt8=function(Q,I){return Q=Q>>>0,I||L(Q,1,this.length),this[Q]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(Q,I){return Q=Q>>>0,I||L(Q,2,this.length),this[Q]|this[Q+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(Q,I){return Q=Q>>>0,I||L(Q,2,this.length),this[Q]<<8|this[Q+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),(this[Q]|this[Q+1]<<8|this[Q+2]<<16)+this[Q+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),this[Q]*16777216+(this[Q+1]<<16|this[Q+2]<<8|this[Q+3])},a.prototype.readBigUInt64LE=fe(function(Q){Q=Q>>>0,Be(Q,"offset");const I=this[Q],D=this[Q+7];(I===void 0||D===void 0)&&pe(Q,this.length-8);const $=I+this[++Q]*2**8+this[++Q]*2**16+this[++Q]*2**24,ee=this[++Q]+this[++Q]*2**8+this[++Q]*2**16+D*2**24;return BigInt($)+(BigInt(ee)<>>0,Be(Q,"offset");const I=this[Q],D=this[Q+7];(I===void 0||D===void 0)&&pe(Q,this.length-8);const $=I*2**24+this[++Q]*2**16+this[++Q]*2**8+this[++Q],ee=this[++Q]*2**24+this[++Q]*2**16+this[++Q]*2**8+D;return(BigInt($)<>>0,I=I>>>0,D||L(Q,I,this.length);let $=this[Q],ee=1,te=0;for(;++te=ee&&($-=Math.pow(2,8*I)),$},a.prototype.readIntBE=function(Q,I,D){Q=Q>>>0,I=I>>>0,D||L(Q,I,this.length);let $=I,ee=1,te=this[Q+--$];for(;$>0&&(ee*=256);)te+=this[Q+--$]*ee;return ee*=128,te>=ee&&(te-=Math.pow(2,8*I)),te},a.prototype.readInt8=function(Q,I){return Q=Q>>>0,I||L(Q,1,this.length),this[Q]&128?(255-this[Q]+1)*-1:this[Q]},a.prototype.readInt16LE=function(Q,I){Q=Q>>>0,I||L(Q,2,this.length);const D=this[Q]|this[Q+1]<<8;return D&32768?D|4294901760:D},a.prototype.readInt16BE=function(Q,I){Q=Q>>>0,I||L(Q,2,this.length);const D=this[Q+1]|this[Q]<<8;return D&32768?D|4294901760:D},a.prototype.readInt32LE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),this[Q]|this[Q+1]<<8|this[Q+2]<<16|this[Q+3]<<24},a.prototype.readInt32BE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),this[Q]<<24|this[Q+1]<<16|this[Q+2]<<8|this[Q+3]},a.prototype.readBigInt64LE=fe(function(Q){Q=Q>>>0,Be(Q,"offset");const I=this[Q],D=this[Q+7];(I===void 0||D===void 0)&&pe(Q,this.length-8);const $=this[Q+4]+this[Q+5]*2**8+this[Q+6]*2**16+(D<<24);return(BigInt($)<>>0,Be(Q,"offset");const I=this[Q],D=this[Q+7];(I===void 0||D===void 0)&&pe(Q,this.length-8);const $=(I<<24)+this[++Q]*2**16+this[++Q]*2**8+this[++Q];return(BigInt($)<>>0,I||L(Q,4,this.length),t.read(this,Q,!0,23,4)},a.prototype.readFloatBE=function(Q,I){return Q=Q>>>0,I||L(Q,4,this.length),t.read(this,Q,!1,23,4)},a.prototype.readDoubleLE=function(Q,I){return Q=Q>>>0,I||L(Q,8,this.length),t.read(this,Q,!0,52,8)},a.prototype.readDoubleBE=function(Q,I){return Q=Q>>>0,I||L(Q,8,this.length),t.read(this,Q,!1,52,8)};function U(W,Q,I,D,$,ee){if(!a.isBuffer(W))throw new TypeError('"buffer" argument must be a Buffer instance');if(Q>$||QW.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(Q,I,D,$){if(Q=+Q,I=I>>>0,D=D>>>0,!$){const we=Math.pow(2,8*D)-1;U(this,Q,I,D,we,0)}let ee=1,te=0;for(this[I]=Q&255;++te>>0,D=D>>>0,!$){const we=Math.pow(2,8*D)-1;U(this,Q,I,D,we,0)}let ee=D-1,te=1;for(this[I+ee]=Q&255;--ee>=0&&(te*=256);)this[I+ee]=Q/te&255;return I+D},a.prototype.writeUint8=a.prototype.writeUInt8=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,1,255,0),this[I]=Q&255,I+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,2,65535,0),this[I]=Q&255,this[I+1]=Q>>>8,I+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,2,65535,0),this[I]=Q>>>8,this[I+1]=Q&255,I+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,4,4294967295,0),this[I+3]=Q>>>24,this[I+2]=Q>>>16,this[I+1]=Q>>>8,this[I]=Q&255,I+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,4,4294967295,0),this[I]=Q>>>24,this[I+1]=Q>>>16,this[I+2]=Q>>>8,this[I+3]=Q&255,I+4};function H(W,Q,I,D,$){ae(Q,D,$,W,I,7);let ee=Number(Q&BigInt(4294967295));W[I++]=ee,ee=ee>>8,W[I++]=ee,ee=ee>>8,W[I++]=ee,ee=ee>>8,W[I++]=ee;let te=Number(Q>>BigInt(32)&BigInt(4294967295));return W[I++]=te,te=te>>8,W[I++]=te,te=te>>8,W[I++]=te,te=te>>8,W[I++]=te,I}function le(W,Q,I,D,$){ae(Q,D,$,W,I,7);let ee=Number(Q&BigInt(4294967295));W[I+7]=ee,ee=ee>>8,W[I+6]=ee,ee=ee>>8,W[I+5]=ee,ee=ee>>8,W[I+4]=ee;let te=Number(Q>>BigInt(32)&BigInt(4294967295));return W[I+3]=te,te=te>>8,W[I+2]=te,te=te>>8,W[I+1]=te,te=te>>8,W[I]=te,I+8}a.prototype.writeBigUInt64LE=fe(function(Q,I=0){return H(this,Q,I,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=fe(function(Q,I=0){return le(this,Q,I,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(Q,I,D,$){if(Q=+Q,I=I>>>0,!$){const Ce=Math.pow(2,8*D-1);U(this,Q,I,D,Ce-1,-Ce)}let ee=0,te=1,we=0;for(this[I]=Q&255;++ee>0)-we&255;return I+D},a.prototype.writeIntBE=function(Q,I,D,$){if(Q=+Q,I=I>>>0,!$){const Ce=Math.pow(2,8*D-1);U(this,Q,I,D,Ce-1,-Ce)}let ee=D-1,te=1,we=0;for(this[I+ee]=Q&255;--ee>=0&&(te*=256);)Q<0&&we===0&&this[I+ee+1]!==0&&(we=1),this[I+ee]=(Q/te>>0)-we&255;return I+D},a.prototype.writeInt8=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,1,127,-128),Q<0&&(Q=255+Q+1),this[I]=Q&255,I+1},a.prototype.writeInt16LE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,2,32767,-32768),this[I]=Q&255,this[I+1]=Q>>>8,I+2},a.prototype.writeInt16BE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,2,32767,-32768),this[I]=Q>>>8,this[I+1]=Q&255,I+2},a.prototype.writeInt32LE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,4,2147483647,-2147483648),this[I]=Q&255,this[I+1]=Q>>>8,this[I+2]=Q>>>16,this[I+3]=Q>>>24,I+4},a.prototype.writeInt32BE=function(Q,I,D){return Q=+Q,I=I>>>0,D||U(this,Q,I,4,2147483647,-2147483648),Q<0&&(Q=4294967295+Q+1),this[I]=Q>>>24,this[I+1]=Q>>>16,this[I+2]=Q>>>8,this[I+3]=Q&255,I+4},a.prototype.writeBigInt64LE=fe(function(Q,I=0){return H(this,Q,I,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=fe(function(Q,I=0){return le(this,Q,I,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function N(W,Q,I,D,$,ee){if(I+D>W.length)throw new RangeError("Index out of range");if(I<0)throw new RangeError("Index out of range")}function j(W,Q,I,D,$){return Q=+Q,I=I>>>0,$||N(W,Q,I,4),t.write(W,Q,I,D,23,4),I+4}a.prototype.writeFloatLE=function(Q,I,D){return j(this,Q,I,!0,D)},a.prototype.writeFloatBE=function(Q,I,D){return j(this,Q,I,!1,D)};function oe(W,Q,I,D,$){return Q=+Q,I=I>>>0,$||N(W,Q,I,8),t.write(W,Q,I,D,52,8),I+8}a.prototype.writeDoubleLE=function(Q,I,D){return oe(this,Q,I,!0,D)},a.prototype.writeDoubleBE=function(Q,I,D){return oe(this,Q,I,!1,D)},a.prototype.copy=function(Q,I,D,$){if(!a.isBuffer(Q))throw new TypeError("argument should be a Buffer");if(D||(D=0),!$&&$!==0&&($=this.length),I>=Q.length&&(I=Q.length),I||(I=0),$>0&&$=this.length)throw new RangeError("Index out of range");if($<0)throw new RangeError("sourceEnd out of bounds");$>this.length&&($=this.length),Q.length-I<$-D&&($=Q.length-I+D);const ee=$-D;return this===Q&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(I,D,$):Uint8Array.prototype.set.call(Q,this.subarray(D,$),I),ee},a.prototype.fill=function(Q,I,D,$){if(typeof Q=="string"){if(typeof I=="string"?($=I,I=0,D=this.length):typeof D=="string"&&($=D,D=this.length),$!==void 0&&typeof $!="string")throw new TypeError("encoding must be a string");if(typeof $=="string"&&!a.isEncoding($))throw new TypeError("Unknown encoding: "+$);if(Q.length===1){const te=Q.charCodeAt(0);($==="utf8"&&te<128||$==="latin1")&&(Q=te)}}else typeof Q=="number"?Q=Q&255:typeof Q=="boolean"&&(Q=Number(Q));if(I<0||this.length>>0,D=D===void 0?this.length:D>>>0,Q||(Q=0);let ee;if(typeof Q=="number")for(ee=I;ee2**32?$=X(String(I)):typeof I=="bigint"&&($=String(I),(I>BigInt(2)**BigInt(32)||I<-(BigInt(2)**BigInt(32)))&&($=X($)),$+="n"),D+=` It must be ${Q}. Received ${$}`,D},RangeError);function X(W){let Q="",I=W.length;const D=W[0]==="-"?1:0;for(;I>=D+4;I-=3)Q=`_${W.slice(I-3,I)}${Q}`;return`${W.slice(0,I)}${Q}`}function ne(W,Q,I){Be(Q,"offset"),(W[Q]===void 0||W[Q+I]===void 0)&&pe(Q,W.length-(I+1))}function ae(W,Q,I,D,$,ee){if(W>I||W3?Q===0||Q===BigInt(0)?we=`>= 0${te} and < 2${te} ** ${(ee+1)*8}${te}`:we=`>= -(2${te} ** ${(ee+1)*8-1}${te}) and < 2 ** ${(ee+1)*8-1}${te}`:we=`>= ${Q}${te} and <= ${I}${te}`,new ie.ERR_OUT_OF_RANGE("value",we,W)}ne(D,$,ee)}function Be(W,Q){if(typeof W!="number")throw new ie.ERR_INVALID_ARG_TYPE(Q,"number",W)}function pe(W,Q,I){throw Math.floor(W)!==W?(Be(W,I),new ie.ERR_OUT_OF_RANGE(I||"offset","an integer",W)):Q<0?new ie.ERR_BUFFER_OUT_OF_BOUNDS:new ie.ERR_OUT_OF_RANGE(I||"offset",`>= ${I?1:0} and <= ${Q}`,W)}const Fe=/[^+/0-9A-Za-z-_]/g;function rt(W){if(W=W.split("=")[0],W=W.trim().replace(Fe,""),W.length<2)return"";for(;W.length%4!==0;)W=W+"=";return W}function Oe(W,Q){Q=Q||1/0;let I;const D=W.length;let $=null;const ee=[];for(let te=0;te55295&&I<57344){if(!$){if(I>56319){(Q-=3)>-1&&ee.push(239,191,189);continue}else if(te+1===D){(Q-=3)>-1&&ee.push(239,191,189);continue}$=I;continue}if(I<56320){(Q-=3)>-1&&ee.push(239,191,189),$=I;continue}I=($-55296<<10|I-56320)+65536}else $&&(Q-=3)>-1&&ee.push(239,191,189);if($=null,I<128){if((Q-=1)<0)break;ee.push(I)}else if(I<2048){if((Q-=2)<0)break;ee.push(I>>6|192,I&63|128)}else if(I<65536){if((Q-=3)<0)break;ee.push(I>>12|224,I>>6&63|128,I&63|128)}else if(I<1114112){if((Q-=4)<0)break;ee.push(I>>18|240,I>>12&63|128,I>>6&63|128,I&63|128)}else throw new Error("Invalid code point")}return ee}function ke(W){const Q=[];for(let I=0;I>8,$=I%256,ee.push($),ee.push(D);return ee}function Ge(W){return e.toByteArray(rt(W))}function Xe(W,Q,I,D){let $;for($=0;$=Q.length||$>=W.length);++$)Q[$+I]=W[$];return $}function G(W,Q){return W instanceof Q||W!=null&&W.constructor!=null&&W.constructor.name!=null&&W.constructor.name===Q.name}function J(W){return W!==W}const se=function(){const W="0123456789abcdef",Q=new Array(256);for(let I=0;I<16;++I){const D=I*16;for(let $=0;$<16;++$)Q[D+$]=W[I]+W[$]}return Q}();function fe(W){return typeof BigInt>"u"?ve:W}function ve(){throw new Error("BigInt not supported")}})(hJ);/*! * html2canvas 1.4.1 * Copyright (c) 2022 Niklas von Hertzen * Released under MIT License @@ -3233,7 +3233,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var RE=function(n,e){return RE=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])},RE(n,e)};function Lo(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");RE(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Rs(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})}function Ji(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(A){return function(c){return l([A,c])}}function l(A){if(r)throw new TypeError("Generator is already executing.");for(;t;)try{if(r=1,i&&(s=A[0]&2?i.return:A[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,A[1])).done)return s;switch(i=0,s&&(A=[A[0]&2,s.value]),A[0]){case 0:case 1:s=A;break;case 4:return t.label++,{value:A[1],done:!1};case 5:t.label++,i=A[1],A=[0];continue;case 7:A=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(A[0]===6||A[0]===2)){t=0;continue}if(A[0]===3&&(!s||A[1]>s[0]&&A[1]=55296&&i<=56319&&t>10)+55296,o%1024+56320)),(i+1===t||r.length>16384)&&(s+=String.fromCharCode.apply(String,r),r.length=0)}return s},kN="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",loe=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Mv=0;Mv"u"?[]:new Uint8Array(256);for(var Tv=0;Tv>4,c[i++]=(o&15)<<4|a>>2,c[i++]=(a&3)<<6|l&63;return A},coe=function(n){for(var e=n.length,t=[],r=0;r>su,doe=1<>su,poe=gJ+hoe,goe=poe,moe=32,voe=goe+moe,yoe=65536>>W_,Boe=1<=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>su],t=(t<>su)],t=(t<>W_),t=this.index[t],t+=e>>su&woe,t=this.index[t],t=(t<"u"?[]:new Uint8Array(256);for(var Nv=0;NvWN?(i.push(!0),a-=WN):i.push(!1),["normal","auto","loose"].indexOf(e)!==-1&&[8208,8211,12316,12448].indexOf(s)!==-1)return r.push(o),t.push(NE);if(a===Uoe||a===ME){if(o===0)return r.push(o),t.push(Pc);var l=t[o-1];return Doe.indexOf(l)===-1?(r.push(r[o-1]),t.push(l)):(r.push(o),t.push(Pc))}if(r.push(o),a===Moe)return t.push(e==="strict"?DE:Tm);if(a===BJ||a===Roe)return t.push(Pc);if(a===Toe)return s>=131072&&s<=196605||s>=196608&&s<=262141?t.push(Tm):t.push(Pc);t.push(a)}),[r,t,i]},kI=function(n,e,t,r){var i=r[t];if(Array.isArray(n)?n.indexOf(i)!==-1:n===i)for(var s=t;s<=r.length;){s++;var o=r[s];if(o===e)return!0;if(o!==EA)break}if(i===EA)for(var s=t;s>0;){s--;var a=r[s];if(Array.isArray(n)?n.indexOf(a)!==-1:n===a)for(var l=t;l<=r.length;){l++;var o=r[l];if(o===e)return!0;if(o!==EA)break}if(a!==EA)break}return!1},YN=function(n,e){for(var t=n;t>=0;){var r=e[t];if(r===EA)t--;else return r}return 0},Loe=function(n,e,t,r,i){if(t[r]===0)return Et;var s=r-1;if(Array.isArray(i)&&i[s]===!0)return Et;var o=s-1,a=s+1,l=e[s],A=o>=0?e[o]:0,c=e[a];if(l===mJ&&c===vJ)return Et;if(OE.indexOf(l)!==-1)return wJ;if(OE.indexOf(c)!==-1||CJ.indexOf(c)!==-1)return Et;if(YN(s,e)===yJ)return Lv;if(WE.get(n[s])===ME||(l===kv||l===Vv)&&WE.get(n[a])===ME||l===ON||c===ON||l===GN||[EA,TE,pg].indexOf(l)===-1&&c===GN||[Dv,Rp,Qoe,df,hf].indexOf(c)!==-1||YN(s,e)===Mp||kI(NI,Mp,s,e)||kI([Dv,Rp],DE,s,e)||kI(ZN,ZN,s,e))return Et;if(l===EA)return Lv;if(l===NI||c===NI)return Et;if(c===NE||l===NE)return Lv;if([TE,pg,DE].indexOf(c)!==-1||l===_oe||A===LE&&koe.indexOf(l)!==-1||l===hf&&c===LE||c===JN||Xa.indexOf(c)!==-1&&l===Hi||Xa.indexOf(l)!==-1&&c===Hi||l===mg&&[Tm,kv,Vv].indexOf(c)!==-1||[Tm,kv,Vv].indexOf(l)!==-1&&c===gg||Xa.indexOf(l)!==-1&&HN.indexOf(c)!==-1||HN.indexOf(l)!==-1&&Xa.indexOf(c)!==-1||[mg,gg].indexOf(l)!==-1&&(c===Hi||[Mp,pg].indexOf(c)!==-1&&e[a+1]===Hi)||[Mp,pg].indexOf(l)!==-1&&c===Hi||l===Hi&&[Hi,hf,df].indexOf(c)!==-1)return Et;if([Hi,hf,df,Dv,Rp].indexOf(c)!==-1)for(var u=s;u>=0;){var f=e[u];if(f===Hi)return Et;if([hf,df].indexOf(f)!==-1)u--;else break}if([mg,gg].indexOf(c)!==-1)for(var u=[Dv,Rp].indexOf(l)!==-1?o:s;u>=0;){var f=e[u];if(f===Hi)return Et;if([hf,df].indexOf(f)!==-1)u--;else break}if(PE===l&&[PE,lB,kE,VE].indexOf(c)!==-1||[lB,kE].indexOf(l)!==-1&&[lB,AB].indexOf(c)!==-1||[AB,VE].indexOf(l)!==-1&&c===AB||zN.indexOf(l)!==-1&&[JN,gg].indexOf(c)!==-1||zN.indexOf(c)!==-1&&l===mg||Xa.indexOf(l)!==-1&&Xa.indexOf(c)!==-1||l===df&&Xa.indexOf(c)!==-1||Xa.concat(Hi).indexOf(l)!==-1&&c===Mp&&Noe.indexOf(n[a])===-1||Xa.concat(Hi).indexOf(c)!==-1&&l===Rp)return Et;if(l===DI&&c===DI){for(var d=t[s],h=1;d>0&&(d--,e[d]===DI);)h++;if(h%2!==0)return Et}return l===kv&&c===Vv?Et:Lv},Poe=function(n,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=Voe(n,e.lineBreak),r=t[0],i=t[1],s=t[2];(e.wordBreak==="break-all"||e.wordBreak==="break-word")&&(i=i.map(function(a){return[Hi,Pc,BJ].indexOf(a)!==-1?Tm:a}));var o=e.wordBreak==="keep-all"?s.map(function(a,l){return a&&n[l]>=19968&&n[l]<=40959}):void 0;return[r,i,o]},Woe=function(){function n(e,t,r,i){this.codePoints=e,this.required=t===wJ,this.start=r,this.end=i}return n.prototype.slice=function(){return On.apply(void 0,this.codePoints.slice(this.start,this.end))},n}(),Ooe=function(n,e){var t=tb(n),r=Poe(t,e),i=r[0],s=r[1],o=r[2],a=t.length,l=0,A=0;return{next:function(){if(A>=a)return{done:!0,value:null};for(var c=Et;A=bJ&&n<=57},Cae=function(n){return n>=55296&&n<=57343},pf=function(n){return Hr(n)||n>=FJ&&n<=UJ||n>=xJ&&n<=mae},bae=function(n){return n>=xJ&&n<=yae},xae=function(n){return n>=FJ&&n<=wae},Iae=function(n){return bae(n)||xae(n)},Fae=function(n){return n>=aae},Zv=function(n){return n===Sw||n===Joe||n===Hoe},_w=function(n){return Iae(n)||Fae(n)||n===Koe},qN=function(n){return _w(n)||Hr(n)||n===Fi},Eae=function(n){return n>=uae&&n<=fae||n===dae||n>=hae&&n<=pae||n===gae},hA=function(n,e){return n!==Jg?!1:e!==Sw},Jv=function(n,e,t){return n===Fi?_w(e)||hA(e,t):_w(n)?!0:!!(n===Jg&&hA(n,e))},LI=function(n,e,t){return n===zc||n===Fi?Hr(e)?!0:e===Nm&&Hr(t):Hr(n===Nm?e:n)},Uae=function(n){var e=0,t=1;(n[e]===zc||n[e]===Fi)&&(n[e]===Fi&&(t=-1),e++);for(var r=[];Hr(n[e]);)r.push(n[e++]);var i=r.length?parseInt(On.apply(void 0,r),10):0;n[e]===Nm&&e++;for(var s=[];Hr(n[e]);)s.push(n[e++]);var o=s.length,a=o?parseInt(On.apply(void 0,s),10):0;(n[e]===EJ||n[e]===IJ)&&e++;var l=1;(n[e]===zc||n[e]===Fi)&&(n[e]===Fi&&(l=-1),e++);for(var A=[];Hr(n[e]);)A.push(n[e++]);var c=A.length?parseInt(On.apply(void 0,A),10):0;return t*(i+a*Math.pow(10,-o))*Math.pow(10,l*c)},Sae={type:2},_ae={type:3},Qae={type:4},Rae={type:13},Mae={type:8},Tae={type:21},Nae={type:9},Dae={type:10},kae={type:11},Vae={type:12},Lae={type:14},Hv={type:23},Pae={type:1},Wae={type:25},Oae={type:24},Gae={type:26},Zae={type:27},Jae={type:28},Hae={type:29},zae={type:31},GE={type:32},SJ=function(){function n(){this._value=[]}return n.prototype.write=function(e){this._value=this._value.concat(tb(e))},n.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==GE;)e.push(t),t=this.consumeToken();return e},n.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case Pv:return this.consumeStringToken(Pv);case zoe:var t=this.peekCodePoint(0),r=this.peekCodePoint(1),i=this.peekCodePoint(2);if(qN(t)||hA(r,i)){var s=Jv(t,r,i)?Zoe:Goe,o=this.consumeName();return{type:5,value:o,flags:s}}break;case Yoe:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Rae;break;case Wv:return this.consumeStringToken(Wv);case Ov:return Sae;case Np:return _ae;case VI:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Lae;break;case zc:if(LI(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case lae:return Qae;case Fi:var a=e,l=this.peekCodePoint(0),A=this.peekCodePoint(1);if(LI(a,l,A))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Jv(a,l,A))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(l===Fi&&A===qoe)return this.consumeCodePoint(),this.consumeCodePoint(),Oae;break;case Nm:if(LI(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case KN:if(this.peekCodePoint(0)===VI)for(this.consumeCodePoint();;){var c=this.consumeCodePoint();if(c===VI&&(c=this.consumeCodePoint(),c===KN))return this.consumeToken();if(c===Ho)return this.consumeToken()}break;case Aae:return Gae;case cae:return Zae;case $oe:if(this.peekCodePoint(0)===joe&&this.peekCodePoint(1)===Fi&&this.peekCodePoint(2)===Fi)return this.consumeCodePoint(),this.consumeCodePoint(),Wae;break;case eae:var u=this.peekCodePoint(0),f=this.peekCodePoint(1),d=this.peekCodePoint(2);if(Jv(u,f,d)){var o=this.consumeName();return{type:7,value:o}}break;case tae:return Jae;case Jg:if(hA(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case nae:return Hae;case rae:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Mae;break;case iae:return kae;case sae:return Vae;case vae:case Bae:var h=this.peekCodePoint(0),p=this.peekCodePoint(1);return h===zc&&(pf(p)||p===Gv)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case jN:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Nae;if(this.peekCodePoint(0)===jN)return this.consumeCodePoint(),Tae;break;case oae:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Dae;break;case Ho:return GE}return Zv(e)?(this.consumeWhiteSpace(),zae):Hr(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):_w(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:On(e)}},n.prototype.consumeCodePoint=function(){var e=this._value.shift();return typeof e>"u"?-1:e},n.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},n.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},n.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();pf(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var r=!1;t===Gv&&e.length<6;)e.push(t),t=this.consumeCodePoint(),r=!0;if(r){var i=parseInt(On.apply(void 0,e.map(function(l){return l===Gv?bJ:l})),16),s=parseInt(On.apply(void 0,e.map(function(l){return l===Gv?UJ:l})),16);return{type:30,start:i,end:s}}var o=parseInt(On.apply(void 0,e),16);if(this.peekCodePoint(0)===Fi&&pf(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var a=[];pf(t)&&a.length<6;)a.push(t),t=this.consumeCodePoint();var s=parseInt(On.apply(void 0,a),16);return{type:30,start:o,end:s}}else return{type:30,start:o,end:o}},n.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return e.toLowerCase()==="url"&&this.peekCodePoint(0)===Ov?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===Ov?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},n.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ho)return{type:22,value:""};var t=this.peekCodePoint(0);if(t===Wv||t===Pv){var r=this.consumeStringToken(this.consumeCodePoint());return r.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ho||this.peekCodePoint(0)===Np)?(this.consumeCodePoint(),{type:22,value:r.value}):(this.consumeBadUrlRemnants(),Hv)}for(;;){var i=this.consumeCodePoint();if(i===Ho||i===Np)return{type:22,value:On.apply(void 0,e)};if(Zv(i))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Ho||this.peekCodePoint(0)===Np?(this.consumeCodePoint(),{type:22,value:On.apply(void 0,e)}):(this.consumeBadUrlRemnants(),Hv);if(i===Pv||i===Wv||i===Ov||Eae(i))return this.consumeBadUrlRemnants(),Hv;if(i===Jg)if(hA(i,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),Hv;else e.push(i)}},n.prototype.consumeWhiteSpace=function(){for(;Zv(this.peekCodePoint(0));)this.consumeCodePoint()},n.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===Np||e===Ho)return;hA(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},n.prototype.consumeStringSlice=function(e){for(var t=5e4,r="";e>0;){var i=Math.min(t,e);r+=On.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),r},n.prototype.consumeStringToken=function(e){var t="",r=0;do{var i=this._value[r];if(i===Ho||i===void 0||i===e)return t+=this.consumeStringSlice(r),{type:0,value:t};if(i===Sw)return this._value.splice(0,r),Pae;if(i===Jg){var s=this._value[r+1];s!==Ho&&s!==void 0&&(s===Sw?(t+=this.consumeStringSlice(r),r=-1,this._value.shift()):hA(i,s)&&(t+=this.consumeStringSlice(r),t+=On(this.consumeEscapedCodePoint()),r=-1))}r++}while(!0)},n.prototype.consumeNumber=function(){var e=[],t=m0,r=this.peekCodePoint(0);for((r===zc||r===Fi)&&e.push(this.consumeCodePoint());Hr(this.peekCodePoint(0));)e.push(this.consumeCodePoint());r=this.peekCodePoint(0);var i=this.peekCodePoint(1);if(r===Nm&&Hr(i))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=XN;Hr(this.peekCodePoint(0));)e.push(this.consumeCodePoint());r=this.peekCodePoint(0),i=this.peekCodePoint(1);var s=this.peekCodePoint(2);if((r===EJ||r===IJ)&&((i===zc||i===Fi)&&Hr(s)||Hr(i)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=XN;Hr(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Uae(e),t]},n.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],r=e[1],i=this.peekCodePoint(0),s=this.peekCodePoint(1),o=this.peekCodePoint(2);if(Jv(i,s,o)){var a=this.consumeName();return{type:15,number:t,flags:r,unit:a}}return i===Xoe?(this.consumeCodePoint(),{type:16,number:t,flags:r}):{type:17,number:t,flags:r}},n.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(pf(e)){for(var t=On(e);pf(this.peekCodePoint(0))&&t.length<6;)t+=On(this.consumeCodePoint());Zv(this.peekCodePoint(0))&&this.consumeCodePoint();var r=parseInt(t,16);return r===0||Cae(r)||r>1114111?$N:r}return e===Ho?$N:e},n.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(qN(t))e+=On(t);else if(hA(t,this.peekCodePoint(0)))e+=On(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}},n}(),_J=function(){function n(e){this._tokens=e}return n.create=function(e){var t=new SJ;return t.write(e),new n(t.read())},n.parseValue=function(e){return n.create(e).parseComponentValue()},n.parseValues=function(e){return n.create(e).parseComponentValues()},n.prototype.parseComponentValue=function(){for(var e=this.consumeToken();e.type===31;)e=this.consumeToken();if(e.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},n.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(t.type===32)return e;e.push(t),e.push()}},n.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},n.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},r=this.consumeToken();;){if(r.type===32||Yae(r,e))return t;this.reconsumeToken(r),t.values.push(this.consumeComponentValue()),r=this.consumeToken()}},n.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var r=this.consumeToken();if(r.type===32||r.type===3)return t;this.reconsumeToken(r),t.values.push(this.consumeComponentValue())}},n.prototype.consumeToken=function(){var e=this._tokens.shift();return typeof e>"u"?GE:e},n.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},n}(),v0=function(n){return n.type===15},nb=function(n){return n.type===17},Pn=function(n){return n.type===20},ZE=function(n,e){return Pn(n)&&n.value===e},rb=function(n){return n.type!==31&&n.type!==4},ka=function(n){var e=[],t=[];return n.forEach(function(r){if(r.type===4){if(t.length===0)throw new Error("Error parsing function args, zero tokens for arg");e.push(t),t=[];return}r.type!==31&&t.push(r)}),t.length&&e.push(t),e},Yae=function(n,e){return e===11&&n.type===12||e===28&&n.type===29?!0:e===2&&n.type===3},nc=function(n){return n.type===17||n.type===15},tr=function(n){return n.type===16||nc(n)},QJ=function(n){return n.length>1?[n[0],n[1]]:[n[0]]},Nr={type:17,number:0,flags:m0},O_={type:16,number:50,flags:m0},UA={type:16,number:100,flags:m0},vg=function(n,e,t){var r=n[0],i=n[1];return[un(r,e),un(typeof i<"u"?i:r,t)]},un=function(n,e){if(n.type===16)return n.number/100*e;if(v0(n))switch(n.unit){case"rem":case"em":return 16*n.number;case"px":default:return n.number}return n.number},RJ="deg",MJ="grad",TJ="rad",NJ="turn",ib={name:"angle",parse:function(n,e){if(e.type===15)switch(e.unit){case RJ:return Math.PI*e.number/180;case MJ:return Math.PI/200*e.number;case TJ:return e.number;case NJ:return Math.PI*2*e.number}throw new Error("Unsupported angle type")}},DJ=function(n){return n.type===15&&(n.unit===RJ||n.unit===MJ||n.unit===TJ||n.unit===NJ)},kJ=function(n){var e=n.filter(Pn).map(function(t){return t.value}).join(" ");switch(e){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Nr,Nr];case"to top":case"bottom":return zs(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Nr,UA];case"to right":case"left":return zs(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[UA,UA];case"to bottom":case"top":return zs(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[UA,Nr];case"to left":case"right":return zs(270)}return 0},zs=function(n){return Math.PI*n/180},GA={name:"color",parse:function(n,e){if(e.type===18){var t=Xae[e.name];if(typeof t>"u")throw new Error('Attempting to parse an unsupported color function "'+e.name+'"');return t(n,e.values)}if(e.type===5){if(e.value.length===3){var r=e.value.substring(0,1),i=e.value.substring(1,2),s=e.value.substring(2,3);return SA(parseInt(r+r,16),parseInt(i+i,16),parseInt(s+s,16),1)}if(e.value.length===4){var r=e.value.substring(0,1),i=e.value.substring(1,2),s=e.value.substring(2,3),o=e.value.substring(3,4);return SA(parseInt(r+r,16),parseInt(i+i,16),parseInt(s+s,16),parseInt(o+o,16)/255)}if(e.value.length===6){var r=e.value.substring(0,2),i=e.value.substring(2,4),s=e.value.substring(4,6);return SA(parseInt(r,16),parseInt(i,16),parseInt(s,16),1)}if(e.value.length===8){var r=e.value.substring(0,2),i=e.value.substring(2,4),s=e.value.substring(4,6),o=e.value.substring(6,8);return SA(parseInt(r,16),parseInt(i,16),parseInt(s,16),parseInt(o,16)/255)}}if(e.type===20){var a=Dm[e.value.toUpperCase()];if(typeof a<"u")return a}return Dm.TRANSPARENT}},Gd=function(n){return(255&n)===0},vr=function(n){var e=255&n,t=255&n>>8,r=255&n>>16,i=255&n>>24;return e<255?"rgba("+i+","+r+","+t+","+e/255+")":"rgb("+i+","+r+","+t+")"},SA=function(n,e,t,r){return(n<<24|e<<16|t<<8|Math.round(r*255)<<0)>>>0},eD=function(n,e){if(n.type===17)return n.number;if(n.type===16){var t=e===3?1:255;return e===3?n.number/100*t:Math.round(n.number/100*t)}return 0},tD=function(n,e){var t=e.filter(rb);if(t.length===3){var r=t.map(eD),i=r[0],s=r[1],o=r[2];return SA(i,s,o,1)}if(t.length===4){var a=t.map(eD),i=a[0],s=a[1],o=a[2],l=a[3];return SA(i,s,o,l)}return 0};function PI(n,e,t){return t<0&&(t+=1),t>=1&&(t-=1),t<1/6?(e-n)*t*6+n:t<1/2?e:t<2/3?(e-n)*6*(2/3-t)+n:n}var nD=function(n,e){var t=e.filter(rb),r=t[0],i=t[1],s=t[2],o=t[3],a=(r.type===17?zs(r.number):ib.parse(n,r))/(Math.PI*2),l=tr(i)?i.number/100:0,A=tr(s)?s.number/100:0,c=typeof o<"u"&&tr(o)?un(o,1):1;if(l===0)return SA(A*255,A*255,A*255,1);var u=A<=.5?A*(l+1):A+l-A*l,f=A*2-u,d=PI(f,u,a+1/3),h=PI(f,u,a),p=PI(f,u,a-1/3);return SA(d*255,h*255,p*255,c)},Xae={hsl:nD,hsla:nD,rgb:tD,rgba:tD},rD=function(n,e){return GA.parse(n,_J.create(e).parseComponentValue())},Dm={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Kae={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(n,e){return e.map(function(t){if(Pn(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},jae={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},sb=function(n,e){var t=GA.parse(n,e[0]),r=e[1];return r&&tr(r)?{color:t,stop:r}:{color:t,stop:null}},iD=function(n,e){var t=n[0],r=n[n.length-1];t.stop===null&&(t.stop=Nr),r.stop===null&&(r.stop=UA);for(var i=[],s=0,o=0;os?i.push(l):i.push(s),s=l}else i.push(null)}for(var A=null,o=0;oo.optimumDistance)?{optimumCorner:a,optimumDistance:c}:o},{optimumDistance:i?1/0:-1/0,optimumCorner:null}).optimumCorner},ele=function(n,e,t,r,i){var s=0,o=0;switch(n.size){case 0:n.shape===0?s=o=Math.min(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-i)):n.shape===1&&(s=Math.min(Math.abs(e),Math.abs(e-r)),o=Math.min(Math.abs(t),Math.abs(t-i)));break;case 2:if(n.shape===0)s=o=Math.min(Co(e,t),Co(e,t-i),Co(e-r,t),Co(e-r,t-i));else if(n.shape===1){var a=Math.min(Math.abs(t),Math.abs(t-i))/Math.min(Math.abs(e),Math.abs(e-r)),l=sD(r,i,e,t,!0),A=l[0],c=l[1];s=Co(A-e,(c-t)/a),o=a*s}break;case 1:n.shape===0?s=o=Math.max(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-i)):n.shape===1&&(s=Math.max(Math.abs(e),Math.abs(e-r)),o=Math.max(Math.abs(t),Math.abs(t-i)));break;case 3:if(n.shape===0)s=o=Math.max(Co(e,t),Co(e,t-i),Co(e-r,t),Co(e-r,t-i));else if(n.shape===1){var a=Math.max(Math.abs(t),Math.abs(t-i))/Math.max(Math.abs(e),Math.abs(e-r)),u=sD(r,i,e,t,!1),A=u[0],c=u[1];s=Co(A-e,(c-t)/a),o=a*s}break}return Array.isArray(n.size)&&(s=un(n.size[0],r),o=n.size.length===2?un(n.size[1],i):s),[s,o]},tle=function(n,e){var t=zs(180),r=[];return ka(e).forEach(function(i,s){if(s===0){var o=i[0];if(o.type===20&&o.value==="to"){t=kJ(i);return}else if(DJ(o)){t=ib.parse(n,o);return}}var a=sb(n,i);r.push(a)}),{angle:t,stops:r,type:1}},zv=function(n,e){var t=zs(180),r=[];return ka(e).forEach(function(i,s){if(s===0){var o=i[0];if(o.type===20&&["top","left","right","bottom"].indexOf(o.value)!==-1){t=kJ(i);return}else if(DJ(o)){t=(ib.parse(n,o)+zs(270))%zs(360);return}}var a=sb(n,i);r.push(a)}),{angle:t,stops:r,type:1}},nle=function(n,e){var t=zs(180),r=[],i=1,s=0,o=3,a=[];return ka(e).forEach(function(l,A){var c=l[0];if(A===0){if(Pn(c)&&c.value==="linear"){i=1;return}else if(Pn(c)&&c.value==="radial"){i=2;return}}if(c.type===18){if(c.name==="from"){var u=GA.parse(n,c.values[0]);r.push({stop:Nr,color:u})}else if(c.name==="to"){var u=GA.parse(n,c.values[0]);r.push({stop:UA,color:u})}else if(c.name==="color-stop"){var f=c.values.filter(rb);if(f.length===2){var u=GA.parse(n,f[1]),d=f[0];nb(d)&&r.push({stop:{type:16,number:d.number*100,flags:d.flags},color:u})}}}}),i===1?{angle:(t+zs(180))%zs(360),stops:r,type:i}:{size:o,shape:s,stops:r,position:a,type:i}},VJ="closest-side",LJ="farthest-side",PJ="closest-corner",WJ="farthest-corner",OJ="circle",GJ="ellipse",ZJ="cover",JJ="contain",rle=function(n,e){var t=0,r=3,i=[],s=[];return ka(e).forEach(function(o,a){var l=!0;if(a===0){var A=!1;l=o.reduce(function(u,f){if(A)if(Pn(f))switch(f.value){case"center":return s.push(O_),u;case"top":case"left":return s.push(Nr),u;case"right":case"bottom":return s.push(UA),u}else(tr(f)||nc(f))&&s.push(f);else if(Pn(f))switch(f.value){case OJ:return t=0,!1;case GJ:return t=1,!1;case"at":return A=!0,!1;case VJ:return r=0,!1;case ZJ:case LJ:return r=1,!1;case JJ:case PJ:return r=2,!1;case WJ:return r=3,!1}else if(nc(f)||tr(f))return Array.isArray(r)||(r=[]),r.push(f),!1;return u},l)}if(l){var c=sb(n,o);i.push(c)}}),{size:r,shape:t,stops:i,position:s,type:2}},Yv=function(n,e){var t=0,r=3,i=[],s=[];return ka(e).forEach(function(o,a){var l=!0;if(a===0?l=o.reduce(function(c,u){if(Pn(u))switch(u.value){case"center":return s.push(O_),!1;case"top":case"left":return s.push(Nr),!1;case"right":case"bottom":return s.push(UA),!1}else if(tr(u)||nc(u))return s.push(u),!1;return c},l):a===1&&(l=o.reduce(function(c,u){if(Pn(u))switch(u.value){case OJ:return t=0,!1;case GJ:return t=1,!1;case JJ:case VJ:return r=0,!1;case LJ:return r=1,!1;case PJ:return r=2,!1;case ZJ:case WJ:return r=3,!1}else if(nc(u)||tr(u))return Array.isArray(r)||(r=[]),r.push(u),!1;return c},l)),l){var A=sb(n,o);i.push(A)}}),{size:r,shape:t,stops:i,position:s,type:2}},ile=function(n){return n.type===1},sle=function(n){return n.type===2},G_={name:"image",parse:function(n,e){if(e.type===22){var t={url:e.value,type:0};return n.cache.addImage(e.value),t}if(e.type===18){var r=HJ[e.name];if(typeof r>"u")throw new Error('Attempting to parse an unsupported image function "'+e.name+'"');return r(n,e.values)}throw new Error("Unsupported image type "+e.type)}};function ole(n){return!(n.type===20&&n.value==="none")&&(n.type!==18||!!HJ[n.name])}var HJ={"linear-gradient":tle,"-moz-linear-gradient":zv,"-ms-linear-gradient":zv,"-o-linear-gradient":zv,"-webkit-linear-gradient":zv,"radial-gradient":rle,"-moz-radial-gradient":Yv,"-ms-radial-gradient":Yv,"-o-radial-gradient":Yv,"-webkit-radial-gradient":Yv,"-webkit-gradient":nle},ale={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(n,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e.filter(function(r){return rb(r)&&ole(r)}).map(function(r){return G_.parse(n,r)})}},lle={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(n,e){return e.map(function(t){if(Pn(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},Ale={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(n,e){return ka(e).map(function(t){return t.filter(tr)}).map(QJ)}},cle={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(n,e){return ka(e).map(function(t){return t.filter(Pn).map(function(r){return r.value}).join(" ")}).map(ule)}},ule=function(n){switch(n){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;case"repeat":default:return 0}},Zd;(function(n){n.AUTO="auto",n.CONTAIN="contain",n.COVER="cover"})(Zd||(Zd={}));var fle={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(n,e){return ka(e).map(function(t){return t.filter(dle)})}},dle=function(n){return Pn(n)||tr(n)},ob=function(n){return{name:"border-"+n+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},hle=ob("top"),ple=ob("right"),gle=ob("bottom"),mle=ob("left"),ab=function(n){return{name:"border-radius-"+n,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return QJ(t.filter(tr))}}},vle=ab("top-left"),yle=ab("top-right"),Ble=ab("bottom-right"),wle=ab("bottom-left"),lb=function(n){return{name:"border-"+n+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},Cle=lb("top"),ble=lb("right"),xle=lb("bottom"),Ile=lb("left"),Ab=function(n){return{name:"border-"+n+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return v0(t)?t.number:0}}},Fle=Ab("top"),Ele=Ab("right"),Ule=Ab("bottom"),Sle=Ab("left"),_le={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Qle={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(n,e){switch(e){case"rtl":return 1;case"ltr":default:return 0}}},Rle={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(n,e){return e.filter(Pn).reduce(function(t,r){return t|Mle(r.value)},0)}},Mle=function(n){switch(n){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},Tle={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Nle={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(n,e){return e.type===20&&e.value==="normal"?0:e.type===17||e.type===15?e.number:0}},Qw;(function(n){n.NORMAL="normal",n.STRICT="strict"})(Qw||(Qw={}));var Dle={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"strict":return Qw.STRICT;case"normal":default:return Qw.NORMAL}}},kle={name:"line-height",initialValue:"normal",prefix:!1,type:4},oD=function(n,e){return Pn(n)&&n.value==="normal"?1.2*e:n.type===17?e*n.number:tr(n)?un(n,e):e},Vle={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(n,e){return e.type===20&&e.value==="none"?null:G_.parse(n,e)}},Lle={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(n,e){switch(e){case"inside":return 0;case"outside":default:return 1}}},Ple={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;case"none":default:return-1}}},cb=function(n){return{name:"margin-"+n,initialValue:"0",prefix:!1,type:4}},Wle=cb("top"),Ole=cb("right"),Gle=cb("bottom"),Zle=cb("left"),Jle={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(n,e){return e.filter(Pn).map(function(t){switch(t.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;case"visible":default:return 0}})}},Hle={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"break-word":return"break-word";case"normal":default:return"normal"}}},ub=function(n){return{name:"padding-"+n,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},zle=ub("top"),Yle=ub("right"),Xle=ub("bottom"),Kle=ub("left"),jle={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(n,e){switch(e){case"right":return 2;case"center":case"justify":return 1;case"left":default:return 0}}},$le={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(n,e){switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},qle={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.length===1&&ZE(e[0],"none")?[]:ka(e).map(function(t){for(var r={color:Dm.TRANSPARENT,offsetX:Nr,offsetY:Nr,blur:Nr},i=0,s=0;s"u")throw new Error('Attempting to parse an unsupported transform function "'+e.name+'"');return t(e.values)}return null}},nAe=function(n){var e=n.filter(function(t){return t.type===17}).map(function(t){return t.number});return e.length===6?e:null},rAe=function(n){var e=n.filter(function(l){return l.type===17}).map(function(l){return l.number}),t=e[0],r=e[1];e[2],e[3];var i=e[4],s=e[5];e[6],e[7],e[8],e[9],e[10],e[11];var o=e[12],a=e[13];return e[14],e[15],e.length===16?[t,r,i,s,o,a]:null},iAe={matrix:nAe,matrix3d:rAe},aD={type:16,number:50,flags:m0},sAe=[aD,aD],oAe={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(n,e){var t=e.filter(tr);return t.length!==2?sAe:[t[0],t[1]]}},aAe={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"hidden":return 1;case"collapse":return 2;case"visible":default:return 0}}},Hg;(function(n){n.NORMAL="normal",n.BREAK_ALL="break-all",n.KEEP_ALL="keep-all"})(Hg||(Hg={}));var lAe={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"break-all":return Hg.BREAK_ALL;case"keep-all":return Hg.KEEP_ALL;case"normal":default:return Hg.NORMAL}}},AAe={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(n,e){if(e.type===20)return{auto:!0,order:0};if(nb(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},zJ={name:"time",parse:function(n,e){if(e.type===15)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")}},cAe={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(n,e){return nb(e)?e.number:1}},uAe={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},fAe={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(n,e){return e.filter(Pn).map(function(t){switch(t.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(t){return t!==0})}},dAe={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(n,e){var t=[],r=[];return e.forEach(function(i){switch(i.type){case 20:case 0:t.push(i.value);break;case 17:t.push(i.number.toString());break;case 4:r.push(t.join(" ")),t.length=0;break}}),t.length&&r.push(t.join(" ")),r.map(function(i){return i.indexOf(" ")===-1?i:"'"+i+"'"})}},hAe={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},pAe={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(n,e){if(nb(e))return e.number;if(Pn(e))switch(e.value){case"bold":return 700;case"normal":default:return 400}return 400}},gAe={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.filter(Pn).map(function(t){return t.value})}},mAe={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"oblique":return"oblique";case"italic":return"italic";case"normal":default:return"normal"}}},dr=function(n,e){return(n&e)!==0},vAe={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(n,e){return e.filter(v0).map(function(t){return zJ.parse(n,t)})}},yAe={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.length===1&&ZE(e[0],"none")?[]:ka(e).map(function(t){for(var r={color:255,offsetX:Nr,offsetY:Nr,blur:Nr,spread:Nr,inset:!1},i=0,s=0;s1?1:0],this.overflowWrap=ze(e,Hle,t.overflowWrap),this.paddingTop=ze(e,zle,t.paddingTop),this.paddingRight=ze(e,Yle,t.paddingRight),this.paddingBottom=ze(e,Xle,t.paddingBottom),this.paddingLeft=ze(e,Kle,t.paddingLeft),this.paintOrder=ze(e,BAe,t.paintOrder),this.position=ze(e,$le,t.position),this.textAlign=ze(e,jle,t.textAlign),this.textDecorationColor=ze(e,uAe,(r=t.textDecorationColor)!==null&&r!==void 0?r:t.color),this.textDecorationLine=ze(e,fAe,(i=t.textDecorationLine)!==null&&i!==void 0?i:t.textDecoration),this.textShadow=ze(e,qle,t.textShadow),this.textTransform=ze(e,eAe,t.textTransform),this.transform=ze(e,tAe,t.transform),this.transformOrigin=ze(e,oAe,t.transformOrigin),this.visibility=ze(e,aAe,t.visibility),this.webkitTextStrokeColor=ze(e,wAe,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=ze(e,CAe,t.webkitTextStrokeWidth),this.wordBreak=ze(e,lAe,t.wordBreak),this.zIndex=ze(e,AAe,t.zIndex)}return n.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&this.visibility===0},n.prototype.isTransparent=function(){return Gd(this.backgroundColor)},n.prototype.isTransformed=function(){return this.transform!==null},n.prototype.isPositioned=function(){return this.position!==0},n.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},n.prototype.isFloating=function(){return this.float!==0},n.prototype.isInlineLevel=function(){return dr(this.display,4)||dr(this.display,33554432)||dr(this.display,268435456)||dr(this.display,536870912)||dr(this.display,67108864)||dr(this.display,134217728)},n}(),ze=function(n,e,t){var r=new SJ,i=t!==null&&typeof t<"u"?t.toString():e.initialValue;r.write(i);var s=new _J(r.read());switch(e.type){case 2:var o=s.parseComponentValue();return e.parse(n,Pn(o)?o.value:e.initialValue);case 0:return e.parse(n,s.parseComponentValue());case 1:return e.parse(n,s.parseComponentValues());case 4:return s.parseComponentValue();case 3:switch(e.format){case"angle":return ib.parse(n,s.parseComponentValue());case"color":return GA.parse(n,s.parseComponentValue());case"image":return G_.parse(n,s.parseComponentValue());case"length":var a=s.parseComponentValue();return nc(a)?a:Nr;case"length-percentage":var l=s.parseComponentValue();return tr(l)?l:Nr;case"time":return zJ.parse(n,s.parseComponentValue())}break}},xAe="data-html2canvas-debug",IAe=function(n){var e=n.getAttribute(xAe);switch(e){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},lD=function(n,e){var t=IAe(n);return t===1||e===t},Va=function(){function n(e,t){if(this.context=e,this.textNodes=[],this.elements=[],this.flags=0,lD(t,3))debugger;this.styles=new bAe(e,window.getComputedStyle(t,null)),Ice(t)&&(this.styles.animationDuration.some(function(r){return r>0})&&(t.style.animationDuration="0s"),this.styles.transform!==null&&(t.style.transform="none")),this.bounds=P_(this.context,t),lD(t,4)&&(this.flags|=16)}return n}(),FAe="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",AD="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yg=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Xv=0;Xv>4,c[i++]=(o&15)<<4|a>>2,c[i++]=(a&3)<<6|l&63;return A},UAe=function(n){for(var e=n.length,t=[],r=0;r>ou,QAe=1<>ou,MAe=YJ+RAe,TAe=MAe,NAe=32,DAe=TAe+NAe,kAe=65536>>Z_,VAe=1<<_Ae,LAe=VAe-1,cD=function(n,e,t){return n.slice?n.slice(e,t):new Uint16Array(Array.prototype.slice.call(n,e,t))},PAe=function(n,e,t){return n.slice?n.slice(e,t):new Uint32Array(Array.prototype.slice.call(n,e,t))},WAe=function(n,e){var t=EAe(n),r=Array.isArray(t)?SAe(t):new Uint32Array(t),i=Array.isArray(t)?UAe(t):new Uint16Array(t),s=24,o=cD(i,s/2,r[4]/2),a=r[5]===2?cD(i,(s+r[4])/2):PAe(r,Math.ceil((s+r[4])/4));return new OAe(r[0],r[1],r[2],r[3],o,a)},OAe=function(){function n(e,t,r,i,s,o){this.initialValue=e,this.errorValue=t,this.highStart=r,this.highValueIndex=i,this.index=s,this.data=o}return n.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>ou],t=(t<>ou)],t=(t<>Z_),t=this.index[t],t+=e>>ou&LAe,t=this.index[t],t=(t<"u"?[]:new Uint8Array(256);for(var Kv=0;Kv=55296&&i<=56319&&t>10)+55296,o%1024+56320)),(i+1===t||r.length>16384)&&(s+=String.fromCharCode.apply(String,r),r.length=0)}return s},YAe=WAe(FAe),ks="×",YI="÷",XAe=function(n){return YAe.get(n)},KAe=function(n,e,t){var r=t-2,i=e[r],s=e[t-1],o=e[t];if(s===GI&&o===ZI)return ks;if(s===GI||s===ZI||s===fD||o===GI||o===ZI||o===fD)return YI;if(s===hD&&[hD,JI,pD,gD].indexOf(o)!==-1||(s===pD||s===JI)&&(o===JI||o===HI)||(s===gD||s===HI)&&o===HI||o===mD||o===dD||o===JAe||s===ZAe)return ks;if(s===mD&&o===vD){for(;i===dD;)i=e[--r];if(i===vD)return ks}if(s===zI&&o===zI){for(var a=0;i===zI;)a++,i=e[--r];if(a%2===0)return ks}return YI},jAe=function(n){var e=HAe(n),t=e.length,r=0,i=0,s=e.map(XAe);return{next:function(){if(r>=t)return{done:!0,value:null};for(var o=ks;ro.x||c.y>o.y;return o=c,A===0?!0:u});return n.body.removeChild(e),a},tce=function(){return typeof new Image().crossOrigin<"u"},nce=function(){return typeof new XMLHttpRequest().responseType=="string"},rce=function(n){var e=new Image,t=n.createElement("canvas"),r=t.getContext("2d");if(!r)return!1;e.src="data:image/svg+xml,";try{r.drawImage(e,0,0),t.toDataURL()}catch{return!1}return!0},yD=function(n){return n[0]===0&&n[1]===255&&n[2]===0&&n[3]===255},ice=function(n){var e=n.createElement("canvas"),t=100;e.width=t,e.height=t;var r=e.getContext("2d");if(!r)return Promise.reject(!1);r.fillStyle="rgb(0, 255, 0)",r.fillRect(0,0,t,t);var i=new Image,s=e.toDataURL();i.src=s;var o=JE(t,t,0,0,i);return r.fillStyle="red",r.fillRect(0,0,t,t),BD(o).then(function(a){r.drawImage(a,0,0);var l=r.getImageData(0,0,t,t).data;r.fillStyle="red",r.fillRect(0,0,t,t);var A=n.createElement("div");return A.style.backgroundImage="url("+s+")",A.style.height=t+"px",yD(l)?BD(JE(t,t,0,0,A)):Promise.reject(!1)}).then(function(a){return r.drawImage(a,0,0),yD(r.getImageData(0,0,t,t).data)}).catch(function(){return!1})},JE=function(n,e,t,r,i){var s="http://www.w3.org/2000/svg",o=document.createElementNS(s,"svg"),a=document.createElementNS(s,"foreignObject");return o.setAttributeNS(null,"width",n.toString()),o.setAttributeNS(null,"height",e.toString()),a.setAttributeNS(null,"width","100%"),a.setAttributeNS(null,"height","100%"),a.setAttributeNS(null,"x",t.toString()),a.setAttributeNS(null,"y",r.toString()),a.setAttributeNS(null,"externalResourcesRequired","true"),o.appendChild(a),a.appendChild(i),o},BD=function(n){return new Promise(function(e,t){var r=new Image;r.onload=function(){return e(r)},r.onerror=t,r.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(n))})},Ki={get SUPPORT_RANGE_BOUNDS(){var n=qAe(document);return Object.defineProperty(Ki,"SUPPORT_RANGE_BOUNDS",{value:n}),n},get SUPPORT_WORD_BREAKING(){var n=Ki.SUPPORT_RANGE_BOUNDS&&ece(document);return Object.defineProperty(Ki,"SUPPORT_WORD_BREAKING",{value:n}),n},get SUPPORT_SVG_DRAWING(){var n=rce(document);return Object.defineProperty(Ki,"SUPPORT_SVG_DRAWING",{value:n}),n},get SUPPORT_FOREIGNOBJECT_DRAWING(){var n=typeof Array.from=="function"&&typeof window.fetch=="function"?ice(document):Promise.resolve(!1);return Object.defineProperty(Ki,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:n}),n},get SUPPORT_CORS_IMAGES(){var n=tce();return Object.defineProperty(Ki,"SUPPORT_CORS_IMAGES",{value:n}),n},get SUPPORT_RESPONSE_TYPE(){var n=nce();return Object.defineProperty(Ki,"SUPPORT_RESPONSE_TYPE",{value:n}),n},get SUPPORT_CORS_XHR(){var n="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Ki,"SUPPORT_CORS_XHR",{value:n}),n},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var n=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(Ki,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:n}),n}},zg=function(){function n(e,t){this.text=e,this.bounds=t}return n}(),sce=function(n,e,t,r){var i=lce(e,t),s=[],o=0;return i.forEach(function(a){if(t.textDecorationLine.length||a.trim().length>0)if(Ki.SUPPORT_RANGE_BOUNDS){var l=wD(r,o,a.length).getClientRects();if(l.length>1){var A=J_(a),c=0;A.forEach(function(f){s.push(new zg(f,yu.fromDOMRectList(n,wD(r,c+o,f.length).getClientRects()))),c+=f.length})}else s.push(new zg(a,yu.fromDOMRectList(n,l)))}else{var u=r.splitText(a.length);s.push(new zg(a,oce(n,r))),r=u}else Ki.SUPPORT_RANGE_BOUNDS||(r=r.splitText(a.length));o+=a.length}),s},oce=function(n,e){var t=e.ownerDocument;if(t){var r=t.createElement("html2canvaswrapper");r.appendChild(e.cloneNode(!0));var i=e.parentNode;if(i){i.replaceChild(r,e);var s=P_(n,r);return r.firstChild&&i.replaceChild(r.firstChild,r),s}}return yu.EMPTY},wD=function(n,e,t){var r=n.ownerDocument;if(!r)throw new Error("Node has no owner document");var i=r.createRange();return i.setStart(n,e),i.setEnd(n,e+t),i},J_=function(n){if(Ki.SUPPORT_NATIVE_TEXT_SEGMENTATION){var e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(n)).map(function(t){return t.segment})}return $Ae(n)},ace=function(n,e){if(Ki.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(n)).map(function(r){return r.segment})}return cce(n,e)},lce=function(n,e){return e.letterSpacing!==0?J_(n):ace(n,e)},Ace=[32,160,4961,65792,65793,4153,4241],cce=function(n,e){for(var t=Ooe(n,{lineBreak:e.lineBreak,wordBreak:e.overflowWrap==="break-word"?"break-word":e.wordBreak}),r=[],i,s=function(){if(i.value){var o=i.value.slice(),a=tb(o),l="";a.forEach(function(A){Ace.indexOf(A)===-1?l+=On(A):(l.length&&r.push(l),r.push(On(A)),l="")}),l.length&&r.push(l)}};!(i=t.next()).done;)s();return r},uce=function(){function n(e,t,r){this.text=fce(t.data,r.textTransform),this.textBounds=sce(e,this.text,r,t)}return n}(),fce=function(n,e){switch(e){case 1:return n.toLowerCase();case 3:return n.replace(dce,hce);case 2:return n.toUpperCase();default:return n}},dce=/(^|\s|:|-|\(|\))([a-z])/g,hce=function(n,e,t){return n.length>0?e+t.toUpperCase():n},XJ=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i.src=r.currentSrc||r.src,i.intrinsicWidth=r.naturalWidth,i.intrinsicHeight=r.naturalHeight,i.context.cache.addImage(i.src),i}return e}(Va),KJ=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i.canvas=r,i.intrinsicWidth=r.width,i.intrinsicHeight=r.height,i}return e}(Va),jJ=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this,s=new XMLSerializer,o=P_(t,r);return r.setAttribute("width",o.width+"px"),r.setAttribute("height",o.height+"px"),i.svg="data:image/svg+xml,"+encodeURIComponent(s.serializeToString(r)),i.intrinsicWidth=r.width.baseVal.value,i.intrinsicHeight=r.height.baseVal.value,i.context.cache.addImage(i.svg),i}return e}(Va),$J=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i.value=r.value,i}return e}(Va),HE=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i.start=r.start,i.reversed=typeof r.reversed=="boolean"&&r.reversed===!0,i}return e}(Va),pce=[{type:15,flags:0,unit:"px",number:3}],gce=[{type:16,flags:0,number:50}],mce=function(n){return n.width>n.height?new yu(n.left+(n.width-n.height)/2,n.top,n.height,n.height):n.width0)t.textNodes.push(new uce(n,i,t.styles));else if(rH(i))if(Tce(i)&&i.assignedNodes)i.assignedNodes().forEach(function(a){return cB(n,a,t,r)});else{var o=nH(n,i);o.styles.isVisible()&&(Cce(i,o,r)?o.flags|=4:bce(o.styles)&&(o.flags|=2),Bce.indexOf(i.tagName)!==-1&&(o.flags|=8),t.elements.push(o),i.slot,i.shadowRoot?cB(n,i.shadowRoot,o,r):!sH(i)&&!iH(i)&&!oH(i)&&cB(n,i,o,r))}},nH=function(n,e){return Rce(e)?new XJ(n,e):Qce(e)?new KJ(n,e):iH(e)?new jJ(n,e):Ece(e)?new $J(n,e):Uce(e)?new HE(n,e):Sce(e)?new H_(n,e):oH(e)?new qJ(n,e):sH(e)?new eH(n,e):Mce(e)?new tH(n,e):new Va(n,e)},wce=function(n,e){var t=nH(n,e);return t.flags|=4,cB(n,e,t,t),t},Cce=function(n,e,t){return e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||_ce(n)&&t.styles.isTransparent()},bce=function(n){return n.isPositioned()||n.isFloating()},xce=function(n){return n.nodeType===Node.TEXT_NODE},rH=function(n){return n.nodeType===Node.ELEMENT_NODE},Ice=function(n){return rH(n)&&typeof n.style<"u"&&!Fce(n)},Fce=function(n){return typeof n.className=="object"},Ece=function(n){return n.tagName==="LI"},Uce=function(n){return n.tagName==="OL"},Sce=function(n){return n.tagName==="INPUT"},iH=function(n){return n.tagName==="svg"},_ce=function(n){return n.tagName==="BODY"},Qce=function(n){return n.tagName==="CANVAS"},Rce=function(n){return n.tagName==="IMG"},Mce=function(n){return n.tagName==="IFRAME"},sH=function(n){return n.tagName==="TEXTAREA"},oH=function(n){return n.tagName==="SELECT"},Tce=function(n){return n.tagName==="SLOT"},bD={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},xD={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},Nce={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},Dce={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},gf=function(n,e,t,r,i,s){return nt?z_(n,i,s.length>0):r.integers.reduce(function(o,a,l){for(;n>=a;)n-=a,o+=r.values[l];return o},"")+s},aH=function(n,e,t,r){var i="";do t||n--,i=r(n)+i,n/=e;while(n*e>=e);return i},Wn=function(n,e,t,r,i){var s=t-e+1;return(n<0?"-":"")+(aH(Math.abs(n),s,r,function(o){return On(Math.floor(o%s)+e)})+i)},xc=function(n,e,t){t===void 0&&(t=". ");var r=e.length;return aH(Math.abs(n),r,!1,function(i){return e[Math.floor(i%r)]})+t},Nf=1,cA=2,uA=4,Bg=8,Ka=function(n,e,t,r,i,s){if(n<-9999||n>9999)return z_(n,4,i.length>0);var o=Math.abs(n),a=i;if(o===0)return e[0]+a;for(var l=0;o>0&&l<=4;l++){var A=o%10;A===0&&dr(s,Nf)&&a!==""?a=e[A]+a:A>1||A===1&&l===0||A===1&&l===1&&dr(s,cA)||A===1&&l===1&&dr(s,uA)&&n>100||A===1&&l>1&&dr(s,Bg)?a=e[A]+(l>0?t[l-1]:"")+a:A===1&&l>0&&(a=t[l-1]+a),o=Math.floor(o/10)}return(n<0?r:"")+a},ID="十百千萬",FD="拾佰仟萬",ED="マイナス",XI="마이너스",z_=function(n,e,t){var r=t?". ":"",i=t?"、":"",s=t?", ":"",o=t?" ":"";switch(e){case 0:return"•"+o;case 1:return"◦"+o;case 2:return"◾"+o;case 5:var a=Wn(n,48,57,!0,r);return a.length<4?"0"+a:a;case 4:return xc(n,"〇一二三四五六七八九",i);case 6:return gf(n,1,3999,bD,3,r).toLowerCase();case 7:return gf(n,1,3999,bD,3,r);case 8:return Wn(n,945,969,!1,r);case 9:return Wn(n,97,122,!1,r);case 10:return Wn(n,65,90,!1,r);case 11:return Wn(n,1632,1641,!0,r);case 12:case 49:return gf(n,1,9999,xD,3,r);case 35:return gf(n,1,9999,xD,3,r).toLowerCase();case 13:return Wn(n,2534,2543,!0,r);case 14:case 30:return Wn(n,6112,6121,!0,r);case 15:return xc(n,"子丑寅卯辰巳午未申酉戌亥",i);case 16:return xc(n,"甲乙丙丁戊己庚辛壬癸",i);case 17:case 48:return Ka(n,"零一二三四五六七八九",ID,"負",i,cA|uA|Bg);case 47:return Ka(n,"零壹貳參肆伍陸柒捌玖",FD,"負",i,Nf|cA|uA|Bg);case 42:return Ka(n,"零一二三四五六七八九",ID,"负",i,cA|uA|Bg);case 41:return Ka(n,"零壹贰叁肆伍陆柒捌玖",FD,"负",i,Nf|cA|uA|Bg);case 26:return Ka(n,"〇一二三四五六七八九","十百千万",ED,i,0);case 25:return Ka(n,"零壱弐参四伍六七八九","拾百千万",ED,i,Nf|cA|uA);case 31:return Ka(n,"영일이삼사오육칠팔구","십백천만",XI,s,Nf|cA|uA);case 33:return Ka(n,"零一二三四五六七八九","十百千萬",XI,s,0);case 32:return Ka(n,"零壹貳參四五六七八九","拾百千",XI,s,Nf|cA|uA);case 18:return Wn(n,2406,2415,!0,r);case 20:return gf(n,1,19999,Dce,3,r);case 21:return Wn(n,2790,2799,!0,r);case 22:return Wn(n,2662,2671,!0,r);case 22:return gf(n,1,10999,Nce,3,r);case 23:return xc(n,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return xc(n,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return Wn(n,3302,3311,!0,r);case 28:return xc(n,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",i);case 29:return xc(n,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",i);case 34:return Wn(n,3792,3801,!0,r);case 37:return Wn(n,6160,6169,!0,r);case 38:return Wn(n,4160,4169,!0,r);case 39:return Wn(n,2918,2927,!0,r);case 40:return Wn(n,1776,1785,!0,r);case 43:return Wn(n,3046,3055,!0,r);case 44:return Wn(n,3174,3183,!0,r);case 45:return Wn(n,3664,3673,!0,r);case 46:return Wn(n,3872,3881,!0,r);case 3:default:return Wn(n,48,57,!0,r)}},UD;(function(n){n[n.BEFORE=0]="BEFORE",n[n.AFTER=1]="AFTER"})(UD||(UD={}));var kce=function(){function n(){}return n.getOrigin=function(e){var t=n._link;return t?(t.href=e,t.href=t.href,t.protocol+t.hostname+t.port):"about:blank"},n.isSameOrigin=function(e){return n.getOrigin(e)===n._origin},n.setContext=function(e){n._link=e.document.createElement("a"),n._origin=n.getOrigin(e.location.href)},n._origin="about:blank",n}(),Pe=function(){function n(e,t){this.type=0,this.x=e,this.y=t}return n.prototype.add=function(e,t){return new n(this.x+e,this.y+t)},n}(),mf=function(n,e,t){return new Pe(n.x+(e.x-n.x)*t,n.y+(e.y-n.y)*t)},jv=function(){function n(e,t,r,i){this.type=1,this.start=e,this.startControl=t,this.endControl=r,this.end=i}return n.prototype.subdivide=function(e,t){var r=mf(this.start,this.startControl,e),i=mf(this.startControl,this.endControl,e),s=mf(this.endControl,this.end,e),o=mf(r,i,e),a=mf(i,s,e),l=mf(o,a,e);return t?new n(this.start,r,o,l):new n(l,a,s,this.end)},n.prototype.add=function(e,t){return new n(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))},n.prototype.reverse=function(){return new n(this.end,this.endControl,this.startControl,this.start)},n}(),Ws=function(n){return n.type===1},Vce=function(){function n(e){var t=e.styles,r=e.bounds,i=vg(t.borderTopLeftRadius,r.width,r.height),s=i[0],o=i[1],a=vg(t.borderTopRightRadius,r.width,r.height),l=a[0],A=a[1],c=vg(t.borderBottomRightRadius,r.width,r.height),u=c[0],f=c[1],d=vg(t.borderBottomLeftRadius,r.width,r.height),h=d[0],p=d[1],m=[];m.push((s+l)/r.width),m.push((h+u)/r.width),m.push((o+p)/r.height),m.push((A+f)/r.height);var g=Math.max.apply(Math,m);g>1&&(s/=g,o/=g,l/=g,A/=g,u/=g,f/=g,h/=g,p/=g);var v=r.width-l,y=r.height-f,w=r.width-u,C=r.height-p,b=t.borderTopWidth,E=t.borderRightWidth,x=t.borderBottomWidth,S=t.borderLeftWidth,M=un(t.paddingTop,e.bounds.width),Z=un(t.paddingRight,e.bounds.width),K=un(t.paddingBottom,e.bounds.width),_=un(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=s>0||o>0?yn(r.left+S/3,r.top+b/3,s-S/3,o-b/3,Kt.TOP_LEFT):new Pe(r.left+S/3,r.top+b/3),this.topRightBorderDoubleOuterBox=s>0||o>0?yn(r.left+v,r.top+b/3,l-E/3,A-b/3,Kt.TOP_RIGHT):new Pe(r.left+r.width-E/3,r.top+b/3),this.bottomRightBorderDoubleOuterBox=u>0||f>0?yn(r.left+w,r.top+y,u-E/3,f-x/3,Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-E/3,r.top+r.height-x/3),this.bottomLeftBorderDoubleOuterBox=h>0||p>0?yn(r.left+S/3,r.top+C,h-S/3,p-x/3,Kt.BOTTOM_LEFT):new Pe(r.left+S/3,r.top+r.height-x/3),this.topLeftBorderDoubleInnerBox=s>0||o>0?yn(r.left+S*2/3,r.top+b*2/3,s-S*2/3,o-b*2/3,Kt.TOP_LEFT):new Pe(r.left+S*2/3,r.top+b*2/3),this.topRightBorderDoubleInnerBox=s>0||o>0?yn(r.left+v,r.top+b*2/3,l-E*2/3,A-b*2/3,Kt.TOP_RIGHT):new Pe(r.left+r.width-E*2/3,r.top+b*2/3),this.bottomRightBorderDoubleInnerBox=u>0||f>0?yn(r.left+w,r.top+y,u-E*2/3,f-x*2/3,Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-E*2/3,r.top+r.height-x*2/3),this.bottomLeftBorderDoubleInnerBox=h>0||p>0?yn(r.left+S*2/3,r.top+C,h-S*2/3,p-x*2/3,Kt.BOTTOM_LEFT):new Pe(r.left+S*2/3,r.top+r.height-x*2/3),this.topLeftBorderStroke=s>0||o>0?yn(r.left+S/2,r.top+b/2,s-S/2,o-b/2,Kt.TOP_LEFT):new Pe(r.left+S/2,r.top+b/2),this.topRightBorderStroke=s>0||o>0?yn(r.left+v,r.top+b/2,l-E/2,A-b/2,Kt.TOP_RIGHT):new Pe(r.left+r.width-E/2,r.top+b/2),this.bottomRightBorderStroke=u>0||f>0?yn(r.left+w,r.top+y,u-E/2,f-x/2,Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-E/2,r.top+r.height-x/2),this.bottomLeftBorderStroke=h>0||p>0?yn(r.left+S/2,r.top+C,h-S/2,p-x/2,Kt.BOTTOM_LEFT):new Pe(r.left+S/2,r.top+r.height-x/2),this.topLeftBorderBox=s>0||o>0?yn(r.left,r.top,s,o,Kt.TOP_LEFT):new Pe(r.left,r.top),this.topRightBorderBox=l>0||A>0?yn(r.left+v,r.top,l,A,Kt.TOP_RIGHT):new Pe(r.left+r.width,r.top),this.bottomRightBorderBox=u>0||f>0?yn(r.left+w,r.top+y,u,f,Kt.BOTTOM_RIGHT):new Pe(r.left+r.width,r.top+r.height),this.bottomLeftBorderBox=h>0||p>0?yn(r.left,r.top+C,h,p,Kt.BOTTOM_LEFT):new Pe(r.left,r.top+r.height),this.topLeftPaddingBox=s>0||o>0?yn(r.left+S,r.top+b,Math.max(0,s-S),Math.max(0,o-b),Kt.TOP_LEFT):new Pe(r.left+S,r.top+b),this.topRightPaddingBox=l>0||A>0?yn(r.left+Math.min(v,r.width-E),r.top+b,v>r.width+E?0:Math.max(0,l-E),Math.max(0,A-b),Kt.TOP_RIGHT):new Pe(r.left+r.width-E,r.top+b),this.bottomRightPaddingBox=u>0||f>0?yn(r.left+Math.min(w,r.width-S),r.top+Math.min(y,r.height-x),Math.max(0,u-E),Math.max(0,f-x),Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-E,r.top+r.height-x),this.bottomLeftPaddingBox=h>0||p>0?yn(r.left+S,r.top+Math.min(C,r.height-x),Math.max(0,h-S),Math.max(0,p-x),Kt.BOTTOM_LEFT):new Pe(r.left+S,r.top+r.height-x),this.topLeftContentBox=s>0||o>0?yn(r.left+S+_,r.top+b+M,Math.max(0,s-(S+_)),Math.max(0,o-(b+M)),Kt.TOP_LEFT):new Pe(r.left+S+_,r.top+b+M),this.topRightContentBox=l>0||A>0?yn(r.left+Math.min(v,r.width+S+_),r.top+b+M,v>r.width+S+_?0:l-S+_,A-(b+M),Kt.TOP_RIGHT):new Pe(r.left+r.width-(E+Z),r.top+b+M),this.bottomRightContentBox=u>0||f>0?yn(r.left+Math.min(w,r.width-(S+_)),r.top+Math.min(y,r.height+b+M),Math.max(0,u-(E+Z)),f-(x+K),Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-(E+Z),r.top+r.height-(x+K)),this.bottomLeftContentBox=h>0||p>0?yn(r.left+S+_,r.top+C,Math.max(0,h-(S+_)),p-(x+K),Kt.BOTTOM_LEFT):new Pe(r.left+S+_,r.top+r.height-(x+K))}return n}(),Kt;(function(n){n[n.TOP_LEFT=0]="TOP_LEFT",n[n.TOP_RIGHT=1]="TOP_RIGHT",n[n.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",n[n.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(Kt||(Kt={}));var yn=function(n,e,t,r,i){var s=4*((Math.sqrt(2)-1)/3),o=t*s,a=r*s,l=n+t,A=e+r;switch(i){case Kt.TOP_LEFT:return new jv(new Pe(n,A),new Pe(n,A-a),new Pe(l-o,e),new Pe(l,e));case Kt.TOP_RIGHT:return new jv(new Pe(n,e),new Pe(n+o,e),new Pe(l,A-a),new Pe(l,A));case Kt.BOTTOM_RIGHT:return new jv(new Pe(l,e),new Pe(l,e+a),new Pe(n+o,A),new Pe(n,A));case Kt.BOTTOM_LEFT:default:return new jv(new Pe(l,A),new Pe(l-o,A),new Pe(n,e+a),new Pe(n,e))}},Tw=function(n){return[n.topLeftBorderBox,n.topRightBorderBox,n.bottomRightBorderBox,n.bottomLeftBorderBox]},Lce=function(n){return[n.topLeftContentBox,n.topRightContentBox,n.bottomRightContentBox,n.bottomLeftContentBox]},Nw=function(n){return[n.topLeftPaddingBox,n.topRightPaddingBox,n.bottomRightPaddingBox,n.bottomLeftPaddingBox]},Pce=function(){function n(e,t,r){this.offsetX=e,this.offsetY=t,this.matrix=r,this.type=0,this.target=6}return n}(),$v=function(){function n(e,t){this.path=e,this.target=t,this.type=1}return n}(),Wce=function(){function n(e){this.opacity=e,this.type=2,this.target=6}return n}(),Oce=function(n){return n.type===0},lH=function(n){return n.type===1},Gce=function(n){return n.type===2},SD=function(n,e){return n.length===e.length?n.some(function(t,r){return t===e[r]}):!1},Zce=function(n,e,t,r,i){return n.map(function(s,o){switch(o){case 0:return s.add(e,t);case 1:return s.add(e+r,t);case 2:return s.add(e+r,t+i);case 3:return s.add(e,t+i)}return s})},AH=function(){function n(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return n}(),cH=function(){function n(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new Vce(this.container),this.container.styles.opacity<1&&this.effects.push(new Wce(this.container.styles.opacity)),this.container.styles.transform!==null){var r=this.container.bounds.left+this.container.styles.transformOrigin[0].number,i=this.container.bounds.top+this.container.styles.transformOrigin[1].number,s=this.container.styles.transform;this.effects.push(new Pce(r,i,s))}if(this.container.styles.overflowX!==0){var o=Tw(this.curves),a=Nw(this.curves);SD(o,a)?this.effects.push(new $v(o,6)):(this.effects.push(new $v(o,2)),this.effects.push(new $v(a,4)))}}return n.prototype.getEffects=function(e){for(var t=[2,3].indexOf(this.container.styles.position)===-1,r=this.parent,i=this.effects.slice(0);r;){var s=r.effects.filter(function(l){return!lH(l)});if(t||r.container.styles.position!==0||!r.parent){if(i.unshift.apply(i,s),t=[2,3].indexOf(r.container.styles.position)===-1,r.container.styles.overflowX!==0){var o=Tw(r.curves),a=Nw(r.curves);SD(o,a)||i.unshift(new $v(a,6))}}else i.unshift.apply(i,s);r=r.parent}return i.filter(function(l){return dr(l.target,e)})},n}(),zE=function(n,e,t,r){n.container.elements.forEach(function(i){var s=dr(i.flags,4),o=dr(i.flags,2),a=new cH(i,n);dr(i.styles.display,2048)&&r.push(a);var l=dr(i.flags,8)?[]:r;if(s||o){var A=s||i.styles.isPositioned()?t:e,c=new AH(a);if(i.styles.isPositioned()||i.styles.opacity<1||i.styles.isTransformed()){var u=i.styles.zIndex.order;if(u<0){var f=0;A.negativeZIndex.some(function(h,p){return u>h.element.container.styles.zIndex.order?(f=p,!1):f>0}),A.negativeZIndex.splice(f,0,c)}else if(u>0){var d=0;A.positiveZIndex.some(function(h,p){return u>=h.element.container.styles.zIndex.order?(d=p+1,!1):d>0}),A.positiveZIndex.splice(d,0,c)}else A.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else i.styles.isFloating()?A.nonPositionedFloats.push(c):A.nonPositionedInlineLevel.push(c);zE(a,c,s?c:t,l)}else i.styles.isInlineLevel()?e.inlineLevel.push(a):e.nonInlineLevel.push(a),zE(a,e,t,l);dr(i.flags,8)&&uH(i,l)})},uH=function(n,e){for(var t=n instanceof HE?n.start:1,r=n instanceof HE?n.reversed:!1,i=0;i"u"?n[0]:t},$ce=function(n,e,t,r,i){var s=e[0],o=e[1],a=t[0],l=t[1];switch(n){case 2:return[new Pe(Math.round(r.left),Math.round(r.top+o)),new Pe(Math.round(r.left+r.width),Math.round(r.top+o)),new Pe(Math.round(r.left+r.width),Math.round(l+r.top+o)),new Pe(Math.round(r.left),Math.round(l+r.top+o))];case 3:return[new Pe(Math.round(r.left+s),Math.round(r.top)),new Pe(Math.round(r.left+s+a),Math.round(r.top)),new Pe(Math.round(r.left+s+a),Math.round(r.height+r.top)),new Pe(Math.round(r.left+s),Math.round(r.height+r.top))];case 1:return[new Pe(Math.round(r.left+s),Math.round(r.top+o)),new Pe(Math.round(r.left+s+a),Math.round(r.top+o)),new Pe(Math.round(r.left+s+a),Math.round(r.top+o+l)),new Pe(Math.round(r.left+s),Math.round(r.top+o+l))];default:return[new Pe(Math.round(i.left),Math.round(i.top)),new Pe(Math.round(i.left+i.width),Math.round(i.top)),new Pe(Math.round(i.left+i.width),Math.round(i.height+i.top)),new Pe(Math.round(i.left),Math.round(i.height+i.top))]}},qce="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",QD="Hidden Text",eue=function(){function n(e){this._data={},this._document=e}return n.prototype.parseMetrics=function(e,t){var r=this._document.createElement("div"),i=this._document.createElement("img"),s=this._document.createElement("span"),o=this._document.body;r.style.visibility="hidden",r.style.fontFamily=e,r.style.fontSize=t,r.style.margin="0",r.style.padding="0",r.style.whiteSpace="nowrap",o.appendChild(r),i.src=qce,i.width=1,i.height=1,i.style.margin="0",i.style.padding="0",i.style.verticalAlign="baseline",s.style.fontFamily=e,s.style.fontSize=t,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode(QD)),r.appendChild(s),r.appendChild(i);var a=i.offsetTop-s.offsetTop+2;r.removeChild(s),r.appendChild(this._document.createTextNode(QD)),r.style.lineHeight="normal",i.style.verticalAlign="super";var l=i.offsetTop-r.offsetTop+2;return o.removeChild(r),{baseline:a,middle:l}},n.prototype.getMetrics=function(e,t){var r=e+" "+t;return typeof this._data[r]>"u"&&(this._data[r]=this.parseMetrics(e,t)),this._data[r]},n}(),dH=function(){function n(e,t){this.context=e,this.options=t}return n}(),tue=1e4;(function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i._activeEffects=[],i.canvas=r.canvas?r.canvas:document.createElement("canvas"),i.ctx=i.canvas.getContext("2d"),r.canvas||(i.canvas.width=Math.floor(r.width*r.scale),i.canvas.height=Math.floor(r.height*r.scale),i.canvas.style.width=r.width+"px",i.canvas.style.height=r.height+"px"),i.fontMetrics=new eue(document),i.ctx.scale(i.options.scale,i.options.scale),i.ctx.translate(-r.x,-r.y),i.ctx.textBaseline="bottom",i._activeEffects=[],i.context.logger.debug("Canvas renderer initialized ("+r.width+"x"+r.height+") with scale "+r.scale),i}return e.prototype.applyEffects=function(t){for(var r=this;this._activeEffects.length;)this.popEffect();t.forEach(function(i){return r.applyEffect(i)})},e.prototype.applyEffect=function(t){this.ctx.save(),Gce(t)&&(this.ctx.globalAlpha=t.opacity),Oce(t)&&(this.ctx.translate(t.offsetX,t.offsetY),this.ctx.transform(t.matrix[0],t.matrix[1],t.matrix[2],t.matrix[3],t.matrix[4],t.matrix[5]),this.ctx.translate(-t.offsetX,-t.offsetY)),lH(t)&&(this.path(t.path),this.ctx.clip()),this._activeEffects.push(t)},e.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},e.prototype.renderStack=function(t){return Rs(this,void 0,void 0,function(){var r;return Ji(this,function(i){switch(i.label){case 0:return r=t.element.container.styles,r.isVisible()?[4,this.renderStackContent(t)]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}})})},e.prototype.renderNode=function(t){return Rs(this,void 0,void 0,function(){return Ji(this,function(r){switch(r.label){case 0:if(dr(t.container.flags,16))debugger;return t.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(t)]:[3,3];case 1:return r.sent(),[4,this.renderNodeContent(t)];case 2:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.renderTextWithLetterSpacing=function(t,r,i){var s=this;if(r===0)this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+i);else{var o=J_(t.text);o.reduce(function(a,l){return s.ctx.fillText(l,a,t.bounds.top+i),a+s.ctx.measureText(l).width},t.bounds.left)}},e.prototype.createFontStyle=function(t){var r=t.fontVariant.filter(function(o){return o==="normal"||o==="small-caps"}).join(""),i=oue(t.fontFamily).join(", "),s=v0(t.fontSize)?""+t.fontSize.number+t.fontSize.unit:t.fontSize.number+"px";return[[t.fontStyle,r,t.fontWeight,s,i].join(" "),i,s]},e.prototype.renderTextNode=function(t,r){return Rs(this,void 0,void 0,function(){var i,s,o,a,l,A,c,u,f=this;return Ji(this,function(d){return i=this.createFontStyle(r),s=i[0],o=i[1],a=i[2],this.ctx.font=s,this.ctx.direction=r.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",l=this.fontMetrics.getMetrics(o,a),A=l.baseline,c=l.middle,u=r.paintOrder,t.textBounds.forEach(function(h){u.forEach(function(p){switch(p){case 0:f.ctx.fillStyle=vr(r.color),f.renderTextWithLetterSpacing(h,r.letterSpacing,A);var m=r.textShadow;m.length&&h.text.trim().length&&(m.slice(0).reverse().forEach(function(g){f.ctx.shadowColor=vr(g.color),f.ctx.shadowOffsetX=g.offsetX.number*f.options.scale,f.ctx.shadowOffsetY=g.offsetY.number*f.options.scale,f.ctx.shadowBlur=g.blur.number,f.renderTextWithLetterSpacing(h,r.letterSpacing,A)}),f.ctx.shadowColor="",f.ctx.shadowOffsetX=0,f.ctx.shadowOffsetY=0,f.ctx.shadowBlur=0),r.textDecorationLine.length&&(f.ctx.fillStyle=vr(r.textDecorationColor||r.color),r.textDecorationLine.forEach(function(g){switch(g){case 1:f.ctx.fillRect(h.bounds.left,Math.round(h.bounds.top+A),h.bounds.width,1);break;case 2:f.ctx.fillRect(h.bounds.left,Math.round(h.bounds.top),h.bounds.width,1);break;case 3:f.ctx.fillRect(h.bounds.left,Math.ceil(h.bounds.top+c),h.bounds.width,1);break}}));break;case 1:r.webkitTextStrokeWidth&&h.text.trim().length&&(f.ctx.strokeStyle=vr(r.webkitTextStrokeColor),f.ctx.lineWidth=r.webkitTextStrokeWidth,f.ctx.lineJoin=window.chrome?"miter":"round",f.ctx.strokeText(h.text,h.bounds.left,h.bounds.top+A)),f.ctx.strokeStyle="",f.ctx.lineWidth=0,f.ctx.lineJoin="miter";break}})}),[2]})})},e.prototype.renderReplacedElement=function(t,r,i){if(i&&t.intrinsicWidth>0&&t.intrinsicHeight>0){var s=Dw(t),o=Nw(r);this.path(o),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,t.intrinsicWidth,t.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},e.prototype.renderNodeContent=function(t){return Rs(this,void 0,void 0,function(){var r,i,s,o,a,l,v,v,A,c,u,f,w,d,h,C,p,m,g,v,y,w,C;return Ji(this,function(b){switch(b.label){case 0:this.applyEffects(t.getEffects(4)),r=t.container,i=t.curves,s=r.styles,o=0,a=r.textNodes,b.label=1;case 1:return o0&&B>0&&(x=s.ctx.createPattern(C,"repeat"),s.renderRepeat(M,x,R,k))):sle(c)&&(S=KI(t,r,[null,null,null]),M=S[0],Z=S[1],K=S[2],_=S[3],B=S[4],F=c.position.length===0?[O_]:c.position,R=un(F[0],_),k=un(F[F.length-1],B),T=ele(c,R,k,_,B),V=T[0],O=T[1],V>0&&O>0&&(L=s.ctx.createRadialGradient(Z+R,K+k,0,Z+R,K+k,V),iD(c.stops,V*2).forEach(function(oe){return L.addColorStop(oe.stop,vr(oe.color))}),s.path(M),s.ctx.fillStyle=L,V!==O?(U=t.bounds.left+.5*t.bounds.width,H=t.bounds.top+.5*t.bounds.height,Ae=O/V,N=1/Ae,s.ctx.save(),s.ctx.translate(U,H),s.ctx.transform(1,0,0,Ae,0,0),s.ctx.translate(-U,-H),s.ctx.fillRect(Z,N*(K-H)+H,_,B*N),s.ctx.restore()):s.ctx.fill())),j.label=6;case 6:return r--,[2]}})},s=this,o=0,a=t.styles.backgroundImage.slice(0).reverse(),A.label=1;case 1:return o0?c.style!==2?[3,5]:[4,this.renderDashedDottedBorder(c.color,c.width,a,t.curves,2)]:[3,11]):[3,13];case 4:return f.sent(),[3,11];case 5:return c.style!==3?[3,7]:[4,this.renderDashedDottedBorder(c.color,c.width,a,t.curves,3)];case 6:return f.sent(),[3,11];case 7:return c.style!==4?[3,9]:[4,this.renderDoubleBorder(c.color,c.width,a,t.curves)];case 8:return f.sent(),[3,11];case 9:return[4,this.renderSolidBorder(c.color,a,t.curves)];case 10:f.sent(),f.label=11;case 11:a++,f.label=12;case 12:return l++,[3,3];case 13:return[2]}})})},e.prototype.renderDashedDottedBorder=function(t,r,i,s,o){return Rs(this,void 0,void 0,function(){var a,l,A,c,u,f,d,h,p,m,g,v,y,w,C,b,C,b;return Ji(this,function(E){return this.ctx.save(),a=Yce(s,i),l=_D(s,i),o===2&&(this.path(l),this.ctx.clip()),Ws(l[0])?(A=l[0].start.x,c=l[0].start.y):(A=l[0].x,c=l[0].y),Ws(l[1])?(u=l[1].end.x,f=l[1].end.y):(u=l[1].x,f=l[1].y),i===0||i===2?d=Math.abs(A-u):d=Math.abs(c-f),this.ctx.beginPath(),o===3?this.formatPath(a):this.formatPath(l.slice(0,2)),h=r<3?r*3:r*2,p=r<3?r*2:r,o===3&&(h=r,p=r),m=!0,d<=h*2?m=!1:d<=h*2+p?(g=d/(2*h+p),h*=g,p*=g):(v=Math.floor((d+p)/(h+p)),y=(d-v*h)/(v-1),w=(d-(v+1)*h)/v,p=w<=0||Math.abs(p-y)0&&s[s.length-1])&&(A[0]===6||A[0]===2)){t=0;continue}if(A[0]===3&&(!s||A[1]>s[0]&&A[1]=55296&&i<=56319&&t>10)+55296,o%1024+56320)),(i+1===t||r.length>16384)&&(s+=String.fromCharCode.apply(String,r),r.length=0)}return s},kN="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",loe=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Mv=0;Mv"u"?[]:new Uint8Array(256);for(var Tv=0;Tv>4,c[i++]=(o&15)<<4|a>>2,c[i++]=(a&3)<<6|l&63;return A},coe=function(n){for(var e=n.length,t=[],r=0;r>su,doe=1<>su,poe=gJ+hoe,goe=poe,moe=32,voe=goe+moe,yoe=65536>>W_,Boe=1<=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>su],t=(t<>su)],t=(t<>W_),t=this.index[t],t+=e>>su&woe,t=this.index[t],t=(t<"u"?[]:new Uint8Array(256);for(var Nv=0;NvWN?(i.push(!0),a-=WN):i.push(!1),["normal","auto","loose"].indexOf(e)!==-1&&[8208,8211,12316,12448].indexOf(s)!==-1)return r.push(o),t.push(NE);if(a===Uoe||a===ME){if(o===0)return r.push(o),t.push(Pc);var l=t[o-1];return Doe.indexOf(l)===-1?(r.push(r[o-1]),t.push(l)):(r.push(o),t.push(Pc))}if(r.push(o),a===Moe)return t.push(e==="strict"?DE:Tm);if(a===BJ||a===Roe)return t.push(Pc);if(a===Toe)return s>=131072&&s<=196605||s>=196608&&s<=262141?t.push(Tm):t.push(Pc);t.push(a)}),[r,t,i]},kI=function(n,e,t,r){var i=r[t];if(Array.isArray(n)?n.indexOf(i)!==-1:n===i)for(var s=t;s<=r.length;){s++;var o=r[s];if(o===e)return!0;if(o!==EA)break}if(i===EA)for(var s=t;s>0;){s--;var a=r[s];if(Array.isArray(n)?n.indexOf(a)!==-1:n===a)for(var l=t;l<=r.length;){l++;var o=r[l];if(o===e)return!0;if(o!==EA)break}if(a!==EA)break}return!1},YN=function(n,e){for(var t=n;t>=0;){var r=e[t];if(r===EA)t--;else return r}return 0},Loe=function(n,e,t,r,i){if(t[r]===0)return Et;var s=r-1;if(Array.isArray(i)&&i[s]===!0)return Et;var o=s-1,a=s+1,l=e[s],A=o>=0?e[o]:0,c=e[a];if(l===mJ&&c===vJ)return Et;if(OE.indexOf(l)!==-1)return wJ;if(OE.indexOf(c)!==-1||CJ.indexOf(c)!==-1)return Et;if(YN(s,e)===yJ)return Lv;if(WE.get(n[s])===ME||(l===kv||l===Vv)&&WE.get(n[a])===ME||l===ON||c===ON||l===GN||[EA,TE,pg].indexOf(l)===-1&&c===GN||[Dv,Rp,Qoe,df,hf].indexOf(c)!==-1||YN(s,e)===Mp||kI(NI,Mp,s,e)||kI([Dv,Rp],DE,s,e)||kI(ZN,ZN,s,e))return Et;if(l===EA)return Lv;if(l===NI||c===NI)return Et;if(c===NE||l===NE)return Lv;if([TE,pg,DE].indexOf(c)!==-1||l===_oe||A===LE&&koe.indexOf(l)!==-1||l===hf&&c===LE||c===JN||Xa.indexOf(c)!==-1&&l===Hi||Xa.indexOf(l)!==-1&&c===Hi||l===mg&&[Tm,kv,Vv].indexOf(c)!==-1||[Tm,kv,Vv].indexOf(l)!==-1&&c===gg||Xa.indexOf(l)!==-1&&HN.indexOf(c)!==-1||HN.indexOf(l)!==-1&&Xa.indexOf(c)!==-1||[mg,gg].indexOf(l)!==-1&&(c===Hi||[Mp,pg].indexOf(c)!==-1&&e[a+1]===Hi)||[Mp,pg].indexOf(l)!==-1&&c===Hi||l===Hi&&[Hi,hf,df].indexOf(c)!==-1)return Et;if([Hi,hf,df,Dv,Rp].indexOf(c)!==-1)for(var u=s;u>=0;){var f=e[u];if(f===Hi)return Et;if([hf,df].indexOf(f)!==-1)u--;else break}if([mg,gg].indexOf(c)!==-1)for(var u=[Dv,Rp].indexOf(l)!==-1?o:s;u>=0;){var f=e[u];if(f===Hi)return Et;if([hf,df].indexOf(f)!==-1)u--;else break}if(PE===l&&[PE,lB,kE,VE].indexOf(c)!==-1||[lB,kE].indexOf(l)!==-1&&[lB,AB].indexOf(c)!==-1||[AB,VE].indexOf(l)!==-1&&c===AB||zN.indexOf(l)!==-1&&[JN,gg].indexOf(c)!==-1||zN.indexOf(c)!==-1&&l===mg||Xa.indexOf(l)!==-1&&Xa.indexOf(c)!==-1||l===df&&Xa.indexOf(c)!==-1||Xa.concat(Hi).indexOf(l)!==-1&&c===Mp&&Noe.indexOf(n[a])===-1||Xa.concat(Hi).indexOf(c)!==-1&&l===Rp)return Et;if(l===DI&&c===DI){for(var d=t[s],h=1;d>0&&(d--,e[d]===DI);)h++;if(h%2!==0)return Et}return l===kv&&c===Vv?Et:Lv},Poe=function(n,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=Voe(n,e.lineBreak),r=t[0],i=t[1],s=t[2];(e.wordBreak==="break-all"||e.wordBreak==="break-word")&&(i=i.map(function(a){return[Hi,Pc,BJ].indexOf(a)!==-1?Tm:a}));var o=e.wordBreak==="keep-all"?s.map(function(a,l){return a&&n[l]>=19968&&n[l]<=40959}):void 0;return[r,i,o]},Woe=function(){function n(e,t,r,i){this.codePoints=e,this.required=t===wJ,this.start=r,this.end=i}return n.prototype.slice=function(){return On.apply(void 0,this.codePoints.slice(this.start,this.end))},n}(),Ooe=function(n,e){var t=tb(n),r=Poe(t,e),i=r[0],s=r[1],o=r[2],a=t.length,l=0,A=0;return{next:function(){if(A>=a)return{done:!0,value:null};for(var c=Et;A=bJ&&n<=57},Cae=function(n){return n>=55296&&n<=57343},pf=function(n){return Hr(n)||n>=FJ&&n<=UJ||n>=xJ&&n<=mae},bae=function(n){return n>=xJ&&n<=yae},xae=function(n){return n>=FJ&&n<=wae},Iae=function(n){return bae(n)||xae(n)},Fae=function(n){return n>=aae},Zv=function(n){return n===Sw||n===Joe||n===Hoe},_w=function(n){return Iae(n)||Fae(n)||n===Koe},qN=function(n){return _w(n)||Hr(n)||n===Fi},Eae=function(n){return n>=uae&&n<=fae||n===dae||n>=hae&&n<=pae||n===gae},hA=function(n,e){return n!==Jg?!1:e!==Sw},Jv=function(n,e,t){return n===Fi?_w(e)||hA(e,t):_w(n)?!0:!!(n===Jg&&hA(n,e))},LI=function(n,e,t){return n===zc||n===Fi?Hr(e)?!0:e===Nm&&Hr(t):Hr(n===Nm?e:n)},Uae=function(n){var e=0,t=1;(n[e]===zc||n[e]===Fi)&&(n[e]===Fi&&(t=-1),e++);for(var r=[];Hr(n[e]);)r.push(n[e++]);var i=r.length?parseInt(On.apply(void 0,r),10):0;n[e]===Nm&&e++;for(var s=[];Hr(n[e]);)s.push(n[e++]);var o=s.length,a=o?parseInt(On.apply(void 0,s),10):0;(n[e]===EJ||n[e]===IJ)&&e++;var l=1;(n[e]===zc||n[e]===Fi)&&(n[e]===Fi&&(l=-1),e++);for(var A=[];Hr(n[e]);)A.push(n[e++]);var c=A.length?parseInt(On.apply(void 0,A),10):0;return t*(i+a*Math.pow(10,-o))*Math.pow(10,l*c)},Sae={type:2},_ae={type:3},Qae={type:4},Rae={type:13},Mae={type:8},Tae={type:21},Nae={type:9},Dae={type:10},kae={type:11},Vae={type:12},Lae={type:14},Hv={type:23},Pae={type:1},Wae={type:25},Oae={type:24},Gae={type:26},Zae={type:27},Jae={type:28},Hae={type:29},zae={type:31},GE={type:32},SJ=function(){function n(){this._value=[]}return n.prototype.write=function(e){this._value=this._value.concat(tb(e))},n.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==GE;)e.push(t),t=this.consumeToken();return e},n.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case Pv:return this.consumeStringToken(Pv);case zoe:var t=this.peekCodePoint(0),r=this.peekCodePoint(1),i=this.peekCodePoint(2);if(qN(t)||hA(r,i)){var s=Jv(t,r,i)?Zoe:Goe,o=this.consumeName();return{type:5,value:o,flags:s}}break;case Yoe:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Rae;break;case Wv:return this.consumeStringToken(Wv);case Ov:return Sae;case Np:return _ae;case VI:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Lae;break;case zc:if(LI(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case lae:return Qae;case Fi:var a=e,l=this.peekCodePoint(0),A=this.peekCodePoint(1);if(LI(a,l,A))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Jv(a,l,A))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(l===Fi&&A===qoe)return this.consumeCodePoint(),this.consumeCodePoint(),Oae;break;case Nm:if(LI(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case KN:if(this.peekCodePoint(0)===VI)for(this.consumeCodePoint();;){var c=this.consumeCodePoint();if(c===VI&&(c=this.consumeCodePoint(),c===KN))return this.consumeToken();if(c===Ho)return this.consumeToken()}break;case Aae:return Gae;case cae:return Zae;case $oe:if(this.peekCodePoint(0)===joe&&this.peekCodePoint(1)===Fi&&this.peekCodePoint(2)===Fi)return this.consumeCodePoint(),this.consumeCodePoint(),Wae;break;case eae:var u=this.peekCodePoint(0),f=this.peekCodePoint(1),d=this.peekCodePoint(2);if(Jv(u,f,d)){var o=this.consumeName();return{type:7,value:o}}break;case tae:return Jae;case Jg:if(hA(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case nae:return Hae;case rae:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Mae;break;case iae:return kae;case sae:return Vae;case vae:case Bae:var h=this.peekCodePoint(0),p=this.peekCodePoint(1);return h===zc&&(pf(p)||p===Gv)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case jN:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Nae;if(this.peekCodePoint(0)===jN)return this.consumeCodePoint(),Tae;break;case oae:if(this.peekCodePoint(0)===Tp)return this.consumeCodePoint(),Dae;break;case Ho:return GE}return Zv(e)?(this.consumeWhiteSpace(),zae):Hr(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):_w(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:On(e)}},n.prototype.consumeCodePoint=function(){var e=this._value.shift();return typeof e>"u"?-1:e},n.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},n.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},n.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();pf(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var r=!1;t===Gv&&e.length<6;)e.push(t),t=this.consumeCodePoint(),r=!0;if(r){var i=parseInt(On.apply(void 0,e.map(function(l){return l===Gv?bJ:l})),16),s=parseInt(On.apply(void 0,e.map(function(l){return l===Gv?UJ:l})),16);return{type:30,start:i,end:s}}var o=parseInt(On.apply(void 0,e),16);if(this.peekCodePoint(0)===Fi&&pf(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var a=[];pf(t)&&a.length<6;)a.push(t),t=this.consumeCodePoint();var s=parseInt(On.apply(void 0,a),16);return{type:30,start:o,end:s}}else return{type:30,start:o,end:o}},n.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return e.toLowerCase()==="url"&&this.peekCodePoint(0)===Ov?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===Ov?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},n.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ho)return{type:22,value:""};var t=this.peekCodePoint(0);if(t===Wv||t===Pv){var r=this.consumeStringToken(this.consumeCodePoint());return r.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ho||this.peekCodePoint(0)===Np)?(this.consumeCodePoint(),{type:22,value:r.value}):(this.consumeBadUrlRemnants(),Hv)}for(;;){var i=this.consumeCodePoint();if(i===Ho||i===Np)return{type:22,value:On.apply(void 0,e)};if(Zv(i))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Ho||this.peekCodePoint(0)===Np?(this.consumeCodePoint(),{type:22,value:On.apply(void 0,e)}):(this.consumeBadUrlRemnants(),Hv);if(i===Pv||i===Wv||i===Ov||Eae(i))return this.consumeBadUrlRemnants(),Hv;if(i===Jg)if(hA(i,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),Hv;else e.push(i)}},n.prototype.consumeWhiteSpace=function(){for(;Zv(this.peekCodePoint(0));)this.consumeCodePoint()},n.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===Np||e===Ho)return;hA(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},n.prototype.consumeStringSlice=function(e){for(var t=5e4,r="";e>0;){var i=Math.min(t,e);r+=On.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),r},n.prototype.consumeStringToken=function(e){var t="",r=0;do{var i=this._value[r];if(i===Ho||i===void 0||i===e)return t+=this.consumeStringSlice(r),{type:0,value:t};if(i===Sw)return this._value.splice(0,r),Pae;if(i===Jg){var s=this._value[r+1];s!==Ho&&s!==void 0&&(s===Sw?(t+=this.consumeStringSlice(r),r=-1,this._value.shift()):hA(i,s)&&(t+=this.consumeStringSlice(r),t+=On(this.consumeEscapedCodePoint()),r=-1))}r++}while(!0)},n.prototype.consumeNumber=function(){var e=[],t=m0,r=this.peekCodePoint(0);for((r===zc||r===Fi)&&e.push(this.consumeCodePoint());Hr(this.peekCodePoint(0));)e.push(this.consumeCodePoint());r=this.peekCodePoint(0);var i=this.peekCodePoint(1);if(r===Nm&&Hr(i))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=XN;Hr(this.peekCodePoint(0));)e.push(this.consumeCodePoint());r=this.peekCodePoint(0),i=this.peekCodePoint(1);var s=this.peekCodePoint(2);if((r===EJ||r===IJ)&&((i===zc||i===Fi)&&Hr(s)||Hr(i)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=XN;Hr(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Uae(e),t]},n.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],r=e[1],i=this.peekCodePoint(0),s=this.peekCodePoint(1),o=this.peekCodePoint(2);if(Jv(i,s,o)){var a=this.consumeName();return{type:15,number:t,flags:r,unit:a}}return i===Xoe?(this.consumeCodePoint(),{type:16,number:t,flags:r}):{type:17,number:t,flags:r}},n.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(pf(e)){for(var t=On(e);pf(this.peekCodePoint(0))&&t.length<6;)t+=On(this.consumeCodePoint());Zv(this.peekCodePoint(0))&&this.consumeCodePoint();var r=parseInt(t,16);return r===0||Cae(r)||r>1114111?$N:r}return e===Ho?$N:e},n.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(qN(t))e+=On(t);else if(hA(t,this.peekCodePoint(0)))e+=On(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}},n}(),_J=function(){function n(e){this._tokens=e}return n.create=function(e){var t=new SJ;return t.write(e),new n(t.read())},n.parseValue=function(e){return n.create(e).parseComponentValue()},n.parseValues=function(e){return n.create(e).parseComponentValues()},n.prototype.parseComponentValue=function(){for(var e=this.consumeToken();e.type===31;)e=this.consumeToken();if(e.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},n.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(t.type===32)return e;e.push(t),e.push()}},n.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},n.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},r=this.consumeToken();;){if(r.type===32||Yae(r,e))return t;this.reconsumeToken(r),t.values.push(this.consumeComponentValue()),r=this.consumeToken()}},n.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var r=this.consumeToken();if(r.type===32||r.type===3)return t;this.reconsumeToken(r),t.values.push(this.consumeComponentValue())}},n.prototype.consumeToken=function(){var e=this._tokens.shift();return typeof e>"u"?GE:e},n.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},n}(),v0=function(n){return n.type===15},nb=function(n){return n.type===17},Pn=function(n){return n.type===20},ZE=function(n,e){return Pn(n)&&n.value===e},rb=function(n){return n.type!==31&&n.type!==4},ka=function(n){var e=[],t=[];return n.forEach(function(r){if(r.type===4){if(t.length===0)throw new Error("Error parsing function args, zero tokens for arg");e.push(t),t=[];return}r.type!==31&&t.push(r)}),t.length&&e.push(t),e},Yae=function(n,e){return e===11&&n.type===12||e===28&&n.type===29?!0:e===2&&n.type===3},nc=function(n){return n.type===17||n.type===15},tr=function(n){return n.type===16||nc(n)},QJ=function(n){return n.length>1?[n[0],n[1]]:[n[0]]},Nr={type:17,number:0,flags:m0},O_={type:16,number:50,flags:m0},UA={type:16,number:100,flags:m0},vg=function(n,e,t){var r=n[0],i=n[1];return[un(r,e),un(typeof i<"u"?i:r,t)]},un=function(n,e){if(n.type===16)return n.number/100*e;if(v0(n))switch(n.unit){case"rem":case"em":return 16*n.number;case"px":default:return n.number}return n.number},RJ="deg",MJ="grad",TJ="rad",NJ="turn",ib={name:"angle",parse:function(n,e){if(e.type===15)switch(e.unit){case RJ:return Math.PI*e.number/180;case MJ:return Math.PI/200*e.number;case TJ:return e.number;case NJ:return Math.PI*2*e.number}throw new Error("Unsupported angle type")}},DJ=function(n){return n.type===15&&(n.unit===RJ||n.unit===MJ||n.unit===TJ||n.unit===NJ)},kJ=function(n){var e=n.filter(Pn).map(function(t){return t.value}).join(" ");switch(e){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Nr,Nr];case"to top":case"bottom":return zs(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Nr,UA];case"to right":case"left":return zs(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[UA,UA];case"to bottom":case"top":return zs(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[UA,Nr];case"to left":case"right":return zs(270)}return 0},zs=function(n){return Math.PI*n/180},GA={name:"color",parse:function(n,e){if(e.type===18){var t=Xae[e.name];if(typeof t>"u")throw new Error('Attempting to parse an unsupported color function "'+e.name+'"');return t(n,e.values)}if(e.type===5){if(e.value.length===3){var r=e.value.substring(0,1),i=e.value.substring(1,2),s=e.value.substring(2,3);return SA(parseInt(r+r,16),parseInt(i+i,16),parseInt(s+s,16),1)}if(e.value.length===4){var r=e.value.substring(0,1),i=e.value.substring(1,2),s=e.value.substring(2,3),o=e.value.substring(3,4);return SA(parseInt(r+r,16),parseInt(i+i,16),parseInt(s+s,16),parseInt(o+o,16)/255)}if(e.value.length===6){var r=e.value.substring(0,2),i=e.value.substring(2,4),s=e.value.substring(4,6);return SA(parseInt(r,16),parseInt(i,16),parseInt(s,16),1)}if(e.value.length===8){var r=e.value.substring(0,2),i=e.value.substring(2,4),s=e.value.substring(4,6),o=e.value.substring(6,8);return SA(parseInt(r,16),parseInt(i,16),parseInt(s,16),parseInt(o,16)/255)}}if(e.type===20){var a=Dm[e.value.toUpperCase()];if(typeof a<"u")return a}return Dm.TRANSPARENT}},Gd=function(n){return(255&n)===0},vr=function(n){var e=255&n,t=255&n>>8,r=255&n>>16,i=255&n>>24;return e<255?"rgba("+i+","+r+","+t+","+e/255+")":"rgb("+i+","+r+","+t+")"},SA=function(n,e,t,r){return(n<<24|e<<16|t<<8|Math.round(r*255)<<0)>>>0},eD=function(n,e){if(n.type===17)return n.number;if(n.type===16){var t=e===3?1:255;return e===3?n.number/100*t:Math.round(n.number/100*t)}return 0},tD=function(n,e){var t=e.filter(rb);if(t.length===3){var r=t.map(eD),i=r[0],s=r[1],o=r[2];return SA(i,s,o,1)}if(t.length===4){var a=t.map(eD),i=a[0],s=a[1],o=a[2],l=a[3];return SA(i,s,o,l)}return 0};function PI(n,e,t){return t<0&&(t+=1),t>=1&&(t-=1),t<1/6?(e-n)*t*6+n:t<1/2?e:t<2/3?(e-n)*6*(2/3-t)+n:n}var nD=function(n,e){var t=e.filter(rb),r=t[0],i=t[1],s=t[2],o=t[3],a=(r.type===17?zs(r.number):ib.parse(n,r))/(Math.PI*2),l=tr(i)?i.number/100:0,A=tr(s)?s.number/100:0,c=typeof o<"u"&&tr(o)?un(o,1):1;if(l===0)return SA(A*255,A*255,A*255,1);var u=A<=.5?A*(l+1):A+l-A*l,f=A*2-u,d=PI(f,u,a+1/3),h=PI(f,u,a),p=PI(f,u,a-1/3);return SA(d*255,h*255,p*255,c)},Xae={hsl:nD,hsla:nD,rgb:tD,rgba:tD},rD=function(n,e){return GA.parse(n,_J.create(e).parseComponentValue())},Dm={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Kae={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(n,e){return e.map(function(t){if(Pn(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},jae={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},sb=function(n,e){var t=GA.parse(n,e[0]),r=e[1];return r&&tr(r)?{color:t,stop:r}:{color:t,stop:null}},iD=function(n,e){var t=n[0],r=n[n.length-1];t.stop===null&&(t.stop=Nr),r.stop===null&&(r.stop=UA);for(var i=[],s=0,o=0;os?i.push(l):i.push(s),s=l}else i.push(null)}for(var A=null,o=0;oo.optimumDistance)?{optimumCorner:a,optimumDistance:c}:o},{optimumDistance:i?1/0:-1/0,optimumCorner:null}).optimumCorner},ele=function(n,e,t,r,i){var s=0,o=0;switch(n.size){case 0:n.shape===0?s=o=Math.min(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-i)):n.shape===1&&(s=Math.min(Math.abs(e),Math.abs(e-r)),o=Math.min(Math.abs(t),Math.abs(t-i)));break;case 2:if(n.shape===0)s=o=Math.min(Co(e,t),Co(e,t-i),Co(e-r,t),Co(e-r,t-i));else if(n.shape===1){var a=Math.min(Math.abs(t),Math.abs(t-i))/Math.min(Math.abs(e),Math.abs(e-r)),l=sD(r,i,e,t,!0),A=l[0],c=l[1];s=Co(A-e,(c-t)/a),o=a*s}break;case 1:n.shape===0?s=o=Math.max(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-i)):n.shape===1&&(s=Math.max(Math.abs(e),Math.abs(e-r)),o=Math.max(Math.abs(t),Math.abs(t-i)));break;case 3:if(n.shape===0)s=o=Math.max(Co(e,t),Co(e,t-i),Co(e-r,t),Co(e-r,t-i));else if(n.shape===1){var a=Math.max(Math.abs(t),Math.abs(t-i))/Math.max(Math.abs(e),Math.abs(e-r)),u=sD(r,i,e,t,!1),A=u[0],c=u[1];s=Co(A-e,(c-t)/a),o=a*s}break}return Array.isArray(n.size)&&(s=un(n.size[0],r),o=n.size.length===2?un(n.size[1],i):s),[s,o]},tle=function(n,e){var t=zs(180),r=[];return ka(e).forEach(function(i,s){if(s===0){var o=i[0];if(o.type===20&&o.value==="to"){t=kJ(i);return}else if(DJ(o)){t=ib.parse(n,o);return}}var a=sb(n,i);r.push(a)}),{angle:t,stops:r,type:1}},zv=function(n,e){var t=zs(180),r=[];return ka(e).forEach(function(i,s){if(s===0){var o=i[0];if(o.type===20&&["top","left","right","bottom"].indexOf(o.value)!==-1){t=kJ(i);return}else if(DJ(o)){t=(ib.parse(n,o)+zs(270))%zs(360);return}}var a=sb(n,i);r.push(a)}),{angle:t,stops:r,type:1}},nle=function(n,e){var t=zs(180),r=[],i=1,s=0,o=3,a=[];return ka(e).forEach(function(l,A){var c=l[0];if(A===0){if(Pn(c)&&c.value==="linear"){i=1;return}else if(Pn(c)&&c.value==="radial"){i=2;return}}if(c.type===18){if(c.name==="from"){var u=GA.parse(n,c.values[0]);r.push({stop:Nr,color:u})}else if(c.name==="to"){var u=GA.parse(n,c.values[0]);r.push({stop:UA,color:u})}else if(c.name==="color-stop"){var f=c.values.filter(rb);if(f.length===2){var u=GA.parse(n,f[1]),d=f[0];nb(d)&&r.push({stop:{type:16,number:d.number*100,flags:d.flags},color:u})}}}}),i===1?{angle:(t+zs(180))%zs(360),stops:r,type:i}:{size:o,shape:s,stops:r,position:a,type:i}},VJ="closest-side",LJ="farthest-side",PJ="closest-corner",WJ="farthest-corner",OJ="circle",GJ="ellipse",ZJ="cover",JJ="contain",rle=function(n,e){var t=0,r=3,i=[],s=[];return ka(e).forEach(function(o,a){var l=!0;if(a===0){var A=!1;l=o.reduce(function(u,f){if(A)if(Pn(f))switch(f.value){case"center":return s.push(O_),u;case"top":case"left":return s.push(Nr),u;case"right":case"bottom":return s.push(UA),u}else(tr(f)||nc(f))&&s.push(f);else if(Pn(f))switch(f.value){case OJ:return t=0,!1;case GJ:return t=1,!1;case"at":return A=!0,!1;case VJ:return r=0,!1;case ZJ:case LJ:return r=1,!1;case JJ:case PJ:return r=2,!1;case WJ:return r=3,!1}else if(nc(f)||tr(f))return Array.isArray(r)||(r=[]),r.push(f),!1;return u},l)}if(l){var c=sb(n,o);i.push(c)}}),{size:r,shape:t,stops:i,position:s,type:2}},Yv=function(n,e){var t=0,r=3,i=[],s=[];return ka(e).forEach(function(o,a){var l=!0;if(a===0?l=o.reduce(function(c,u){if(Pn(u))switch(u.value){case"center":return s.push(O_),!1;case"top":case"left":return s.push(Nr),!1;case"right":case"bottom":return s.push(UA),!1}else if(tr(u)||nc(u))return s.push(u),!1;return c},l):a===1&&(l=o.reduce(function(c,u){if(Pn(u))switch(u.value){case OJ:return t=0,!1;case GJ:return t=1,!1;case JJ:case VJ:return r=0,!1;case LJ:return r=1,!1;case PJ:return r=2,!1;case ZJ:case WJ:return r=3,!1}else if(nc(u)||tr(u))return Array.isArray(r)||(r=[]),r.push(u),!1;return c},l)),l){var A=sb(n,o);i.push(A)}}),{size:r,shape:t,stops:i,position:s,type:2}},ile=function(n){return n.type===1},sle=function(n){return n.type===2},G_={name:"image",parse:function(n,e){if(e.type===22){var t={url:e.value,type:0};return n.cache.addImage(e.value),t}if(e.type===18){var r=HJ[e.name];if(typeof r>"u")throw new Error('Attempting to parse an unsupported image function "'+e.name+'"');return r(n,e.values)}throw new Error("Unsupported image type "+e.type)}};function ole(n){return!(n.type===20&&n.value==="none")&&(n.type!==18||!!HJ[n.name])}var HJ={"linear-gradient":tle,"-moz-linear-gradient":zv,"-ms-linear-gradient":zv,"-o-linear-gradient":zv,"-webkit-linear-gradient":zv,"radial-gradient":rle,"-moz-radial-gradient":Yv,"-ms-radial-gradient":Yv,"-o-radial-gradient":Yv,"-webkit-radial-gradient":Yv,"-webkit-gradient":nle},ale={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(n,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e.filter(function(r){return rb(r)&&ole(r)}).map(function(r){return G_.parse(n,r)})}},lle={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(n,e){return e.map(function(t){if(Pn(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},Ale={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(n,e){return ka(e).map(function(t){return t.filter(tr)}).map(QJ)}},cle={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(n,e){return ka(e).map(function(t){return t.filter(Pn).map(function(r){return r.value}).join(" ")}).map(ule)}},ule=function(n){switch(n){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;case"repeat":default:return 0}},Zd;(function(n){n.AUTO="auto",n.CONTAIN="contain",n.COVER="cover"})(Zd||(Zd={}));var fle={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(n,e){return ka(e).map(function(t){return t.filter(dle)})}},dle=function(n){return Pn(n)||tr(n)},ob=function(n){return{name:"border-"+n+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},hle=ob("top"),ple=ob("right"),gle=ob("bottom"),mle=ob("left"),ab=function(n){return{name:"border-radius-"+n,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return QJ(t.filter(tr))}}},vle=ab("top-left"),yle=ab("top-right"),Ble=ab("bottom-right"),wle=ab("bottom-left"),lb=function(n){return{name:"border-"+n+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},Cle=lb("top"),ble=lb("right"),xle=lb("bottom"),Ile=lb("left"),Ab=function(n){return{name:"border-"+n+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return v0(t)?t.number:0}}},Fle=Ab("top"),Ele=Ab("right"),Ule=Ab("bottom"),Sle=Ab("left"),_le={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Qle={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(n,e){switch(e){case"rtl":return 1;case"ltr":default:return 0}}},Rle={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(n,e){return e.filter(Pn).reduce(function(t,r){return t|Mle(r.value)},0)}},Mle=function(n){switch(n){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},Tle={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Nle={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(n,e){return e.type===20&&e.value==="normal"?0:e.type===17||e.type===15?e.number:0}},Qw;(function(n){n.NORMAL="normal",n.STRICT="strict"})(Qw||(Qw={}));var Dle={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"strict":return Qw.STRICT;case"normal":default:return Qw.NORMAL}}},kle={name:"line-height",initialValue:"normal",prefix:!1,type:4},oD=function(n,e){return Pn(n)&&n.value==="normal"?1.2*e:n.type===17?e*n.number:tr(n)?un(n,e):e},Vle={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(n,e){return e.type===20&&e.value==="none"?null:G_.parse(n,e)}},Lle={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(n,e){switch(e){case"inside":return 0;case"outside":default:return 1}}},Ple={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;case"none":default:return-1}}},cb=function(n){return{name:"margin-"+n,initialValue:"0",prefix:!1,type:4}},Wle=cb("top"),Ole=cb("right"),Gle=cb("bottom"),Zle=cb("left"),Jle={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(n,e){return e.filter(Pn).map(function(t){switch(t.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;case"visible":default:return 0}})}},Hle={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"break-word":return"break-word";case"normal":default:return"normal"}}},ub=function(n){return{name:"padding-"+n,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},zle=ub("top"),Yle=ub("right"),Xle=ub("bottom"),Kle=ub("left"),jle={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(n,e){switch(e){case"right":return 2;case"center":case"justify":return 1;case"left":default:return 0}}},$le={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(n,e){switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},qle={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.length===1&&ZE(e[0],"none")?[]:ka(e).map(function(t){for(var r={color:Dm.TRANSPARENT,offsetX:Nr,offsetY:Nr,blur:Nr},i=0,s=0;s"u")throw new Error('Attempting to parse an unsupported transform function "'+e.name+'"');return t(e.values)}return null}},nAe=function(n){var e=n.filter(function(t){return t.type===17}).map(function(t){return t.number});return e.length===6?e:null},rAe=function(n){var e=n.filter(function(l){return l.type===17}).map(function(l){return l.number}),t=e[0],r=e[1];e[2],e[3];var i=e[4],s=e[5];e[6],e[7],e[8],e[9],e[10],e[11];var o=e[12],a=e[13];return e[14],e[15],e.length===16?[t,r,i,s,o,a]:null},iAe={matrix:nAe,matrix3d:rAe},aD={type:16,number:50,flags:m0},sAe=[aD,aD],oAe={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(n,e){var t=e.filter(tr);return t.length!==2?sAe:[t[0],t[1]]}},aAe={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(n,e){switch(e){case"hidden":return 1;case"collapse":return 2;case"visible":default:return 0}}},Hg;(function(n){n.NORMAL="normal",n.BREAK_ALL="break-all",n.KEEP_ALL="keep-all"})(Hg||(Hg={}));var lAe={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"break-all":return Hg.BREAK_ALL;case"keep-all":return Hg.KEEP_ALL;case"normal":default:return Hg.NORMAL}}},AAe={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(n,e){if(e.type===20)return{auto:!0,order:0};if(nb(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},zJ={name:"time",parse:function(n,e){if(e.type===15)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")}},cAe={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(n,e){return nb(e)?e.number:1}},uAe={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},fAe={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(n,e){return e.filter(Pn).map(function(t){switch(t.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(t){return t!==0})}},dAe={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(n,e){var t=[],r=[];return e.forEach(function(i){switch(i.type){case 20:case 0:t.push(i.value);break;case 17:t.push(i.number.toString());break;case 4:r.push(t.join(" ")),t.length=0;break}}),t.length&&r.push(t.join(" ")),r.map(function(i){return i.indexOf(" ")===-1?i:"'"+i+"'"})}},hAe={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},pAe={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(n,e){if(nb(e))return e.number;if(Pn(e))switch(e.value){case"bold":return 700;case"normal":default:return 400}return 400}},gAe={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.filter(Pn).map(function(t){return t.value})}},mAe={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(n,e){switch(e){case"oblique":return"oblique";case"italic":return"italic";case"normal":default:return"normal"}}},dr=function(n,e){return(n&e)!==0},vAe={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(n,e){return e.filter(v0).map(function(t){return zJ.parse(n,t)})}},yAe={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,e){return e.length===1&&ZE(e[0],"none")?[]:ka(e).map(function(t){for(var r={color:255,offsetX:Nr,offsetY:Nr,blur:Nr,spread:Nr,inset:!1},i=0,s=0;s1?1:0],this.overflowWrap=ze(e,Hle,t.overflowWrap),this.paddingTop=ze(e,zle,t.paddingTop),this.paddingRight=ze(e,Yle,t.paddingRight),this.paddingBottom=ze(e,Xle,t.paddingBottom),this.paddingLeft=ze(e,Kle,t.paddingLeft),this.paintOrder=ze(e,BAe,t.paintOrder),this.position=ze(e,$le,t.position),this.textAlign=ze(e,jle,t.textAlign),this.textDecorationColor=ze(e,uAe,(r=t.textDecorationColor)!==null&&r!==void 0?r:t.color),this.textDecorationLine=ze(e,fAe,(i=t.textDecorationLine)!==null&&i!==void 0?i:t.textDecoration),this.textShadow=ze(e,qle,t.textShadow),this.textTransform=ze(e,eAe,t.textTransform),this.transform=ze(e,tAe,t.transform),this.transformOrigin=ze(e,oAe,t.transformOrigin),this.visibility=ze(e,aAe,t.visibility),this.webkitTextStrokeColor=ze(e,wAe,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=ze(e,CAe,t.webkitTextStrokeWidth),this.wordBreak=ze(e,lAe,t.wordBreak),this.zIndex=ze(e,AAe,t.zIndex)}return n.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&this.visibility===0},n.prototype.isTransparent=function(){return Gd(this.backgroundColor)},n.prototype.isTransformed=function(){return this.transform!==null},n.prototype.isPositioned=function(){return this.position!==0},n.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},n.prototype.isFloating=function(){return this.float!==0},n.prototype.isInlineLevel=function(){return dr(this.display,4)||dr(this.display,33554432)||dr(this.display,268435456)||dr(this.display,536870912)||dr(this.display,67108864)||dr(this.display,134217728)},n}(),ze=function(n,e,t){var r=new SJ,i=t!==null&&typeof t<"u"?t.toString():e.initialValue;r.write(i);var s=new _J(r.read());switch(e.type){case 2:var o=s.parseComponentValue();return e.parse(n,Pn(o)?o.value:e.initialValue);case 0:return e.parse(n,s.parseComponentValue());case 1:return e.parse(n,s.parseComponentValues());case 4:return s.parseComponentValue();case 3:switch(e.format){case"angle":return ib.parse(n,s.parseComponentValue());case"color":return GA.parse(n,s.parseComponentValue());case"image":return G_.parse(n,s.parseComponentValue());case"length":var a=s.parseComponentValue();return nc(a)?a:Nr;case"length-percentage":var l=s.parseComponentValue();return tr(l)?l:Nr;case"time":return zJ.parse(n,s.parseComponentValue())}break}},xAe="data-html2canvas-debug",IAe=function(n){var e=n.getAttribute(xAe);switch(e){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},lD=function(n,e){var t=IAe(n);return t===1||e===t},Va=function(){function n(e,t){if(this.context=e,this.textNodes=[],this.elements=[],this.flags=0,lD(t,3))debugger;this.styles=new bAe(e,window.getComputedStyle(t,null)),Ice(t)&&(this.styles.animationDuration.some(function(r){return r>0})&&(t.style.animationDuration="0s"),this.styles.transform!==null&&(t.style.transform="none")),this.bounds=P_(this.context,t),lD(t,4)&&(this.flags|=16)}return n}(),FAe="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",AD="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yg=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Xv=0;Xv>4,c[i++]=(o&15)<<4|a>>2,c[i++]=(a&3)<<6|l&63;return A},UAe=function(n){for(var e=n.length,t=[],r=0;r>ou,QAe=1<>ou,MAe=YJ+RAe,TAe=MAe,NAe=32,DAe=TAe+NAe,kAe=65536>>Z_,VAe=1<<_Ae,LAe=VAe-1,cD=function(n,e,t){return n.slice?n.slice(e,t):new Uint16Array(Array.prototype.slice.call(n,e,t))},PAe=function(n,e,t){return n.slice?n.slice(e,t):new Uint32Array(Array.prototype.slice.call(n,e,t))},WAe=function(n,e){var t=EAe(n),r=Array.isArray(t)?SAe(t):new Uint32Array(t),i=Array.isArray(t)?UAe(t):new Uint16Array(t),s=24,o=cD(i,s/2,r[4]/2),a=r[5]===2?cD(i,(s+r[4])/2):PAe(r,Math.ceil((s+r[4])/4));return new OAe(r[0],r[1],r[2],r[3],o,a)},OAe=function(){function n(e,t,r,i,s,o){this.initialValue=e,this.errorValue=t,this.highStart=r,this.highValueIndex=i,this.index=s,this.data=o}return n.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>ou],t=(t<>ou)],t=(t<>Z_),t=this.index[t],t+=e>>ou&LAe,t=this.index[t],t=(t<"u"?[]:new Uint8Array(256);for(var Kv=0;Kv=55296&&i<=56319&&t>10)+55296,o%1024+56320)),(i+1===t||r.length>16384)&&(s+=String.fromCharCode.apply(String,r),r.length=0)}return s},YAe=WAe(FAe),ks="×",YI="÷",XAe=function(n){return YAe.get(n)},KAe=function(n,e,t){var r=t-2,i=e[r],s=e[t-1],o=e[t];if(s===GI&&o===ZI)return ks;if(s===GI||s===ZI||s===fD||o===GI||o===ZI||o===fD)return YI;if(s===hD&&[hD,JI,pD,gD].indexOf(o)!==-1||(s===pD||s===JI)&&(o===JI||o===HI)||(s===gD||s===HI)&&o===HI||o===mD||o===dD||o===JAe||s===ZAe)return ks;if(s===mD&&o===vD){for(;i===dD;)i=e[--r];if(i===vD)return ks}if(s===zI&&o===zI){for(var a=0;i===zI;)a++,i=e[--r];if(a%2===0)return ks}return YI},jAe=function(n){var e=HAe(n),t=e.length,r=0,i=0,s=e.map(XAe);return{next:function(){if(r>=t)return{done:!0,value:null};for(var o=ks;ro.x||c.y>o.y;return o=c,A===0?!0:u});return n.body.removeChild(e),a},tce=function(){return typeof new Image().crossOrigin<"u"},nce=function(){return typeof new XMLHttpRequest().responseType=="string"},rce=function(n){var e=new Image,t=n.createElement("canvas"),r=t.getContext("2d");if(!r)return!1;e.src="data:image/svg+xml,";try{r.drawImage(e,0,0),t.toDataURL()}catch{return!1}return!0},yD=function(n){return n[0]===0&&n[1]===255&&n[2]===0&&n[3]===255},ice=function(n){var e=n.createElement("canvas"),t=100;e.width=t,e.height=t;var r=e.getContext("2d");if(!r)return Promise.reject(!1);r.fillStyle="rgb(0, 255, 0)",r.fillRect(0,0,t,t);var i=new Image,s=e.toDataURL();i.src=s;var o=JE(t,t,0,0,i);return r.fillStyle="red",r.fillRect(0,0,t,t),BD(o).then(function(a){r.drawImage(a,0,0);var l=r.getImageData(0,0,t,t).data;r.fillStyle="red",r.fillRect(0,0,t,t);var A=n.createElement("div");return A.style.backgroundImage="url("+s+")",A.style.height=t+"px",yD(l)?BD(JE(t,t,0,0,A)):Promise.reject(!1)}).then(function(a){return r.drawImage(a,0,0),yD(r.getImageData(0,0,t,t).data)}).catch(function(){return!1})},JE=function(n,e,t,r,i){var s="http://www.w3.org/2000/svg",o=document.createElementNS(s,"svg"),a=document.createElementNS(s,"foreignObject");return o.setAttributeNS(null,"width",n.toString()),o.setAttributeNS(null,"height",e.toString()),a.setAttributeNS(null,"width","100%"),a.setAttributeNS(null,"height","100%"),a.setAttributeNS(null,"x",t.toString()),a.setAttributeNS(null,"y",r.toString()),a.setAttributeNS(null,"externalResourcesRequired","true"),o.appendChild(a),a.appendChild(i),o},BD=function(n){return new Promise(function(e,t){var r=new Image;r.onload=function(){return e(r)},r.onerror=t,r.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(n))})},Ki={get SUPPORT_RANGE_BOUNDS(){var n=qAe(document);return Object.defineProperty(Ki,"SUPPORT_RANGE_BOUNDS",{value:n}),n},get SUPPORT_WORD_BREAKING(){var n=Ki.SUPPORT_RANGE_BOUNDS&&ece(document);return Object.defineProperty(Ki,"SUPPORT_WORD_BREAKING",{value:n}),n},get SUPPORT_SVG_DRAWING(){var n=rce(document);return Object.defineProperty(Ki,"SUPPORT_SVG_DRAWING",{value:n}),n},get SUPPORT_FOREIGNOBJECT_DRAWING(){var n=typeof Array.from=="function"&&typeof window.fetch=="function"?ice(document):Promise.resolve(!1);return Object.defineProperty(Ki,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:n}),n},get SUPPORT_CORS_IMAGES(){var n=tce();return Object.defineProperty(Ki,"SUPPORT_CORS_IMAGES",{value:n}),n},get SUPPORT_RESPONSE_TYPE(){var n=nce();return Object.defineProperty(Ki,"SUPPORT_RESPONSE_TYPE",{value:n}),n},get SUPPORT_CORS_XHR(){var n="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Ki,"SUPPORT_CORS_XHR",{value:n}),n},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var n=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(Ki,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:n}),n}},zg=function(){function n(e,t){this.text=e,this.bounds=t}return n}(),sce=function(n,e,t,r){var i=lce(e,t),s=[],o=0;return i.forEach(function(a){if(t.textDecorationLine.length||a.trim().length>0)if(Ki.SUPPORT_RANGE_BOUNDS){var l=wD(r,o,a.length).getClientRects();if(l.length>1){var A=J_(a),c=0;A.forEach(function(f){s.push(new zg(f,yu.fromDOMRectList(n,wD(r,c+o,f.length).getClientRects()))),c+=f.length})}else s.push(new zg(a,yu.fromDOMRectList(n,l)))}else{var u=r.splitText(a.length);s.push(new zg(a,oce(n,r))),r=u}else Ki.SUPPORT_RANGE_BOUNDS||(r=r.splitText(a.length));o+=a.length}),s},oce=function(n,e){var t=e.ownerDocument;if(t){var r=t.createElement("html2canvaswrapper");r.appendChild(e.cloneNode(!0));var i=e.parentNode;if(i){i.replaceChild(r,e);var s=P_(n,r);return r.firstChild&&i.replaceChild(r.firstChild,r),s}}return yu.EMPTY},wD=function(n,e,t){var r=n.ownerDocument;if(!r)throw new Error("Node has no owner document");var i=r.createRange();return i.setStart(n,e),i.setEnd(n,e+t),i},J_=function(n){if(Ki.SUPPORT_NATIVE_TEXT_SEGMENTATION){var e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(n)).map(function(t){return t.segment})}return $Ae(n)},ace=function(n,e){if(Ki.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(n)).map(function(r){return r.segment})}return cce(n,e)},lce=function(n,e){return e.letterSpacing!==0?J_(n):ace(n,e)},Ace=[32,160,4961,65792,65793,4153,4241],cce=function(n,e){for(var t=Ooe(n,{lineBreak:e.lineBreak,wordBreak:e.overflowWrap==="break-word"?"break-word":e.wordBreak}),r=[],i,s=function(){if(i.value){var o=i.value.slice(),a=tb(o),l="";a.forEach(function(A){Ace.indexOf(A)===-1?l+=On(A):(l.length&&r.push(l),r.push(On(A)),l="")}),l.length&&r.push(l)}};!(i=t.next()).done;)s();return r},uce=function(){function n(e,t,r){this.text=fce(t.data,r.textTransform),this.textBounds=sce(e,this.text,r,t)}return n}(),fce=function(n,e){switch(e){case 1:return n.toLowerCase();case 3:return n.replace(dce,hce);case 2:return n.toUpperCase();default:return n}},dce=/(^|\s|:|-|\(|\))([a-z])/g,hce=function(n,e,t){return n.length>0?e+t.toUpperCase():n},XJ=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i.src=r.currentSrc||r.src,i.intrinsicWidth=r.naturalWidth,i.intrinsicHeight=r.naturalHeight,i.context.cache.addImage(i.src),i}return e}(Va),KJ=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i.canvas=r,i.intrinsicWidth=r.width,i.intrinsicHeight=r.height,i}return e}(Va),jJ=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this,s=new XMLSerializer,o=P_(t,r);return r.setAttribute("width",o.width+"px"),r.setAttribute("height",o.height+"px"),i.svg="data:image/svg+xml,"+encodeURIComponent(s.serializeToString(r)),i.intrinsicWidth=r.width.baseVal.value,i.intrinsicHeight=r.height.baseVal.value,i.context.cache.addImage(i.svg),i}return e}(Va),$J=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i.value=r.value,i}return e}(Va),HE=function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i.start=r.start,i.reversed=typeof r.reversed=="boolean"&&r.reversed===!0,i}return e}(Va),pce=[{type:15,flags:0,unit:"px",number:3}],gce=[{type:16,flags:0,number:50}],mce=function(n){return n.width>n.height?new yu(n.left+(n.width-n.height)/2,n.top,n.height,n.height):n.width0)t.textNodes.push(new uce(n,i,t.styles));else if(rH(i))if(Tce(i)&&i.assignedNodes)i.assignedNodes().forEach(function(a){return cB(n,a,t,r)});else{var o=nH(n,i);o.styles.isVisible()&&(Cce(i,o,r)?o.flags|=4:bce(o.styles)&&(o.flags|=2),Bce.indexOf(i.tagName)!==-1&&(o.flags|=8),t.elements.push(o),i.slot,i.shadowRoot?cB(n,i.shadowRoot,o,r):!sH(i)&&!iH(i)&&!oH(i)&&cB(n,i,o,r))}},nH=function(n,e){return Rce(e)?new XJ(n,e):Qce(e)?new KJ(n,e):iH(e)?new jJ(n,e):Ece(e)?new $J(n,e):Uce(e)?new HE(n,e):Sce(e)?new H_(n,e):oH(e)?new qJ(n,e):sH(e)?new eH(n,e):Mce(e)?new tH(n,e):new Va(n,e)},wce=function(n,e){var t=nH(n,e);return t.flags|=4,cB(n,e,t,t),t},Cce=function(n,e,t){return e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||_ce(n)&&t.styles.isTransparent()},bce=function(n){return n.isPositioned()||n.isFloating()},xce=function(n){return n.nodeType===Node.TEXT_NODE},rH=function(n){return n.nodeType===Node.ELEMENT_NODE},Ice=function(n){return rH(n)&&typeof n.style<"u"&&!Fce(n)},Fce=function(n){return typeof n.className=="object"},Ece=function(n){return n.tagName==="LI"},Uce=function(n){return n.tagName==="OL"},Sce=function(n){return n.tagName==="INPUT"},iH=function(n){return n.tagName==="svg"},_ce=function(n){return n.tagName==="BODY"},Qce=function(n){return n.tagName==="CANVAS"},Rce=function(n){return n.tagName==="IMG"},Mce=function(n){return n.tagName==="IFRAME"},sH=function(n){return n.tagName==="TEXTAREA"},oH=function(n){return n.tagName==="SELECT"},Tce=function(n){return n.tagName==="SLOT"},bD={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},xD={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},Nce={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},Dce={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},gf=function(n,e,t,r,i,s){return nt?z_(n,i,s.length>0):r.integers.reduce(function(o,a,l){for(;n>=a;)n-=a,o+=r.values[l];return o},"")+s},aH=function(n,e,t,r){var i="";do t||n--,i=r(n)+i,n/=e;while(n*e>=e);return i},Wn=function(n,e,t,r,i){var s=t-e+1;return(n<0?"-":"")+(aH(Math.abs(n),s,r,function(o){return On(Math.floor(o%s)+e)})+i)},xc=function(n,e,t){t===void 0&&(t=". ");var r=e.length;return aH(Math.abs(n),r,!1,function(i){return e[Math.floor(i%r)]})+t},Nf=1,cA=2,uA=4,Bg=8,Ka=function(n,e,t,r,i,s){if(n<-9999||n>9999)return z_(n,4,i.length>0);var o=Math.abs(n),a=i;if(o===0)return e[0]+a;for(var l=0;o>0&&l<=4;l++){var A=o%10;A===0&&dr(s,Nf)&&a!==""?a=e[A]+a:A>1||A===1&&l===0||A===1&&l===1&&dr(s,cA)||A===1&&l===1&&dr(s,uA)&&n>100||A===1&&l>1&&dr(s,Bg)?a=e[A]+(l>0?t[l-1]:"")+a:A===1&&l>0&&(a=t[l-1]+a),o=Math.floor(o/10)}return(n<0?r:"")+a},ID="十百千萬",FD="拾佰仟萬",ED="マイナス",XI="마이너스",z_=function(n,e,t){var r=t?". ":"",i=t?"、":"",s=t?", ":"",o=t?" ":"";switch(e){case 0:return"•"+o;case 1:return"◦"+o;case 2:return"◾"+o;case 5:var a=Wn(n,48,57,!0,r);return a.length<4?"0"+a:a;case 4:return xc(n,"〇一二三四五六七八九",i);case 6:return gf(n,1,3999,bD,3,r).toLowerCase();case 7:return gf(n,1,3999,bD,3,r);case 8:return Wn(n,945,969,!1,r);case 9:return Wn(n,97,122,!1,r);case 10:return Wn(n,65,90,!1,r);case 11:return Wn(n,1632,1641,!0,r);case 12:case 49:return gf(n,1,9999,xD,3,r);case 35:return gf(n,1,9999,xD,3,r).toLowerCase();case 13:return Wn(n,2534,2543,!0,r);case 14:case 30:return Wn(n,6112,6121,!0,r);case 15:return xc(n,"子丑寅卯辰巳午未申酉戌亥",i);case 16:return xc(n,"甲乙丙丁戊己庚辛壬癸",i);case 17:case 48:return Ka(n,"零一二三四五六七八九",ID,"負",i,cA|uA|Bg);case 47:return Ka(n,"零壹貳參肆伍陸柒捌玖",FD,"負",i,Nf|cA|uA|Bg);case 42:return Ka(n,"零一二三四五六七八九",ID,"负",i,cA|uA|Bg);case 41:return Ka(n,"零壹贰叁肆伍陆柒捌玖",FD,"负",i,Nf|cA|uA|Bg);case 26:return Ka(n,"〇一二三四五六七八九","十百千万",ED,i,0);case 25:return Ka(n,"零壱弐参四伍六七八九","拾百千万",ED,i,Nf|cA|uA);case 31:return Ka(n,"영일이삼사오육칠팔구","십백천만",XI,s,Nf|cA|uA);case 33:return Ka(n,"零一二三四五六七八九","十百千萬",XI,s,0);case 32:return Ka(n,"零壹貳參四五六七八九","拾百千",XI,s,Nf|cA|uA);case 18:return Wn(n,2406,2415,!0,r);case 20:return gf(n,1,19999,Dce,3,r);case 21:return Wn(n,2790,2799,!0,r);case 22:return Wn(n,2662,2671,!0,r);case 22:return gf(n,1,10999,Nce,3,r);case 23:return xc(n,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return xc(n,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return Wn(n,3302,3311,!0,r);case 28:return xc(n,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",i);case 29:return xc(n,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",i);case 34:return Wn(n,3792,3801,!0,r);case 37:return Wn(n,6160,6169,!0,r);case 38:return Wn(n,4160,4169,!0,r);case 39:return Wn(n,2918,2927,!0,r);case 40:return Wn(n,1776,1785,!0,r);case 43:return Wn(n,3046,3055,!0,r);case 44:return Wn(n,3174,3183,!0,r);case 45:return Wn(n,3664,3673,!0,r);case 46:return Wn(n,3872,3881,!0,r);case 3:default:return Wn(n,48,57,!0,r)}},UD;(function(n){n[n.BEFORE=0]="BEFORE",n[n.AFTER=1]="AFTER"})(UD||(UD={}));var kce=function(){function n(){}return n.getOrigin=function(e){var t=n._link;return t?(t.href=e,t.href=t.href,t.protocol+t.hostname+t.port):"about:blank"},n.isSameOrigin=function(e){return n.getOrigin(e)===n._origin},n.setContext=function(e){n._link=e.document.createElement("a"),n._origin=n.getOrigin(e.location.href)},n._origin="about:blank",n}(),Pe=function(){function n(e,t){this.type=0,this.x=e,this.y=t}return n.prototype.add=function(e,t){return new n(this.x+e,this.y+t)},n}(),mf=function(n,e,t){return new Pe(n.x+(e.x-n.x)*t,n.y+(e.y-n.y)*t)},jv=function(){function n(e,t,r,i){this.type=1,this.start=e,this.startControl=t,this.endControl=r,this.end=i}return n.prototype.subdivide=function(e,t){var r=mf(this.start,this.startControl,e),i=mf(this.startControl,this.endControl,e),s=mf(this.endControl,this.end,e),o=mf(r,i,e),a=mf(i,s,e),l=mf(o,a,e);return t?new n(this.start,r,o,l):new n(l,a,s,this.end)},n.prototype.add=function(e,t){return new n(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))},n.prototype.reverse=function(){return new n(this.end,this.endControl,this.startControl,this.start)},n}(),Ws=function(n){return n.type===1},Vce=function(){function n(e){var t=e.styles,r=e.bounds,i=vg(t.borderTopLeftRadius,r.width,r.height),s=i[0],o=i[1],a=vg(t.borderTopRightRadius,r.width,r.height),l=a[0],A=a[1],c=vg(t.borderBottomRightRadius,r.width,r.height),u=c[0],f=c[1],d=vg(t.borderBottomLeftRadius,r.width,r.height),h=d[0],p=d[1],m=[];m.push((s+l)/r.width),m.push((h+u)/r.width),m.push((o+p)/r.height),m.push((A+f)/r.height);var g=Math.max.apply(Math,m);g>1&&(s/=g,o/=g,l/=g,A/=g,u/=g,f/=g,h/=g,p/=g);var v=r.width-l,y=r.height-f,w=r.width-u,C=r.height-p,b=t.borderTopWidth,E=t.borderRightWidth,x=t.borderBottomWidth,S=t.borderLeftWidth,M=un(t.paddingTop,e.bounds.width),Z=un(t.paddingRight,e.bounds.width),K=un(t.paddingBottom,e.bounds.width),_=un(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=s>0||o>0?yn(r.left+S/3,r.top+b/3,s-S/3,o-b/3,Kt.TOP_LEFT):new Pe(r.left+S/3,r.top+b/3),this.topRightBorderDoubleOuterBox=s>0||o>0?yn(r.left+v,r.top+b/3,l-E/3,A-b/3,Kt.TOP_RIGHT):new Pe(r.left+r.width-E/3,r.top+b/3),this.bottomRightBorderDoubleOuterBox=u>0||f>0?yn(r.left+w,r.top+y,u-E/3,f-x/3,Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-E/3,r.top+r.height-x/3),this.bottomLeftBorderDoubleOuterBox=h>0||p>0?yn(r.left+S/3,r.top+C,h-S/3,p-x/3,Kt.BOTTOM_LEFT):new Pe(r.left+S/3,r.top+r.height-x/3),this.topLeftBorderDoubleInnerBox=s>0||o>0?yn(r.left+S*2/3,r.top+b*2/3,s-S*2/3,o-b*2/3,Kt.TOP_LEFT):new Pe(r.left+S*2/3,r.top+b*2/3),this.topRightBorderDoubleInnerBox=s>0||o>0?yn(r.left+v,r.top+b*2/3,l-E*2/3,A-b*2/3,Kt.TOP_RIGHT):new Pe(r.left+r.width-E*2/3,r.top+b*2/3),this.bottomRightBorderDoubleInnerBox=u>0||f>0?yn(r.left+w,r.top+y,u-E*2/3,f-x*2/3,Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-E*2/3,r.top+r.height-x*2/3),this.bottomLeftBorderDoubleInnerBox=h>0||p>0?yn(r.left+S*2/3,r.top+C,h-S*2/3,p-x*2/3,Kt.BOTTOM_LEFT):new Pe(r.left+S*2/3,r.top+r.height-x*2/3),this.topLeftBorderStroke=s>0||o>0?yn(r.left+S/2,r.top+b/2,s-S/2,o-b/2,Kt.TOP_LEFT):new Pe(r.left+S/2,r.top+b/2),this.topRightBorderStroke=s>0||o>0?yn(r.left+v,r.top+b/2,l-E/2,A-b/2,Kt.TOP_RIGHT):new Pe(r.left+r.width-E/2,r.top+b/2),this.bottomRightBorderStroke=u>0||f>0?yn(r.left+w,r.top+y,u-E/2,f-x/2,Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-E/2,r.top+r.height-x/2),this.bottomLeftBorderStroke=h>0||p>0?yn(r.left+S/2,r.top+C,h-S/2,p-x/2,Kt.BOTTOM_LEFT):new Pe(r.left+S/2,r.top+r.height-x/2),this.topLeftBorderBox=s>0||o>0?yn(r.left,r.top,s,o,Kt.TOP_LEFT):new Pe(r.left,r.top),this.topRightBorderBox=l>0||A>0?yn(r.left+v,r.top,l,A,Kt.TOP_RIGHT):new Pe(r.left+r.width,r.top),this.bottomRightBorderBox=u>0||f>0?yn(r.left+w,r.top+y,u,f,Kt.BOTTOM_RIGHT):new Pe(r.left+r.width,r.top+r.height),this.bottomLeftBorderBox=h>0||p>0?yn(r.left,r.top+C,h,p,Kt.BOTTOM_LEFT):new Pe(r.left,r.top+r.height),this.topLeftPaddingBox=s>0||o>0?yn(r.left+S,r.top+b,Math.max(0,s-S),Math.max(0,o-b),Kt.TOP_LEFT):new Pe(r.left+S,r.top+b),this.topRightPaddingBox=l>0||A>0?yn(r.left+Math.min(v,r.width-E),r.top+b,v>r.width+E?0:Math.max(0,l-E),Math.max(0,A-b),Kt.TOP_RIGHT):new Pe(r.left+r.width-E,r.top+b),this.bottomRightPaddingBox=u>0||f>0?yn(r.left+Math.min(w,r.width-S),r.top+Math.min(y,r.height-x),Math.max(0,u-E),Math.max(0,f-x),Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-E,r.top+r.height-x),this.bottomLeftPaddingBox=h>0||p>0?yn(r.left+S,r.top+Math.min(C,r.height-x),Math.max(0,h-S),Math.max(0,p-x),Kt.BOTTOM_LEFT):new Pe(r.left+S,r.top+r.height-x),this.topLeftContentBox=s>0||o>0?yn(r.left+S+_,r.top+b+M,Math.max(0,s-(S+_)),Math.max(0,o-(b+M)),Kt.TOP_LEFT):new Pe(r.left+S+_,r.top+b+M),this.topRightContentBox=l>0||A>0?yn(r.left+Math.min(v,r.width+S+_),r.top+b+M,v>r.width+S+_?0:l-S+_,A-(b+M),Kt.TOP_RIGHT):new Pe(r.left+r.width-(E+Z),r.top+b+M),this.bottomRightContentBox=u>0||f>0?yn(r.left+Math.min(w,r.width-(S+_)),r.top+Math.min(y,r.height+b+M),Math.max(0,u-(E+Z)),f-(x+K),Kt.BOTTOM_RIGHT):new Pe(r.left+r.width-(E+Z),r.top+r.height-(x+K)),this.bottomLeftContentBox=h>0||p>0?yn(r.left+S+_,r.top+C,Math.max(0,h-(S+_)),p-(x+K),Kt.BOTTOM_LEFT):new Pe(r.left+S+_,r.top+r.height-(x+K))}return n}(),Kt;(function(n){n[n.TOP_LEFT=0]="TOP_LEFT",n[n.TOP_RIGHT=1]="TOP_RIGHT",n[n.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",n[n.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(Kt||(Kt={}));var yn=function(n,e,t,r,i){var s=4*((Math.sqrt(2)-1)/3),o=t*s,a=r*s,l=n+t,A=e+r;switch(i){case Kt.TOP_LEFT:return new jv(new Pe(n,A),new Pe(n,A-a),new Pe(l-o,e),new Pe(l,e));case Kt.TOP_RIGHT:return new jv(new Pe(n,e),new Pe(n+o,e),new Pe(l,A-a),new Pe(l,A));case Kt.BOTTOM_RIGHT:return new jv(new Pe(l,e),new Pe(l,e+a),new Pe(n+o,A),new Pe(n,A));case Kt.BOTTOM_LEFT:default:return new jv(new Pe(l,A),new Pe(l-o,A),new Pe(n,e+a),new Pe(n,e))}},Tw=function(n){return[n.topLeftBorderBox,n.topRightBorderBox,n.bottomRightBorderBox,n.bottomLeftBorderBox]},Lce=function(n){return[n.topLeftContentBox,n.topRightContentBox,n.bottomRightContentBox,n.bottomLeftContentBox]},Nw=function(n){return[n.topLeftPaddingBox,n.topRightPaddingBox,n.bottomRightPaddingBox,n.bottomLeftPaddingBox]},Pce=function(){function n(e,t,r){this.offsetX=e,this.offsetY=t,this.matrix=r,this.type=0,this.target=6}return n}(),$v=function(){function n(e,t){this.path=e,this.target=t,this.type=1}return n}(),Wce=function(){function n(e){this.opacity=e,this.type=2,this.target=6}return n}(),Oce=function(n){return n.type===0},lH=function(n){return n.type===1},Gce=function(n){return n.type===2},SD=function(n,e){return n.length===e.length?n.some(function(t,r){return t===e[r]}):!1},Zce=function(n,e,t,r,i){return n.map(function(s,o){switch(o){case 0:return s.add(e,t);case 1:return s.add(e+r,t);case 2:return s.add(e+r,t+i);case 3:return s.add(e,t+i)}return s})},AH=function(){function n(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return n}(),cH=function(){function n(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new Vce(this.container),this.container.styles.opacity<1&&this.effects.push(new Wce(this.container.styles.opacity)),this.container.styles.transform!==null){var r=this.container.bounds.left+this.container.styles.transformOrigin[0].number,i=this.container.bounds.top+this.container.styles.transformOrigin[1].number,s=this.container.styles.transform;this.effects.push(new Pce(r,i,s))}if(this.container.styles.overflowX!==0){var o=Tw(this.curves),a=Nw(this.curves);SD(o,a)?this.effects.push(new $v(o,6)):(this.effects.push(new $v(o,2)),this.effects.push(new $v(a,4)))}}return n.prototype.getEffects=function(e){for(var t=[2,3].indexOf(this.container.styles.position)===-1,r=this.parent,i=this.effects.slice(0);r;){var s=r.effects.filter(function(l){return!lH(l)});if(t||r.container.styles.position!==0||!r.parent){if(i.unshift.apply(i,s),t=[2,3].indexOf(r.container.styles.position)===-1,r.container.styles.overflowX!==0){var o=Tw(r.curves),a=Nw(r.curves);SD(o,a)||i.unshift(new $v(a,6))}}else i.unshift.apply(i,s);r=r.parent}return i.filter(function(l){return dr(l.target,e)})},n}(),zE=function(n,e,t,r){n.container.elements.forEach(function(i){var s=dr(i.flags,4),o=dr(i.flags,2),a=new cH(i,n);dr(i.styles.display,2048)&&r.push(a);var l=dr(i.flags,8)?[]:r;if(s||o){var A=s||i.styles.isPositioned()?t:e,c=new AH(a);if(i.styles.isPositioned()||i.styles.opacity<1||i.styles.isTransformed()){var u=i.styles.zIndex.order;if(u<0){var f=0;A.negativeZIndex.some(function(h,p){return u>h.element.container.styles.zIndex.order?(f=p,!1):f>0}),A.negativeZIndex.splice(f,0,c)}else if(u>0){var d=0;A.positiveZIndex.some(function(h,p){return u>=h.element.container.styles.zIndex.order?(d=p+1,!1):d>0}),A.positiveZIndex.splice(d,0,c)}else A.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else i.styles.isFloating()?A.nonPositionedFloats.push(c):A.nonPositionedInlineLevel.push(c);zE(a,c,s?c:t,l)}else i.styles.isInlineLevel()?e.inlineLevel.push(a):e.nonInlineLevel.push(a),zE(a,e,t,l);dr(i.flags,8)&&uH(i,l)})},uH=function(n,e){for(var t=n instanceof HE?n.start:1,r=n instanceof HE?n.reversed:!1,i=0;i"u"?n[0]:t},$ce=function(n,e,t,r,i){var s=e[0],o=e[1],a=t[0],l=t[1];switch(n){case 2:return[new Pe(Math.round(r.left),Math.round(r.top+o)),new Pe(Math.round(r.left+r.width),Math.round(r.top+o)),new Pe(Math.round(r.left+r.width),Math.round(l+r.top+o)),new Pe(Math.round(r.left),Math.round(l+r.top+o))];case 3:return[new Pe(Math.round(r.left+s),Math.round(r.top)),new Pe(Math.round(r.left+s+a),Math.round(r.top)),new Pe(Math.round(r.left+s+a),Math.round(r.height+r.top)),new Pe(Math.round(r.left+s),Math.round(r.height+r.top))];case 1:return[new Pe(Math.round(r.left+s),Math.round(r.top+o)),new Pe(Math.round(r.left+s+a),Math.round(r.top+o)),new Pe(Math.round(r.left+s+a),Math.round(r.top+o+l)),new Pe(Math.round(r.left+s),Math.round(r.top+o+l))];default:return[new Pe(Math.round(i.left),Math.round(i.top)),new Pe(Math.round(i.left+i.width),Math.round(i.top)),new Pe(Math.round(i.left+i.width),Math.round(i.height+i.top)),new Pe(Math.round(i.left),Math.round(i.height+i.top))]}},qce="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",QD="Hidden Text",eue=function(){function n(e){this._data={},this._document=e}return n.prototype.parseMetrics=function(e,t){var r=this._document.createElement("div"),i=this._document.createElement("img"),s=this._document.createElement("span"),o=this._document.body;r.style.visibility="hidden",r.style.fontFamily=e,r.style.fontSize=t,r.style.margin="0",r.style.padding="0",r.style.whiteSpace="nowrap",o.appendChild(r),i.src=qce,i.width=1,i.height=1,i.style.margin="0",i.style.padding="0",i.style.verticalAlign="baseline",s.style.fontFamily=e,s.style.fontSize=t,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode(QD)),r.appendChild(s),r.appendChild(i);var a=i.offsetTop-s.offsetTop+2;r.removeChild(s),r.appendChild(this._document.createTextNode(QD)),r.style.lineHeight="normal",i.style.verticalAlign="super";var l=i.offsetTop-r.offsetTop+2;return o.removeChild(r),{baseline:a,middle:l}},n.prototype.getMetrics=function(e,t){var r=e+" "+t;return typeof this._data[r]>"u"&&(this._data[r]=this.parseMetrics(e,t)),this._data[r]},n}(),dH=function(){function n(e,t){this.context=e,this.options=t}return n}(),tue=1e4;(function(n){Lo(e,n);function e(t,r){var i=n.call(this,t,r)||this;return i._activeEffects=[],i.canvas=r.canvas?r.canvas:document.createElement("canvas"),i.ctx=i.canvas.getContext("2d"),r.canvas||(i.canvas.width=Math.floor(r.width*r.scale),i.canvas.height=Math.floor(r.height*r.scale),i.canvas.style.width=r.width+"px",i.canvas.style.height=r.height+"px"),i.fontMetrics=new eue(document),i.ctx.scale(i.options.scale,i.options.scale),i.ctx.translate(-r.x,-r.y),i.ctx.textBaseline="bottom",i._activeEffects=[],i.context.logger.debug("Canvas renderer initialized ("+r.width+"x"+r.height+") with scale "+r.scale),i}return e.prototype.applyEffects=function(t){for(var r=this;this._activeEffects.length;)this.popEffect();t.forEach(function(i){return r.applyEffect(i)})},e.prototype.applyEffect=function(t){this.ctx.save(),Gce(t)&&(this.ctx.globalAlpha=t.opacity),Oce(t)&&(this.ctx.translate(t.offsetX,t.offsetY),this.ctx.transform(t.matrix[0],t.matrix[1],t.matrix[2],t.matrix[3],t.matrix[4],t.matrix[5]),this.ctx.translate(-t.offsetX,-t.offsetY)),lH(t)&&(this.path(t.path),this.ctx.clip()),this._activeEffects.push(t)},e.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},e.prototype.renderStack=function(t){return Rs(this,void 0,void 0,function(){var r;return Ji(this,function(i){switch(i.label){case 0:return r=t.element.container.styles,r.isVisible()?[4,this.renderStackContent(t)]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}})})},e.prototype.renderNode=function(t){return Rs(this,void 0,void 0,function(){return Ji(this,function(r){switch(r.label){case 0:if(dr(t.container.flags,16))debugger;return t.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(t)]:[3,3];case 1:return r.sent(),[4,this.renderNodeContent(t)];case 2:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.renderTextWithLetterSpacing=function(t,r,i){var s=this;if(r===0)this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+i);else{var o=J_(t.text);o.reduce(function(a,l){return s.ctx.fillText(l,a,t.bounds.top+i),a+s.ctx.measureText(l).width},t.bounds.left)}},e.prototype.createFontStyle=function(t){var r=t.fontVariant.filter(function(o){return o==="normal"||o==="small-caps"}).join(""),i=oue(t.fontFamily).join(", "),s=v0(t.fontSize)?""+t.fontSize.number+t.fontSize.unit:t.fontSize.number+"px";return[[t.fontStyle,r,t.fontWeight,s,i].join(" "),i,s]},e.prototype.renderTextNode=function(t,r){return Rs(this,void 0,void 0,function(){var i,s,o,a,l,A,c,u,f=this;return Ji(this,function(d){return i=this.createFontStyle(r),s=i[0],o=i[1],a=i[2],this.ctx.font=s,this.ctx.direction=r.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",l=this.fontMetrics.getMetrics(o,a),A=l.baseline,c=l.middle,u=r.paintOrder,t.textBounds.forEach(function(h){u.forEach(function(p){switch(p){case 0:f.ctx.fillStyle=vr(r.color),f.renderTextWithLetterSpacing(h,r.letterSpacing,A);var m=r.textShadow;m.length&&h.text.trim().length&&(m.slice(0).reverse().forEach(function(g){f.ctx.shadowColor=vr(g.color),f.ctx.shadowOffsetX=g.offsetX.number*f.options.scale,f.ctx.shadowOffsetY=g.offsetY.number*f.options.scale,f.ctx.shadowBlur=g.blur.number,f.renderTextWithLetterSpacing(h,r.letterSpacing,A)}),f.ctx.shadowColor="",f.ctx.shadowOffsetX=0,f.ctx.shadowOffsetY=0,f.ctx.shadowBlur=0),r.textDecorationLine.length&&(f.ctx.fillStyle=vr(r.textDecorationColor||r.color),r.textDecorationLine.forEach(function(g){switch(g){case 1:f.ctx.fillRect(h.bounds.left,Math.round(h.bounds.top+A),h.bounds.width,1);break;case 2:f.ctx.fillRect(h.bounds.left,Math.round(h.bounds.top),h.bounds.width,1);break;case 3:f.ctx.fillRect(h.bounds.left,Math.ceil(h.bounds.top+c),h.bounds.width,1);break}}));break;case 1:r.webkitTextStrokeWidth&&h.text.trim().length&&(f.ctx.strokeStyle=vr(r.webkitTextStrokeColor),f.ctx.lineWidth=r.webkitTextStrokeWidth,f.ctx.lineJoin=window.chrome?"miter":"round",f.ctx.strokeText(h.text,h.bounds.left,h.bounds.top+A)),f.ctx.strokeStyle="",f.ctx.lineWidth=0,f.ctx.lineJoin="miter";break}})}),[2]})})},e.prototype.renderReplacedElement=function(t,r,i){if(i&&t.intrinsicWidth>0&&t.intrinsicHeight>0){var s=Dw(t),o=Nw(r);this.path(o),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,t.intrinsicWidth,t.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},e.prototype.renderNodeContent=function(t){return Rs(this,void 0,void 0,function(){var r,i,s,o,a,l,v,v,A,c,u,f,w,d,h,C,p,m,g,v,y,w,C;return Ji(this,function(b){switch(b.label){case 0:this.applyEffects(t.getEffects(4)),r=t.container,i=t.curves,s=r.styles,o=0,a=r.textNodes,b.label=1;case 1:return o0&&B>0&&(x=s.ctx.createPattern(C,"repeat"),s.renderRepeat(M,x,R,k))):sle(c)&&(S=KI(t,r,[null,null,null]),M=S[0],Z=S[1],K=S[2],_=S[3],B=S[4],F=c.position.length===0?[O_]:c.position,R=un(F[0],_),k=un(F[F.length-1],B),T=ele(c,R,k,_,B),V=T[0],O=T[1],V>0&&O>0&&(L=s.ctx.createRadialGradient(Z+R,K+k,0,Z+R,K+k,V),iD(c.stops,V*2).forEach(function(oe){return L.addColorStop(oe.stop,vr(oe.color))}),s.path(M),s.ctx.fillStyle=L,V!==O?(U=t.bounds.left+.5*t.bounds.width,H=t.bounds.top+.5*t.bounds.height,le=O/V,N=1/le,s.ctx.save(),s.ctx.translate(U,H),s.ctx.transform(1,0,0,le,0,0),s.ctx.translate(-U,-H),s.ctx.fillRect(Z,N*(K-H)+H,_,B*N),s.ctx.restore()):s.ctx.fill())),j.label=6;case 6:return r--,[2]}})},s=this,o=0,a=t.styles.backgroundImage.slice(0).reverse(),A.label=1;case 1:return o0?c.style!==2?[3,5]:[4,this.renderDashedDottedBorder(c.color,c.width,a,t.curves,2)]:[3,11]):[3,13];case 4:return f.sent(),[3,11];case 5:return c.style!==3?[3,7]:[4,this.renderDashedDottedBorder(c.color,c.width,a,t.curves,3)];case 6:return f.sent(),[3,11];case 7:return c.style!==4?[3,9]:[4,this.renderDoubleBorder(c.color,c.width,a,t.curves)];case 8:return f.sent(),[3,11];case 9:return[4,this.renderSolidBorder(c.color,a,t.curves)];case 10:f.sent(),f.label=11;case 11:a++,f.label=12;case 12:return l++,[3,3];case 13:return[2]}})})},e.prototype.renderDashedDottedBorder=function(t,r,i,s,o){return Rs(this,void 0,void 0,function(){var a,l,A,c,u,f,d,h,p,m,g,v,y,w,C,b,C,b;return Ji(this,function(E){return this.ctx.save(),a=Yce(s,i),l=_D(s,i),o===2&&(this.path(l),this.ctx.clip()),Ws(l[0])?(A=l[0].start.x,c=l[0].start.y):(A=l[0].x,c=l[0].y),Ws(l[1])?(u=l[1].end.x,f=l[1].end.y):(u=l[1].x,f=l[1].y),i===0||i===2?d=Math.abs(A-u):d=Math.abs(c-f),this.ctx.beginPath(),o===3?this.formatPath(a):this.formatPath(l.slice(0,2)),h=r<3?r*3:r*2,p=r<3?r*2:r,o===3&&(h=r,p=r),m=!0,d<=h*2?m=!1:d<=h*2+p?(g=d/(2*h+p),h*=g,p*=g):(v=Math.floor((d+p)/(h+p)),y=(d-v*h)/(v-1),w=(d-(v+1)*h)/v,p=w<=0||Math.abs(p-y){var a,l;const A=(a=t.materials)===null||a===void 0?void 0:a[o];if(A==null){console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${o}] of glTF but the material doesn't exist`);return}if(s.shader==="VRM/MToon"){const c=this._parseV0MToonProperties(s,A);t.materials[o]=c}else if(!((l=s.shader)===null||l===void 0)&&l.startsWith("VRM/Unlit")){const c=this._parseV0UnlitProperties(s,A);t.materials[o]=c}else s.shader==="VRM_USE_GLTFSHADER"||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${s.shader}`)}))})}_parseV0MToonProperties(e,t){var r,i,s,o,a,l,A,c,u,f,d,h,p,m,g,v,y,w,C,b,E,x,S,M,Z,K,_,B,F,R,k,T,V,O,L,U,H,Ae,N,j,oe,ie,de,X;const ne=(i=(r=e.keywordMap)===null||r===void 0?void 0:r._ALPHABLEND_ON)!==null&&i!==void 0?i:!1,Be=((s=e.floatProperties)===null||s===void 0?void 0:s._ZWrite)===1&&ne,pe=this._v0ParseRenderQueue(e),Fe=(a=(o=e.keywordMap)===null||o===void 0?void 0:o._ALPHATEST_ON)!==null&&a!==void 0?a:!1,rt=ne?"BLEND":Fe?"MASK":"OPAQUE",Oe=Fe?(l=e.floatProperties)===null||l===void 0?void 0:l._Cutoff:void 0,Qe=((c=(A=e.floatProperties)===null||A===void 0?void 0:A._CullMode)!==null&&c!==void 0?c:2)===0,Ge=this._portTextureTransform(e),Xe=(f=(u=e.vectorProperties)===null||u===void 0?void 0:u._Color)===null||f===void 0?void 0:f.map((ge,Ne)=>Ne===3?ge:Bf(ge)),G=(d=e.textureProperties)===null||d===void 0?void 0:d._MainTex,J=G!=null?{index:G,extensions:Object.assign({},Ge)}:void 0,se=(h=e.floatProperties)===null||h===void 0?void 0:h._BumpScale,fe=(p=e.textureProperties)===null||p===void 0?void 0:p._BumpMap,ve=fe!=null?{index:fe,scale:se,extensions:Object.assign({},Ge)}:void 0,W=(g=(m=e.vectorProperties)===null||m===void 0?void 0:m._EmissionColor)===null||g===void 0?void 0:g.map(Bf),Q=(v=e.textureProperties)===null||v===void 0?void 0:v._EmissionMap,I=Q!=null?{index:Q,extensions:Object.assign({},Ge)}:void 0,D=(w=(y=e.vectorProperties)===null||y===void 0?void 0:y._ShadeColor)===null||w===void 0?void 0:w.map(Bf),$=(C=e.textureProperties)===null||C===void 0?void 0:C._ShadeTexture,ee=$!=null?{index:$,extensions:Object.assign({},Ge)}:void 0;let te=(E=(b=e.floatProperties)===null||b===void 0?void 0:b._ShadeShift)!==null&&E!==void 0?E:0,we=(S=(x=e.floatProperties)===null||x===void 0?void 0:x._ShadeToony)!==null&&S!==void 0?S:.9;we=Wt.lerp(we,1,.5+.5*te),te=-te-(1-we);const Ce=(M=e.floatProperties)===null||M===void 0?void 0:M._IndirectLightIntensity,Ee=Ce?1-Ce:void 0,Ve=(Z=e.textureProperties)===null||Z===void 0?void 0:Z._SphereAdd,_e=Ve!=null?[1,1,1]:void 0,re=Ve!=null?{index:Ve}:void 0,ye=(K=e.floatProperties)===null||K===void 0?void 0:K._RimLightingMix,be=(_=e.textureProperties)===null||_===void 0?void 0:_._RimTexture,Ue=be!=null?{index:be,extensions:Object.assign({},Ge)}:void 0,Je=(F=(B=e.vectorProperties)===null||B===void 0?void 0:B._RimColor)===null||F===void 0?void 0:F.map(Bf),qe=(R=e.floatProperties)===null||R===void 0?void 0:R._RimFresnelPower,ct=(k=e.floatProperties)===null||k===void 0?void 0:k._RimLift,An=["none","worldCoordinates","screenCoordinates"][(V=(T=e.floatProperties)===null||T===void 0?void 0:T._OutlineWidthMode)!==null&&V!==void 0?V:0];let xt=(L=(O=e.floatProperties)===null||O===void 0?void 0:O._OutlineWidth)!==null&&L!==void 0?L:0;xt=.01*xt;const st=(U=e.textureProperties)===null||U===void 0?void 0:U._OutlineWidthTexture,or=st!=null?{index:st,extensions:Object.assign({},Ge)}:void 0,mt=(Ae=(H=e.vectorProperties)===null||H===void 0?void 0:H._OutlineColor)===null||Ae===void 0?void 0:Ae.map(Bf),co=((N=e.floatProperties)===null||N===void 0?void 0:N._OutlineColorMode)===1?(j=e.floatProperties)===null||j===void 0?void 0:j._OutlineLightingMix:0,Xt=(oe=e.textureProperties)===null||oe===void 0?void 0:oe._UvAnimMaskTexture,en=Xt!=null?{index:Xt,extensions:Object.assign({},Ge)}:void 0,q=(ie=e.floatProperties)===null||ie===void 0?void 0:ie._UvAnimScrollX;let le=(de=e.floatProperties)===null||de===void 0?void 0:de._UvAnimScrollY;le!=null&&(le=-le);const he=(X=e.floatProperties)===null||X===void 0?void 0:X._UvAnimRotation,ue={specVersion:"1.0",transparentWithZWrite:Be,renderQueueOffsetNumber:pe,shadeColorFactor:D,shadeMultiplyTexture:ee,shadingShiftFactor:te,shadingToonyFactor:we,giEqualizationFactor:Ee,matcapFactor:_e,matcapTexture:re,rimLightingMixFactor:ye,rimMultiplyTexture:Ue,parametricRimColorFactor:Je,parametricRimFresnelPowerFactor:qe,parametricRimLiftFactor:ct,outlineWidthMode:An,outlineWidthFactor:xt,outlineWidthMultiplyTexture:or,outlineColorFactor:mt,outlineLightingMixFactor:co,uvAnimationMaskTexture:en,uvAnimationScrollXSpeedFactor:q,uvAnimationScrollYSpeedFactor:le,uvAnimationRotationSpeedFactor:he};return Object.assign(Object.assign({},t),{pbrMetallicRoughness:{baseColorFactor:Xe,baseColorTexture:J},normalTexture:ve,emissiveTexture:I,emissiveFactor:W,alphaMode:rt,alphaCutoff:Oe,doubleSided:Qe,extensions:{VRMC_materials_mtoon:ue}})}_parseV0UnlitProperties(e,t){var r,i,s,o;const a=e.shader==="VRM/UnlitTransparentZWrite",l=e.shader==="VRM/UnlitTransparent"||a,A=this._v0ParseRenderQueue(e),c=e.shader==="VRM/UnlitCutout",u=l?"BLEND":c?"MASK":"OPAQUE",f=c?(r=e.floatProperties)===null||r===void 0?void 0:r._Cutoff:void 0,d=this._portTextureTransform(e),h=(s=(i=e.vectorProperties)===null||i===void 0?void 0:i._Color)===null||s===void 0?void 0:s.map(Bf),p=(o=e.textureProperties)===null||o===void 0?void 0:o._MainTex,m=p!=null?{index:p,extensions:Object.assign({},d)}:void 0,g={specVersion:"1.0",transparentWithZWrite:a,renderQueueOffsetNumber:A,shadeColorFactor:h,shadeMultiplyTexture:m};return Object.assign(Object.assign({},t),{pbrMetallicRoughness:{baseColorFactor:h,baseColorTexture:m},alphaMode:u,alphaCutoff:f,extensions:{VRMC_materials_mtoon:g}})}_portTextureTransform(e){var t,r,i,s,o;const a=(t=e.vectorProperties)===null||t===void 0?void 0:t._MainTex;if(a==null)return{};const l=[(r=a==null?void 0:a[0])!==null&&r!==void 0?r:0,(i=a==null?void 0:a[1])!==null&&i!==void 0?i:0],A=[(s=a==null?void 0:a[2])!==null&&s!==void 0?s:1,(o=a==null?void 0:a[3])!==null&&o!==void 0?o:1];return l[1]=A[1]*(1-l[1])%1,{KHR_texture_transform:{offset:l,scale:A}}}_v0ParseRenderQueue(e){var t,r,i;const s=(r=(t=e.keywordMap)===null||t===void 0?void 0:t._ALPHABLEND_ON)!==null&&r!==void 0?r:!1,o=((i=e.floatProperties)===null||i===void 0?void 0:i._ZWrite)===1;let a=0;if(s){const l=e.renderQueue;l!=null&&(o?a=this._renderQueueMapTransparentZWrite.get(l):a=this._renderQueueMapTransparent.get(l))}return a}_populateRenderQueueMap(e){const t=new Set,r=new Set;e.forEach(i=>{var s,o,a;const l=(o=(s=i.keywordMap)===null||s===void 0?void 0:s._ALPHABLEND_ON)!==null&&o!==void 0?o:!1,A=((a=i.floatProperties)===null||a===void 0?void 0:a._ZWrite)===1;if(l){const c=i.renderQueue;c!=null&&(A?r.add(c):t.add(c))}}),t.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${t.size} render queues for Transparent materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),r.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${r.size} render queues for TransparentZWrite materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),Array.from(t).sort().forEach((i,s)=>{const o=Math.min(Math.max(s-t.size+1,-9),0);this._renderQueueMapTransparent.set(i,o)}),Array.from(r).sort().forEach((i,s)=>{const o=Math.min(Math.max(s,0),9);this._renderQueueMapTransparentZWrite.set(i,o)})}}/*! + */function $ue(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})}function Bf(n){return Math.pow(n,2.2)}class que{constructor(e){var t;this.parser=e,this._renderQueueMapTransparent=new Map,this._renderQueueMapTransparentZWrite=new Map;const r=this.parser.json;r.extensionsUsed=(t=r.extensionsUsed)!==null&&t!==void 0?t:[],r.extensionsUsed.indexOf("KHR_texture_transform")===-1&&r.extensionsUsed.push("KHR_texture_transform")}get name(){return"VRMMaterialsV0CompatPlugin"}beforeRoot(){var e;return $ue(this,void 0,void 0,function*(){const t=this.parser.json,r=(e=t.extensions)===null||e===void 0?void 0:e.VRM,i=r==null?void 0:r.materialProperties;i&&(this._populateRenderQueueMap(i),i.forEach((s,o)=>{var a,l;const A=(a=t.materials)===null||a===void 0?void 0:a[o];if(A==null){console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${o}] of glTF but the material doesn't exist`);return}if(s.shader==="VRM/MToon"){const c=this._parseV0MToonProperties(s,A);t.materials[o]=c}else if(!((l=s.shader)===null||l===void 0)&&l.startsWith("VRM/Unlit")){const c=this._parseV0UnlitProperties(s,A);t.materials[o]=c}else s.shader==="VRM_USE_GLTFSHADER"||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${s.shader}`)}))})}_parseV0MToonProperties(e,t){var r,i,s,o,a,l,A,c,u,f,d,h,p,m,g,v,y,w,C,b,E,x,S,M,Z,K,_,B,F,R,k,T,V,O,L,U,H,le,N,j,oe,ie,de,X;const ne=(i=(r=e.keywordMap)===null||r===void 0?void 0:r._ALPHABLEND_ON)!==null&&i!==void 0?i:!1,Be=((s=e.floatProperties)===null||s===void 0?void 0:s._ZWrite)===1&&ne,pe=this._v0ParseRenderQueue(e),Fe=(a=(o=e.keywordMap)===null||o===void 0?void 0:o._ALPHATEST_ON)!==null&&a!==void 0?a:!1,rt=ne?"BLEND":Fe?"MASK":"OPAQUE",Oe=Fe?(l=e.floatProperties)===null||l===void 0?void 0:l._Cutoff:void 0,Qe=((c=(A=e.floatProperties)===null||A===void 0?void 0:A._CullMode)!==null&&c!==void 0?c:2)===0,Ge=this._portTextureTransform(e),Xe=(f=(u=e.vectorProperties)===null||u===void 0?void 0:u._Color)===null||f===void 0?void 0:f.map((ge,Ne)=>Ne===3?ge:Bf(ge)),G=(d=e.textureProperties)===null||d===void 0?void 0:d._MainTex,J=G!=null?{index:G,extensions:Object.assign({},Ge)}:void 0,se=(h=e.floatProperties)===null||h===void 0?void 0:h._BumpScale,fe=(p=e.textureProperties)===null||p===void 0?void 0:p._BumpMap,ve=fe!=null?{index:fe,scale:se,extensions:Object.assign({},Ge)}:void 0,W=(g=(m=e.vectorProperties)===null||m===void 0?void 0:m._EmissionColor)===null||g===void 0?void 0:g.map(Bf),Q=(v=e.textureProperties)===null||v===void 0?void 0:v._EmissionMap,I=Q!=null?{index:Q,extensions:Object.assign({},Ge)}:void 0,D=(w=(y=e.vectorProperties)===null||y===void 0?void 0:y._ShadeColor)===null||w===void 0?void 0:w.map(Bf),$=(C=e.textureProperties)===null||C===void 0?void 0:C._ShadeTexture,ee=$!=null?{index:$,extensions:Object.assign({},Ge)}:void 0;let te=(E=(b=e.floatProperties)===null||b===void 0?void 0:b._ShadeShift)!==null&&E!==void 0?E:0,we=(S=(x=e.floatProperties)===null||x===void 0?void 0:x._ShadeToony)!==null&&S!==void 0?S:.9;we=Wt.lerp(we,1,.5+.5*te),te=-te-(1-we);const Ce=(M=e.floatProperties)===null||M===void 0?void 0:M._IndirectLightIntensity,Ee=Ce?1-Ce:void 0,Ve=(Z=e.textureProperties)===null||Z===void 0?void 0:Z._SphereAdd,_e=Ve!=null?[1,1,1]:void 0,re=Ve!=null?{index:Ve}:void 0,ye=(K=e.floatProperties)===null||K===void 0?void 0:K._RimLightingMix,be=(_=e.textureProperties)===null||_===void 0?void 0:_._RimTexture,Ue=be!=null?{index:be,extensions:Object.assign({},Ge)}:void 0,Je=(F=(B=e.vectorProperties)===null||B===void 0?void 0:B._RimColor)===null||F===void 0?void 0:F.map(Bf),qe=(R=e.floatProperties)===null||R===void 0?void 0:R._RimFresnelPower,ct=(k=e.floatProperties)===null||k===void 0?void 0:k._RimLift,An=["none","worldCoordinates","screenCoordinates"][(V=(T=e.floatProperties)===null||T===void 0?void 0:T._OutlineWidthMode)!==null&&V!==void 0?V:0];let xt=(L=(O=e.floatProperties)===null||O===void 0?void 0:O._OutlineWidth)!==null&&L!==void 0?L:0;xt=.01*xt;const st=(U=e.textureProperties)===null||U===void 0?void 0:U._OutlineWidthTexture,or=st!=null?{index:st,extensions:Object.assign({},Ge)}:void 0,mt=(le=(H=e.vectorProperties)===null||H===void 0?void 0:H._OutlineColor)===null||le===void 0?void 0:le.map(Bf),co=((N=e.floatProperties)===null||N===void 0?void 0:N._OutlineColorMode)===1?(j=e.floatProperties)===null||j===void 0?void 0:j._OutlineLightingMix:0,Xt=(oe=e.textureProperties)===null||oe===void 0?void 0:oe._UvAnimMaskTexture,en=Xt!=null?{index:Xt,extensions:Object.assign({},Ge)}:void 0,q=(ie=e.floatProperties)===null||ie===void 0?void 0:ie._UvAnimScrollX;let Ae=(de=e.floatProperties)===null||de===void 0?void 0:de._UvAnimScrollY;Ae!=null&&(Ae=-Ae);const he=(X=e.floatProperties)===null||X===void 0?void 0:X._UvAnimRotation,ue={specVersion:"1.0",transparentWithZWrite:Be,renderQueueOffsetNumber:pe,shadeColorFactor:D,shadeMultiplyTexture:ee,shadingShiftFactor:te,shadingToonyFactor:we,giEqualizationFactor:Ee,matcapFactor:_e,matcapTexture:re,rimLightingMixFactor:ye,rimMultiplyTexture:Ue,parametricRimColorFactor:Je,parametricRimFresnelPowerFactor:qe,parametricRimLiftFactor:ct,outlineWidthMode:An,outlineWidthFactor:xt,outlineWidthMultiplyTexture:or,outlineColorFactor:mt,outlineLightingMixFactor:co,uvAnimationMaskTexture:en,uvAnimationScrollXSpeedFactor:q,uvAnimationScrollYSpeedFactor:Ae,uvAnimationRotationSpeedFactor:he};return Object.assign(Object.assign({},t),{pbrMetallicRoughness:{baseColorFactor:Xe,baseColorTexture:J},normalTexture:ve,emissiveTexture:I,emissiveFactor:W,alphaMode:rt,alphaCutoff:Oe,doubleSided:Qe,extensions:{VRMC_materials_mtoon:ue}})}_parseV0UnlitProperties(e,t){var r,i,s,o;const a=e.shader==="VRM/UnlitTransparentZWrite",l=e.shader==="VRM/UnlitTransparent"||a,A=this._v0ParseRenderQueue(e),c=e.shader==="VRM/UnlitCutout",u=l?"BLEND":c?"MASK":"OPAQUE",f=c?(r=e.floatProperties)===null||r===void 0?void 0:r._Cutoff:void 0,d=this._portTextureTransform(e),h=(s=(i=e.vectorProperties)===null||i===void 0?void 0:i._Color)===null||s===void 0?void 0:s.map(Bf),p=(o=e.textureProperties)===null||o===void 0?void 0:o._MainTex,m=p!=null?{index:p,extensions:Object.assign({},d)}:void 0,g={specVersion:"1.0",transparentWithZWrite:a,renderQueueOffsetNumber:A,shadeColorFactor:h,shadeMultiplyTexture:m};return Object.assign(Object.assign({},t),{pbrMetallicRoughness:{baseColorFactor:h,baseColorTexture:m},alphaMode:u,alphaCutoff:f,extensions:{VRMC_materials_mtoon:g}})}_portTextureTransform(e){var t,r,i,s,o;const a=(t=e.vectorProperties)===null||t===void 0?void 0:t._MainTex;if(a==null)return{};const l=[(r=a==null?void 0:a[0])!==null&&r!==void 0?r:0,(i=a==null?void 0:a[1])!==null&&i!==void 0?i:0],A=[(s=a==null?void 0:a[2])!==null&&s!==void 0?s:1,(o=a==null?void 0:a[3])!==null&&o!==void 0?o:1];return l[1]=A[1]*(1-l[1])%1,{KHR_texture_transform:{offset:l,scale:A}}}_v0ParseRenderQueue(e){var t,r,i;const s=(r=(t=e.keywordMap)===null||t===void 0?void 0:t._ALPHABLEND_ON)!==null&&r!==void 0?r:!1,o=((i=e.floatProperties)===null||i===void 0?void 0:i._ZWrite)===1;let a=0;if(s){const l=e.renderQueue;l!=null&&(o?a=this._renderQueueMapTransparentZWrite.get(l):a=this._renderQueueMapTransparent.get(l))}return a}_populateRenderQueueMap(e){const t=new Set,r=new Set;e.forEach(i=>{var s,o,a;const l=(o=(s=i.keywordMap)===null||s===void 0?void 0:s._ALPHABLEND_ON)!==null&&o!==void 0?o:!1,A=((a=i.floatProperties)===null||a===void 0?void 0:a._ZWrite)===1;if(l){const c=i.renderQueue;c!=null&&(A?r.add(c):t.add(c))}}),t.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${t.size} render queues for Transparent materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),r.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${r.size} render queues for TransparentZWrite materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),Array.from(t).sort().forEach((i,s)=>{const o=Math.min(Math.max(s-t.size+1,-9),0);this._renderQueueMapTransparent.set(i,o)}),Array.from(r).sort().forEach((i,s)=>{const o=Math.min(Math.max(s,0),9);this._renderQueueMapTransparentZWrite.set(i,o)})}}/*! * @pixiv/three-vrm-node-constraint v1.0.9 * Node constraint module for @pixiv/three-vrm * @@ -4104,7 +4104,7 @@ void main() { * Copyright (c) 2020-2023 pixiv Inc. * @pixiv/three-vrm-springbone is distributed under MIT License * https://github.com/pixiv/three-vrm/blob/release/LICENSE - */class mH{}const i1=new z,Ec=new z;class vH extends mH{constructor(e){var t,r,i;super(),this.offset=(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:new z(0,0,0),this.tail=(r=e==null?void 0:e.tail)!==null&&r!==void 0?r:new z(0,0,0),this.radius=(i=e==null?void 0:e.radius)!==null&&i!==void 0?i:0}get type(){return"capsule"}calculateCollision(e,t,r,i){i1.copy(this.offset).applyMatrix4(e),Ec.copy(this.tail).applyMatrix4(e),Ec.sub(i1);const s=Ec.lengthSq();i.copy(t).sub(i1);const o=Ec.dot(i);o<=0||(s<=o||Ec.multiplyScalar(o/s),i.sub(Ec));const a=r+this.radius,l=i.length()-a;return i.normalize(),l}}class yH extends mH{constructor(e){var t,r;super(),this.offset=(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:new z(0,0,0),this.radius=(r=e==null?void 0:e.radius)!==null&&r!==void 0?r:0}get type(){return"sphere"}calculateCollision(e,t,r,i){i.copy(this.offset).applyMatrix4(e),i.negate().add(t);const s=r+this.radius,o=i.length()-s;return i.normalize(),o}}const Yo=new z;class Bfe extends Ht{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new z,this._currentTail=new z,this._shape=e,this._attrPos=new At(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new At(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;const t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0);const r=Yo.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(r)>1e-10&&(this._currentTail.copy(r),e=!0),e&&this._buildPosition()}_buildPosition(){Yo.copy(this._currentTail).sub(this._currentOffset);const e=Yo.length()/this._currentRadius;for(let i=0;i<=16;i++){const s=i/16*Math.PI;this._attrPos.setXYZ(i,-Math.sin(s),-Math.cos(s),0),this._attrPos.setXYZ(17+i,e+Math.sin(s),Math.cos(s),0),this._attrPos.setXYZ(34+i,-Math.sin(s),0,-Math.cos(s)),this._attrPos.setXYZ(51+i,e+Math.sin(s),0,Math.cos(s))}for(let i=0;i<32;i++){const s=i/16*Math.PI;this._attrPos.setXYZ(68+i,0,Math.sin(s),Math.cos(s)),this._attrPos.setXYZ(100+i,e,Math.sin(s),Math.cos(s))}const t=Math.atan2(Yo.y,Math.sqrt(Yo.x*Yo.x+Yo.z*Yo.z)),r=-Math.atan2(Yo.z,Yo.x);this.rotateZ(t),this.rotateY(r),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<34;e++){const t=(e+1)%34;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(68+e*2,34+e,34+t)}for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(136+e*2,68+e,68+t),this._attrIndex.setXY(200+e*2,100+e,100+t)}this._attrIndex.needsUpdate=!0}}class wfe extends Ht{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new z,this._shape=e,this._attrPos=new At(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new At(new Uint16Array(64*3),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;const t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){const t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.needsUpdate=!0}}const Cfe=new z;class $D extends Tr{constructor(e){if(super(),this.matrixAutoUpdate=!1,this.collider=e,this.collider.shape instanceof yH)this._geometry=new wfe(this.collider.shape);else if(this.collider.shape instanceof vH)this._geometry=new Bfe(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");const t=new Wl({color:16711935,depthTest:!1,depthWrite:!1});this._line=new u0(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);const t=this.matrix.elements;this._geometry.worldScale=Cfe.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}}class bfe extends Ht{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new z,this._springBone=e,this._attrPos=new At(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new At(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;const t=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){const t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}}const xfe=new z;class Ife extends Tr{constructor(e){super(),this.matrixAutoUpdate=!1,this.springBone=e,this._geometry=new bfe(this.springBone);const t=new Wl({color:16776960,depthTest:!1,depthWrite:!1});this._line=new u0(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);const t=this.matrix.elements;this._geometry.worldScale=xfe.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}}class qD extends kt{constructor(e){super(),this.shape=e}}const Ffe=new Le;function BH(n){return n.invert?n.invert():n.getInverse(Ffe.copy(n)),n}class Efe{constructor(e){this._inverseCache=new Le,this._shouldUpdateInverse=!0,this.matrix=e;const t={set:(r,i,s)=>(this._shouldUpdateInverse=!0,r[i]=s,!0)};this._originalElements=e.elements,e.elements=new Proxy(e.elements,t)}get inverse(){return this._shouldUpdateInverse&&(this._inverseCache.copy(this.matrix),BH(this._inverseCache),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}}const Ufe=new Le,ja=new z,Vp=new z,Sfe=new z,wf=new z,ek=new z,Lp=new z,tk=new tt,Cf=new Le,_fe=new Le;class Qfe{constructor(e,t,r={},i=[]){var s,o,a,l,A,c;this._currentTail=new z,this._prevTail=new z,this._boneAxis=new z,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new Le,this._initialLocalRotation=new tt,this._initialLocalChildPosition=new z,this.bone=e,this.bone.matrixAutoUpdate=!1,this.child=t,this.settings={hitRadius:(s=r.hitRadius)!==null&&s!==void 0?s:0,stiffness:(o=r.stiffness)!==null&&o!==void 0?o:1,gravityPower:(a=r.gravityPower)!==null&&a!==void 0?a:0,gravityDir:(A=(l=r.gravityDir)===null||l===void 0?void 0:l.clone())!==null&&A!==void 0?A:new z(0,-1,0),dragForce:(c=r.dragForce)!==null&&c!==void 0?c:.4},this.colliderGroups=i}get center(){return this._center}set center(e){var t;!((t=this._center)===null||t===void 0)&&t.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=e,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new Efe(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:Ufe}setInitState(){this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),this.child?this._initialLocalChildPosition.copy(this.child.position):this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);const e=this._getMatrixWorldToCenter(Cf);this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(e),this._prevTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix);const e=this._getMatrixWorldToCenter(Cf);this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(e),this._prevTail.copy(this._currentTail)}update(e){if(e<=0)return;this._calcWorldSpaceBoneLength(),wf.setFromMatrixPosition(this.bone.matrixWorld);let t=this._getMatrixWorldToCenter(Cf);ek.copy(wf).applyMatrix4(t);const r=tk.setFromRotationMatrix(t),i=_fe.copy(t).multiply(this._parentMatrixWorld),s=Vp.copy(this._boneAxis).applyMatrix4(this._initialLocalMatrix).applyMatrix4(i).sub(ek).normalize(),o=Sfe.copy(this.settings.gravityDir).applyQuaternion(r).normalize(),a=this._getMatrixCenterToWorld(Cf);Lp.copy(this._currentTail).add(ja.copy(this._currentTail).sub(this._prevTail).multiplyScalar(1-this.settings.dragForce)).add(ja.copy(s).multiplyScalar(this.settings.stiffness*e)).add(ja.copy(o).multiplyScalar(this.settings.gravityPower*e)).applyMatrix4(a),Lp.sub(wf).normalize().multiplyScalar(this._worldSpaceBoneLength).add(wf),this._collision(Lp),t=this._getMatrixWorldToCenter(Cf),this._prevTail.copy(this._currentTail),this._currentTail.copy(ja.copy(Lp).applyMatrix4(t));const l=BH(Cf.copy(this._parentMatrixWorld).multiply(this._initialLocalMatrix)),A=tk.setFromUnitVectors(this._boneAxis,ja.copy(Lp).applyMatrix4(l).normalize());this.bone.quaternion.copy(this._initialLocalRotation).multiply(A),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(e){this.colliderGroups.forEach(t=>{t.colliders.forEach(r=>{const i=r.shape.calculateCollision(r.matrixWorld,e,this.settings.hitRadius,ja);i<0&&(e.add(ja.multiplyScalar(-i)),e.sub(wf).normalize().multiplyScalar(this._worldSpaceBoneLength).add(wf))})})}_calcWorldSpaceBoneLength(){ja.setFromMatrixPosition(this.bone.matrixWorld),this.child?Vp.setFromMatrixPosition(this.child.matrixWorld):(Vp.copy(this._initialLocalChildPosition),Vp.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=ja.sub(Vp).length()}_getMatrixCenterToWorld(e){return this._center?e.copy(this._center.matrixWorld):e.identity(),e}_getMatrixWorldToCenter(e){return this._center?e.copy(this._center.userData.inverseCacheProxy.inverse):e.identity(),e}}function ry(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})}function Rfe(n,e){const t=[];let r=n;for(;r!==null;)t.unshift(r),r=r.parent;t.forEach(i=>{e(i)})}function wH(n,e){n.children.forEach(t=>{e(t)||wH(t,e)})}class nk{constructor(){this._joints=new Set,this._objectSpringBonesMap=new Map}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){const e=new Set;return this._joints.forEach(t=>{t.colliderGroups.forEach(r=>{e.add(r)})}),Array.from(e)}get colliders(){const e=new Set;return this.colliderGroups.forEach(t=>{t.colliders.forEach(r=>{e.add(r)})}),Array.from(e)}addJoint(e){this._joints.add(e);let t=this._objectSpringBonesMap.get(e.bone);t==null&&(t=new Set,this._objectSpringBonesMap.set(e.bone,t)),t.add(e)}addSpringBone(e){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(e)}deleteJoint(e){this._joints.delete(e),this._objectSpringBonesMap.get(e.bone).delete(e)}deleteSpringBone(e){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(e)}setInitState(){const e=new Set,t=new Set,r=new Set;for(const i of this._joints)this._processSpringBone(i,e,t,r,s=>s.setInitState())}reset(){const e=new Set,t=new Set,r=new Set;for(const i of this._joints)this._processSpringBone(i,e,t,r,s=>s.reset())}update(e){const t=new Set,r=new Set,i=new Set;for(const s of this._joints)this._processSpringBone(s,t,r,i,o=>o.update(e)),wH(s.bone,o=>{var a,l;return((l=(a=this._objectSpringBonesMap.get(o))===null||a===void 0?void 0:a.size)!==null&&l!==void 0?l:0)>0?!0:(o.updateWorldMatrix(!1,!1),!1)})}_processSpringBone(e,t,r,i,s){if(r.has(e))return;if(t.has(e))throw new Error("VRMSpringBoneManager: Circular dependency detected while updating springbones");t.add(e);const o=this._getDependencies(e);for(const a of o)Rfe(a,l=>{const A=this._objectSpringBonesMap.get(l);if(A)for(const c of A)this._processSpringBone(c,t,r,i,s);else i.has(l)||(l.updateWorldMatrix(!1,!1),i.add(l))});e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),s(e),i.add(e.bone),r.add(e)}_getDependencies(e){const t=new Set,r=e.bone.parent;return r&&t.add(r),e.colliderGroups.forEach(i=>{i.colliders.forEach(s=>{t.add(s)})}),t}}const Mfe=new Set(["1.0","1.0-beta"]);class Kc{constructor(e,t){this.parser=e,this.jointHelperRoot=t==null?void 0:t.jointHelperRoot,this.colliderHelperRoot=t==null?void 0:t.colliderHelperRoot}get name(){return Kc.EXTENSION_NAME}afterRoot(e){return ry(this,void 0,void 0,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return ry(this,void 0,void 0,function*(){const t=yield this._v1Import(e);if(t!=null)return t;const r=yield this._v0Import(e);return r??null})}_v1Import(e){var t,r,i,s,o;return ry(this,void 0,void 0,function*(){const a=e.parser.json;if(!(((t=a.extensionsUsed)===null||t===void 0?void 0:t.indexOf(Kc.EXTENSION_NAME))!==-1))return null;const A=new nk,c=yield e.parser.getDependencies("node"),u=(r=a.extensions)===null||r===void 0?void 0:r[Kc.EXTENSION_NAME];if(!u)return null;const f=u.specVersion;if(!Mfe.has(f))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Kc.EXTENSION_NAME} specVersion "${f}"`),null;const d=(i=u.colliders)===null||i===void 0?void 0:i.map((p,m)=>{var g,v,y,w,C;const b=c[p.node],E=p.shape;if(E.sphere)return this._importSphereCollider(b,{offset:new z().fromArray((g=E.sphere.offset)!==null&&g!==void 0?g:[0,0,0]),radius:(v=E.sphere.radius)!==null&&v!==void 0?v:0});if(E.capsule)return this._importCapsuleCollider(b,{offset:new z().fromArray((y=E.capsule.offset)!==null&&y!==void 0?y:[0,0,0]),radius:(w=E.capsule.radius)!==null&&w!==void 0?w:0,tail:new z().fromArray((C=E.capsule.tail)!==null&&C!==void 0?C:[0,0,0])});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${m} has no valid shape`)}),h=(s=u.colliderGroups)===null||s===void 0?void 0:s.map((p,m)=>{var g;return{colliders:((g=p.colliders)!==null&&g!==void 0?g:[]).map(y=>{const w=d==null?void 0:d[y];if(w==null)throw new Error(`VRMSpringBoneLoaderPlugin: The colliderGroup #${m} attempted to use a collider #${y} but not found`);return w}),name:p.name}});return(o=u.springs)===null||o===void 0||o.forEach((p,m)=>{var g;const v=p.joints,y=(g=p.colliderGroups)===null||g===void 0?void 0:g.map(b=>{const E=h==null?void 0:h[b];if(E==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${m} attempted to use a colliderGroup ${b} but not found`);return E}),w=p.center!=null?c[p.center]:void 0;let C;v.forEach(b=>{if(C){const E=C.node,x=c[E],S=b.node,M=c[S],Z={hitRadius:C.hitRadius,dragForce:C.dragForce,gravityPower:C.gravityPower,stiffness:C.stiffness,gravityDir:C.gravityDir!=null?new z().fromArray(C.gravityDir):void 0},K=this._importJoint(x,M,Z,y);w&&(K.center=w),A.addJoint(K)}C=b})}),A.setInitState(),A})}_v0Import(e){var t,r,i;return ry(this,void 0,void 0,function*(){const s=e.parser.json;if(!(((t=s.extensionsUsed)===null||t===void 0?void 0:t.indexOf("VRM"))!==-1))return null;const a=(r=s.extensions)===null||r===void 0?void 0:r.VRM,l=a==null?void 0:a.secondaryAnimation;if(!l)return null;const A=l==null?void 0:l.boneGroups;if(!A)return null;const c=new nk,u=yield e.parser.getDependencies("node"),f=(i=l.colliderGroups)===null||i===void 0?void 0:i.map(d=>{var h;const p=u[d.node];return{colliders:((h=d.colliders)!==null&&h!==void 0?h:[]).map((g,v)=>{var y,w,C;const b=new z(0,0,0);return g.offset&&b.set((y=g.offset.x)!==null&&y!==void 0?y:0,(w=g.offset.y)!==null&&w!==void 0?w:0,g.offset.z?-g.offset.z:0),this._importSphereCollider(p,{offset:b,radius:(C=g.radius)!==null&&C!==void 0?C:0})})}});return A==null||A.forEach((d,h)=>{const p=d.bones;p&&p.forEach(m=>{var g,v,y,w;const C=u[m],b=new z;d.gravityDir?b.set((g=d.gravityDir.x)!==null&&g!==void 0?g:0,(v=d.gravityDir.y)!==null&&v!==void 0?v:0,(y=d.gravityDir.z)!==null&&y!==void 0?y:0):b.set(0,-1,0);const E=d.center!=null?u[d.center]:void 0,x={hitRadius:d.hitRadius,dragForce:d.dragForce,gravityPower:d.gravityPower,stiffness:d.stiffiness,gravityDir:b},S=(w=d.colliderGroups)===null||w===void 0?void 0:w.map(M=>{const Z=f==null?void 0:f[M];if(Z==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${h} attempted to use a colliderGroup ${M} but not found`);return Z});C.traverse(M=>{var Z;const K=(Z=M.children[0])!==null&&Z!==void 0?Z:null,_=this._importJoint(M,K,x,S);E&&(_.center=E),c.addJoint(_)})})}),e.scene.updateMatrixWorld(),c.setInitState(),c})}_importJoint(e,t,r,i){const s=new Qfe(e,t,r,i);if(this.jointHelperRoot){const o=new Ife(s);this.jointHelperRoot.add(o),o.renderOrder=this.jointHelperRoot.renderOrder}return s}_importSphereCollider(e,t){const{offset:r,radius:i}=t,s=new yH({offset:r,radius:i}),o=new qD(s);if(e.add(o),this.colliderHelperRoot){const a=new $D(o);this.colliderHelperRoot.add(a),a.renderOrder=this.colliderHelperRoot.renderOrder}return o}_importCapsuleCollider(e,t){const{offset:r,radius:i,tail:s}=t,o=new vH({offset:r,radius:i,tail:s}),a=new qD(o);if(e.add(a),this.colliderHelperRoot){const l=new $D(a);this.colliderHelperRoot.add(l),l.renderOrder=this.colliderHelperRoot.renderOrder}return a}}Kc.EXTENSION_NAME="VRMC_springBone";class Tfe{constructor(e,t){var r,i,s,o,a,l,A,c,u,f;this.parser=e;const d=t==null?void 0:t.helperRoot,h=t==null?void 0:t.autoUpdateHumanBones;this.expressionPlugin=(r=t==null?void 0:t.expressionPlugin)!==null&&r!==void 0?r:new fb(e),this.firstPersonPlugin=(i=t==null?void 0:t.firstPersonPlugin)!==null&&i!==void 0?i:new fue(e),this.humanoidPlugin=(s=t==null?void 0:t.humanoidPlugin)!==null&&s!==void 0?s:new Bue(e,{helperRoot:d,autoUpdateHumanBones:h}),this.lookAtPlugin=(o=t==null?void 0:t.lookAtPlugin)!==null&&o!==void 0?o:new Tue(e,{helperRoot:d}),this.metaPlugin=(a=t==null?void 0:t.metaPlugin)!==null&&a!==void 0?a:new kue(e),this.mtoonMaterialPlugin=(l=t==null?void 0:t.mtoonMaterialPlugin)!==null&&l!==void 0?l:new Jd(e),this.materialsHDREmissiveMultiplierPlugin=(A=t==null?void 0:t.materialsHDREmissiveMultiplierPlugin)!==null&&A!==void 0?A:new Pm(e),this.materialsV0CompatPlugin=(c=t==null?void 0:t.materialsV0CompatPlugin)!==null&&c!==void 0?c:new que(e),this.springBonePlugin=(u=t==null?void 0:t.springBonePlugin)!==null&&u!==void 0?u:new Kc(e,{colliderHelperRoot:d,jointHelperRoot:d}),this.nodeConstraintPlugin=(f=t==null?void 0:t.nodeConstraintPlugin)!==null&&f!==void 0?f:new Xc(e,{helperRoot:d})}get name(){return"VRMLoaderPlugin"}beforeRoot(){return ny(this,void 0,void 0,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(e){return ny(this,void 0,void 0,function*(){return yield this.mtoonMaterialPlugin.loadMesh(e)})}getMaterialType(e){const t=this.mtoonMaterialPlugin.getMaterialType(e);return t??null}extendMaterialParams(e,t){return ny(this,void 0,void 0,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(e,t),yield this.mtoonMaterialPlugin.extendMaterialParams(e,t)})}afterRoot(e){return ny(this,void 0,void 0,function*(){yield this.metaPlugin.afterRoot(e),yield this.humanoidPlugin.afterRoot(e),yield this.expressionPlugin.afterRoot(e),yield this.lookAtPlugin.afterRoot(e),yield this.firstPersonPlugin.afterRoot(e),yield this.springBonePlugin.afterRoot(e),yield this.nodeConstraintPlugin.afterRoot(e),yield this.mtoonMaterialPlugin.afterRoot(e);const t=e.userData.vrmMeta,r=e.userData.vrmHumanoid;if(t&&r){const i=new Lue({scene:e.scene,expressionManager:e.userData.vrmExpressionManager,firstPerson:e.userData.vrmFirstPerson,humanoid:r,lookAt:e.userData.vrmLookAt,meta:t,materials:e.userData.vrmMToonMaterials,springBoneManager:e.userData.vrmSpringBoneManager,nodeConstraintManager:e.userData.vrmNodeConstraintManager});e.userData.vrm=i}})}}function rk(n){if(Object.values(n).forEach(e=>{e!=null&&e.isTexture&&e.dispose()}),n.isShaderMaterial){const e=n.uniforms;e&&Object.values(e).forEach(t=>{const r=t.value;r!=null&&r.isTexture&&r.dispose()})}n.dispose()}function Nfe(n){const e=n.geometry;e&&e.dispose();const t=n.skeleton;t&&t.dispose();const r=n.material;r&&(Array.isArray(r)?r.forEach(i=>rk(i)):r&&rk(r))}function Dfe(n){n.traverse(Nfe)}function kfe(n){const e=new Map;n.traverse(t=>{if(t.type!=="SkinnedMesh")return;const r=t,s=r.geometry.getAttribute("skinIndex");let o=e.get(s);if(!o){const a=[],l=[],A={},c=s.array;for(let u=0;u{var r,i,s,o;if(!t.isMesh)return;const a=t,l=a.geometry,A=l.index;if(A==null)return;const c=e.get(l);if(c!=null){a.geometry=c;return}const u=new Ht;u.name=l.name,u.morphTargetsRelative=l.morphTargetsRelative,l.groups.forEach(p=>{u.addGroup(p.start,p.count,p.materialIndex)}),u.boundingBox=(i=(r=l.boundingBox)===null||r===void 0?void 0:r.clone())!==null&&i!==void 0?i:null,u.boundingSphere=(o=(s=l.boundingSphere)===null||s===void 0?void 0:s.clone())!==null&&o!==void 0?o:null,u.setDrawRange(l.drawRange.start,l.drawRange.count),u.userData=l.userData,e.set(l,u);const f=[],d=[];{const p=A.array,m=new p.constructor(p.length);let g=0;for(let v=0;v{const m=l.attributes[p];if(m.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const g=m.array,{itemSize:v,normalized:y}=m,w=new g.constructor(d.length*v);d.forEach((C,b)=>{for(let E=0;E{u.morphAttributes[p]=[];const m=l.morphAttributes[p];for(let g=0;g{for(let S=0;SE===0),u.morphAttributes[p][g]=new At(b,w,C)}}),h&&(u.morphAttributes={}),a.geometry=u}),Array.from(e.keys()).forEach(t=>{t.dispose()})}function Lfe(n){var e;((e=n.meta)===null||e===void 0?void 0:e.metaVersion)==="0"&&(n.scene.rotation.y=Math.PI)}class Xh{constructor(){}}Xh.deepDispose=Dfe;Xh.removeUnnecessaryJoints=kfe;Xh.removeUnnecessaryVertices=Vfe;Xh.rotateVRM0=Lfe;var Kn;(function(n){n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.LINEAR=9729]="LINEAR",n[n.REPEAT=10497]="REPEAT"})(Kn||(Kn={}));const Ww="blend_",ik="vrmColliderSphere";class Pfe{parse(e,t,r,i){const s=e.humanoid,o=e.meta,a=e.materials,l={},A={},c={},u=e.lookAt,f={generator:"UniGLTF-2.0.0",version:"2.0"};if(t)if(s)if(o)if(a){if(!u)throw new Error("lookAt is undefined or null")}else throw new Error("materials is undefined or null");else throw new Error("meta is undefined or null");else throw new Error("humanoid is undefined or null");else throw new Error("avatar is undefined or null");const d=a.filter((X,ne,ae)=>ae.findIndex(Be=>Be.name===X.name.replace(" (Outline)",""))===ne).map(X=>X),h=d.map(X=>X.name),p=r?{name:"icon",imageBitmap:r.image}:null,m=d.filter(X=>X.map).map(X=>{if(!X.map)throw new Error(X.name+" map is null");return{name:X.name,imageBitmap:X.map.image}}),g=d.filter(X=>X.userData.shadeTexture).map(X=>{if(!X.userData.shadeTexture)throw new Error(X.userData.shadeTexture+" map is null");return{name:X.name+"_shade",imageBitmap:X.userData.shadeTexture.image}}),v=m.concat(g),y=Jfe(v,p),w=Hfe(y),C=zfe(y),b=Zfe(d,v),E=t.children.filter(X=>X.children.length>0&&X.children[0].type===ui.Bone)[0],x=CH(E).filter(X=>X.name!==ik),S=x.map(X=>X.name),M=x.map(X=>({children:X.children.filter(ne=>ne.name!==ik).map(ne=>S.indexOf(ne.name)),name:X.name,rotation:[X.quaternion.x,X.quaternion.y,X.quaternion.z,X.quaternion.w],scale:[X.scale.x,X.scale.y,X.scale.z],translation:[X.position.x,X.position.y,X.position.z]})),Z=[],K=t.children.filter(X=>X.type===ui.Group||X.type===ui.SkinnedMesh),_=[];K.forEach(X=>{const ne=X.type===ui.Group?X.children[0]:X,ae=ne.geometry.attributes;_.push(new $a(ae.position,Kn.FLOAT,jt.POSITION,xo.VEC3,ne.name,void 0)),_.push(new $a(ae.normal,Kn.FLOAT,jt.NORMAL,xo.VEC3,ne.name,void 0)),_.push(new $a(ae.uv,Kn.FLOAT,jt.UV,xo.VEC2,ne.name,void 0)),_.push(new $a(ae.skinWeight,Kn.FLOAT,jt.SKIN_WEIGHT,xo.VEC4,ne.name,void 0)),_.push(new $a(ae.skinIndex,Kn.UNSIGNED_SHORT,jt.SKIN_INDEX,xo.VEC4,ne.name,void 0)),(X.type===ui.Group?X.children.map(pe=>pe):[X]).forEach(pe=>{if(!pe.geometry.index)throw new Error(pe.name+" geometry.index is null");_.push(new $a(pe.geometry.index,Kn.UNSIGNED_INT,jt.INDEX,xo.SCALAR,ne.name,pe.name))}),ne.morphTargetDictionary||(ne.morphTargetDictionary={},ne.morphTargetInfluences=[],ne.geometry.morphAttributes={},ne.updateMorphTargets()),ne.geometry.userData.targetNames=[];for(const pe in e.expressionManager.expressionMap){const Fe=e.expressionManager.expressionMap[pe],rt=Fe._binds.map(ke=>({node:x.length,index:ke.index,weight:ke.weight}));let Oe=!1;for(const ke in ci)if(pe.toLowerCase()===ci[ke].toLowerCase()){l[ci[ke]]={morphTargetBinds:rt,isBinary:Fe.isBinary,overrideBlink:Fe.overrideBlink,overrideLookAt:Fe.overrideLookAt,overrideMouth:Fe.overrideMouth},Oe=!0;break}!Oe&&pe.toLowerCase()==="surprise"&&(l.surprised={morphTargetBinds:rt,isBinary:Fe.isBinary,overrideBlink:Fe.overrideBlink,overrideLookAt:Fe.overrideLookAt,overrideMouth:Fe.overrideMouth},Oe=!0),Oe===!1&&(A[pe]={morphTargetBinds:rt,isBinary:Fe.isBinary,overrideBlink:Fe.overrideBlink,overrideLookAt:Fe.overrideLookAt,overrideMouth:Fe.overrideMouth})}for(const pe in ne.morphTargetDictionary){ne.geometry.userData.targetNames.push(pe);const Fe=ne.morphTargetDictionary[pe],rt=ne.geometry.morphAttributes;_.push(new $a(rt.position[Fe],Kn.FLOAT,jt.BLEND_POSITION,xo.VEC3,ne.name,Ww+pe)),_.push(new $a(rt.normal[Fe],Kn.FLOAT,jt.BLEND_NORMAL,xo.VEC3,ne.name,Ww+pe))}}),Object.keys(l).length>0&&(c.preset=l),Object.keys(A).length>0&&(c.custom=A),K.forEach(X=>{const ne=X.type===ui.Group?X.children[0]:X,ae=new Float32Array(ne.skeleton.boneInverses.map(Be=>Be.elements).flat());_.push(new $a(new At(ae,16),Kn.FLOAT,jt.BIND_MATRIX,xo.MAT4,ne.name,ne.name))}),Z.push(..._.map(X=>({bufferView:-1,byteOffset:0,componentType:X.valueType,count:X.attribute.count,max:X.max,min:X.min,normalized:!1,type:X.accessorsType})));const B=Ofe(K,_,h);K.forEach((X,ne)=>{M.push({mesh:ne,name:X.name,rotation:[X.quaternion.x,X.quaternion.y,X.quaternion.z,X.quaternion.w],scale:[X.scale.x,X.scale.y,X.scale.z],skin:ne,translation:[X.position.x,X.position.y,X.position.z]})});const F=Gfe(K,_,S),R={offsetFromHeadBone:[0,0,0],rangeMapHorizontalInner:{inputMaxValue:u.applier.rangeMapHorizontalInner.inputMaxValue,outputScale:u.applier.rangeMapHorizontalInner.outputScale},rangeMapHorizontalOuter:{inputMaxValue:u.applier.rangeMapHorizontalOuter.inputMaxValue,outputScale:u.applier.rangeMapHorizontalOuter.outputScale},rangeMapVerticalDown:{inputMaxValue:u.applier.rangeMapVerticalDown.inputMaxValue,outputScale:u.applier.rangeMapVerticalDown.outputScale},rangeMapVerticalUp:{inputMaxValue:u.applier.rangeMapVerticalUp.inputMaxValue,outputScale:u.applier.rangeMapVerticalUp.outputScale},type:"bone"},k={humanBones:{}};for(const X in s.humanBones)k.humanBones[X]={node:S.indexOf(s.humanBones[X].node.name)};const T=o,V=[];V.push(...v.map(X=>({buffer:sk(X.imageBitmap),type:jt.IMAGE}))),V.push(..._.map(X=>({buffer:X.buffer,type:X.type}))),p&&V.push({buffer:sk(p.imageBitmap),type:jt.IMAGE});let O=0,L=0,U=0;const H=V.map((X,ne)=>{const ae={buffer:0,byteLength:X.buffer.byteLength,byteOffset:O,target:X.type===jt.IMAGE||X.type===jt.BIND_MATRIX?void 0:X.type===jt.INDEX?Kn.ELEMENT_ARRAY_BUFFER:Kn.ARRAY_BUFFER};return O+=X.buffer.byteLength,X.type===jt.IMAGE?y[L++].bufferView=ne:Z[U++].bufferView=ne,ae}),Ae=Yfe(t,M),N={accessors:Z,asset:f,buffers:[{byteLength:O}],bufferViews:H,extensions:{VRMC_vrm:{expressions:c,humanoid:k,lookAt:R,meta:T,specVersion:"1.0"}},extensionsUsed:["KHR_materials_unlit","KHR_texture_transform","VRMC_materials_mtoon","VRMC_vrm"],images:y,materials:b,meshes:B,nodes:M,samplers:w,avatar:0,scenes:Ae,skins:F,textures:C},j=new ok($E(JSON.stringify(N,void 0,2)),"JSON"),oe=new ok(wg(V.map(X=>X.buffer)),"BIN\0"),ie=wg([j.buffer,oe.buffer]),de=wg([$E("glTF"),jE(2,4),jE(ie.byteLength+12,4)]);i(wg([de,ie]))}}function CH(n){return n.children.length<=0?[n]:[n].concat(n.children.map(e=>CH(e)).flat())}function sk(n){const e=document.createElement("canvas");e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0);const t=e.toDataURL("image/png"),r=atob(t.split(",")[1]),i=new ArrayBuffer(r.length),s=new DataView(i);for(let o=0;o4?A=r[a*n.itemSize+l]:l===0?A=n.getX(a):l===1?A=n.getY(a):l===2?A=n.getZ(a):A=n.getW(a),e===Kn.UNSIGNED_SHORT?o.setUint16(i,A,!0):e===Kn.UNSIGNED_INT?o.setUint32(i,A,!0):o.setFloat32(i,A,!0),i+=t}return s}let ok=class{constructor(e,t){this.data=e,this.type=t;const r=this.data;this.buffer=wg([jE(r.byteLength,4),$E(this.type),r])}paddingBinary(e,t){const r=Math.ceil(e.byteLength/4)*4;if(e.byteLength===r)return e;const i=new Uint8Array(r);i.set(new Uint8Array(e),0);for(let s=e.byteLength;sl%3===0)),Math.max.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===1)),Math.max.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===2))]:void 0,this.min=r===jt.POSITION||r===jt.BLEND_POSITION?[Math.min.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===0)),Math.min.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===1)),Math.min.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===2))]:void 0}};var xd;(function(n){n.MeshBasicMaterial="MeshBasicMaterial",n.MeshStandardMaterial="MeshStandardMaterial",n.MToonMaterial="MToonMaterial"})(xd||(xd={}));var xo;(function(n){n.SCALAR="SCALAR",n.VEC2="VEC2",n.VEC3="VEC3",n.VEC4="VEC4",n.MAT4="MAT4"})(xo||(xo={}));var jt;(function(n){n.POSITION="POSITION",n.NORMAL="NORMAL",n.UV="UV",n.INDEX="INDEX",n.SKIN_WEIGHT="SKIN_WEIGHT",n.SKIN_INDEX="SKIN_INDEX",n.BLEND_POSITION="BLEND_POSITION",n.BLEND_NORMAL="BLEND_NORMAL",n.BIND_MATRIX="BIND_MATRIX",n.IMAGE="IMAGE"})(jt||(jt={}));var ui;(function(n){n.Group="Group",n.SkinnedMesh="SkinnedMesh",n.Object3D="Object3D",n.Bone="Bone"})(ui||(ui={}));const Ofe=(n,e,t)=>n.map(r=>{const i=r.type===ui.Group?r.children[0]:r,s=r.type===ui.Group?r.children.map(o=>o):[r];return{name:r.name,primitives:s.map(o=>{const a=e.map(A=>A.meshName===i.name?A.type:null),l=Array.isArray(o.material)?o.material[0].name:o.material.name;return{attributes:{JOINTS_0:a.indexOf(jt.SKIN_INDEX),NORMAL:a.indexOf(jt.NORMAL),POSITION:a.indexOf(jt.POSITION),TEXCOORD_0:a.indexOf(jt.UV),WEIGHTS_0:a.indexOf(jt.SKIN_WEIGHT)},extras:{targetNames:o.geometry.userData.targetNames},indices:e.map(A=>A.type===jt.INDEX&&A.meshName===i.name?A.name:null).indexOf(o.name),material:t.indexOf(l),mode:4,targets:i.geometry.userData.targetNames?i.geometry.userData.targetNames.map(A=>({NORMAL:e.map(c=>c.type===jt.BLEND_NORMAL&&c.meshName===i.name?c.name:null).indexOf(Ww+A),POSITION:e.map(c=>c.type===jt.BLEND_POSITION&&c.meshName===i.name?c.name:null).indexOf(Ww+A)})):void 0}})}}),Gfe=(n,e,t)=>n.map(r=>{const i=r.type===ui.Group?r.children[0]:r;return{inverseBindMatrices:e.map(s=>s.type===jt.BIND_MATRIX?s.meshName:null).indexOf(i.name),joints:i.skeleton.bones.map(s=>t.indexOf(s.name)),skeleton:t.indexOf(i.skeleton.bones[0].name)}}),Zfe=(n,e)=>n.map(t=>{let r,i=null;if(t=t.userData.vrmMaterial?t.userData.vrmMaterial:t,t.type==="ShaderMaterial")i=t.userData.gltfExtensions.VRMC_materials_mtoon,i.shadeMultiplyTexture={index:e.map(c=>c.name).indexOf(t.uniforms.shadeMultiplyTexture.name)},r=t.color?[1,1,1,1]:void 0;else{const A=t;r=A.color?[A.color.r,A.color.g,A.color.b,1]:void 0}let s=-1;t.map?s=e.map(A=>A.name).indexOf(t.name):t.uniforms&&t.uniforms.map&&(s=e.map(A=>A.name).indexOf(t.uniforms.map.name));const o=s>=0?{extensions:{KHR_texture_transform:{offset:[0,0],scale:[1,1]}},index:s,texCoord:0}:void 0,a=(()=>{switch(t.type){case xd.MeshStandardMaterial:return t.metalness;case xd.MeshBasicMaterial:return 0;default:return 0}})(),l=(()=>{switch(t.type){case xd.MeshStandardMaterial:return t.roughness;case xd.MeshBasicMaterial:return .9;default:return .9}})();return{alphaCutoff:t.alphaTest>0?t.alphaTest:void 0,alphaMode:t.transparent?"BLEND":t.alphaTest>0?"MASK":"OPAQUE",doubleSided:t.side===2,extensions:t.type==="ShaderMaterial"?{KHR_materials_unlit:{},VRMC_materials_mtoon:i}:void 0,name:t.name,pbrMetallicRoughness:{baseColorFactor:r,baseColorTexture:o,metallicFactor:a,roughnessFactor:l}}}),Jfe=(n,e)=>(e?n.concat(e):n).filter(t=>t&&t.imageBitmap).map(t=>({bufferView:-1,mimeType:"image/png",name:t.name})),Hfe=n=>n.map(()=>({magFilter:Kn.LINEAR,minFilter:Kn.LINEAR,wrapS:Kn.REPEAT,wrapT:Kn.REPEAT})),zfe=n=>n.map((e,t)=>({sampler:0,source:t})),Yfe=(n,e)=>{const t=e.map(r=>r.name);return[{nodes:n.children.filter(r=>r.type===ui.Object3D||r.type===ui.SkinnedMesh||r.type===ui.Group||r.type===ui.Bone).map(r=>t.indexOf(r.name))}]},bH=0,Xfe=1,xH=2,ak=2,s1=1.25,lk=1,hB=6*4+4+4,qE=65535,Kfe=Math.pow(2,-24);class iy{constructor(){}}function fa(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function Ak(n){let e=-1,t=-1/0;for(let r=0;r<3;r++){const i=n[r+3]-n[r];i>t&&(t=i,e=r)}return e}function ck(n,e){e.set(n)}function uk(n,e,t){let r,i;for(let s=0;s<3;s++){const o=s+3;r=n[s],i=e[s],t[s]=ri?r:i}}function sy(n,e,t){for(let r=0;r<3;r++){const i=e[n+2*r],s=e[n+2*r+1],o=i-s,a=i+s;ot[r+3]&&(t[r+3]=a)}}function Pp(n){const e=n[3]-n[0],t=n[4]-n[1],r=n[5]-n[2];return 2*(e*t+t*r+r*e)}function jfe(n,e){if(!n.index){const t=n.attributes.position.count,r=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;let i;t>65535?i=new Uint32Array(new r(4*t)):i=new Uint16Array(new r(2*t)),n.setIndex(new At(i,1));for(let s=0;si-s);for(let i=0;il&&(l=E),g&&wh&&(h=w);const x=n[v+2],S=n[v+3],M=x-S,Z=x+S;MA&&(A=Z),g&&xp&&(p=x);const K=n[v+4],_=n[v+5],B=K-_,F=K+_;Bc&&(c=F),g&&Km&&(m=K)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=A,r[5]=c,g&&(i[0]=u,i[1]=f,i[2]=d,i[3]=h,i[4]=p,i[5]=m)}function qfe(n,e,t,r){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,A=-1/0;for(let c=e*6,u=(e+t)*6;ca&&(a=f);const d=n[c+2];dl&&(l=d);const h=n[c+4];hA&&(A=h)}r[0]=i,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=A}function ede(n,e,t,r,i){let s=t,o=t+r-1;const a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&e[s*6+l]=a;)o--;if(sn.candidate-e.candidate,oA=new Array(rl).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),oy=new Float32Array(6);function nde(n,e,t,r,i,s){let o=-1,a=0;if(s===bH)o=Ak(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===Xfe)o=Ak(n),o!==-1&&(a=rde(t,r,i,o));else if(s===xH){const l=Pp(n);let A=s1*i;const c=r*6,u=(r+i)*6;for(let f=0;f<3;f++){const d=e[f],m=(e[f+3]-d)/rl;if(i=E.candidate?sy(w,t,E.rightCacheBounds):(sy(w,t,E.leftCacheBounds),E.count++)}}for(let w=0;w=rl&&(b=rl-1);const E=oA[b];E.count++,sy(y,t,E.bounds)}const g=oA[rl-1];ck(g.bounds,g.rightCacheBounds);for(let y=rl-2;y>=0;y--){const w=oA[y],C=oA[y+1];uk(w.bounds,C.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let y=0;yb&&(b=y),w>b&&(b=w);const E=(b-C)/2,x=g*2;s[d+x+0]=C+E,s[d+x+1]=E+(Math.abs(C)+E)*Kfe,Ce[g+3]&&(e[g+3]=b)}}return s}function sde(n,e){function t(g){f&&f(g/d)}function r(g,v,y,w=null,C=0){if(!h&&C>=l&&(h=!0,A&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(n))),y<=c||C>=l)return t(v+y),g.offset=v,g.count=y,g;const b=nde(g.boundingData,w,o,v,y,u);if(b.axis===-1)return t(v+y),g.offset=v,g.count=y,g;const E=ede(a,o,v,y,b);if(E===v||E===v+y)t(v+y),g.offset=v,g.count=y;else{g.splitAxis=b.axis;const x=new iy,S=v,M=E-v;g.left=x,x.boundingData=new Float32Array(6),o1(o,S,M,x.boundingData,s),r(x,S,M,s,C+1);const Z=new iy,K=E,_=y-M;g.right=Z,Z.boundingData=new Float32Array(6),o1(o,K,_,Z.boundingData,s),r(Z,K,_,s,C+1)}return g}jfe(n,e);const i=new Float32Array(6),s=new Float32Array(6),o=ide(n,i),a=n.index.array,l=e.maxDepth,A=e.verbose,c=e.maxLeafTris,u=e.strategy,f=e.onProgress,d=n.index.count/3;let h=!1;const p=[],m=$fe(n);if(m.length===1){const g=m[0],v=new iy;v.boundingData=i,qfe(o,g.offset,g.count,s),r(v,g.offset,g.count,s),p.push(v)}else for(let g of m){const v=new iy;v.boundingData=new Float32Array(6),o1(o,g.offset,g.count,v.boundingData,s),r(v,g.offset,g.count,s),p.push(v)}return p}function ode(n,e){const t=sde(n,e);let r,i,s;const o=[],a=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;cMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[f+6]=y/4,y=A(y,g),i[f+7]=v,y}}}class kl{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let r=1/0,i=-1/0;for(let s=0,o=e.length;si?l:i}this.min=r,this.max=i}setFromPoints(e,t){let r=1/0,i=-1/0;for(let s=0,o=t.length;si?l:i}this.min=r,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}kl.prototype.setFromBox=function(){const n=new z;return function(t,r){const i=r.min,s=r.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let A=0;A<=1;A++)for(let c=0;c<=1;c++){n.x=i.x*l+s.x*(1-l),n.y=i.y*A+s.y*(1-A),n.z=i.z*c+s.z*(1-c);const u=t.dot(n);o=Math.min(u,o),a=Math.max(u,a)}this.min=o,this.max=a}}();const ade=function(){const n=new z,e=new z,t=new z;return function(i,s,o){const a=i.start,l=n,A=s.start,c=e;t.subVectors(a,A),n.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const u=t.dot(c),f=c.dot(l),d=c.dot(c),h=t.dot(l),m=l.dot(l)*d-f*f;let g,v;m!==0?g=(u*f-h*d)/m:g=0,v=(u+g*f)/d,o.x=g,o.y=v}}(),X_=function(){const n=new We,e=new z,t=new z;return function(i,s,o,a){ade(i,s,n);let l=n.x,A=n.y;if(l>=0&&l<=1&&A>=0&&A<=1){i.at(l,o),s.at(A,a);return}else if(l>=0&&l<=1){A<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(A>=0&&A<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let u;A<0?u=s.start:u=s.end;const f=e,d=t;if(i.closestPointToPoint(u,!0,e),s.closestPointToPoint(c,!0,t),f.distanceToSquared(u)<=d.distanceToSquared(c)){o.copy(f),a.copy(u);return}else{o.copy(c),a.copy(d);return}}}}(),lde=function(){const n=new z,e=new z,t=new hl,r=new Il;return function(s,o){const{radius:a,center:l}=s,{a:A,b:c,c:u}=o;if(r.start=A,r.end=c,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a||(r.start=A,r.end=u,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a)||(r.start=c,r.end=u,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a))return!0;const p=o.getPlane(t);if(Math.abs(p.distanceToPoint(l))<=a){const g=p.projectPoint(l,e);if(o.containsPoint(g))return!0}return!1}}(),Ade=1e-15;function bf(n){return Math.abs(n)new z),this.satBounds=new Array(4).fill().map(()=>new kl),this.points=[this.a,this.b,this.c],this.sphere=new Qu,this.plane=new hl,this.needsUpdate=!0}intersectsSphere(e){return lde(e,this)}update(){const e=this.a,t=this.b,r=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);const A=s[1],c=o[1];A.subVectors(e,t),c.setFromPoints(A,i);const u=s[2],f=o[2];u.subVectors(t,r),f.setFromPoints(u,i);const d=s[3],h=o[3];d.subVectors(r,e),h.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Vl.prototype.closestPointToSegment=function(){const n=new z,e=new z,t=new Il;return function(i,s=null,o=null){const{start:a,end:l}=i,A=this.points;let c,u=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;t.start.copy(A[f]),t.end.copy(A[d]),X_(t,i,n,e),c=n.distanceToSquared(e),c1-1e-10){const v=this.satBounds,y=this.satAxes;t[0]=d.a,t[1]=d.b,t[2]=d.c;for(let b=0;b<4;b++){const E=v[b],x=y[b];if(r.setFromPoints(x,t),E.isSeparated(r))return!1}const w=d.satBounds,C=d.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let b=0;b<4;b++){const E=w[b],x=C[b];if(r.setFromPoints(x,e),E.isSeparated(r))return!1}for(let b=0;b<4;b++){const E=y[b];for(let x=0;x<4;x++){const S=C[x];if(s.crossVectors(E,S),r.setFromPoints(s,e),i.setFromPoints(s,t),r.isSeparated(i))return!1}}return h&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),h.start.set(0,0,0),h.end.set(0,0,0)),!0}else{const v=this.points;let y=!1,w=0;for(let B=0;B<3;B++){const F=v[B],R=v[(B+1)%3];A.start.copy(F),A.end.copy(R),A.delta(o);const k=y?c.start:c.end,T=bf(g.distanceToPoint(F));if(bf(g.normal.dot(o))&&T){c.copy(A),w=2;break}if((g.intersectLine(A,k)||T)&&!bf(k.distanceTo(R))){if(w++,y)break;y=!0}}if(w===1&&d.containsPoint(c.end))return h&&(h.start.copy(c.end),h.end.copy(c.end)),!0;if(w!==2)return!1;const C=d.points;let b=!1,E=0;for(let B=0;B<3;B++){const F=C[B],R=C[(B+1)%3];A.start.copy(F),A.end.copy(R),A.delta(a);const k=b?u.start:u.end,T=bf(m.distanceToPoint(F));if(bf(m.normal.dot(a))&&T){u.copy(A),E=2;break}if((m.intersectLine(A,k)||T)&&!bf(k.distanceTo(R))){if(E++,b)break;b=!0}}if(E===1&&this.containsPoint(u.end))return h&&(h.start.copy(u.end),h.end.copy(u.end)),!0;if(E!==2)return!1;if(c.delta(o),u.delta(a),o.dot(a)<0){let B=u.start;u.start=u.end,u.end=B}const x=c.start.dot(o),S=c.end.dot(o),M=u.start.dot(o),Z=u.end.dot(o),K=S0?h.start.copy(c.start):h.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(o)<0?h.end.copy(c.end):h.end.copy(u.end)),!0)}}}();Vl.prototype.distanceToPoint=function(){const n=new z;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}}();Vl.prototype.distanceToTriangle=function(){const n=new z,e=new z,t=["a","b","c"],r=new Il,i=new Il;return function(o,a=null,l=null){const A=a||l?r:null;if(this.intersectsTriangle(o,A))return(a||l)&&(a&&A.getCenter(a),l&&A.getCenter(l)),0;let c=1/0;for(let u=0;u<3;u++){let f;const d=t[u],h=o[d];this.closestPointToPoint(h,n),f=h.distanceToSquared(n),fnew z),this.satAxes=new Array(3).fill().map(()=>new z),this.satBounds=new Array(3).fill().map(()=>new kl),this.alignedSatBounds=new Array(3).fill().map(()=>new kl),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),r&&this.matrix.copy(r)}set(e,t,r){this.min.copy(e),this.max.copy(t),this.matrix.copy(r),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ma.prototype.update=function(){return function(){const e=this.matrix,t=this.min,r=this.max,i=this.points;for(let A=0;A<=1;A++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){const f=1*A|2*c|4*u,d=i[f];d.x=A?r.x:t.x,d.y=c?r.y:t.y,d.z=u?r.z:t.z,d.applyMatrix4(e)}const s=this.satBounds,o=this.satAxes,a=i[0];for(let A=0;A<3;A++){const c=o[A],u=s[A],f=1<new Il),t=new Array(12).fill().map(()=>new Il),r=new z,i=new z;return function(o,a=0,l=null,A=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||A)&&(o.getCenter(i),this.closestPointToPoint(i,r),o.closestPointToPoint(r,i),l&&l.copy(r),A&&A.copy(i)),0;const c=a*a,u=o.min,f=o.max,d=this.points;let h=1/0;for(let m=0;m<8;m++){const g=d[m];i.copy(g).clamp(u,f);const v=g.distanceToSquared(i);if(vt.far)?null:n}function aa(n,e,t,r){const i=n.a,s=n.b,o=n.c;let a=e,l=e+1,A=e+2;t&&(a=t.getX(e),l=t.getX(e+1),A=t.getX(e+2)),i.x=r.getX(a),i.y=r.getY(a),i.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(A),o.y=r.getY(A),o.z=r.getZ(A)}function mk(n,e,t,r,i,s,o){const a=t.index,l=t.attributes.position;for(let A=n,c=e+n;A=0;let d,h;f?(d=Om(n),h=Gm(n,a)):(d=Gm(n,a),h=Om(n));const m=Gw(d,s,r,Ow)?tU(d,e,t,r):null;if(m){const y=m.point[c];if(f?y<=s[h+A]:y>=s[h+A+3])return m}const v=Gw(h,s,r,Ow)?tU(h,e,t,r):null;return m&&v?m.distance<=v.distance?m:v:m||v||null}}const gde=function(){let n,e;const t=[],r=new FH(()=>new ws);return function(...o){n=r.getPrimitive(),e=r.getPrimitive(),t.push(n,e);const a=i(...o);r.releasePrimitive(n),r.releasePrimitive(e),t.pop(),t.pop();const l=t.length;return l>0&&(e=t[l-1],n=t[l-2]),a};function i(s,o,a,l,A=null,c=0,u=0){function f(y){let w=y*2,C=ZA,b=JA;for(;!yA(w,C);)y=Om(y),w=y*2;return Hd(y,b)}function d(y){let w=y*2,C=ZA,b=JA;for(;!yA(w,C);)y=Gm(y,b),w=y*2;return Hd(y,b)+Wm(w,C)}let h=s*2,p=Kh,m=ZA,g=JA;if(yA(h,m)){const y=Hd(s,g),w=Wm(h,m);return fa(s,p,n),l(y,w,!1,u,c+s,n)}else{const y=Om(s),w=Gm(s,g);let C=y,b=w,E,x,S,M;if(A&&(S=n,M=e,fa(C,p,S),fa(b,p,M),E=A(S),x=A(M),xi.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(A),x.b.applyMatrix4(A),x.c.applyMatrix4(A),x.needsUpdate=!0;for(let S=C*3,M=(b+C)*3;Snew Vl);class Yg{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Yg.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};const r=e.geometry,i=e._roots,s=r.getIndex();let o;return t.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(e,t,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Yg.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};const{index:i,roots:s}=e,o=new Yg(t,{...r,[a1]:!0});if(o._roots=s,r.setIndex){const a=t.getIndex();if(a===null){const l=new At(e.index,1,!1);t.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:bH,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[a1]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[a1]||(this._roots=ode(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new ws))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=this.geometry,r=t.index.array,i=t.attributes.position;let s,o,a,l,A=0;const c=this._roots;for(let f=0,d=c.length;fb&&(b=K),_E&&(E=_),Bx&&(x=B)}return l[f+0]!==y||l[f+1]!==w||l[f+2]!==C||l[f+3]!==b||l[f+4]!==E||l[f+5]!==x?(l[f+0]=y,l[f+1]=w,l[f+2]=C,l[f+3]=b,l[f+4]=E,l[f+5]=x,!0):!1}else{const g=f+8,v=o[f+6],y=g+d,w=v+d;let C=h,b=!1,E=!1;e?C||(b=e.has(y),E=e.has(w),C=!b&&!E):(b=!0,E=!0);const x=C||b,S=C||E;let M=!1;x&&(M=u(g,d,C));let Z=!1;S&&(Z=u(v,d,C));const K=M||Z;if(K)for(let _=0;_<3;_++){const B=g+_,F=v+_,R=l[B],k=l[B+3],T=l[F],V=l[F+3];l[f+_]=RV?k:V}return K}}}traverse(e,t=0){const r=this._roots[t],i=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){const A=a*2,c=s[A+15]===qE;if(c){const u=i[a+6],f=s[A+14];e(l,c,new Float32Array(r,a*4,6),u,f)}else{const u=a+hB/4,f=i[a+6],d=i[a+7];e(l,c,new Float32Array(r,a*4,6),d)||(o(u,l+1),o(f,l+1))}}}raycast(e,t=Vo){const r=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,A=o?t.side:t;for(let c=0,u=r.length;c{const g=h*3;return f(d,g,g+1,g+2,p,m)}}e={boundsTraverseOrder:r,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}const s=Xo.getPrimitive();let{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:A}=e;if(l&&A){const f=l;l=(d,h,p,m,g)=>f(d,h,p,m,g)?!0:mk(d,h,i,A,p,m,s)}else l||(A?l=(f,d,h,p)=>mk(f,d,i,A,h,p,s):l=(f,d,h)=>h);let c=!1,u=0;for(const f of this._roots){if(Cg(f),c=gde(0,i,a,l,o,u),cy(),c)break;u+=f.byteLength}return Xo.releasePrimitive(s),c}bvhcast(e,t,r){let{intersectsRanges:i,intersectsTriangles:s}=r;const o=this.geometry.index,a=this.geometry.attributes.position,l=e.geometry.index,A=e.geometry.attributes.position;xf.copy(t).invert();const c=Xo.getPrimitive(),u=Xo.getPrimitive();if(s){let d=function(h,p,m,g,v,y,w,C){for(let b=m,E=m+g;bA1.intersectsBox(d),intersectsRange:(d,h,p,m,g,v)=>(l1.copy(v),l1.applyMatrix4(xf),e.shapecast({intersectsBounds:y=>l1.intersectsBox(y),intersectsRange:(y,w,C,b,E)=>i(d,h,y,w,m,g,b,E)}))});return Xo.releasePrimitive(c),Xo.releasePrimitive(u),f}intersectsBox(e,t){return Uc.set(e.min,e.max,t),Uc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Uc.intersectsBox(r),intersectsTriangle:r=>Uc.intersectsTriangle(r)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,r={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Uc.set(e.boundingBox.min,e.boundingBox.max,t),Uc.needsUpdate=!0;const a=this.geometry,l=a.attributes.position,A=a.index,c=e.attributes.position,u=e.index,f=Xo.getPrimitive(),d=Xo.getPrimitive();let h=uy,p=vde,m=null,g=null;i&&(m=yde,g=Bde);let v=1/0,y=null,w=null;return xf.copy(t).invert(),Wp.matrix.copy(xf),this.shapecast({boundsTraverseOrder:C=>Uc.distanceToBox(C),intersectsBounds:(C,b,E)=>E{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:E=>Wp.distanceToBox(E),intersectsBounds:(E,x,S)=>S{for(let S=E*3,M=(E+x)*3;S(Op.copy(e).clamp(c.min,c.max),Op.distanceToSquared(e)),intersectsBounds:(c,u,f)=>f{c.closestPointToPoint(e,Op);const f=e.distanceToSquared(Op);return f{fa(0,new Float32Array(r),vk),e.union(vk)}),e}}const c1=new l0,yk=new Le,wde=In.prototype.raycast;function Cde(n,e){if(this.geometry.boundsTree){if(this.material===void 0)return;yk.copy(this.matrixWorld).invert(),c1.copy(n.ray).applyMatrix4(yk);const t=this.geometry.boundsTree;if(n.firstHitOnly===!0){const r=gk(t.raycastFirst(c1,this.material),this,n);r&&e.push(r)}else{const r=t.raycast(c1,this.material);for(let i=0,s=r.length;i{const e=n.attributes.position,t=n.index,r=new ns,i=new z,s=new z,o=new z,a=[];for(let l=0;l{const e=n.geometry.clone();let t=[];if(Array.isArray(n.material))for(let i=0;i{n.isMesh&&(n.geometry.userData.faceNormals=null,n.geometry.dispose(),n.geometry.disposeBoundsTree(),n.parent&&n.parent.remove(n),n.userData.cancelMesh&&gB(n.userData.cancelMesh))},EH=n=>{var e,t;n.userData.cullingClone&&(gB(n.userData.cullingClone),n.userData.cullingClone=null,gB(n.userData.cullingCloneP),n.userData.cullingCloneP=null,gB(n.userData.cullingCloneN),n.userData.cullingCloneN=null,((e=n.userData)==null?void 0:e.clippedIndexGeometry)!=null&&(n.userData.clippedIndexGeometry=null),((t=n.userData)==null?void 0:t.origIndexBuffer)!=null&&(n.userData.origIndexBuffer=null))},Qde=async n=>{if(n==null){console.warn("Null parameter for meshes was provided. Skipping mesh culling.");return}if(!Array.isArray(n)){console.warn("No valid mesh array was provided. Skipping mesh culling.");return}if(n.length==0){console.warn("No mesh array with elements was provided. Skipping mesh culling.");return}const e=[];bg=n[0].parent,bg.lines!=null&&(bg.lines.forEach(i=>{i.visible=!1}),bg.lines.length=0),n.forEach(i=>{if(i.userData.cullLayer!=null){i.userData.origIndexBuffer==null&&(i.userData.origIndexBuffer=i.geometry.index.clone()),e[i.userData.cullLayer]==null&&(e[i.userData.cullLayer]={origMeshes:[],cloneMeshes:[],posMeshes:[],negMeshes:[],scaleMeshes:[],positionMeshes:[]}),i.userData.cullingClone==null&&(i.userData.cullingClone=_de(i),i.userData.cullingCloneP=i.userData.cullingClone.clone(),i.userData.cullingCloneN=i.userData.cullingClone.clone());const s=i.userData.cullingClone,o=i.userData.cullingCloneP,a=i.userData.cullingCloneN;o.material=Ede,a.userData.cancelMesh=o,a.material=Ude,o.userData.maxCullDistance=a.userData.maxCullDistance=i.userData.maxCullDistance,e[i.userData.cullLayer].origMeshes.push(i),e[i.userData.cullLayer].cloneMeshes.push(s),e[i.userData.cullLayer].posMeshes.push(o),e[i.userData.cullLayer].negMeshes.push(a),i.geometry.setIndex(i.userData.origIndexBuffer)}});for(let i=e.length-1;i>=0;i--)e[i]==null&&e.splice(i,1);let t=[];const r=[];for(let i=e.length-1;i>=0;i--){if(t.length!=0||e.length>=1)for(let s=0;s{i.geom.setIndex(i.index)})},Rde=n=>{let e=Ide,t=Fde;return n&&(isNaN(n)?Array.isArray(n)&&(isNaN(n[0])||(e=n[0]),isNaN(n[1])||(t=n[1])):e=n),[e,t]},Mde=(n,e,t,r,i,s,o=!1)=>{const a=[],l=Rde(s);let A=l[0],c=l[1];fy.far=A+c;for(let f=0;f=0;v--)A-g[v].distance>=g[v].object.userData.maxCullDistance&&g.splice(v,1);if(g.length===0){for(let v=0;v<3;v++)a.push(n[d+v]);break}else{const v=g.map(y=>y.object);for(let y=0;yy).length===0){for(let y=0;y<3;y++)a.push(n[d+y]);break}if(p===0)h=g.map(y=>y.object);else if(h=g.map(y=>{if(h.indexOf(y.object)!==-1)return y.object}),h=h.filter(y=>y),p===2&&h.filter(y=>y).length===0)for(let y=0;y<3;y++)a.push(n[d+y]);o&&Tde(u1,Gp.clone().multiplyScalar(-1),fy.far,16711680,bg)}}}const u=new Uint32Array(a);return new At(u,1,!1)};function Tde(n,e,t,r,i){i.lines==null&&(i.lines=[]);let s=new z;s.addVectors(n,e.clone().multiplyScalar(t));const o=[];o.push(n),o.push(s);const a=new Ht().setFromPoints(o),l=[];l.push(new Re(0)),l.push(new Re(16777215));let A=new Wl({color:r});var c=new kh(a,A);c.renderOrder=100,i.add(c),i.lines.push(c)}function UH(n){let e,t,r,i=0;for(let a=0;atypeof window>"u"?await Lde({meshes:e,atlasSize:t,mtoon:r,transparentMaterial:i,transparentTexture:s}):await Pde({backColor:n,meshes:e,atlasSize:t,mtoon:r,transparentMaterial:i,transparentTexture:s,twoSidedMaterial:o}),Lde=async({meshes:n,atlasSize:e,mtoon:t,transparentMaterial:r,transparentTexture:i})=>{const s=e,o=["diffuse"],a=[];n.forEach(E=>{const x=E.material;let S=a.find(M=>M.material===x);if(!S)a.push({material:x,mesh:E});else{const{dest:M}=K_({meshes:[S.mesh,E]});S.mesh.geometry=M}});const l=Object.fromEntries(o.map(E=>[E,SH({width:s,height:s,transparent:i})])),A=Math.floor(Math.sqrt(n.length)+1),c=s/A,u=new Map(a.map((E,x)=>{const S=new We(x%A,Math.floor(x/A)).multiplyScalar(1/A),M=new We(S.x+1/A,S.y+1/A);return[E.mesh,{min:S,max:M}]})),f={diffuse:["map"],normal:["normalMap"],orm:["ormMap","aoMap","roughnessMap","metalnessMap"]},d=[],h=[];a.forEach(E=>{const{min:x,max:S}=u.get(E.mesh);h.push(S),d.push(x)});const p=new We(Math.max(...h.map(E=>E.x)),Math.max(...h.map(E=>E.y))),m=new We(Math.min(...d.map(E=>E.x)),Math.min(...d.map(E=>E.y))),g=1/(p.x-m.x),v=1/(p.y-m.y),y=c*g,w=c*v,C=new Map(a.map(E=>{let{min:x,max:S}=u.get(E.mesh);return x.x=x.x*g,x.y=x.y*v,S.x=S.x*g,S.y=S.y*v,[E.mesh,{min:x,max:S}]}));a.forEach(E=>{const{material:x,mesh:S}=E,{min:M,max:Z}=C.get(S);o.forEach(F=>{const R=l[F];R.globalCompositeOperation="source-over";let k=rU(x,f[F].find(T=>rU(x,T)));if(k!==""&&k!==void 0)try{const T=new Uint8ClampedArray(k.data),V=new ImageData(T,y,w),O=document.createElement("canvas");O.width=y,O.height=w;const L=O.getContext("2d");L.putImageData(V,0,0),L.save(),R.drawImage(O,M.x*s,M.y*s,y,w)}catch(T){console.error("error",T)}else R.fillStyle=F==="diffuse"?`#${x.color.clone().getHexString()}`:F==="normal"?"#8080ff":F==="orm"?`#${new Re(x.aoMapIntensity,x.roughness,x.metalness).getHexString()}`:"#7F7F7F",R.fillRect(M.x*s,M.y*s,y,w)});const K=S.geometry,_=K.attributes.uv;if(_)for(let F=0;F<_.array.length;F+=2)_.array[F]=_A(_.array[F],0,1,M.x,Z.x),_.array[F+1]=_A(_.array[F+1],0,1,M.y,Z.y);const B=K.attributes.uv2;if(B)for(let F=0;F{const x=new ir(l[E].canvas);return x.flipY=!1,[E,x]})));return{bakeObjects:a,textures:b,uvs:C}},Pde=async({backColor:n,meshes:e,atlasSize:t,mtoon:r,transparentMaterial:i,transparentTexture:s,twoSidedMaterial:o})=>{Nde();const a=t,l=r?["diffuse"]:["diffuse","orm"],A=[];let c=null;e.forEach(_=>{_=_.clone();const B=_.material.length==null?_.material:_.material[0];r&&c==null&&B.type=="ShaderMaterial"&&(c=B.clone());let F=A.find(R=>{R.material});if(!F)A.push({material:B,mesh:_});else{const{dest:R}=K_({meshes:[F.mesh,_]});F.mesh.geometry=R}});const u=Object.fromEntries(l.map(_=>[_,SH({width:a,height:a,transparent:s})])),f=Math.floor(Math.sqrt(e.length)+1),d=a/f,h=new Map(A.map((_,B)=>{const F=new We(B%f,Math.floor(B/f)).multiplyScalar(1/f),R=new We(F.x+1/f,F.y+1/f);return[_.mesh,{min:F,max:R}]})),p={diffuse:["map"],normal:["normalMap"],orm:["ormMap","aoMap","roughnessMap","metalnessMap"]},m=[],g=[];A.forEach(_=>{const{min:B,max:F}=h.get(_.mesh);g.push(F),m.push(B)});const v=new We(Math.max(...g.map(_=>_.x)),Math.max(...g.map(_=>_.y))),y=new We(Math.min(...m.map(_=>_.x)),Math.min(...m.map(_=>_.y))),w=1/(v.x-y.x),C=1/(v.y-y.y),b=d*w,E=d*C,x=new Map(A.map(_=>{let{min:B,max:F}=h.get(_.mesh);return B.x=B.x*w,B.y=B.y*C,F.x=F.x*w,F.y=F.y*C,[_.mesh,{min:B,max:F}]}));A.forEach(_=>{const{material:B,mesh:F}=_,{min:R,max:k}=x.get(F);l.forEach(L=>{var oe;const U=u[L];U.globalCompositeOperation="source-over";let H,Ae=new Re(1,1,1);switch(L){case"diffuse":H=B.color||n,(oe=B.uniforms)!=null&&oe.litFactor&&(Ae=B.uniforms.litFactor.value);break;case"normal":H=new Re(8421631);break;case"orm":H=new Re(B.aoMapIntensity,B.roughness,B.metalness);break;default:H=new Re(1,1,1);break}let N=kde(B,p[L].find(ie=>rU(B,ie)));const j=Dde(N,Ae,H,a,a,s);createImageBitmap(j).then(ie=>U.drawImage(ie,R.x*a,R.y*a,b,E))});const T=F.geometry.clone();F.geometry=T;const V=T.attributes.uv.clone();if(T.attributes.uv=V,V)for(let L=0;L{const B=new ir(u[_].canvas);return B.flipY=!1,[_,B]}))),M=o?pi:Vo;let Z;const K=i?"transparent":"opaque";return r?(Z=new mu({map:S.diffuse,transparent:i,side:M}),c==null&&(c=new dB),c.side=M,c.uniforms.map=S.diffuse,c.uniforms.shadeMultiplyTexture=S.diffuse,c.transparent=i,s&&!i&&(Z.alphaTest=.5,c.alphaTest=.5),Z.userData.vrmMaterial=c,Z.userData.shadeTexture=S.uniformColor,Z.name="mToon_"+K,Z.map.name=Z.name):(Z=new mu({map:S.diffuse,roughnessMap:S.orm,metalnessMap:S.orm,normalMap:S.normal,transparent:i,side:M}),s&&!i&&(Z.alphaTest=.5),Z.name="standard_"+K,Z.roughnessMap!=null&&(Z.roughnessMap.name=Z.name+"_orm"),Z.normalMap!=null&&(Z.normalMap.name=Z.name+"_normal")),{bakeObjects:A,material:Z}};function _H(n){const e=new Map;for(const r of n.skeleton.bones){const i=r.clone(!1);e.set(r,i)}n.skeleton.bones[0].traverse(r=>{if(r.type!=="Bone")return;const i=e.get(r);for(const s of r.children){const o=e.get(s);o&&i.add(o)}});const t=new hc(n.skeleton.bones.map(r=>e.get(r)));return t.boneInverses=n.skeleton.boneInverses,t.pose(),t}function QH(n,e){const t=new Map;new z(-1,1,-1),new Le,new z;let r=0;n.forEach(l=>{if(l.skeleton){var A=_H(l);const c=A.bones;A.bones.forEach((u,f)=>{var d;if(c.indexOf(u)!==-1){const h=t.get(u.name);if(h==null){const p={index:r,boneInverses:A.boneInverses[f],bone:u.clone(!1),parentName:((d=u.parent)==null?void 0:d.type)=="Bone"?u.parent.name:null};r++,t.set(u.name,p)}else u.userData.VRMcolliders!=null&&(h.bone.userData.VRMcolliders==null?h.bone.userData.VRMcolliders=u.userData.VRMcolliders:h.bone.userData.VRMcolliders=[...h.bone.userData.VRMcolliders,...u.userData.VRMcolliders])}})}});const i=[],s=[];[...t.values()].forEach(l=>{var A;if(i.push(l.bone),s.push(l.boneInverses),l.parentName!=null){const c=(A=t.get(l.parentName))==null?void 0:A.bone;c&&c.add(l.bone)}});const a=new hc(i,s);return a.bones.forEach(l=>{var c;const A=(c=l.userData)==null?void 0:c.vrm0RestPosition;A&&l.position.set(-A.x,A.y,-A.z),l.position.set(l.position.x*e,l.position.y*e,l.position.z*e)}),a}function Wde(n,e){if(!e.skeleton)return;const t=new Map;if(e.skeleton){e.skeleton.bones.forEach((o,a)=>{const l=n.bones.filter(c=>c.name===o.name),A=l.length>0?n.bones.indexOf(l[0]):-1;t.set(a,A)});const r=[],i=e.geometry.attributes.skinIndex.array;for(let o=0;oe.indexOf(t)===r)}function Ode(n){const t=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array].filter(r=>n.constructor===r);return t.length&&t[0]||null}function Zw(n,e){const t=[];for(let s=0;ss.name===r.name);return i?t.bones.indexOf(i):-1}async function Jde(n,e){const{scale:t,isVrm0:r}=e,i=[],s=[];Ih(n,"SkinnedMesh").forEach(A=>{const c=A.clone();i.push(c),Array.isArray(A.material)?s.push(...A.material):s.push(A.material)});const a=QH(i,t),l=new kt;return l.name="AvatarRoot",i.forEach(A=>{var b;const c=new Ht,u={};for(const E in A.geometry.attributes){const x=A.geometry.attributes[E];u[E]=x.clone()}if((b=A.userData)!=null&&b.isVRM0)for(let E=0;E[E,E.geometry.morphAttributes])),h=new Map([A].map(E=>[E,E.morphTargetDictionary||{}]));if(f.morphAttributes=MH({meshes:[A],sourceMorphAttributes:d,sourceMorphTargetDictionaries:h,destMorphTargetDictionary:f.morphTargetDictionary,scale:t},r),r)for(let E=0;Ed.name===e.userData.boneName),s=e.userData.globalPosition,o=e.userData.globalScale||new z(1,1,1),a=e.userData.globalRotationMatrix;t.add(r.bones[0]);const l=[],A=[],c=t.geometry.attributes.position.array,u=new z,f=e.userData.isVRM0?-1:1;for(let d=0;d0){const{bakeObjects:M,material:Z}=await Vde({transparentColor:t,atlasSize:x.size,meshes:S,mtoon:x.isMtoon,transparentMaterial:x.transparentMaterial,transparentTexture:y,twoSidedMaterial:u}),K=M.map(T=>T.mesh),_=[];K.forEach(T=>{T.type=="Mesh"&&(T=zde(C,T)),_.push(T);const V=T.geometry,O=V.index.array,L=RH(T.geometry.index.array),U=[];for(let N=0;N{const o=n.find(l=>e.get(l).hasOwnProperty(i)),a=o.morphTargetDictionary[i];r[s]=o.morphTargetInfluences[a]}),r}function Kde({sourceAttributes:n}){const e=new Set,t=Array.from(n.values());t.forEach(i=>{Object.keys(i).forEach(s=>e.add(s))});const r={};return Array.from(e.keys()).map(i=>{r[i]=UH(t.map(s=>s[i]).flat().filter(s=>s!==void 0))}),r}function jde({sourceMorphTargetDictionaries:n}){const e=new Set;Array.from(n.values()).forEach(i=>{Object.keys(i).forEach(s=>e.add(s))});const r={};return Array.from(e.keys()).map((i,s)=>{r[i]=s}),r}function MH({meshes:n,sourceMorphTargetDictionaries:e,sourceMorphAttributes:t,destMorphTargetDictionary:r,scale:i},s=!1){const o=new Set;Array.from(t.values()).forEach(u=>{Object.keys(u).forEach(f=>o.add(f))});const l=Array.from(o),A={};l.forEach(u=>{A[u]=[],Object.entries(r).forEach(([f,d])=>{A[u][d]=[],n.forEach(h=>{let p;const m=e.get(h);if(m.hasOwnProperty(f)&&h.geometry.morphAttributes[u]){const g=m[f];p=h.geometry.morphAttributes[u][g]}else{const g=h.geometry.attributes[u],v=new g.array.constructor(new Array(g.array.length).fill(0));p=new At(v,g.itemSize,g.normalized)}A[u][d].push(p)})})});const c={};return l.forEach(u=>{c[u]=[];for(let f=0;f{const i=r.geometry.index;for(var s=0;s{var l;if(r+=a.geometry.attributes.uv.count,(l=a.userData)!=null&&l.isVRM0)for(let A=0;A[a,a.geometry.attributes])),morphAttributes:new Map(n.map(a=>[a,a.geometry.morphAttributes])),morphTargetDictionaries:new Map(n.map(a=>[a,a.morphTargetDictionary||{}])),morphTargetInfluences:new Map(n.map(a=>[a,a.morphTargetInfluences||[]]))},s={attributes:null,morphTargetDictionary:null,morphAttributes:null,morphTargetInfluences:null,index:null,animations:{}};s.attributes=Kde({sourceAttributes:i.attributes});const o=jde({sourceMorphTargetDictionaries:i.morphTargetDictionaries});return s.morphTargetDictionary=o,s.morphAttributes=MH({meshes:n,sourceMorphAttributes:i.morphAttributes,sourceMorphTargetDictionaries:i.morphTargetDictionaries,destMorphTargetDictionary:o,scale:e},t),s.morphTargetInfluences=Xde({meshes:n,sourceMorphTargetDictionaries:i.morphTargetDictionaries,destMorphTargetDictionary:o}),s.index=$de({meshes:n}),s.animations={},{source:i,dest:s}}function Yt(n){return n==null?[]:Array.isArray(n)?n:[n]}async function qde(n,e){const r=await new Nu().load(e);r.encoding=ht,r.flipY=!1,n.traverse(i=>{if(i instanceof In){const s=Array.isArray(i.material)?i.material:[i.material];for(let o=0;o{const e=[];for(const t in n){const r=n[t].vrm;if(r){const i=r.data.cullingLayer;i>=0&&r.data.cullingMeshes.map(s=>{s.userData.cullLayer=i,s.userData.cullDistance=r.data.cullingDistance,s.userData.maxCullDistance=r.data.maxCullingDistance,e.push(s)})}}Qde(e)};function nhe(n){const e=[],t=[],r=[],i=[];let s=!1;return n.forEach(o=>{var A;const l=Yt(o.material)[0];l.type=="ShaderMaterial"?l.transparent==!0?(i.push(o),s=!0):(r.push(o),((A=l.uniforms.alphaTest)==null?void 0:A.value)!=0&&(s=!0)):l.transparent==!0?(t.push(o),s=!0):(e.push(o),l.alphaTest!=0&&(s=!0))}),{stdMesh:e,stdTranspMesh:t,mToonMesh:r,mToonTranspMesh:i,requiresTransparency:s}}function rhe(n){const e=[],t=[],r=[],i=[],s=[],o=[];return n.forEach(a=>{Yt(a.material).forEach(A=>{A.type=="ShaderMaterial"?A.transparent==!0?o.push(A):A.uniforms.alphaTest.value!=0?s.push(A):i.push(A):A.transparent==!0?r.push(A):A.alphaTest!=0?t.push(A):e.push(A)})}),{stdMats:e,stdCutoutpMats:t,stdTranspMats:r,mToonMats:i,mToonCutoutMats:s,mToonTranspMats:o}}function wk(n,e){n.data==null?n.data=e:n.data={...n.data,...e}}function ihe(n,e){if(n.data!=null)return n.data[e]}function she(n){const e=ihe(n,"cullingMeshes");e&&(e.forEach(t=>{EH(t)}),n.data.cullingMeshes=null)}function Cn(n){switch(n){case 1:return 128;case 2:return 256;case 3:return 512;case 4:return 1024;case 5:return 2048;case 6:return 4096;case 7:return 8192;case 8:return 16384;default:return 4096}}function ohe(n){const e=n.scene;she(n),e.traverse(t=>{t.material&&iU(t.material),t.geometry&&(EH(t),t.geometry.dispose(),t.geometry.disposeBoundsTree())}),e.parent&&e.parent.remove(e),Xh.deepDispose(e),n.expressionManager&&n.expressionManager.expressions.forEach(t=>{t._binds&&t._binds.forEach(r=>{r.primitives&&r.primitives.forEach(i=>{i.geometry.dispose(),i.material&&iU(i.material)})})});for(const t in n)n[t]=null}const iU=n=>{var e,t,r,i,s,o;if(n.length)for(let a=0;a{const t=new Blob([n],{type:"text/plain"}),r=document.createElement("a");r.href=window.URL.createObjectURL(t),r.download=e+".txt",document.body.appendChild(r),r.click(),document.body.removeChild(r)},TH=n=>{let e,t,r=0;return Array.isArray(n)?(e=n[0]||0,t=n[1]||0,r=n[2]||0):(typeof n=="string"||n instanceof String)&&n.split("-").forEach(s=>{switch(s=s.toLowerCase(),s){case"left":e=-1;break;case"right":e=1;break;case"bottom":case"down":t=-1;break;case"top":case"up":t=1;break;case"back":case"backward":r=-1;break;case"front":case"forward":r=1;break;default:console.warn("unkown cameraPosition name: "+s+" in: "+n+". Please use left, right, bottom, top, back or front");break}}),new z(e,t,r)},lhe=n=>{var t,r,i,s,o,a,l,A,c,u,f;const e=n.humanoid.humanBones;e.upperChest==null&&e.neck.node.parent!=e.chest&&(e.neck.node.parent!=e.chest.node?e.upperChest={node:e.neck.node.parent}:e.upperChest!=null&&(e.upperChest={node:e.neck.node.parent},e.chest={node:e.neck.node.parent.parent})),e.leftShoulder==null&&(e.leftUpperArm.node.parent!=((t=e.chest)==null?void 0:t.node)&&e.leftUpperArm.node.parent!=((r=e.upperChest)==null?void 0:r.node)&&e.leftUpperArm.node.parent!=((i=e.spine)==null?void 0:i.node)&&e.leftUpperArm.node.parent!=((s=e.neck)==null?void 0:s.node)&&e.leftUpperArm.node.parent!=((o=e.head)==null?void 0:o.node),e.leftShoulder={node:e.leftUpperArm.node.parent}),e.rightShoulder==null&&(e.rightUpperArm.node.parent!=((a=e.chest)==null?void 0:a.node)&&e.rightUpperArm.node.parent!=((l=e.upperChest)==null?void 0:l.node)&&e.rightUpperArm.node.parent!=((A=e.spine)==null?void 0:A.node)&&e.rightUpperArm.node.parent!=((c=e.neck)==null?void 0:c.node)&&e.rightUpperArm.node.parent!=((u=e.head)==null?void 0:u.node),e.rightShoulder={node:e.rightUpperArm.node.parent});for(let d in Lm)d=d.charAt(0).toLowerCase()+d.slice(1),(f=e[d])!=null&&f.node&&(e[d].node.name=d)};function NH({candidates:n,predicate:e}){if(!n.length)return null;const t=n.shift();return e(t)?t:(n=n.concat(t.children),NH({candidates:n,predicate:e}))}function DH(n,e){return NH({candidates:[n],predicate:t=>t.name===e})}function kH({candidates:n,predicate:e,results:t=[]}){if(!n.length)return t;const r=n.shift();return e(r)&&t.push(r),n=n.concat(r.children),kH({candidates:n,predicate:e,results:t})}function Ih(n,e){return kH({candidates:[n],predicate:t=>Yt(e).includes(t.type)})}function Ahe(n,e,t){const r=Ih(n,"SkinnedMesh");return{humanBones:uhe(r[0]),materials:n.userData.atlasMaterial,meta:che(e,t)}}function che(n,e){return e=e||{},{...{authors:["CharacterStudio"],metaVersion:"1",version:"v1",name:n,licenseUrl:"https://vrm.dev/licenses/1.0/",commercialUssageName:"personalNonProfit",contactInformation:"https://m3org.com/",allowExcessivelyViolentUsage:!1,allowExcessivelySexualUsage:!1,allowPoliticalOrReligiousUsage:!1,allowAntisocialOrHateUsage:!1,creditNotation:"required",allowRedistribution:!1,modification:"prohibited"},...e}}function uhe(n){const e={};return n.skeleton.bones.map(t=>{for(const r in Lm)if(Lm[r]===t.name){e[t.name]={node:t};break}}),e}const fhe={mixamorigHips:"hips",mixamorigSpine:"spine",mixamorigSpine1:"chest",mixamorigSpine2:"upperChest",mixamorigNeck:"neck",mixamorigHead:"head",mixamorigLeftShoulder:"leftShoulder",mixamorigLeftArm:"leftUpperArm",mixamorigLeftForeArm:"leftLowerArm",mixamorigLeftHand:"leftHand",mixamorigLeftHandThumb1:"leftThumbMetacarpal",mixamorigLeftHandThumb2:"leftThumbProximal",mixamorigLeftHandThumb3:"leftThumbDistal",mixamorigLeftHandIndex1:"leftIndexProximal",mixamorigLeftHandIndex2:"leftIndexIntermediate",mixamorigLeftHandIndex3:"leftIndexDistal",mixamorigLeftHandMiddle1:"leftMiddleProximal",mixamorigLeftHandMiddle2:"leftMiddleIntermediate",mixamorigLeftHandMiddle3:"leftMiddleDistal",mixamorigLeftHandRing1:"leftRingProximal",mixamorigLeftHandRing2:"leftRingIntermediate",mixamorigLeftHandRing3:"leftRingDistal",mixamorigLeftHandPinky1:"leftLittleProximal",mixamorigLeftHandPinky2:"leftLittleIntermediate",mixamorigLeftHandPinky3:"leftLittleDistal",mixamorigRightShoulder:"rightShoulder",mixamorigRightArm:"rightUpperArm",mixamorigRightForeArm:"rightLowerArm",mixamorigRightHand:"rightHand",mixamorigRightHandPinky1:"rightLittleProximal",mixamorigRightHandPinky2:"rightLittleIntermediate",mixamorigRightHandPinky3:"rightLittleDistal",mixamorigRightHandRing1:"rightRingProximal",mixamorigRightHandRing2:"rightRingIntermediate",mixamorigRightHandRing3:"rightRingDistal",mixamorigRightHandMiddle1:"rightMiddleProximal",mixamorigRightHandMiddle2:"rightMiddleIntermediate",mixamorigRightHandMiddle3:"rightMiddleDistal",mixamorigRightHandIndex1:"rightIndexProximal",mixamorigRightHandIndex2:"rightIndexIntermediate",mixamorigRightHandIndex3:"rightIndexDistal",mixamorigRightHandThumb1:"rightThumbMetacarpal",mixamorigRightHandThumb2:"rightThumbProximal",mixamorigRightHandThumb3:"rightThumbDistal",mixamorigLeftUpLeg:"leftUpperLeg",mixamorigLeftLeg:"leftLowerLeg",mixamorigLeftFoot:"leftFoot",mixamorigLeftToeBase:"leftToes",mixamorigRightUpLeg:"rightUpperLeg",mixamorigRightLeg:"rightLowerLeg",mixamorigRightFoot:"rightFoot",mixamorigRightToeBase:"rightToes"};function VH(n,e,t){var p;const r=vu.findByName(n,"mixamo.com");if(r==null)return null;const i=[],s=new tt,o=new tt,a=new tt,l=new z,A=e.getObjectByName("mixamorigHips").position.y,c=(p=t.humanoid)==null?void 0:p.getNormalizedBoneNode("hips").getWorldPosition(l).y,u=t.scene.getWorldPosition(l).y,d=Math.abs(c-u)/A;return r.tracks.forEach(m=>{const g=m.clone(),v=g.name.split("."),y=v[0],C=fhe[y],b=e.getObjectByName(y);if(C!=null){const E=v[1];if(b.getWorldQuaternion(s).invert(),b.parent.getWorldQuaternion(o),g instanceof Qa){for(let x=0;x{g.values[Z+x]=M})}i.push(new Qa(`${C}.${E}`,g.times,g.values.map((x,S)=>{var M;return((M=t.meta)==null?void 0:M.metaVersion)==="0"&&S%2===0?-x:x})))}else if(g instanceof ec){const x=g.values.map((S,M)=>{var Z;return(((Z=t.meta)==null?void 0:Z.metaVersion)==="0"&&M%3!==1?-S:S)*d});i.push(new ec(`${C}.${E}`,g.times,x))}}}),new vu("vrmAnimation",r.duration,i)}const dhe=new Ese,hhe=new x_,h1=.2,phe=n=>Math.floor(Math.random()*n);class Ck{constructor(e,t,r,i,s,o,a){var l,A,c,u;this.mixer=new wie(t),this.actions=[],this.to=null,this.from=null,this.vrm=r,this.animationManager=e,this.mixamoModel=null,this.fadeOutActions=null,this.newAnimationWeight=1,this.neckBone=(A=(l=r==null?void 0:r.humanoid)==null?void 0:l.humanBones)==null?void 0:A.neck,this.spineBone=(u=(c=r==null?void 0:r.humanoid)==null?void 0:c.humanBones)==null?void 0:u.spine,this.timeScale=1,i&&(this.setAnimations(i,null,null,a),this.to=this.actions[s],o!=-1&&(this.from=this.actions[o],this.from.reset(),this.from.time=e.getFromActionTime(),this.from.play(),this.to.weight=e.getWeightIn(),this.from.weight=e.getWeightOut()),this.actions[s].reset(),this.actions[s].time=e.getToActionTime(),this.actions[s].play())}setTimeScale(e){this.timeScale=e,this.actions.forEach(t=>{t.timeScale=e})}setMouseLookEnabled(e){this.setAnimations(this.animations,this.mixamoModel,e)}setAnimations(e,t=null,r=null,i=!1){if(r=r??this.animationManager.mouseLookEnabled,this.animations=e,t!=null){if(this.vrm!=null){const s=VH(e,t,this.vrm);s&&(e=[s],this.mixamoModel=t)}}else{const s=[];e.forEach(o=>{s.push(o.clone())}),e=s}if(r&&e[0].tracks.map((s,o)=>{(s.name==="neck.quaternion"||s.name==="spine.quaternion")&&e[0].tracks.splice(o,1)}),i){this.actions.forEach(s=>{s.weight=0,s.stop()}),this.actions=[],this.newAnimationWeight=1;for(let s=0;s{r.weight=1-this.newAnimationWeight}),this.newAnimationWeight>=1&&(this.newAnimationWeight=1,this.fadeOutActions.forEach(r=>{r.weight=0,r.stop()}),this.fadeOutActions=null),this.actions.forEach(r=>{r.weight=this.newAnimationWeight})),this.from!=null&&(this.from.weight=t),this.to!=null&&(this.to.weight=e),this.mixer.update(1/30)}reset(){this.mixer.setTime(0),this.to.paused=!0}resume(){this.to.paused=!1}setTime(e){this.mixer.setTime(e)}dispose(){this.animationManager.disposeAnimation(this)}}class ghe{constructor(){this.animationPaths=null,this.lastAnimID=null,this.mainControl=null,this.animationControl=null,this.animations=null,this.paused=!1,this.scale=1,this.curLoadAnim=0,this.currentAnimationName="",this.weightIn=NaN,this.weightOut=NaN,this.lastAnimID=-1,this.curAnimID=0,this.animationControls=[],this.started=!1,this.mouseLookEnabled=!1,this.mixamoModel=null,this.mixamoAnimations=null,this.currentClip=null,setInterval(()=>{this.update()},1e3/30)}enableMouseLook(e){this.mouseLookEnabled=e,this.animationControls.forEach(t=>{t.setMouseLookEnabled(e)})}setScale(e){this.scale=e}async loadAnimation(e,t,r=0,i=!0,s="",o=""){const a=s+(s!=""?"/":"")+Yt(e)[0];o=o==""?rc(a):o,this.currentAnimationName=o;const A=await(i?dhe:hhe).loadAsync(a);A.scale.set(this.scale,this.scale,this.scale),this._scaleOffsetHips(A.animations);const c=vu.findByName(A.animations,"mixamo.com");c!=null?(this.mixamoModel=A.clone(),this.mixamoAnimations=A.animations,this.currentClip=c):(this.mixamoModel=null,this.animations=A.animations,this.currentClip=A.animations[0]),this.mainControl==null&&(this.curAnimID=0,this.lastAnimID=-1,this.mainControl=new Ck(this,A,null,A.animations,this.curAnimID,this.lastAnimID,t),this.animationControls.push(this.mainControl)),this.animationControls.forEach(u=>{u.setAnimations(A.animations,this.mixamoModel,this.mouseLookEnabled,t)}),this.setTime(r),t?this.pause():this.play()}getCurrentClip(){return this.currentClip}getCurrentAnimationName(){return this.currentAnimationName}clearCurrentAnimations(){this.animationPaths=null,this.animationControls=[],this.mainControl=null}storeAnimationPaths(e,t){const r=Yt(e);this.animationPaths=r.map(i=>`${t}/${i}`)}loadNextAnimation(){this.curLoadAnim==this.animationPaths.length-1?this.curLoadAnim=0:this.curLoadAnim++,this.loadAnimation(this.animationPaths[this.curLoadAnim])}loadPreviousAnimation(){this.curLoadAnim==0?this.curLoadAnim=this.animationPaths.length-1:this.curLoadAnim--,this.loadAnimation(this.animationPaths[this.curLoadAnim])}enableScreenshot(){this.animationControls.forEach(e=>{e.reset()})}disableScreenshot(){this.animationControls.forEach(e=>{e.resume()})}_scaleOffsetHips(e){e.forEach(t=>{for(let r=0;rr.vrm===e);t!==-1&&this.animationControls.splice(t,1)[0].dispose()}getFromActionTime(){return this.mainControl.actions[this.lastAnimID].time}getToActionTime(){return this.mainControl?this.mainControl.actions[this.curAnimID].time:.1}getWeightIn(){return this.weightIn}getWeightOut(){return this.weightOut}disposeAnimation(e){if(e!=null){const t=this.animationControls.indexOf(e);t!=-1&&this.animationControls.splice(t,1)}}dispose(){this.animationControls.forEach(e=>{e.dispose()})}animRandomizer(e){setTimeout(()=>{this.lastAnimID=this.curAnimID,this.curAnimID=phe(this.animations.length),this.curAnimID!=this.lastAnimID&&this.animationControls.forEach(t=>{t.from=t.actions[this.lastAnimID],t.to=t.actions[this.curAnimID],this.weightIn=0,this.weightOut=1,t.to.play(),t.to.reset()}),this.animRandomizer(this.animations[this.curAnimID].duration-h1)},e*1e3)}pause(){this.paused=!0}play(){this.paused=!1}isPaused(){return this.paused}setTime(e){this.mainControl&&this.animationControls.forEach(t=>{t.setTime(e)})}setSpeed(e){this.mainControl&&this.animationControls.forEach(t=>{t.setTimeScale(e)})}update(){this.mainControl&&!this.paused&&(this.animationControls.forEach(e=>{e.update(this.weightIn,this.weightOut)}),this.weightIn<1?this.weightIn+=1/(30*h1):this.weightIn=1,this.weightOut>0?this.weightOut-=1/(30*h1):this.weightOut=0)}}const bk={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` + */class mH{}const i1=new z,Ec=new z;class vH extends mH{constructor(e){var t,r,i;super(),this.offset=(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:new z(0,0,0),this.tail=(r=e==null?void 0:e.tail)!==null&&r!==void 0?r:new z(0,0,0),this.radius=(i=e==null?void 0:e.radius)!==null&&i!==void 0?i:0}get type(){return"capsule"}calculateCollision(e,t,r,i){i1.copy(this.offset).applyMatrix4(e),Ec.copy(this.tail).applyMatrix4(e),Ec.sub(i1);const s=Ec.lengthSq();i.copy(t).sub(i1);const o=Ec.dot(i);o<=0||(s<=o||Ec.multiplyScalar(o/s),i.sub(Ec));const a=r+this.radius,l=i.length()-a;return i.normalize(),l}}class yH extends mH{constructor(e){var t,r;super(),this.offset=(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:new z(0,0,0),this.radius=(r=e==null?void 0:e.radius)!==null&&r!==void 0?r:0}get type(){return"sphere"}calculateCollision(e,t,r,i){i.copy(this.offset).applyMatrix4(e),i.negate().add(t);const s=r+this.radius,o=i.length()-s;return i.normalize(),o}}const Yo=new z;class Bfe extends Ht{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new z,this._currentTail=new z,this._shape=e,this._attrPos=new At(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new At(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;const t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0);const r=Yo.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(r)>1e-10&&(this._currentTail.copy(r),e=!0),e&&this._buildPosition()}_buildPosition(){Yo.copy(this._currentTail).sub(this._currentOffset);const e=Yo.length()/this._currentRadius;for(let i=0;i<=16;i++){const s=i/16*Math.PI;this._attrPos.setXYZ(i,-Math.sin(s),-Math.cos(s),0),this._attrPos.setXYZ(17+i,e+Math.sin(s),Math.cos(s),0),this._attrPos.setXYZ(34+i,-Math.sin(s),0,-Math.cos(s)),this._attrPos.setXYZ(51+i,e+Math.sin(s),0,Math.cos(s))}for(let i=0;i<32;i++){const s=i/16*Math.PI;this._attrPos.setXYZ(68+i,0,Math.sin(s),Math.cos(s)),this._attrPos.setXYZ(100+i,e,Math.sin(s),Math.cos(s))}const t=Math.atan2(Yo.y,Math.sqrt(Yo.x*Yo.x+Yo.z*Yo.z)),r=-Math.atan2(Yo.z,Yo.x);this.rotateZ(t),this.rotateY(r),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<34;e++){const t=(e+1)%34;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(68+e*2,34+e,34+t)}for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(136+e*2,68+e,68+t),this._attrIndex.setXY(200+e*2,100+e,100+t)}this._attrIndex.needsUpdate=!0}}class wfe extends Ht{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new z,this._shape=e,this._attrPos=new At(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new At(new Uint16Array(64*3),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;const t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){const t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.needsUpdate=!0}}const Cfe=new z;class $D extends Tr{constructor(e){if(super(),this.matrixAutoUpdate=!1,this.collider=e,this.collider.shape instanceof yH)this._geometry=new wfe(this.collider.shape);else if(this.collider.shape instanceof vH)this._geometry=new Bfe(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");const t=new Wl({color:16711935,depthTest:!1,depthWrite:!1});this._line=new u0(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);const t=this.matrix.elements;this._geometry.worldScale=Cfe.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}}class bfe extends Ht{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new z,this._springBone=e,this._attrPos=new At(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new At(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;const t=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){const t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}}const xfe=new z;class Ife extends Tr{constructor(e){super(),this.matrixAutoUpdate=!1,this.springBone=e,this._geometry=new bfe(this.springBone);const t=new Wl({color:16776960,depthTest:!1,depthWrite:!1});this._line=new u0(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);const t=this.matrix.elements;this._geometry.worldScale=xfe.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}}class qD extends kt{constructor(e){super(),this.shape=e}}const Ffe=new Le;function BH(n){return n.invert?n.invert():n.getInverse(Ffe.copy(n)),n}class Efe{constructor(e){this._inverseCache=new Le,this._shouldUpdateInverse=!0,this.matrix=e;const t={set:(r,i,s)=>(this._shouldUpdateInverse=!0,r[i]=s,!0)};this._originalElements=e.elements,e.elements=new Proxy(e.elements,t)}get inverse(){return this._shouldUpdateInverse&&(this._inverseCache.copy(this.matrix),BH(this._inverseCache),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}}const Ufe=new Le,ja=new z,Vp=new z,Sfe=new z,wf=new z,ek=new z,Lp=new z,tk=new tt,Cf=new Le,_fe=new Le;class Qfe{constructor(e,t,r={},i=[]){var s,o,a,l,A,c;this._currentTail=new z,this._prevTail=new z,this._boneAxis=new z,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new Le,this._initialLocalRotation=new tt,this._initialLocalChildPosition=new z,this.bone=e,this.bone.matrixAutoUpdate=!1,this.child=t,this.settings={hitRadius:(s=r.hitRadius)!==null&&s!==void 0?s:0,stiffness:(o=r.stiffness)!==null&&o!==void 0?o:1,gravityPower:(a=r.gravityPower)!==null&&a!==void 0?a:0,gravityDir:(A=(l=r.gravityDir)===null||l===void 0?void 0:l.clone())!==null&&A!==void 0?A:new z(0,-1,0),dragForce:(c=r.dragForce)!==null&&c!==void 0?c:.4},this.colliderGroups=i}get center(){return this._center}set center(e){var t;!((t=this._center)===null||t===void 0)&&t.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=e,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new Efe(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:Ufe}setInitState(){this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),this.child?this._initialLocalChildPosition.copy(this.child.position):this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);const e=this._getMatrixWorldToCenter(Cf);this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(e),this._prevTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix);const e=this._getMatrixWorldToCenter(Cf);this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(e),this._prevTail.copy(this._currentTail)}update(e){if(e<=0)return;this._calcWorldSpaceBoneLength(),wf.setFromMatrixPosition(this.bone.matrixWorld);let t=this._getMatrixWorldToCenter(Cf);ek.copy(wf).applyMatrix4(t);const r=tk.setFromRotationMatrix(t),i=_fe.copy(t).multiply(this._parentMatrixWorld),s=Vp.copy(this._boneAxis).applyMatrix4(this._initialLocalMatrix).applyMatrix4(i).sub(ek).normalize(),o=Sfe.copy(this.settings.gravityDir).applyQuaternion(r).normalize(),a=this._getMatrixCenterToWorld(Cf);Lp.copy(this._currentTail).add(ja.copy(this._currentTail).sub(this._prevTail).multiplyScalar(1-this.settings.dragForce)).add(ja.copy(s).multiplyScalar(this.settings.stiffness*e)).add(ja.copy(o).multiplyScalar(this.settings.gravityPower*e)).applyMatrix4(a),Lp.sub(wf).normalize().multiplyScalar(this._worldSpaceBoneLength).add(wf),this._collision(Lp),t=this._getMatrixWorldToCenter(Cf),this._prevTail.copy(this._currentTail),this._currentTail.copy(ja.copy(Lp).applyMatrix4(t));const l=BH(Cf.copy(this._parentMatrixWorld).multiply(this._initialLocalMatrix)),A=tk.setFromUnitVectors(this._boneAxis,ja.copy(Lp).applyMatrix4(l).normalize());this.bone.quaternion.copy(this._initialLocalRotation).multiply(A),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(e){this.colliderGroups.forEach(t=>{t.colliders.forEach(r=>{const i=r.shape.calculateCollision(r.matrixWorld,e,this.settings.hitRadius,ja);i<0&&(e.add(ja.multiplyScalar(-i)),e.sub(wf).normalize().multiplyScalar(this._worldSpaceBoneLength).add(wf))})})}_calcWorldSpaceBoneLength(){ja.setFromMatrixPosition(this.bone.matrixWorld),this.child?Vp.setFromMatrixPosition(this.child.matrixWorld):(Vp.copy(this._initialLocalChildPosition),Vp.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=ja.sub(Vp).length()}_getMatrixCenterToWorld(e){return this._center?e.copy(this._center.matrixWorld):e.identity(),e}_getMatrixWorldToCenter(e){return this._center?e.copy(this._center.userData.inverseCacheProxy.inverse):e.identity(),e}}function ry(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(c){try{A(r.next(c))}catch(u){o(u)}}function l(c){try{A(r.throw(c))}catch(u){o(u)}}function A(c){c.done?s(c.value):i(c.value).then(a,l)}A((r=r.apply(n,e||[])).next())})}function Rfe(n,e){const t=[];let r=n;for(;r!==null;)t.unshift(r),r=r.parent;t.forEach(i=>{e(i)})}function wH(n,e){n.children.forEach(t=>{e(t)||wH(t,e)})}class nk{constructor(){this._joints=new Set,this._objectSpringBonesMap=new Map}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){const e=new Set;return this._joints.forEach(t=>{t.colliderGroups.forEach(r=>{e.add(r)})}),Array.from(e)}get colliders(){const e=new Set;return this.colliderGroups.forEach(t=>{t.colliders.forEach(r=>{e.add(r)})}),Array.from(e)}addJoint(e){this._joints.add(e);let t=this._objectSpringBonesMap.get(e.bone);t==null&&(t=new Set,this._objectSpringBonesMap.set(e.bone,t)),t.add(e)}addSpringBone(e){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(e)}deleteJoint(e){this._joints.delete(e),this._objectSpringBonesMap.get(e.bone).delete(e)}deleteSpringBone(e){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(e)}setInitState(){const e=new Set,t=new Set,r=new Set;for(const i of this._joints)this._processSpringBone(i,e,t,r,s=>s.setInitState())}reset(){const e=new Set,t=new Set,r=new Set;for(const i of this._joints)this._processSpringBone(i,e,t,r,s=>s.reset())}update(e){const t=new Set,r=new Set,i=new Set;for(const s of this._joints)this._processSpringBone(s,t,r,i,o=>o.update(e)),wH(s.bone,o=>{var a,l;return((l=(a=this._objectSpringBonesMap.get(o))===null||a===void 0?void 0:a.size)!==null&&l!==void 0?l:0)>0?!0:(o.updateWorldMatrix(!1,!1),!1)})}_processSpringBone(e,t,r,i,s){if(r.has(e))return;if(t.has(e))throw new Error("VRMSpringBoneManager: Circular dependency detected while updating springbones");t.add(e);const o=this._getDependencies(e);for(const a of o)Rfe(a,l=>{const A=this._objectSpringBonesMap.get(l);if(A)for(const c of A)this._processSpringBone(c,t,r,i,s);else i.has(l)||(l.updateWorldMatrix(!1,!1),i.add(l))});e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),s(e),i.add(e.bone),r.add(e)}_getDependencies(e){const t=new Set,r=e.bone.parent;return r&&t.add(r),e.colliderGroups.forEach(i=>{i.colliders.forEach(s=>{t.add(s)})}),t}}const Mfe=new Set(["1.0","1.0-beta"]);class Kc{constructor(e,t){this.parser=e,this.jointHelperRoot=t==null?void 0:t.jointHelperRoot,this.colliderHelperRoot=t==null?void 0:t.colliderHelperRoot}get name(){return Kc.EXTENSION_NAME}afterRoot(e){return ry(this,void 0,void 0,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return ry(this,void 0,void 0,function*(){const t=yield this._v1Import(e);if(t!=null)return t;const r=yield this._v0Import(e);return r??null})}_v1Import(e){var t,r,i,s,o;return ry(this,void 0,void 0,function*(){const a=e.parser.json;if(!(((t=a.extensionsUsed)===null||t===void 0?void 0:t.indexOf(Kc.EXTENSION_NAME))!==-1))return null;const A=new nk,c=yield e.parser.getDependencies("node"),u=(r=a.extensions)===null||r===void 0?void 0:r[Kc.EXTENSION_NAME];if(!u)return null;const f=u.specVersion;if(!Mfe.has(f))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Kc.EXTENSION_NAME} specVersion "${f}"`),null;const d=(i=u.colliders)===null||i===void 0?void 0:i.map((p,m)=>{var g,v,y,w,C;const b=c[p.node],E=p.shape;if(E.sphere)return this._importSphereCollider(b,{offset:new z().fromArray((g=E.sphere.offset)!==null&&g!==void 0?g:[0,0,0]),radius:(v=E.sphere.radius)!==null&&v!==void 0?v:0});if(E.capsule)return this._importCapsuleCollider(b,{offset:new z().fromArray((y=E.capsule.offset)!==null&&y!==void 0?y:[0,0,0]),radius:(w=E.capsule.radius)!==null&&w!==void 0?w:0,tail:new z().fromArray((C=E.capsule.tail)!==null&&C!==void 0?C:[0,0,0])});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${m} has no valid shape`)}),h=(s=u.colliderGroups)===null||s===void 0?void 0:s.map((p,m)=>{var g;return{colliders:((g=p.colliders)!==null&&g!==void 0?g:[]).map(y=>{const w=d==null?void 0:d[y];if(w==null)throw new Error(`VRMSpringBoneLoaderPlugin: The colliderGroup #${m} attempted to use a collider #${y} but not found`);return w}),name:p.name}});return(o=u.springs)===null||o===void 0||o.forEach((p,m)=>{var g;const v=p.joints,y=(g=p.colliderGroups)===null||g===void 0?void 0:g.map(b=>{const E=h==null?void 0:h[b];if(E==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${m} attempted to use a colliderGroup ${b} but not found`);return E}),w=p.center!=null?c[p.center]:void 0;let C;v.forEach(b=>{if(C){const E=C.node,x=c[E],S=b.node,M=c[S],Z={hitRadius:C.hitRadius,dragForce:C.dragForce,gravityPower:C.gravityPower,stiffness:C.stiffness,gravityDir:C.gravityDir!=null?new z().fromArray(C.gravityDir):void 0},K=this._importJoint(x,M,Z,y);w&&(K.center=w),A.addJoint(K)}C=b})}),A.setInitState(),A})}_v0Import(e){var t,r,i;return ry(this,void 0,void 0,function*(){const s=e.parser.json;if(!(((t=s.extensionsUsed)===null||t===void 0?void 0:t.indexOf("VRM"))!==-1))return null;const a=(r=s.extensions)===null||r===void 0?void 0:r.VRM,l=a==null?void 0:a.secondaryAnimation;if(!l)return null;const A=l==null?void 0:l.boneGroups;if(!A)return null;const c=new nk,u=yield e.parser.getDependencies("node"),f=(i=l.colliderGroups)===null||i===void 0?void 0:i.map(d=>{var h;const p=u[d.node];return{colliders:((h=d.colliders)!==null&&h!==void 0?h:[]).map((g,v)=>{var y,w,C;const b=new z(0,0,0);return g.offset&&b.set((y=g.offset.x)!==null&&y!==void 0?y:0,(w=g.offset.y)!==null&&w!==void 0?w:0,g.offset.z?-g.offset.z:0),this._importSphereCollider(p,{offset:b,radius:(C=g.radius)!==null&&C!==void 0?C:0})})}});return A==null||A.forEach((d,h)=>{const p=d.bones;p&&p.forEach(m=>{var g,v,y,w;const C=u[m],b=new z;d.gravityDir?b.set((g=d.gravityDir.x)!==null&&g!==void 0?g:0,(v=d.gravityDir.y)!==null&&v!==void 0?v:0,(y=d.gravityDir.z)!==null&&y!==void 0?y:0):b.set(0,-1,0);const E=d.center!=null?u[d.center]:void 0,x={hitRadius:d.hitRadius,dragForce:d.dragForce,gravityPower:d.gravityPower,stiffness:d.stiffiness,gravityDir:b},S=(w=d.colliderGroups)===null||w===void 0?void 0:w.map(M=>{const Z=f==null?void 0:f[M];if(Z==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${h} attempted to use a colliderGroup ${M} but not found`);return Z});C.traverse(M=>{var Z;const K=(Z=M.children[0])!==null&&Z!==void 0?Z:null,_=this._importJoint(M,K,x,S);E&&(_.center=E),c.addJoint(_)})})}),e.scene.updateMatrixWorld(),c.setInitState(),c})}_importJoint(e,t,r,i){const s=new Qfe(e,t,r,i);if(this.jointHelperRoot){const o=new Ife(s);this.jointHelperRoot.add(o),o.renderOrder=this.jointHelperRoot.renderOrder}return s}_importSphereCollider(e,t){const{offset:r,radius:i}=t,s=new yH({offset:r,radius:i}),o=new qD(s);if(e.add(o),this.colliderHelperRoot){const a=new $D(o);this.colliderHelperRoot.add(a),a.renderOrder=this.colliderHelperRoot.renderOrder}return o}_importCapsuleCollider(e,t){const{offset:r,radius:i,tail:s}=t,o=new vH({offset:r,radius:i,tail:s}),a=new qD(o);if(e.add(a),this.colliderHelperRoot){const l=new $D(a);this.colliderHelperRoot.add(l),l.renderOrder=this.colliderHelperRoot.renderOrder}return a}}Kc.EXTENSION_NAME="VRMC_springBone";class Tfe{constructor(e,t){var r,i,s,o,a,l,A,c,u,f;this.parser=e;const d=t==null?void 0:t.helperRoot,h=t==null?void 0:t.autoUpdateHumanBones;this.expressionPlugin=(r=t==null?void 0:t.expressionPlugin)!==null&&r!==void 0?r:new fb(e),this.firstPersonPlugin=(i=t==null?void 0:t.firstPersonPlugin)!==null&&i!==void 0?i:new fue(e),this.humanoidPlugin=(s=t==null?void 0:t.humanoidPlugin)!==null&&s!==void 0?s:new Bue(e,{helperRoot:d,autoUpdateHumanBones:h}),this.lookAtPlugin=(o=t==null?void 0:t.lookAtPlugin)!==null&&o!==void 0?o:new Tue(e,{helperRoot:d}),this.metaPlugin=(a=t==null?void 0:t.metaPlugin)!==null&&a!==void 0?a:new kue(e),this.mtoonMaterialPlugin=(l=t==null?void 0:t.mtoonMaterialPlugin)!==null&&l!==void 0?l:new Jd(e),this.materialsHDREmissiveMultiplierPlugin=(A=t==null?void 0:t.materialsHDREmissiveMultiplierPlugin)!==null&&A!==void 0?A:new Pm(e),this.materialsV0CompatPlugin=(c=t==null?void 0:t.materialsV0CompatPlugin)!==null&&c!==void 0?c:new que(e),this.springBonePlugin=(u=t==null?void 0:t.springBonePlugin)!==null&&u!==void 0?u:new Kc(e,{colliderHelperRoot:d,jointHelperRoot:d}),this.nodeConstraintPlugin=(f=t==null?void 0:t.nodeConstraintPlugin)!==null&&f!==void 0?f:new Xc(e,{helperRoot:d})}get name(){return"VRMLoaderPlugin"}beforeRoot(){return ny(this,void 0,void 0,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(e){return ny(this,void 0,void 0,function*(){return yield this.mtoonMaterialPlugin.loadMesh(e)})}getMaterialType(e){const t=this.mtoonMaterialPlugin.getMaterialType(e);return t??null}extendMaterialParams(e,t){return ny(this,void 0,void 0,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(e,t),yield this.mtoonMaterialPlugin.extendMaterialParams(e,t)})}afterRoot(e){return ny(this,void 0,void 0,function*(){yield this.metaPlugin.afterRoot(e),yield this.humanoidPlugin.afterRoot(e),yield this.expressionPlugin.afterRoot(e),yield this.lookAtPlugin.afterRoot(e),yield this.firstPersonPlugin.afterRoot(e),yield this.springBonePlugin.afterRoot(e),yield this.nodeConstraintPlugin.afterRoot(e),yield this.mtoonMaterialPlugin.afterRoot(e);const t=e.userData.vrmMeta,r=e.userData.vrmHumanoid;if(t&&r){const i=new Lue({scene:e.scene,expressionManager:e.userData.vrmExpressionManager,firstPerson:e.userData.vrmFirstPerson,humanoid:r,lookAt:e.userData.vrmLookAt,meta:t,materials:e.userData.vrmMToonMaterials,springBoneManager:e.userData.vrmSpringBoneManager,nodeConstraintManager:e.userData.vrmNodeConstraintManager});e.userData.vrm=i}})}}function rk(n){if(Object.values(n).forEach(e=>{e!=null&&e.isTexture&&e.dispose()}),n.isShaderMaterial){const e=n.uniforms;e&&Object.values(e).forEach(t=>{const r=t.value;r!=null&&r.isTexture&&r.dispose()})}n.dispose()}function Nfe(n){const e=n.geometry;e&&e.dispose();const t=n.skeleton;t&&t.dispose();const r=n.material;r&&(Array.isArray(r)?r.forEach(i=>rk(i)):r&&rk(r))}function Dfe(n){n.traverse(Nfe)}function kfe(n){const e=new Map;n.traverse(t=>{if(t.type!=="SkinnedMesh")return;const r=t,s=r.geometry.getAttribute("skinIndex");let o=e.get(s);if(!o){const a=[],l=[],A={},c=s.array;for(let u=0;u{var r,i,s,o;if(!t.isMesh)return;const a=t,l=a.geometry,A=l.index;if(A==null)return;const c=e.get(l);if(c!=null){a.geometry=c;return}const u=new Ht;u.name=l.name,u.morphTargetsRelative=l.morphTargetsRelative,l.groups.forEach(p=>{u.addGroup(p.start,p.count,p.materialIndex)}),u.boundingBox=(i=(r=l.boundingBox)===null||r===void 0?void 0:r.clone())!==null&&i!==void 0?i:null,u.boundingSphere=(o=(s=l.boundingSphere)===null||s===void 0?void 0:s.clone())!==null&&o!==void 0?o:null,u.setDrawRange(l.drawRange.start,l.drawRange.count),u.userData=l.userData,e.set(l,u);const f=[],d=[];{const p=A.array,m=new p.constructor(p.length);let g=0;for(let v=0;v{const m=l.attributes[p];if(m.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const g=m.array,{itemSize:v,normalized:y}=m,w=new g.constructor(d.length*v);d.forEach((C,b)=>{for(let E=0;E{u.morphAttributes[p]=[];const m=l.morphAttributes[p];for(let g=0;g{for(let S=0;SE===0),u.morphAttributes[p][g]=new At(b,w,C)}}),h&&(u.morphAttributes={}),a.geometry=u}),Array.from(e.keys()).forEach(t=>{t.dispose()})}function Lfe(n){var e;((e=n.meta)===null||e===void 0?void 0:e.metaVersion)==="0"&&(n.scene.rotation.y=Math.PI)}class Xh{constructor(){}}Xh.deepDispose=Dfe;Xh.removeUnnecessaryJoints=kfe;Xh.removeUnnecessaryVertices=Vfe;Xh.rotateVRM0=Lfe;var Kn;(function(n){n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.LINEAR=9729]="LINEAR",n[n.REPEAT=10497]="REPEAT"})(Kn||(Kn={}));const Ww="blend_",ik="vrmColliderSphere";class Pfe{parse(e,t,r,i){const s=e.humanoid,o=e.meta,a=e.materials,l={},A={},c={},u=e.lookAt,f={generator:"UniGLTF-2.0.0",version:"2.0"};if(t)if(s)if(o)if(a){if(!u)throw new Error("lookAt is undefined or null")}else throw new Error("materials is undefined or null");else throw new Error("meta is undefined or null");else throw new Error("humanoid is undefined or null");else throw new Error("avatar is undefined or null");const d=a.filter((X,ne,ae)=>ae.findIndex(Be=>Be.name===X.name.replace(" (Outline)",""))===ne).map(X=>X),h=d.map(X=>X.name),p=r?{name:"icon",imageBitmap:r.image}:null,m=d.filter(X=>X.map).map(X=>{if(!X.map)throw new Error(X.name+" map is null");return{name:X.name,imageBitmap:X.map.image}}),g=d.filter(X=>X.userData.shadeTexture).map(X=>{if(!X.userData.shadeTexture)throw new Error(X.userData.shadeTexture+" map is null");return{name:X.name+"_shade",imageBitmap:X.userData.shadeTexture.image}}),v=m.concat(g),y=Jfe(v,p),w=Hfe(y),C=zfe(y),b=Zfe(d,v),E=t.children.filter(X=>X.children.length>0&&X.children[0].type===ui.Bone)[0],x=CH(E).filter(X=>X.name!==ik),S=x.map(X=>X.name),M=x.map(X=>({children:X.children.filter(ne=>ne.name!==ik).map(ne=>S.indexOf(ne.name)),name:X.name,rotation:[X.quaternion.x,X.quaternion.y,X.quaternion.z,X.quaternion.w],scale:[X.scale.x,X.scale.y,X.scale.z],translation:[X.position.x,X.position.y,X.position.z]})),Z=[],K=t.children.filter(X=>X.type===ui.Group||X.type===ui.SkinnedMesh),_=[];K.forEach(X=>{const ne=X.type===ui.Group?X.children[0]:X,ae=ne.geometry.attributes;_.push(new $a(ae.position,Kn.FLOAT,jt.POSITION,xo.VEC3,ne.name,void 0)),_.push(new $a(ae.normal,Kn.FLOAT,jt.NORMAL,xo.VEC3,ne.name,void 0)),_.push(new $a(ae.uv,Kn.FLOAT,jt.UV,xo.VEC2,ne.name,void 0)),_.push(new $a(ae.skinWeight,Kn.FLOAT,jt.SKIN_WEIGHT,xo.VEC4,ne.name,void 0)),_.push(new $a(ae.skinIndex,Kn.UNSIGNED_SHORT,jt.SKIN_INDEX,xo.VEC4,ne.name,void 0)),(X.type===ui.Group?X.children.map(pe=>pe):[X]).forEach(pe=>{if(!pe.geometry.index)throw new Error(pe.name+" geometry.index is null");_.push(new $a(pe.geometry.index,Kn.UNSIGNED_INT,jt.INDEX,xo.SCALAR,ne.name,pe.name))}),ne.morphTargetDictionary||(ne.morphTargetDictionary={},ne.morphTargetInfluences=[],ne.geometry.morphAttributes={},ne.updateMorphTargets()),ne.geometry.userData.targetNames=[];for(const pe in e.expressionManager.expressionMap){const Fe=e.expressionManager.expressionMap[pe],rt=Fe._binds.map(ke=>({node:x.length,index:ke.index,weight:ke.weight}));let Oe=!1;for(const ke in ci)if(pe.toLowerCase()===ci[ke].toLowerCase()){l[ci[ke]]={morphTargetBinds:rt,isBinary:Fe.isBinary,overrideBlink:Fe.overrideBlink,overrideLookAt:Fe.overrideLookAt,overrideMouth:Fe.overrideMouth},Oe=!0;break}!Oe&&pe.toLowerCase()==="surprise"&&(l.surprised={morphTargetBinds:rt,isBinary:Fe.isBinary,overrideBlink:Fe.overrideBlink,overrideLookAt:Fe.overrideLookAt,overrideMouth:Fe.overrideMouth},Oe=!0),Oe===!1&&(A[pe]={morphTargetBinds:rt,isBinary:Fe.isBinary,overrideBlink:Fe.overrideBlink,overrideLookAt:Fe.overrideLookAt,overrideMouth:Fe.overrideMouth})}for(const pe in ne.morphTargetDictionary){ne.geometry.userData.targetNames.push(pe);const Fe=ne.morphTargetDictionary[pe],rt=ne.geometry.morphAttributes;_.push(new $a(rt.position[Fe],Kn.FLOAT,jt.BLEND_POSITION,xo.VEC3,ne.name,Ww+pe)),_.push(new $a(rt.normal[Fe],Kn.FLOAT,jt.BLEND_NORMAL,xo.VEC3,ne.name,Ww+pe))}}),Object.keys(l).length>0&&(c.preset=l),Object.keys(A).length>0&&(c.custom=A),K.forEach(X=>{const ne=X.type===ui.Group?X.children[0]:X,ae=new Float32Array(ne.skeleton.boneInverses.map(Be=>Be.elements).flat());_.push(new $a(new At(ae,16),Kn.FLOAT,jt.BIND_MATRIX,xo.MAT4,ne.name,ne.name))}),Z.push(..._.map(X=>({bufferView:-1,byteOffset:0,componentType:X.valueType,count:X.attribute.count,max:X.max,min:X.min,normalized:!1,type:X.accessorsType})));const B=Ofe(K,_,h);K.forEach((X,ne)=>{M.push({mesh:ne,name:X.name,rotation:[X.quaternion.x,X.quaternion.y,X.quaternion.z,X.quaternion.w],scale:[X.scale.x,X.scale.y,X.scale.z],skin:ne,translation:[X.position.x,X.position.y,X.position.z]})});const F=Gfe(K,_,S),R={offsetFromHeadBone:[0,0,0],rangeMapHorizontalInner:{inputMaxValue:u.applier.rangeMapHorizontalInner.inputMaxValue,outputScale:u.applier.rangeMapHorizontalInner.outputScale},rangeMapHorizontalOuter:{inputMaxValue:u.applier.rangeMapHorizontalOuter.inputMaxValue,outputScale:u.applier.rangeMapHorizontalOuter.outputScale},rangeMapVerticalDown:{inputMaxValue:u.applier.rangeMapVerticalDown.inputMaxValue,outputScale:u.applier.rangeMapVerticalDown.outputScale},rangeMapVerticalUp:{inputMaxValue:u.applier.rangeMapVerticalUp.inputMaxValue,outputScale:u.applier.rangeMapVerticalUp.outputScale},type:"bone"},k={humanBones:{}};for(const X in s.humanBones)k.humanBones[X]={node:S.indexOf(s.humanBones[X].node.name)};const T=o,V=[];V.push(...v.map(X=>({buffer:sk(X.imageBitmap),type:jt.IMAGE}))),V.push(..._.map(X=>({buffer:X.buffer,type:X.type}))),p&&V.push({buffer:sk(p.imageBitmap),type:jt.IMAGE});let O=0,L=0,U=0;const H=V.map((X,ne)=>{const ae={buffer:0,byteLength:X.buffer.byteLength,byteOffset:O,target:X.type===jt.IMAGE||X.type===jt.BIND_MATRIX?void 0:X.type===jt.INDEX?Kn.ELEMENT_ARRAY_BUFFER:Kn.ARRAY_BUFFER};return O+=X.buffer.byteLength,X.type===jt.IMAGE?y[L++].bufferView=ne:Z[U++].bufferView=ne,ae}),le=Yfe(t,M),N={accessors:Z,asset:f,buffers:[{byteLength:O}],bufferViews:H,extensions:{VRMC_vrm:{expressions:c,humanoid:k,lookAt:R,meta:T,specVersion:"1.0"}},extensionsUsed:["KHR_materials_unlit","KHR_texture_transform","VRMC_materials_mtoon","VRMC_vrm"],images:y,materials:b,meshes:B,nodes:M,samplers:w,avatar:0,scenes:le,skins:F,textures:C},j=new ok($E(JSON.stringify(N,void 0,2)),"JSON"),oe=new ok(wg(V.map(X=>X.buffer)),"BIN\0"),ie=wg([j.buffer,oe.buffer]),de=wg([$E("glTF"),jE(2,4),jE(ie.byteLength+12,4)]);i(wg([de,ie]))}}function CH(n){return n.children.length<=0?[n]:[n].concat(n.children.map(e=>CH(e)).flat())}function sk(n){const e=document.createElement("canvas");e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0);const t=e.toDataURL("image/png"),r=atob(t.split(",")[1]),i=new ArrayBuffer(r.length),s=new DataView(i);for(let o=0;o4?A=r[a*n.itemSize+l]:l===0?A=n.getX(a):l===1?A=n.getY(a):l===2?A=n.getZ(a):A=n.getW(a),e===Kn.UNSIGNED_SHORT?o.setUint16(i,A,!0):e===Kn.UNSIGNED_INT?o.setUint32(i,A,!0):o.setFloat32(i,A,!0),i+=t}return s}let ok=class{constructor(e,t){this.data=e,this.type=t;const r=this.data;this.buffer=wg([jE(r.byteLength,4),$E(this.type),r])}paddingBinary(e,t){const r=Math.ceil(e.byteLength/4)*4;if(e.byteLength===r)return e;const i=new Uint8Array(r);i.set(new Uint8Array(e),0);for(let s=e.byteLength;sl%3===0)),Math.max.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===1)),Math.max.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===2))]:void 0,this.min=r===jt.POSITION||r===jt.BLEND_POSITION?[Math.min.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===0)),Math.min.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===1)),Math.min.apply(null,Array.from(this.attribute.array).filter((a,l)=>l%3===2))]:void 0}};var xd;(function(n){n.MeshBasicMaterial="MeshBasicMaterial",n.MeshStandardMaterial="MeshStandardMaterial",n.MToonMaterial="MToonMaterial"})(xd||(xd={}));var xo;(function(n){n.SCALAR="SCALAR",n.VEC2="VEC2",n.VEC3="VEC3",n.VEC4="VEC4",n.MAT4="MAT4"})(xo||(xo={}));var jt;(function(n){n.POSITION="POSITION",n.NORMAL="NORMAL",n.UV="UV",n.INDEX="INDEX",n.SKIN_WEIGHT="SKIN_WEIGHT",n.SKIN_INDEX="SKIN_INDEX",n.BLEND_POSITION="BLEND_POSITION",n.BLEND_NORMAL="BLEND_NORMAL",n.BIND_MATRIX="BIND_MATRIX",n.IMAGE="IMAGE"})(jt||(jt={}));var ui;(function(n){n.Group="Group",n.SkinnedMesh="SkinnedMesh",n.Object3D="Object3D",n.Bone="Bone"})(ui||(ui={}));const Ofe=(n,e,t)=>n.map(r=>{const i=r.type===ui.Group?r.children[0]:r,s=r.type===ui.Group?r.children.map(o=>o):[r];return{name:r.name,primitives:s.map(o=>{const a=e.map(A=>A.meshName===i.name?A.type:null),l=Array.isArray(o.material)?o.material[0].name:o.material.name;return{attributes:{JOINTS_0:a.indexOf(jt.SKIN_INDEX),NORMAL:a.indexOf(jt.NORMAL),POSITION:a.indexOf(jt.POSITION),TEXCOORD_0:a.indexOf(jt.UV),WEIGHTS_0:a.indexOf(jt.SKIN_WEIGHT)},extras:{targetNames:o.geometry.userData.targetNames},indices:e.map(A=>A.type===jt.INDEX&&A.meshName===i.name?A.name:null).indexOf(o.name),material:t.indexOf(l),mode:4,targets:i.geometry.userData.targetNames?i.geometry.userData.targetNames.map(A=>({NORMAL:e.map(c=>c.type===jt.BLEND_NORMAL&&c.meshName===i.name?c.name:null).indexOf(Ww+A),POSITION:e.map(c=>c.type===jt.BLEND_POSITION&&c.meshName===i.name?c.name:null).indexOf(Ww+A)})):void 0}})}}),Gfe=(n,e,t)=>n.map(r=>{const i=r.type===ui.Group?r.children[0]:r;return{inverseBindMatrices:e.map(s=>s.type===jt.BIND_MATRIX?s.meshName:null).indexOf(i.name),joints:i.skeleton.bones.map(s=>t.indexOf(s.name)),skeleton:t.indexOf(i.skeleton.bones[0].name)}}),Zfe=(n,e)=>n.map(t=>{let r,i=null;if(t=t.userData.vrmMaterial?t.userData.vrmMaterial:t,t.type==="ShaderMaterial")i=t.userData.gltfExtensions.VRMC_materials_mtoon,i.shadeMultiplyTexture={index:e.map(c=>c.name).indexOf(t.uniforms.shadeMultiplyTexture.name)},r=t.color?[1,1,1,1]:void 0;else{const A=t;r=A.color?[A.color.r,A.color.g,A.color.b,1]:void 0}let s=-1;t.map?s=e.map(A=>A.name).indexOf(t.name):t.uniforms&&t.uniforms.map&&(s=e.map(A=>A.name).indexOf(t.uniforms.map.name));const o=s>=0?{extensions:{KHR_texture_transform:{offset:[0,0],scale:[1,1]}},index:s,texCoord:0}:void 0,a=(()=>{switch(t.type){case xd.MeshStandardMaterial:return t.metalness;case xd.MeshBasicMaterial:return 0;default:return 0}})(),l=(()=>{switch(t.type){case xd.MeshStandardMaterial:return t.roughness;case xd.MeshBasicMaterial:return .9;default:return .9}})();return{alphaCutoff:t.alphaTest>0?t.alphaTest:void 0,alphaMode:t.transparent?"BLEND":t.alphaTest>0?"MASK":"OPAQUE",doubleSided:t.side===2,extensions:t.type==="ShaderMaterial"?{KHR_materials_unlit:{},VRMC_materials_mtoon:i}:void 0,name:t.name,pbrMetallicRoughness:{baseColorFactor:r,baseColorTexture:o,metallicFactor:a,roughnessFactor:l}}}),Jfe=(n,e)=>(e?n.concat(e):n).filter(t=>t&&t.imageBitmap).map(t=>({bufferView:-1,mimeType:"image/png",name:t.name})),Hfe=n=>n.map(()=>({magFilter:Kn.LINEAR,minFilter:Kn.LINEAR,wrapS:Kn.REPEAT,wrapT:Kn.REPEAT})),zfe=n=>n.map((e,t)=>({sampler:0,source:t})),Yfe=(n,e)=>{const t=e.map(r=>r.name);return[{nodes:n.children.filter(r=>r.type===ui.Object3D||r.type===ui.SkinnedMesh||r.type===ui.Group||r.type===ui.Bone).map(r=>t.indexOf(r.name))}]},bH=0,Xfe=1,xH=2,ak=2,s1=1.25,lk=1,hB=6*4+4+4,qE=65535,Kfe=Math.pow(2,-24);class iy{constructor(){}}function fa(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function Ak(n){let e=-1,t=-1/0;for(let r=0;r<3;r++){const i=n[r+3]-n[r];i>t&&(t=i,e=r)}return e}function ck(n,e){e.set(n)}function uk(n,e,t){let r,i;for(let s=0;s<3;s++){const o=s+3;r=n[s],i=e[s],t[s]=ri?r:i}}function sy(n,e,t){for(let r=0;r<3;r++){const i=e[n+2*r],s=e[n+2*r+1],o=i-s,a=i+s;ot[r+3]&&(t[r+3]=a)}}function Pp(n){const e=n[3]-n[0],t=n[4]-n[1],r=n[5]-n[2];return 2*(e*t+t*r+r*e)}function jfe(n,e){if(!n.index){const t=n.attributes.position.count,r=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;let i;t>65535?i=new Uint32Array(new r(4*t)):i=new Uint16Array(new r(2*t)),n.setIndex(new At(i,1));for(let s=0;si-s);for(let i=0;il&&(l=E),g&&wh&&(h=w);const x=n[v+2],S=n[v+3],M=x-S,Z=x+S;MA&&(A=Z),g&&xp&&(p=x);const K=n[v+4],_=n[v+5],B=K-_,F=K+_;Bc&&(c=F),g&&Km&&(m=K)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=A,r[5]=c,g&&(i[0]=u,i[1]=f,i[2]=d,i[3]=h,i[4]=p,i[5]=m)}function qfe(n,e,t,r){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,A=-1/0;for(let c=e*6,u=(e+t)*6;ca&&(a=f);const d=n[c+2];dl&&(l=d);const h=n[c+4];hA&&(A=h)}r[0]=i,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=A}function ede(n,e,t,r,i){let s=t,o=t+r-1;const a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&e[s*6+l]=a;)o--;if(sn.candidate-e.candidate,oA=new Array(rl).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),oy=new Float32Array(6);function nde(n,e,t,r,i,s){let o=-1,a=0;if(s===bH)o=Ak(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===Xfe)o=Ak(n),o!==-1&&(a=rde(t,r,i,o));else if(s===xH){const l=Pp(n);let A=s1*i;const c=r*6,u=(r+i)*6;for(let f=0;f<3;f++){const d=e[f],m=(e[f+3]-d)/rl;if(i=E.candidate?sy(w,t,E.rightCacheBounds):(sy(w,t,E.leftCacheBounds),E.count++)}}for(let w=0;w=rl&&(b=rl-1);const E=oA[b];E.count++,sy(y,t,E.bounds)}const g=oA[rl-1];ck(g.bounds,g.rightCacheBounds);for(let y=rl-2;y>=0;y--){const w=oA[y],C=oA[y+1];uk(w.bounds,C.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let y=0;yb&&(b=y),w>b&&(b=w);const E=(b-C)/2,x=g*2;s[d+x+0]=C+E,s[d+x+1]=E+(Math.abs(C)+E)*Kfe,Ce[g+3]&&(e[g+3]=b)}}return s}function sde(n,e){function t(g){f&&f(g/d)}function r(g,v,y,w=null,C=0){if(!h&&C>=l&&(h=!0,A&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(n))),y<=c||C>=l)return t(v+y),g.offset=v,g.count=y,g;const b=nde(g.boundingData,w,o,v,y,u);if(b.axis===-1)return t(v+y),g.offset=v,g.count=y,g;const E=ede(a,o,v,y,b);if(E===v||E===v+y)t(v+y),g.offset=v,g.count=y;else{g.splitAxis=b.axis;const x=new iy,S=v,M=E-v;g.left=x,x.boundingData=new Float32Array(6),o1(o,S,M,x.boundingData,s),r(x,S,M,s,C+1);const Z=new iy,K=E,_=y-M;g.right=Z,Z.boundingData=new Float32Array(6),o1(o,K,_,Z.boundingData,s),r(Z,K,_,s,C+1)}return g}jfe(n,e);const i=new Float32Array(6),s=new Float32Array(6),o=ide(n,i),a=n.index.array,l=e.maxDepth,A=e.verbose,c=e.maxLeafTris,u=e.strategy,f=e.onProgress,d=n.index.count/3;let h=!1;const p=[],m=$fe(n);if(m.length===1){const g=m[0],v=new iy;v.boundingData=i,qfe(o,g.offset,g.count,s),r(v,g.offset,g.count,s),p.push(v)}else for(let g of m){const v=new iy;v.boundingData=new Float32Array(6),o1(o,g.offset,g.count,v.boundingData,s),r(v,g.offset,g.count,s),p.push(v)}return p}function ode(n,e){const t=sde(n,e);let r,i,s;const o=[],a=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;cMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[f+6]=y/4,y=A(y,g),i[f+7]=v,y}}}class kl{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let r=1/0,i=-1/0;for(let s=0,o=e.length;si?l:i}this.min=r,this.max=i}setFromPoints(e,t){let r=1/0,i=-1/0;for(let s=0,o=t.length;si?l:i}this.min=r,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}kl.prototype.setFromBox=function(){const n=new z;return function(t,r){const i=r.min,s=r.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let A=0;A<=1;A++)for(let c=0;c<=1;c++){n.x=i.x*l+s.x*(1-l),n.y=i.y*A+s.y*(1-A),n.z=i.z*c+s.z*(1-c);const u=t.dot(n);o=Math.min(u,o),a=Math.max(u,a)}this.min=o,this.max=a}}();const ade=function(){const n=new z,e=new z,t=new z;return function(i,s,o){const a=i.start,l=n,A=s.start,c=e;t.subVectors(a,A),n.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const u=t.dot(c),f=c.dot(l),d=c.dot(c),h=t.dot(l),m=l.dot(l)*d-f*f;let g,v;m!==0?g=(u*f-h*d)/m:g=0,v=(u+g*f)/d,o.x=g,o.y=v}}(),X_=function(){const n=new We,e=new z,t=new z;return function(i,s,o,a){ade(i,s,n);let l=n.x,A=n.y;if(l>=0&&l<=1&&A>=0&&A<=1){i.at(l,o),s.at(A,a);return}else if(l>=0&&l<=1){A<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(A>=0&&A<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let u;A<0?u=s.start:u=s.end;const f=e,d=t;if(i.closestPointToPoint(u,!0,e),s.closestPointToPoint(c,!0,t),f.distanceToSquared(u)<=d.distanceToSquared(c)){o.copy(f),a.copy(u);return}else{o.copy(c),a.copy(d);return}}}}(),lde=function(){const n=new z,e=new z,t=new hl,r=new Il;return function(s,o){const{radius:a,center:l}=s,{a:A,b:c,c:u}=o;if(r.start=A,r.end=c,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a||(r.start=A,r.end=u,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a)||(r.start=c,r.end=u,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a))return!0;const p=o.getPlane(t);if(Math.abs(p.distanceToPoint(l))<=a){const g=p.projectPoint(l,e);if(o.containsPoint(g))return!0}return!1}}(),Ade=1e-15;function bf(n){return Math.abs(n)new z),this.satBounds=new Array(4).fill().map(()=>new kl),this.points=[this.a,this.b,this.c],this.sphere=new Qu,this.plane=new hl,this.needsUpdate=!0}intersectsSphere(e){return lde(e,this)}update(){const e=this.a,t=this.b,r=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);const A=s[1],c=o[1];A.subVectors(e,t),c.setFromPoints(A,i);const u=s[2],f=o[2];u.subVectors(t,r),f.setFromPoints(u,i);const d=s[3],h=o[3];d.subVectors(r,e),h.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Vl.prototype.closestPointToSegment=function(){const n=new z,e=new z,t=new Il;return function(i,s=null,o=null){const{start:a,end:l}=i,A=this.points;let c,u=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;t.start.copy(A[f]),t.end.copy(A[d]),X_(t,i,n,e),c=n.distanceToSquared(e),c1-1e-10){const v=this.satBounds,y=this.satAxes;t[0]=d.a,t[1]=d.b,t[2]=d.c;for(let b=0;b<4;b++){const E=v[b],x=y[b];if(r.setFromPoints(x,t),E.isSeparated(r))return!1}const w=d.satBounds,C=d.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let b=0;b<4;b++){const E=w[b],x=C[b];if(r.setFromPoints(x,e),E.isSeparated(r))return!1}for(let b=0;b<4;b++){const E=y[b];for(let x=0;x<4;x++){const S=C[x];if(s.crossVectors(E,S),r.setFromPoints(s,e),i.setFromPoints(s,t),r.isSeparated(i))return!1}}return h&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),h.start.set(0,0,0),h.end.set(0,0,0)),!0}else{const v=this.points;let y=!1,w=0;for(let B=0;B<3;B++){const F=v[B],R=v[(B+1)%3];A.start.copy(F),A.end.copy(R),A.delta(o);const k=y?c.start:c.end,T=bf(g.distanceToPoint(F));if(bf(g.normal.dot(o))&&T){c.copy(A),w=2;break}if((g.intersectLine(A,k)||T)&&!bf(k.distanceTo(R))){if(w++,y)break;y=!0}}if(w===1&&d.containsPoint(c.end))return h&&(h.start.copy(c.end),h.end.copy(c.end)),!0;if(w!==2)return!1;const C=d.points;let b=!1,E=0;for(let B=0;B<3;B++){const F=C[B],R=C[(B+1)%3];A.start.copy(F),A.end.copy(R),A.delta(a);const k=b?u.start:u.end,T=bf(m.distanceToPoint(F));if(bf(m.normal.dot(a))&&T){u.copy(A),E=2;break}if((m.intersectLine(A,k)||T)&&!bf(k.distanceTo(R))){if(E++,b)break;b=!0}}if(E===1&&this.containsPoint(u.end))return h&&(h.start.copy(u.end),h.end.copy(u.end)),!0;if(E!==2)return!1;if(c.delta(o),u.delta(a),o.dot(a)<0){let B=u.start;u.start=u.end,u.end=B}const x=c.start.dot(o),S=c.end.dot(o),M=u.start.dot(o),Z=u.end.dot(o),K=S0?h.start.copy(c.start):h.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(o)<0?h.end.copy(c.end):h.end.copy(u.end)),!0)}}}();Vl.prototype.distanceToPoint=function(){const n=new z;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}}();Vl.prototype.distanceToTriangle=function(){const n=new z,e=new z,t=["a","b","c"],r=new Il,i=new Il;return function(o,a=null,l=null){const A=a||l?r:null;if(this.intersectsTriangle(o,A))return(a||l)&&(a&&A.getCenter(a),l&&A.getCenter(l)),0;let c=1/0;for(let u=0;u<3;u++){let f;const d=t[u],h=o[d];this.closestPointToPoint(h,n),f=h.distanceToSquared(n),fnew z),this.satAxes=new Array(3).fill().map(()=>new z),this.satBounds=new Array(3).fill().map(()=>new kl),this.alignedSatBounds=new Array(3).fill().map(()=>new kl),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),r&&this.matrix.copy(r)}set(e,t,r){this.min.copy(e),this.max.copy(t),this.matrix.copy(r),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ma.prototype.update=function(){return function(){const e=this.matrix,t=this.min,r=this.max,i=this.points;for(let A=0;A<=1;A++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){const f=1*A|2*c|4*u,d=i[f];d.x=A?r.x:t.x,d.y=c?r.y:t.y,d.z=u?r.z:t.z,d.applyMatrix4(e)}const s=this.satBounds,o=this.satAxes,a=i[0];for(let A=0;A<3;A++){const c=o[A],u=s[A],f=1<new Il),t=new Array(12).fill().map(()=>new Il),r=new z,i=new z;return function(o,a=0,l=null,A=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||A)&&(o.getCenter(i),this.closestPointToPoint(i,r),o.closestPointToPoint(r,i),l&&l.copy(r),A&&A.copy(i)),0;const c=a*a,u=o.min,f=o.max,d=this.points;let h=1/0;for(let m=0;m<8;m++){const g=d[m];i.copy(g).clamp(u,f);const v=g.distanceToSquared(i);if(vt.far)?null:n}function aa(n,e,t,r){const i=n.a,s=n.b,o=n.c;let a=e,l=e+1,A=e+2;t&&(a=t.getX(e),l=t.getX(e+1),A=t.getX(e+2)),i.x=r.getX(a),i.y=r.getY(a),i.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(A),o.y=r.getY(A),o.z=r.getZ(A)}function mk(n,e,t,r,i,s,o){const a=t.index,l=t.attributes.position;for(let A=n,c=e+n;A=0;let d,h;f?(d=Om(n),h=Gm(n,a)):(d=Gm(n,a),h=Om(n));const m=Gw(d,s,r,Ow)?tU(d,e,t,r):null;if(m){const y=m.point[c];if(f?y<=s[h+A]:y>=s[h+A+3])return m}const v=Gw(h,s,r,Ow)?tU(h,e,t,r):null;return m&&v?m.distance<=v.distance?m:v:m||v||null}}const gde=function(){let n,e;const t=[],r=new FH(()=>new ws);return function(...o){n=r.getPrimitive(),e=r.getPrimitive(),t.push(n,e);const a=i(...o);r.releasePrimitive(n),r.releasePrimitive(e),t.pop(),t.pop();const l=t.length;return l>0&&(e=t[l-1],n=t[l-2]),a};function i(s,o,a,l,A=null,c=0,u=0){function f(y){let w=y*2,C=ZA,b=JA;for(;!yA(w,C);)y=Om(y),w=y*2;return Hd(y,b)}function d(y){let w=y*2,C=ZA,b=JA;for(;!yA(w,C);)y=Gm(y,b),w=y*2;return Hd(y,b)+Wm(w,C)}let h=s*2,p=Kh,m=ZA,g=JA;if(yA(h,m)){const y=Hd(s,g),w=Wm(h,m);return fa(s,p,n),l(y,w,!1,u,c+s,n)}else{const y=Om(s),w=Gm(s,g);let C=y,b=w,E,x,S,M;if(A&&(S=n,M=e,fa(C,p,S),fa(b,p,M),E=A(S),x=A(M),xi.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(A),x.b.applyMatrix4(A),x.c.applyMatrix4(A),x.needsUpdate=!0;for(let S=C*3,M=(b+C)*3;Snew Vl);class Yg{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Yg.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};const r=e.geometry,i=e._roots,s=r.getIndex();let o;return t.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(e,t,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Yg.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};const{index:i,roots:s}=e,o=new Yg(t,{...r,[a1]:!0});if(o._roots=s,r.setIndex){const a=t.getIndex();if(a===null){const l=new At(e.index,1,!1);t.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:bH,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[a1]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[a1]||(this._roots=ode(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new ws))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=this.geometry,r=t.index.array,i=t.attributes.position;let s,o,a,l,A=0;const c=this._roots;for(let f=0,d=c.length;fb&&(b=K),_E&&(E=_),Bx&&(x=B)}return l[f+0]!==y||l[f+1]!==w||l[f+2]!==C||l[f+3]!==b||l[f+4]!==E||l[f+5]!==x?(l[f+0]=y,l[f+1]=w,l[f+2]=C,l[f+3]=b,l[f+4]=E,l[f+5]=x,!0):!1}else{const g=f+8,v=o[f+6],y=g+d,w=v+d;let C=h,b=!1,E=!1;e?C||(b=e.has(y),E=e.has(w),C=!b&&!E):(b=!0,E=!0);const x=C||b,S=C||E;let M=!1;x&&(M=u(g,d,C));let Z=!1;S&&(Z=u(v,d,C));const K=M||Z;if(K)for(let _=0;_<3;_++){const B=g+_,F=v+_,R=l[B],k=l[B+3],T=l[F],V=l[F+3];l[f+_]=RV?k:V}return K}}}traverse(e,t=0){const r=this._roots[t],i=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){const A=a*2,c=s[A+15]===qE;if(c){const u=i[a+6],f=s[A+14];e(l,c,new Float32Array(r,a*4,6),u,f)}else{const u=a+hB/4,f=i[a+6],d=i[a+7];e(l,c,new Float32Array(r,a*4,6),d)||(o(u,l+1),o(f,l+1))}}}raycast(e,t=Vo){const r=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,A=o?t.side:t;for(let c=0,u=r.length;c{const g=h*3;return f(d,g,g+1,g+2,p,m)}}e={boundsTraverseOrder:r,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}const s=Xo.getPrimitive();let{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:A}=e;if(l&&A){const f=l;l=(d,h,p,m,g)=>f(d,h,p,m,g)?!0:mk(d,h,i,A,p,m,s)}else l||(A?l=(f,d,h,p)=>mk(f,d,i,A,h,p,s):l=(f,d,h)=>h);let c=!1,u=0;for(const f of this._roots){if(Cg(f),c=gde(0,i,a,l,o,u),cy(),c)break;u+=f.byteLength}return Xo.releasePrimitive(s),c}bvhcast(e,t,r){let{intersectsRanges:i,intersectsTriangles:s}=r;const o=this.geometry.index,a=this.geometry.attributes.position,l=e.geometry.index,A=e.geometry.attributes.position;xf.copy(t).invert();const c=Xo.getPrimitive(),u=Xo.getPrimitive();if(s){let d=function(h,p,m,g,v,y,w,C){for(let b=m,E=m+g;bA1.intersectsBox(d),intersectsRange:(d,h,p,m,g,v)=>(l1.copy(v),l1.applyMatrix4(xf),e.shapecast({intersectsBounds:y=>l1.intersectsBox(y),intersectsRange:(y,w,C,b,E)=>i(d,h,y,w,m,g,b,E)}))});return Xo.releasePrimitive(c),Xo.releasePrimitive(u),f}intersectsBox(e,t){return Uc.set(e.min,e.max,t),Uc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Uc.intersectsBox(r),intersectsTriangle:r=>Uc.intersectsTriangle(r)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,r={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Uc.set(e.boundingBox.min,e.boundingBox.max,t),Uc.needsUpdate=!0;const a=this.geometry,l=a.attributes.position,A=a.index,c=e.attributes.position,u=e.index,f=Xo.getPrimitive(),d=Xo.getPrimitive();let h=uy,p=vde,m=null,g=null;i&&(m=yde,g=Bde);let v=1/0,y=null,w=null;return xf.copy(t).invert(),Wp.matrix.copy(xf),this.shapecast({boundsTraverseOrder:C=>Uc.distanceToBox(C),intersectsBounds:(C,b,E)=>E{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:E=>Wp.distanceToBox(E),intersectsBounds:(E,x,S)=>S{for(let S=E*3,M=(E+x)*3;S(Op.copy(e).clamp(c.min,c.max),Op.distanceToSquared(e)),intersectsBounds:(c,u,f)=>f{c.closestPointToPoint(e,Op);const f=e.distanceToSquared(Op);return f{fa(0,new Float32Array(r),vk),e.union(vk)}),e}}const c1=new l0,yk=new Le,wde=In.prototype.raycast;function Cde(n,e){if(this.geometry.boundsTree){if(this.material===void 0)return;yk.copy(this.matrixWorld).invert(),c1.copy(n.ray).applyMatrix4(yk);const t=this.geometry.boundsTree;if(n.firstHitOnly===!0){const r=gk(t.raycastFirst(c1,this.material),this,n);r&&e.push(r)}else{const r=t.raycast(c1,this.material);for(let i=0,s=r.length;i{const e=n.attributes.position,t=n.index,r=new ns,i=new z,s=new z,o=new z,a=[];for(let l=0;l{const e=n.geometry.clone();let t=[];if(Array.isArray(n.material))for(let i=0;i{n.isMesh&&(n.geometry.userData.faceNormals=null,n.geometry.dispose(),n.geometry.disposeBoundsTree(),n.parent&&n.parent.remove(n),n.userData.cancelMesh&&gB(n.userData.cancelMesh))},EH=n=>{var e,t;n.userData.cullingClone&&(gB(n.userData.cullingClone),n.userData.cullingClone=null,gB(n.userData.cullingCloneP),n.userData.cullingCloneP=null,gB(n.userData.cullingCloneN),n.userData.cullingCloneN=null,((e=n.userData)==null?void 0:e.clippedIndexGeometry)!=null&&(n.userData.clippedIndexGeometry=null),((t=n.userData)==null?void 0:t.origIndexBuffer)!=null&&(n.userData.origIndexBuffer=null))},Qde=async n=>{if(n==null){console.warn("Null parameter for meshes was provided. Skipping mesh culling.");return}if(!Array.isArray(n)){console.warn("No valid mesh array was provided. Skipping mesh culling.");return}if(n.length==0){console.warn("No mesh array with elements was provided. Skipping mesh culling.");return}const e=[];bg=n[0].parent,bg.lines!=null&&(bg.lines.forEach(i=>{i.visible=!1}),bg.lines.length=0),n.forEach(i=>{if(i.userData.cullLayer!=null){i.userData.origIndexBuffer==null&&(i.userData.origIndexBuffer=i.geometry.index.clone()),e[i.userData.cullLayer]==null&&(e[i.userData.cullLayer]={origMeshes:[],cloneMeshes:[],posMeshes:[],negMeshes:[],scaleMeshes:[],positionMeshes:[]}),i.userData.cullingClone==null&&(i.userData.cullingClone=_de(i),i.userData.cullingCloneP=i.userData.cullingClone.clone(),i.userData.cullingCloneN=i.userData.cullingClone.clone());const s=i.userData.cullingClone,o=i.userData.cullingCloneP,a=i.userData.cullingCloneN;o.material=Ede,a.userData.cancelMesh=o,a.material=Ude,o.userData.maxCullDistance=a.userData.maxCullDistance=i.userData.maxCullDistance,e[i.userData.cullLayer].origMeshes.push(i),e[i.userData.cullLayer].cloneMeshes.push(s),e[i.userData.cullLayer].posMeshes.push(o),e[i.userData.cullLayer].negMeshes.push(a),i.geometry.setIndex(i.userData.origIndexBuffer)}});for(let i=e.length-1;i>=0;i--)e[i]==null&&e.splice(i,1);let t=[];const r=[];for(let i=e.length-1;i>=0;i--){if(t.length!=0||e.length>=1)for(let s=0;s{i.geom.setIndex(i.index)})},Rde=n=>{let e=Ide,t=Fde;return n&&(isNaN(n)?Array.isArray(n)&&(isNaN(n[0])||(e=n[0]),isNaN(n[1])||(t=n[1])):e=n),[e,t]},Mde=(n,e,t,r,i,s,o=!1)=>{const a=[],l=Rde(s);let A=l[0],c=l[1];fy.far=A+c;for(let f=0;f=0;v--)A-g[v].distance>=g[v].object.userData.maxCullDistance&&g.splice(v,1);if(g.length===0){for(let v=0;v<3;v++)a.push(n[d+v]);break}else{const v=g.map(y=>y.object);for(let y=0;yy).length===0){for(let y=0;y<3;y++)a.push(n[d+y]);break}if(p===0)h=g.map(y=>y.object);else if(h=g.map(y=>{if(h.indexOf(y.object)!==-1)return y.object}),h=h.filter(y=>y),p===2&&h.filter(y=>y).length===0)for(let y=0;y<3;y++)a.push(n[d+y]);o&&Tde(u1,Gp.clone().multiplyScalar(-1),fy.far,16711680,bg)}}}const u=new Uint32Array(a);return new At(u,1,!1)};function Tde(n,e,t,r,i){i.lines==null&&(i.lines=[]);let s=new z;s.addVectors(n,e.clone().multiplyScalar(t));const o=[];o.push(n),o.push(s);const a=new Ht().setFromPoints(o),l=[];l.push(new Re(0)),l.push(new Re(16777215));let A=new Wl({color:r});var c=new kh(a,A);c.renderOrder=100,i.add(c),i.lines.push(c)}function UH(n){let e,t,r,i=0;for(let a=0;atypeof window>"u"?await Lde({meshes:e,atlasSize:t,mtoon:r,transparentMaterial:i,transparentTexture:s}):await Pde({backColor:n,meshes:e,atlasSize:t,mtoon:r,transparentMaterial:i,transparentTexture:s,twoSidedMaterial:o}),Lde=async({meshes:n,atlasSize:e,mtoon:t,transparentMaterial:r,transparentTexture:i})=>{const s=e,o=["diffuse"],a=[];n.forEach(E=>{const x=E.material;let S=a.find(M=>M.material===x);if(!S)a.push({material:x,mesh:E});else{const{dest:M}=K_({meshes:[S.mesh,E]});S.mesh.geometry=M}});const l=Object.fromEntries(o.map(E=>[E,SH({width:s,height:s,transparent:i})])),A=Math.floor(Math.sqrt(n.length)+1),c=s/A,u=new Map(a.map((E,x)=>{const S=new We(x%A,Math.floor(x/A)).multiplyScalar(1/A),M=new We(S.x+1/A,S.y+1/A);return[E.mesh,{min:S,max:M}]})),f={diffuse:["map"],normal:["normalMap"],orm:["ormMap","aoMap","roughnessMap","metalnessMap"]},d=[],h=[];a.forEach(E=>{const{min:x,max:S}=u.get(E.mesh);h.push(S),d.push(x)});const p=new We(Math.max(...h.map(E=>E.x)),Math.max(...h.map(E=>E.y))),m=new We(Math.min(...d.map(E=>E.x)),Math.min(...d.map(E=>E.y))),g=1/(p.x-m.x),v=1/(p.y-m.y),y=c*g,w=c*v,C=new Map(a.map(E=>{let{min:x,max:S}=u.get(E.mesh);return x.x=x.x*g,x.y=x.y*v,S.x=S.x*g,S.y=S.y*v,[E.mesh,{min:x,max:S}]}));a.forEach(E=>{const{material:x,mesh:S}=E,{min:M,max:Z}=C.get(S);o.forEach(F=>{const R=l[F];R.globalCompositeOperation="source-over";let k=rU(x,f[F].find(T=>rU(x,T)));if(k!==""&&k!==void 0)try{const T=new Uint8ClampedArray(k.data),V=new ImageData(T,y,w),O=document.createElement("canvas");O.width=y,O.height=w;const L=O.getContext("2d");L.putImageData(V,0,0),L.save(),R.drawImage(O,M.x*s,M.y*s,y,w)}catch(T){console.error("error",T)}else R.fillStyle=F==="diffuse"?`#${x.color.clone().getHexString()}`:F==="normal"?"#8080ff":F==="orm"?`#${new Re(x.aoMapIntensity,x.roughness,x.metalness).getHexString()}`:"#7F7F7F",R.fillRect(M.x*s,M.y*s,y,w)});const K=S.geometry,_=K.attributes.uv;if(_)for(let F=0;F<_.array.length;F+=2)_.array[F]=_A(_.array[F],0,1,M.x,Z.x),_.array[F+1]=_A(_.array[F+1],0,1,M.y,Z.y);const B=K.attributes.uv2;if(B)for(let F=0;F{const x=new ir(l[E].canvas);return x.flipY=!1,[E,x]})));return{bakeObjects:a,textures:b,uvs:C}},Pde=async({backColor:n,meshes:e,atlasSize:t,mtoon:r,transparentMaterial:i,transparentTexture:s,twoSidedMaterial:o})=>{Nde();const a=t,l=r?["diffuse"]:["diffuse","orm"],A=[];let c=null;e.forEach(_=>{_=_.clone();const B=_.material.length==null?_.material:_.material[0];r&&c==null&&B.type=="ShaderMaterial"&&(c=B.clone());let F=A.find(R=>{R.material});if(!F)A.push({material:B,mesh:_});else{const{dest:R}=K_({meshes:[F.mesh,_]});F.mesh.geometry=R}});const u=Object.fromEntries(l.map(_=>[_,SH({width:a,height:a,transparent:s})])),f=Math.floor(Math.sqrt(e.length)+1),d=a/f,h=new Map(A.map((_,B)=>{const F=new We(B%f,Math.floor(B/f)).multiplyScalar(1/f),R=new We(F.x+1/f,F.y+1/f);return[_.mesh,{min:F,max:R}]})),p={diffuse:["map"],normal:["normalMap"],orm:["ormMap","aoMap","roughnessMap","metalnessMap"]},m=[],g=[];A.forEach(_=>{const{min:B,max:F}=h.get(_.mesh);g.push(F),m.push(B)});const v=new We(Math.max(...g.map(_=>_.x)),Math.max(...g.map(_=>_.y))),y=new We(Math.min(...m.map(_=>_.x)),Math.min(...m.map(_=>_.y))),w=1/(v.x-y.x),C=1/(v.y-y.y),b=d*w,E=d*C,x=new Map(A.map(_=>{let{min:B,max:F}=h.get(_.mesh);return B.x=B.x*w,B.y=B.y*C,F.x=F.x*w,F.y=F.y*C,[_.mesh,{min:B,max:F}]}));A.forEach(_=>{const{material:B,mesh:F}=_,{min:R,max:k}=x.get(F);l.forEach(L=>{var oe;const U=u[L];U.globalCompositeOperation="source-over";let H,le=new Re(1,1,1);switch(L){case"diffuse":H=B.color||n,(oe=B.uniforms)!=null&&oe.litFactor?le=B.uniforms.litFactor.value:le=B.color;break;case"normal":H=new Re(8421631);break;case"orm":H=new Re(B.aoMapIntensity,B.roughness,B.metalness);break;default:H=new Re(1,1,1);break}let N=kde(B,p[L].find(ie=>rU(B,ie)));const j=Dde(N,le,H,a,a,s);createImageBitmap(j).then(ie=>U.drawImage(ie,R.x*a,R.y*a,b,E))});const T=F.geometry.clone();F.geometry=T;const V=T.attributes.uv.clone();if(T.attributes.uv=V,V)for(let L=0;L{const B=new ir(u[_].canvas);return B.flipY=!1,[_,B]}))),M=o?pi:Vo;let Z;const K=i?"transparent":"opaque";return r?(Z=new mu({map:S.diffuse,transparent:i,side:M}),c==null&&(c=new dB),c.side=M,c.uniforms.map=S.diffuse,c.uniforms.shadeMultiplyTexture=S.diffuse,c.transparent=i,s&&!i&&(Z.alphaTest=.5,c.alphaTest=.5),Z.userData.vrmMaterial=c,Z.userData.shadeTexture=S.uniformColor,Z.name="mToon_"+K,Z.map.name=Z.name):(Z=new mu({map:S.diffuse,roughnessMap:S.orm,metalnessMap:S.orm,normalMap:S.normal,transparent:i,side:M}),s&&!i&&(Z.alphaTest=.5),Z.name="standard_"+K,Z.roughnessMap!=null&&(Z.roughnessMap.name=Z.name+"_orm"),Z.normalMap!=null&&(Z.normalMap.name=Z.name+"_normal")),{bakeObjects:A,material:Z}};function _H(n){const e=new Map;for(const r of n.skeleton.bones){const i=r.clone(!1);e.set(r,i)}n.skeleton.bones[0].traverse(r=>{if(r.type!=="Bone")return;const i=e.get(r);for(const s of r.children){const o=e.get(s);o&&i.add(o)}});const t=new hc(n.skeleton.bones.map(r=>e.get(r)));return t.boneInverses=n.skeleton.boneInverses,t.pose(),t}function QH(n,e){const t=new Map;new z(-1,1,-1),new Le,new z;let r=0;n.forEach(l=>{if(l.skeleton){var A=_H(l);const c=A.bones;A.bones.forEach((u,f)=>{var d;if(c.indexOf(u)!==-1){const h=t.get(u.name);if(h==null){const p={index:r,boneInverses:A.boneInverses[f],bone:u.clone(!1),parentName:((d=u.parent)==null?void 0:d.type)=="Bone"?u.parent.name:null};r++,t.set(u.name,p)}else u.userData.VRMcolliders!=null&&(h.bone.userData.VRMcolliders==null?h.bone.userData.VRMcolliders=u.userData.VRMcolliders:h.bone.userData.VRMcolliders=[...h.bone.userData.VRMcolliders,...u.userData.VRMcolliders])}})}});const i=[],s=[];[...t.values()].forEach(l=>{var A;if(i.push(l.bone),s.push(l.boneInverses),l.parentName!=null){const c=(A=t.get(l.parentName))==null?void 0:A.bone;c&&c.add(l.bone)}});const a=new hc(i,s);return a.bones.forEach(l=>{var c;const A=(c=l.userData)==null?void 0:c.vrm0RestPosition;A&&l.position.set(-A.x,A.y,-A.z),l.position.set(l.position.x*e,l.position.y*e,l.position.z*e)}),a}function Wde(n,e){if(!e.skeleton)return;const t=new Map;if(e.skeleton){e.skeleton.bones.forEach((o,a)=>{const l=n.bones.filter(c=>c.name===o.name),A=l.length>0?n.bones.indexOf(l[0]):-1;t.set(a,A)});const r=[],i=e.geometry.attributes.skinIndex.array;for(let o=0;oe.indexOf(t)===r)}function Ode(n){const t=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array].filter(r=>n.constructor===r);return t.length&&t[0]||null}function Zw(n,e){const t=[];for(let s=0;ss.name===r.name);return i?t.bones.indexOf(i):-1}async function Jde(n,e){const{scale:t,isVrm0:r}=e,i=[],s=[];Ih(n,"SkinnedMesh").forEach(A=>{const c=A.clone();i.push(c),Array.isArray(A.material)?s.push(...A.material):s.push(A.material)});const a=QH(i,t),l=new kt;return l.name="AvatarRoot",i.forEach(A=>{var b;const c=new Ht,u={};for(const E in A.geometry.attributes){const x=A.geometry.attributes[E];u[E]=x.clone()}if((b=A.userData)!=null&&b.isVRM0)for(let E=0;E[E,E.geometry.morphAttributes])),h=new Map([A].map(E=>[E,E.morphTargetDictionary||{}]));if(f.morphAttributes=MH({meshes:[A],sourceMorphAttributes:d,sourceMorphTargetDictionaries:h,destMorphTargetDictionary:f.morphTargetDictionary,scale:t},r),r)for(let E=0;Ed.name===e.userData.boneName),s=e.userData.globalPosition,o=e.userData.globalScale||new z(1,1,1),a=e.userData.globalRotationMatrix;t.add(r.bones[0]);const l=[],A=[],c=t.geometry.attributes.position.array,u=new z,f=e.userData.isVRM0?-1:1;for(let d=0;d0){const{bakeObjects:M,material:Z}=await Vde({transparentColor:t,atlasSize:x.size,meshes:S,mtoon:x.isMtoon,transparentMaterial:x.transparentMaterial,transparentTexture:y,twoSidedMaterial:u}),K=M.map(T=>T.mesh),_=[];K.forEach(T=>{T.type=="Mesh"&&(T=zde(C,T)),_.push(T);const V=T.geometry,O=V.index.array,L=RH(T.geometry.index.array),U=[];for(let N=0;N{const o=n.find(l=>e.get(l).hasOwnProperty(i)),a=o.morphTargetDictionary[i];r[s]=o.morphTargetInfluences[a]}),r}function Kde({sourceAttributes:n}){const e=new Set,t=Array.from(n.values());t.forEach(i=>{Object.keys(i).forEach(s=>e.add(s))});const r={};return Array.from(e.keys()).map(i=>{r[i]=UH(t.map(s=>s[i]).flat().filter(s=>s!==void 0))}),r}function jde({sourceMorphTargetDictionaries:n}){const e=new Set;Array.from(n.values()).forEach(i=>{Object.keys(i).forEach(s=>e.add(s))});const r={};return Array.from(e.keys()).map((i,s)=>{r[i]=s}),r}function MH({meshes:n,sourceMorphTargetDictionaries:e,sourceMorphAttributes:t,destMorphTargetDictionary:r,scale:i},s=!1){const o=new Set;Array.from(t.values()).forEach(u=>{Object.keys(u).forEach(f=>o.add(f))});const l=Array.from(o),A={};l.forEach(u=>{A[u]=[],Object.entries(r).forEach(([f,d])=>{A[u][d]=[],n.forEach(h=>{let p;const m=e.get(h);if(m.hasOwnProperty(f)&&h.geometry.morphAttributes[u]){const g=m[f];p=h.geometry.morphAttributes[u][g]}else{const g=h.geometry.attributes[u],v=new g.array.constructor(new Array(g.array.length).fill(0));p=new At(v,g.itemSize,g.normalized)}A[u][d].push(p)})})});const c={};return l.forEach(u=>{c[u]=[];for(let f=0;f{const i=r.geometry.index;for(var s=0;s{var l;if(r+=a.geometry.attributes.uv.count,(l=a.userData)!=null&&l.isVRM0)for(let A=0;A[a,a.geometry.attributes])),morphAttributes:new Map(n.map(a=>[a,a.geometry.morphAttributes])),morphTargetDictionaries:new Map(n.map(a=>[a,a.morphTargetDictionary||{}])),morphTargetInfluences:new Map(n.map(a=>[a,a.morphTargetInfluences||[]]))},s={attributes:null,morphTargetDictionary:null,morphAttributes:null,morphTargetInfluences:null,index:null,animations:{}};s.attributes=Kde({sourceAttributes:i.attributes});const o=jde({sourceMorphTargetDictionaries:i.morphTargetDictionaries});return s.morphTargetDictionary=o,s.morphAttributes=MH({meshes:n,sourceMorphAttributes:i.morphAttributes,sourceMorphTargetDictionaries:i.morphTargetDictionaries,destMorphTargetDictionary:o,scale:e},t),s.morphTargetInfluences=Xde({meshes:n,sourceMorphTargetDictionaries:i.morphTargetDictionaries,destMorphTargetDictionary:o}),s.index=$de({meshes:n}),s.animations={},{source:i,dest:s}}function Yt(n){return n==null?[]:Array.isArray(n)?n:[n]}async function qde(n,e){const r=await new Nu().load(e);r.encoding=ht,r.flipY=!1,n.traverse(i=>{if(i instanceof In){const s=Array.isArray(i.material)?i.material:[i.material];for(let o=0;o{const e=[];for(const t in n){const r=n[t].vrm;if(r){const i=r.data.cullingLayer;i>=0&&r.data.cullingMeshes.map(s=>{s.userData.cullLayer=i,s.userData.cullDistance=r.data.cullingDistance,s.userData.maxCullDistance=r.data.maxCullingDistance,e.push(s)})}}Qde(e)};function nhe(n){const e=[],t=[],r=[],i=[];let s=!1;return n.forEach(o=>{var A;const l=Yt(o.material)[0];l.type=="ShaderMaterial"?l.transparent==!0?(i.push(o),s=!0):(r.push(o),((A=l.uniforms.alphaTest)==null?void 0:A.value)!=0&&(s=!0)):l.transparent==!0?(t.push(o),s=!0):(e.push(o),l.alphaTest!=0&&(s=!0))}),{stdMesh:e,stdTranspMesh:t,mToonMesh:r,mToonTranspMesh:i,requiresTransparency:s}}function rhe(n){const e=[],t=[],r=[],i=[],s=[],o=[];return n.forEach(a=>{Yt(a.material).forEach(A=>{A.type=="ShaderMaterial"?A.transparent==!0?o.push(A):A.uniforms.alphaTest.value!=0?s.push(A):i.push(A):A.transparent==!0?r.push(A):A.alphaTest!=0?t.push(A):e.push(A)})}),{stdMats:e,stdCutoutpMats:t,stdTranspMats:r,mToonMats:i,mToonCutoutMats:s,mToonTranspMats:o}}function wk(n,e){n.data==null?n.data=e:n.data={...n.data,...e}}function ihe(n,e){if(n.data!=null)return n.data[e]}function she(n){const e=ihe(n,"cullingMeshes");e&&(e.forEach(t=>{EH(t)}),n.data.cullingMeshes=null)}function Cn(n){switch(n){case 1:return 128;case 2:return 256;case 3:return 512;case 4:return 1024;case 5:return 2048;case 6:return 4096;case 7:return 8192;case 8:return 16384;default:return 4096}}function ohe(n){const e=n.scene;she(n),e.traverse(t=>{t.material&&iU(t.material),t.geometry&&(EH(t),t.geometry.dispose(),t.geometry.disposeBoundsTree())}),e.parent&&e.parent.remove(e),Xh.deepDispose(e),n.expressionManager&&n.expressionManager.expressions.forEach(t=>{t._binds&&t._binds.forEach(r=>{r.primitives&&r.primitives.forEach(i=>{i.geometry.dispose(),i.material&&iU(i.material)})})});for(const t in n)n[t]=null}const iU=n=>{var e,t,r,i,s,o;if(n.length)for(let a=0;a{const t=new Blob([n],{type:"text/plain"}),r=document.createElement("a");r.href=window.URL.createObjectURL(t),r.download=e+".txt",document.body.appendChild(r),r.click(),document.body.removeChild(r)},TH=n=>{let e,t,r=0;return Array.isArray(n)?(e=n[0]||0,t=n[1]||0,r=n[2]||0):(typeof n=="string"||n instanceof String)&&n.split("-").forEach(s=>{switch(s=s.toLowerCase(),s){case"left":e=-1;break;case"right":e=1;break;case"bottom":case"down":t=-1;break;case"top":case"up":t=1;break;case"back":case"backward":r=-1;break;case"front":case"forward":r=1;break;default:console.warn("unkown cameraPosition name: "+s+" in: "+n+". Please use left, right, bottom, top, back or front");break}}),new z(e,t,r)},lhe=n=>{var t,r,i,s,o,a,l,A,c,u,f;const e=n.humanoid.humanBones;e.upperChest==null&&e.neck.node.parent!=e.chest&&(e.neck.node.parent!=e.chest.node?e.upperChest={node:e.neck.node.parent}:e.upperChest!=null&&(e.upperChest={node:e.neck.node.parent},e.chest={node:e.neck.node.parent.parent})),e.leftShoulder==null&&(e.leftUpperArm.node.parent!=((t=e.chest)==null?void 0:t.node)&&e.leftUpperArm.node.parent!=((r=e.upperChest)==null?void 0:r.node)&&e.leftUpperArm.node.parent!=((i=e.spine)==null?void 0:i.node)&&e.leftUpperArm.node.parent!=((s=e.neck)==null?void 0:s.node)&&e.leftUpperArm.node.parent!=((o=e.head)==null?void 0:o.node),e.leftShoulder={node:e.leftUpperArm.node.parent}),e.rightShoulder==null&&(e.rightUpperArm.node.parent!=((a=e.chest)==null?void 0:a.node)&&e.rightUpperArm.node.parent!=((l=e.upperChest)==null?void 0:l.node)&&e.rightUpperArm.node.parent!=((A=e.spine)==null?void 0:A.node)&&e.rightUpperArm.node.parent!=((c=e.neck)==null?void 0:c.node)&&e.rightUpperArm.node.parent!=((u=e.head)==null?void 0:u.node),e.rightShoulder={node:e.rightUpperArm.node.parent});for(let d in Lm)d=d.charAt(0).toLowerCase()+d.slice(1),(f=e[d])!=null&&f.node&&(e[d].node.name=d)};function NH({candidates:n,predicate:e}){if(!n.length)return null;const t=n.shift();return e(t)?t:(n=n.concat(t.children),NH({candidates:n,predicate:e}))}function DH(n,e){return NH({candidates:[n],predicate:t=>t.name===e})}function kH({candidates:n,predicate:e,results:t=[]}){if(!n.length)return t;const r=n.shift();return e(r)&&t.push(r),n=n.concat(r.children),kH({candidates:n,predicate:e,results:t})}function Ih(n,e){return kH({candidates:[n],predicate:t=>Yt(e).includes(t.type)})}function Ahe(n,e,t){const r=Ih(n,"SkinnedMesh");return{humanBones:uhe(r[0]),materials:n.userData.atlasMaterial,meta:che(e,t)}}function che(n,e){return e=e||{},{...{authors:["CharacterStudio"],metaVersion:"1",version:"v1",name:n,licenseUrl:"https://vrm.dev/licenses/1.0/",commercialUssageName:"personalNonProfit",contactInformation:"https://m3org.com/",allowExcessivelyViolentUsage:!1,allowExcessivelySexualUsage:!1,allowPoliticalOrReligiousUsage:!1,allowAntisocialOrHateUsage:!1,creditNotation:"required",allowRedistribution:!1,modification:"prohibited"},...e}}function uhe(n){const e={};return n.skeleton.bones.map(t=>{for(const r in Lm)if(Lm[r]===t.name){e[t.name]={node:t};break}}),e}const fhe={mixamorigHips:"hips",mixamorigSpine:"spine",mixamorigSpine1:"chest",mixamorigSpine2:"upperChest",mixamorigNeck:"neck",mixamorigHead:"head",mixamorigLeftShoulder:"leftShoulder",mixamorigLeftArm:"leftUpperArm",mixamorigLeftForeArm:"leftLowerArm",mixamorigLeftHand:"leftHand",mixamorigLeftHandThumb1:"leftThumbMetacarpal",mixamorigLeftHandThumb2:"leftThumbProximal",mixamorigLeftHandThumb3:"leftThumbDistal",mixamorigLeftHandIndex1:"leftIndexProximal",mixamorigLeftHandIndex2:"leftIndexIntermediate",mixamorigLeftHandIndex3:"leftIndexDistal",mixamorigLeftHandMiddle1:"leftMiddleProximal",mixamorigLeftHandMiddle2:"leftMiddleIntermediate",mixamorigLeftHandMiddle3:"leftMiddleDistal",mixamorigLeftHandRing1:"leftRingProximal",mixamorigLeftHandRing2:"leftRingIntermediate",mixamorigLeftHandRing3:"leftRingDistal",mixamorigLeftHandPinky1:"leftLittleProximal",mixamorigLeftHandPinky2:"leftLittleIntermediate",mixamorigLeftHandPinky3:"leftLittleDistal",mixamorigRightShoulder:"rightShoulder",mixamorigRightArm:"rightUpperArm",mixamorigRightForeArm:"rightLowerArm",mixamorigRightHand:"rightHand",mixamorigRightHandPinky1:"rightLittleProximal",mixamorigRightHandPinky2:"rightLittleIntermediate",mixamorigRightHandPinky3:"rightLittleDistal",mixamorigRightHandRing1:"rightRingProximal",mixamorigRightHandRing2:"rightRingIntermediate",mixamorigRightHandRing3:"rightRingDistal",mixamorigRightHandMiddle1:"rightMiddleProximal",mixamorigRightHandMiddle2:"rightMiddleIntermediate",mixamorigRightHandMiddle3:"rightMiddleDistal",mixamorigRightHandIndex1:"rightIndexProximal",mixamorigRightHandIndex2:"rightIndexIntermediate",mixamorigRightHandIndex3:"rightIndexDistal",mixamorigRightHandThumb1:"rightThumbMetacarpal",mixamorigRightHandThumb2:"rightThumbProximal",mixamorigRightHandThumb3:"rightThumbDistal",mixamorigLeftUpLeg:"leftUpperLeg",mixamorigLeftLeg:"leftLowerLeg",mixamorigLeftFoot:"leftFoot",mixamorigLeftToeBase:"leftToes",mixamorigRightUpLeg:"rightUpperLeg",mixamorigRightLeg:"rightLowerLeg",mixamorigRightFoot:"rightFoot",mixamorigRightToeBase:"rightToes"};function VH(n,e,t){var p;const r=vu.findByName(n,"mixamo.com");if(r==null)return null;const i=[],s=new tt,o=new tt,a=new tt,l=new z,A=e.getObjectByName("mixamorigHips").position.y,c=(p=t.humanoid)==null?void 0:p.getNormalizedBoneNode("hips").getWorldPosition(l).y,u=t.scene.getWorldPosition(l).y,d=Math.abs(c-u)/A;return r.tracks.forEach(m=>{const g=m.clone(),v=g.name.split("."),y=v[0],C=fhe[y],b=e.getObjectByName(y);if(C!=null){const E=v[1];if(b.getWorldQuaternion(s).invert(),b.parent.getWorldQuaternion(o),g instanceof Qa){for(let x=0;x{g.values[Z+x]=M})}i.push(new Qa(`${C}.${E}`,g.times,g.values.map((x,S)=>{var M;return((M=t.meta)==null?void 0:M.metaVersion)==="0"&&S%2===0?-x:x})))}else if(g instanceof ec){const x=g.values.map((S,M)=>{var Z;return(((Z=t.meta)==null?void 0:Z.metaVersion)==="0"&&M%3!==1?-S:S)*d});i.push(new ec(`${C}.${E}`,g.times,x))}}}),new vu("vrmAnimation",r.duration,i)}const dhe=new Ese,hhe=new x_,h1=.2,phe=n=>Math.floor(Math.random()*n);class Ck{constructor(e,t,r,i,s,o,a){var l,A,c,u;this.mixer=new wie(t),this.actions=[],this.to=null,this.from=null,this.vrm=r,this.animationManager=e,this.mixamoModel=null,this.fadeOutActions=null,this.newAnimationWeight=1,this.neckBone=(A=(l=r==null?void 0:r.humanoid)==null?void 0:l.humanBones)==null?void 0:A.neck,this.spineBone=(u=(c=r==null?void 0:r.humanoid)==null?void 0:c.humanBones)==null?void 0:u.spine,this.timeScale=1,i&&(this.setAnimations(i,null,null,a),this.to=this.actions[s],o!=-1&&(this.from=this.actions[o],this.from.reset(),this.from.time=e.getFromActionTime(),this.from.play(),this.to.weight=e.getWeightIn(),this.from.weight=e.getWeightOut()),this.actions[s].reset(),this.actions[s].time=e.getToActionTime(),this.actions[s].play())}setTimeScale(e){this.timeScale=e,this.actions.forEach(t=>{t.timeScale=e})}setMouseLookEnabled(e){this.setAnimations(this.animations,this.mixamoModel,e)}setAnimations(e,t=null,r=null,i=!1){if(r=r??this.animationManager.mouseLookEnabled,this.animations=e,t!=null){if(this.vrm!=null){const s=VH(e,t,this.vrm);s&&(e=[s],this.mixamoModel=t)}}else{const s=[];e.forEach(o=>{s.push(o.clone())}),e=s}if(r&&e[0].tracks.map((s,o)=>{(s.name==="neck.quaternion"||s.name==="spine.quaternion")&&e[0].tracks.splice(o,1)}),i){this.actions.forEach(s=>{s.weight=0,s.stop()}),this.actions=[],this.newAnimationWeight=1;for(let s=0;s{r.weight=1-this.newAnimationWeight}),this.newAnimationWeight>=1&&(this.newAnimationWeight=1,this.fadeOutActions.forEach(r=>{r.weight=0,r.stop()}),this.fadeOutActions=null),this.actions.forEach(r=>{r.weight=this.newAnimationWeight})),this.from!=null&&(this.from.weight=t),this.to!=null&&(this.to.weight=e),this.mixer.update(1/30)}reset(){this.mixer.setTime(0),this.to.paused=!0}resume(){this.to.paused=!1}setTime(e){this.mixer.setTime(e)}dispose(){this.animationManager.disposeAnimation(this)}}class ghe{constructor(){this.animationPaths=null,this.lastAnimID=null,this.mainControl=null,this.animationControl=null,this.animations=null,this.paused=!1,this.scale=1,this.curLoadAnim=0,this.currentAnimationName="",this.weightIn=NaN,this.weightOut=NaN,this.lastAnimID=-1,this.curAnimID=0,this.animationControls=[],this.started=!1,this.mouseLookEnabled=!1,this.mixamoModel=null,this.mixamoAnimations=null,this.currentClip=null,setInterval(()=>{this.update()},1e3/30)}enableMouseLook(e){this.mouseLookEnabled=e,this.animationControls.forEach(t=>{t.setMouseLookEnabled(e)})}setScale(e){this.scale=e}async loadAnimation(e,t,r=0,i=!0,s="",o=""){const a=s+(s!=""?"/":"")+Yt(e)[0];o=o==""?rc(a):o,this.currentAnimationName=o;const A=await(i?dhe:hhe).loadAsync(a);A.scale.set(this.scale,this.scale,this.scale),this._scaleOffsetHips(A.animations);const c=vu.findByName(A.animations,"mixamo.com");c!=null?(this.mixamoModel=A.clone(),this.mixamoAnimations=A.animations,this.currentClip=c):(this.mixamoModel=null,this.animations=A.animations,this.currentClip=A.animations[0]),this.mainControl==null&&(this.curAnimID=0,this.lastAnimID=-1,this.mainControl=new Ck(this,A,null,A.animations,this.curAnimID,this.lastAnimID,t),this.animationControls.push(this.mainControl)),this.animationControls.forEach(u=>{u.setAnimations(A.animations,this.mixamoModel,this.mouseLookEnabled,t)}),this.setTime(r),t?this.pause():this.play()}getCurrentClip(){return this.currentClip}getCurrentAnimationName(){return this.currentAnimationName}clearCurrentAnimations(){this.animationPaths=null,this.animationControls=[],this.mainControl=null}storeAnimationPaths(e,t){const r=Yt(e);this.animationPaths=r.map(i=>`${t}/${i}`)}loadNextAnimation(){this.curLoadAnim==this.animationPaths.length-1?this.curLoadAnim=0:this.curLoadAnim++,this.loadAnimation(this.animationPaths[this.curLoadAnim])}loadPreviousAnimation(){this.curLoadAnim==0?this.curLoadAnim=this.animationPaths.length-1:this.curLoadAnim--,this.loadAnimation(this.animationPaths[this.curLoadAnim])}enableScreenshot(){this.animationControls.forEach(e=>{e.reset()})}disableScreenshot(){this.animationControls.forEach(e=>{e.resume()})}_scaleOffsetHips(e){e.forEach(t=>{for(let r=0;rr.vrm===e);t!==-1&&this.animationControls.splice(t,1)[0].dispose()}getFromActionTime(){return this.mainControl.actions[this.lastAnimID].time}getToActionTime(){return this.mainControl?this.mainControl.actions[this.curAnimID].time:.1}getWeightIn(){return this.weightIn}getWeightOut(){return this.weightOut}disposeAnimation(e){if(e!=null){const t=this.animationControls.indexOf(e);t!=-1&&this.animationControls.splice(t,1)}}dispose(){this.animationControls.forEach(e=>{e.dispose()})}animRandomizer(e){setTimeout(()=>{this.lastAnimID=this.curAnimID,this.curAnimID=phe(this.animations.length),this.curAnimID!=this.lastAnimID&&this.animationControls.forEach(t=>{t.from=t.actions[this.lastAnimID],t.to=t.actions[this.curAnimID],this.weightIn=0,this.weightOut=1,t.to.play(),t.to.reset()}),this.animRandomizer(this.animations[this.curAnimID].duration-h1)},e*1e3)}pause(){this.paused=!0}play(){this.paused=!1}isPaused(){return this.paused}setTime(e){this.mainControl&&this.animationControls.forEach(t=>{t.setTime(e)})}setSpeed(e){this.mainControl&&this.animationControls.forEach(t=>{t.setTimeScale(e)})}update(){this.mainControl&&!this.paused&&(this.animationControls.forEach(e=>{e.update(this.weightIn,this.weightOut)}),this.weightIn<1?this.weightIn+=1/(30*h1):this.weightIn=1,this.weightOut>0?this.weightOut-=1/(30*h1):this.weightOut=0)}}const bk={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` varying vec2 vUv; @@ -4214,8 +4214,8 @@ void main() { texel.rgb = pow(texel.rgb, vec3(1.0 / 2.2)); gl_FragColor = texel; } - `})}}const Jw=4096,Zp=new z;class bhe{constructor(e,t,r){const i=new c0({preserveDrawingBuffer:!0,antialias:!1,alpha:!0});this.pixelSize=r,this.domElement=i.domElement;const s=new We(Jw,Jw);i.setClearColor(0,0),i.outputEncoding=ps,i.setSize(s.x,s.y),i.setPixelRatio(window.devicePixelRatio);let o=s.clone().divideScalar(r);o.x|=0,o.y|=0;const a=new yhe(i);a.addPass(new Bhe(e,t)),this._renderPixelPass=new whe(o,e,t),this._pixelPass=new Che(o),a.addPass(this._renderPixelPass),a.addPass(this._pixelPass),this.renderer=i,this.composer=a}setSize(e,t){let i=new We(e,t).clone().divideScalar(this.pixelSize);i.x|=0,i.y|=0,this.renderer.setSize(e,t),this._renderPixelPass.setResolution(i),this._pixelPass.setResolution(i)}setPixelSize(e){this.pixelSize=e}render(){this.composer.render()}}class xhe{constructor(e,t){this.renderer=new c0({preserveDrawingBuffer:!0,antialias:!0,alpha:!0}),this.renderer.setClearAlpha(0),this.renderer.premultipliedAlpha=!1,this.scene=t,this.characterManager=e,this.renderer.outputEncoding=ht,this.renderer.setSize(Jw,Jw),this.camera=new Mr(30,1,.1,1e3),this.textureLoader=new Nu,this.sceneBackground=new Re(.1,.1,.1),this.sceneBackgroundAlpha=1,this.frameOffset={min:.2,max:.2},this.usesBackgroundImage=!1,this.backgroundMaterial=new Qi({color:16777215,transparent:!0,opacity:.5});const r=new Ru(1e3,1e3),i=new In(r,this.backgroundMaterial);i.renderOrder=-1,this.backgroundPlane=i,this.pixelRenderer=new bhe(t,this.camera,20),this.boneOffsets={head:null,chest:null,hips:null,leftUpperLeg:null,leftFoot:null,rightUpperLeg:null,rightFoot:null}}setScene(e){this.scene=e}setupCamera(e,t,r=30){this.camera.position.copy(e),this.camera.lookAt(t),this.camera.fov=r}_getCharacterMinMax(){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY;return this.characterManager.characterModel.traverse(r=>{r.geometry&&(r.geometry.computeBoundingBox(),r.geometry.boundingBox&&(r.geometry.boundingBox.applyMatrix4(r.matrixWorld),r.geometry.boundingBox.min.yt&&(t=r.geometry.boundingBox.max.y)))}),{minY:e,maxY:t}}frameCloseupShot(){this.frameShot("head","head")}frameMediumShot(){this.frameShot("chest","head")}frameCowboyShot(){this.frameShot("hips","head")}frameFullShot(){this.frameShot("leftFoot","head")}frameShot(e,t,r=null,i=!1,s=!0){const o=this._getBoneWorldPositionWithOffset(e,i),a=this._getBoneWorldPositionWithOffset(t,s);o.y-=this.frameOffset.max,a.y+=this.frameOffset.min,r=r||new z(0,0,0),this.positionCameraBetweenPoints(o,a,r)}setBottomFrameOffset(e){this.frameOffset.min=e}setTopFrameOffset(e){this.frameOffset.max=e}_setBonesOffset(e){for(const t in this.boneOffsets){const r=this._getMinMaxOffsetByBone(this.characterManager.characterModel,t,e);this.boneOffsets[t]=r}}_getBoneWorldPositionWithOffset(e,t){const r=this._getFirstBoneWithName(e);if(!r||!this.boneOffsets[e])return new z;const i=new z;r.getWorldPosition(i);const s=t?this.boneOffsets[e].max:this.boneOffsets[e].min;return i.y+=s.y,i}_getBoneWorldPosition(e){const t=this._getFirstBoneWithName(e);return t!=null?new z().setFromMatrixPosition(t.matrixWorld):(console.warn(`Bone with name '${e}' not found in one of the skinned meshes.`),new z(0,0,0))}_getFirstBoneWithName(e){let t=null;return this.characterManager.characterModel.traverse(r=>{if(r instanceof qA){if(!r.geometry){console.error("Invalid skinned mesh found in children.");return}const i=r.skeleton.bones.findIndex(s=>s.name===e);if(i!==-1){t=r.skeleton.bones[i];return}}}),t}setCameraFrameWithName(e,t){switch(e.toLowerCase()){case"fullshot":this.frameShot("leftFoot","head",t);break;case"cowboyshot":this.frameShot("hips","head",t);break;case"mediumshot":this.frameShot("chest","head",t);break;case"mediumcloseup":case"mediumcloseupshot":this.frameShot("chest","head",t,!0);break;case"closeup":case"closeupshot":this.frameShot("head","head",t);break;default:console.warn("unkown cameraFrame: "+e+". Please use fullShot, cowboyShot, mediumShot, mediumCloseup or closeup"),this.frameShot("leftFoot","head",t);break}}_getMinMaxOffsetByBone(e,t,r){if(!e||!e.traverse)return console.error("Invalid parent object provided."),null;const i=new z(1/0,1/0,1/0),s=new z(-1/0,-1/0,-1/0);return e.traverse(async o=>{if(o instanceof qA){const a=this._saveBonesPos(o.skeleton),l=d=>new Promise(h=>setTimeout(h,d));if(o.skeleton.pose(),await l(10),!o.geometry){console.error("Invalid skinned mesh found in children.");return}const A=o.skeleton.bones.findIndex(d=>d.name===t);if(A===-1){console.error(`Bone with name '${t}' not found in one of the skinned meshes.`);return}const c=o.geometry.getAttribute("position"),u=o.geometry.getAttribute("skinWeight"),f=o.geometry.getAttribute("skinIndex");for(let d=0;d=r){const g=o.skeleton.bones[A],v=new z().setFromMatrixPosition(g.matrixWorld),y=h.clone().sub(v);i.min(y),s.max(y)}}this._restoreSavedPose(a,o.skeleton)}}),{min:i,max:s}}_saveBonesPos(e){let t=[];return e.bones.forEach(r=>{t.push({position:r.position.clone(),rotation:r.rotation.clone(),scale:r.scale.clone()})}),t}_restoreSavedPose(e,t){e&&t.bones.forEach((r,i)=>{r.position.copy(e[i].position),r.rotation.copy(e[i].rotation),r.scale.copy(e[i].scale)})}positionCameraBetweenPoints(e,t,r,i=30){const s=new ws;s.expandByPoint(e),s.expandByPoint(t),this.camera.fov=i;const o=this.camera.fov*(Math.PI/180),l=s.getSize(new z).length()/(2*Math.tan(o/2));s.getCenter(Zp),this.camera.position.copy(Zp),r.y*=.5,this.camera.lookAt(Zp.clone().sub(r));const A=new z;this.camera.getWorldDirection(A),this.camera.position.addScaledVector(A,-l),this.camera.updateProjectionMatrix()}setCamera(e,t,r=30){this.camera.position.copy(e),this.camera.fov=r,Zp.set(0,0,-1),this.cameraDir=Zp.applyQuaternion(this.camera.quaternion),this.cameraDir.normalize(),this.camera.position.x-=this.cameraDir.x*t,this.camera.position.z-=this.cameraDir.z*t}setBackground(e){if(Array.isArray(e)){const t=e[3]==null?1:e[3];this.setBackgroundColor(e[0],e[1],e[2],t)}else this.setBackgroundImage(e)}setBackgroundColor(e,t,r,i){const s=new Re(e,t,r,i);this.sceneBackground=s,i==null&&(i=1),i>1&&(i=1),i<0&&(i=0),this.sceneBackgroundAlpha=i,this.backgroundMaterial.color=s,this.usesBackgroundImage=!1}setBackgroundImage(e){return new Promise(async(t,r)=>{try{const i=await this.texureLoader.load(e);i&&(i.wrapS=i.wrapT=hs,this.sceneBackground=i,this.usesBackgroundImage=!0,this.sceneBackgroundAlpha=1,t())}catch(i){console.error("Error loading background image: ",i),r(i)}})}_setBackground(){if(this.usesBackgroundImage==!1&&this.sceneBackgroundAlpha!=1)if(this.sceneBackgroundAlpha==0)this.scene.background=null;else{this.scene.background=null,this.scene.add(this.backgroundPlane),this.backgroundPlane.position.copy(this.camera.position);var e=new z(0,0,-1);e.applyQuaternion(this.camera.quaternion);var t=100;this.backgroundPlane.position.addScaledVector(e,t),this.backgroundPlane.lookAt(this.camera.position)}else this.scene.background=this.sceneBackground}_restoreBackground(){this.scene.background=null,this.usesBackgroundImage==!1&&this.sceneBackgroundAlpha!=1&&this.scene.remove(this.backgroundPlane)}_createImage(e,t,r=!1){const i=e/t;this.renderer.setSize(e,t);const s="image/png";this.camera.aspect=i,this.camera.updateProjectionMatrix();const o=r?this.pixelRenderer:this.renderer;try{this._setBackground(),o.render(this.scene,this.camera);let a=o.domElement.toDataURL(s);return this._restoreBackground(),a}catch(a){return console.error(a),null}}savePixelScreenshot(e,t,r,i){this.pixelRenderer.setPixelSize(i),this.pixelRenderer.setSize(t,r);const s=this._createImage(t,r,!0),o="image/octet-stream",a="image/png";this.saveFile(s.replace(a,o),e+".png")}saveScreenshot(e,t,r){const i=this._createImage(t,r),s="image/octet-stream",o="image/png";this.saveFile(i.replace(o,s),e+".png")}getScreenshotImage(e,t){const r=this._createImage(e,t),i=new Image;return i.src=r,i}getScreenshotTexture(e,t){const r=this.getScreenshotImage(e,t),i=new ir(r);return i.needsUpdate=!0,i}getScreenshotBlob(e,t){const r=this._createImage(e,t),i=hJ.Buffer.from(r.replace(/^data:image\/\w+;base64,/,""),"base64");return new Blob([i],{type:"image/jpeg"})}saveFile(e,t){const r=document.createElement("a");typeof r.download=="string"?(document.body.appendChild(r),r.download=t,r.href=e,r.click(),document.body.removeChild(r)):window.open(e,"_blank").document.write(""+t+"")}}const Ihe=2;class Fhe{constructor(e=.5,t=.5,r=1,i=5){this.vrmBlinkers=[],this.mode="ready",this.clock=new xZ,this.closeTime=e,this.openTime=t,this.continuity=r,this.randomness=i,this._eyeOpen=1,this._blinkCounter=0,this.isTakingScreenShot=!1,this.update()}addVRM(e){this.vrmBlinkers.push(e)}removeVRM(e){const t=this.vrmBlinkers.indexOf(e);t!==-1&&this.vrmBlinkers.splice(t,1)}enableScreenshot(){this.isTakingScreenShot=!0,this._eyeOpen=Ihe,this._updateBlinkers()}disableScreenshot(){this.isTakingScreenShot=!1}update(){setInterval(()=>{if(this.isTakingScreenShot)return;const e=this.clock.getDelta();switch(this.mode){case"closing":this._eyeOpen>0?this._eyeOpen-=e/this.closeTime:(this._eyeOpen=0,this.mode="open"),this._updateBlinkers();break;case"open":this._eyeOpen<1?this._eyeOpen+=e/this.openTime:(this._eyeOpen=1,this.mode="ready"),this._updateBlinkers();break;case"ready":this._blinkCounter+=e,this._blinkCounter>=this.continuity&&(Math.floor(Math.random()*this.randomness)===0&&(this.mode="closing"),this._blinkCounter=0);break}},1e3/30)}_updateBlinkers(){this.vrmBlinkers.forEach(e=>{e.expressionManager.setValue(ci.Blink,1-this._eyeOpen),e.expressionManager.update()})}}var Nn;(function(n){n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.LINEAR=9729]="LINEAR",n[n.REPEAT=10497]="REPEAT"})(Nn||(Nn={}));const sU="blend_",Fk="vrmColliderSphere";function Ehe(n){return{title:n.name,version:"v0",author:n.authors[0]||"",contactInformation:n.contactInformation,allowedUserName:n.allowedUserName,violentUssageName:n.allowExcessivelyViolentUsage?"Allow":"Disallow",sexualUssageName:n.allowExcessivelySexualUsage?"Allow":"Disallow",commercialUssageName:"Disallow"}}function Uhe(n){const e=[];for(const t in n.humanBones)e.push({bone:t,node:n.humanBones[t].node});return{humanBones:e}}function She(n){switch(n){case"happy":return"joy";case"sad":return"sorrow";case"relaxed":return"fun";case"aa":return"a";case"ih":return"i";case"ou":return"u";case"ee":return"e";case"oh":return"o";default:return n}}function _he(n){if(n.includes("Thumb")){if(n.includes("Metacarpal"))return n.replace("Metacarpal","Proximal");if(n.includes("Proximal"))return n.replace("Proximal","Intermediate")}return n}class Qhe{parse(e,t,r,i,s,o,a){var Xe;const l=Ehe(e.meta),A=Uhe(e.humanoid),c=e.materials,u=[],f={generator:"UniGLTF-2.0.0",version:"2.0"};if(t)if(A)if(l){if(!c)throw new Error("materials is undefined or null")}else throw new Error("meta is undefined or null");else throw new Error("humanoid is undefined or null");else throw new Error("avatar is undefined or null");const d=c.filter((G,J,se)=>se.findIndex(fe=>fe.name===G.name.replace(" (Outline)",""))===J).map(G=>G),h=d.map(G=>G.name),p=r?{name:"icon",imageBitmap:r.image}:null,m=d.filter(G=>G.map).map(G=>{if(!G.map)throw new Error(G.name+" map is null");return{name:G.name,imageBitmap:G.map.image}}),g=d.filter(G=>G.userData.shadeTexture).map(G=>{if(!G.userData.shadeTexture)throw new Error(G.userData.shadeTexture+" map is null");return{name:G.name+"_shade",imageBitmap:G.userData.shadeTexture.image}}),v=d.filter(G=>G.roughnessMap).map(G=>G.roughnessMap?{name:G.name+"_orm",imageBitmap:G.roughnessMap.image}:null),y=d.filter(G=>G.roughnessMap).map(G=>G.normalMap?{name:G.name+"_normal",imageBitmap:G.normalMap.image}:null),w=[...m,...g,...v,...y].filter(G=>G!==null),C=Dhe(w,p),b=khe(C),E=Vhe(C),x=Nhe(d,w),S=t.children.filter(G=>G.children.length>0&&G.children[0].type===fi.Bone)[0],M=PH(S).filter(G=>G.name!==Fk),Z=M.map(G=>G.name),K=M.map(G=>({children:G.children.filter(J=>J.name!==Fk).map(J=>Z.indexOf(J.name)),name:G.name,rotation:[G.quaternion.x,G.quaternion.y,G.quaternion.z,G.quaternion.w],scale:[G.scale.x,G.scale.y,G.scale.z],translation:[G.position.x,G.position.y,G.position.z]})),_=[],B=t.children.filter(G=>G.type===fi.Group||G.type===fi.SkinnedMesh),F=[];B.forEach(G=>{const J=G.type===fi.Group?G.children[0]:G,se=J.geometry.attributes,fe=new aA(se.position,Nn.FLOAT,Lt.POSITION,ra.VEC3,J.name,void 0);F.push(fe);const ve=F.length-1,W=new aA(se.normal,Nn.FLOAT,Lt.NORMAL,ra.VEC3,J.name,void 0);F.push(W),F.push(new aA(se.uv,Nn.FLOAT,Lt.UV,ra.VEC2,J.name,void 0)),F.push(new aA(se.skinWeight,Nn.FLOAT,Lt.SKIN_WEIGHT,ra.VEC4,J.name,void 0)),F.push(new aA(se.skinIndex,Nn.UNSIGNED_SHORT,Lt.SKIN_INDEX,ra.VEC4,J.name,void 0)),(G.type===fi.Group?G.children.map(D=>D):[G]).forEach(D=>{if(!D.geometry.index)throw new Error(D.name+" geometry.index is null");F.push(new aA(D.geometry.index,Nn.UNSIGNED_INT,Lt.INDEX,ra.SCALAR,J.name,D.name))}),J.morphTargetDictionary||(J.morphTargetDictionary={},J.morphTargetInfluences=[],J.geometry.morphAttributes={},J.updateMorphTargets()),J.geometry.userData.targetNames=[],console.warn("taking only mesh 0 for morph targets now, take the correct mesh");for(const D in e.expressionManager.expressionMap){const $=e.expressionManager.expressionMap[D],ee=$._binds.map(te=>({mesh:0,index:te.index,weight:te.weight*100}));if(ee.length>0){let te=!1;for(const we in ci)if(D===ci[we]&&D!=="surprised"){u.push({name:D,presetName:She(D),binds:ee,isBinary:$.isBinary}),te=!0;break}te===!1&&u.push({name:D,presetName:"unknown",binds:ee,isBinary:$.isBinary})}}const I=(D,$,ee,te)=>{const we=[],Ce=[];for(let Ee=0;Ee0){const Ve=we.length%4,_e=Ve===0?0:4-Ve;if(_e>0)for(let ye=0;ye<_e;ye++)we.push(0),Ce.push(0,0,0);const re={targetMeshDataIndex:ve,count:we.length,indices:new Uint32Array(we),values:new Float32Array(Ce)};F.push(new aA(te,Nn.FLOAT,ee,ra.VEC3,J.name,sU+$,re))}};for(const D in J.morphTargetDictionary){J.geometry.userData.targetNames.push(D);const $=J.morphTargetDictionary[D],ee=J.geometry.morphAttributes;I(ee.position[$].array,D,Lt.BLEND_POSITION,se.position),ee.normal&&I(ee.normal[$].array,D,Lt.BLEND_NORMAL,se.normal)}}),B.forEach(G=>{const J=G.type===fi.Group?G.children[0]:G,se=new Float32Array(J.skeleton.boneInverses.map(fe=>fe.elements).flat());F.push(new aA(new At(se,16),Nn.FLOAT,Lt.BIND_MATRIX,ra.MAT4,J.name,J.name))}),_.push(...F.map(G=>({byteOffset:0,componentType:G.valueType,count:G.attribute.count,max:G.max,min:G.min,normalized:!1,type:G.accessorsType})));const R=Mhe(B,F,h);B.forEach((G,J)=>{K.push({mesh:J,name:G.name,rotation:[G.quaternion.x,G.quaternion.y,G.quaternion.z,G.quaternion.w],scale:[G.scale.x,G.scale.y,G.scale.z],skin:J,translation:[G.position.x,G.position.y,G.position.z]})});const k=The(B,F,Z),T={humanBones:[]};A.humanBones.forEach(G=>{Z.indexOf(G.node.name)!=-1&&T.humanBones.push({bone:_he(G.bone),node:Z.indexOf(G.node.name),useDefaultValues:!0})});const V={floatProperties:{_DstBlend:.5,_ShadeShift:.5,_ShadeToony:.5,_ShadingGradeRate:.5},keywordMap:{_NORMALMAP:!1,MTOON_OUTLINE_COLOR_FIXED:!0,MTOON_OUTLINE_WIDTH_WORLD:!0},name:"VRMCombinedMat",renderQueue:2e3,shader:"VRM/MToon",tagMap:{RenderType:"Opaque"},textureProperties:{_MainTex:0,_ShadeTexture:0},vectorProperties:{_Color:[1,1,1,1],_EmissionColor:[0,0,0,1],_EmissionMap:[0,0,1,1],_MainTex:[0,0,1,1],_OutlineColor:[0,0,0,1],_OutlineWidthTexture:[0,0,1,1],_ReceiveShadowTexture:[0,0,1,1],_RimColor:[0,0,0,1],_RimTexture:[0,0,1,1],_ShadeColor:[.9,.9,.9,1]}},O={name:"STDCombinedMat",shader:"VRM_USE_GLTFSHADER"},L=[];d.forEach(G=>{G.type=="ShaderMaterial"?L.push(L.push(Object.assign({},V))):L.push(L.push(Object.assign({},O)))});const U=l;i.forEach(G=>{for(let J=0;JG.isSkinnedMesh))==null?void 0:Xe.skeleton)||null;for(let G=0;G{const ve=fe.sphere;se.colliders.push({radius:ve.radius*o,offset:{x:ve.offset[0]*o,y:ve.offset[1]*o,z:ve.offset[2]*o}})}),H.push(se)}}console.log("COLLIDER GROUPS",H);const N=G=>{for(let J=0;J{const J=N(G);if(J==-1)return[-1];{const se=[];return M[J].traverse(ve=>{ve.isBone&&se.push(N(ve.name))}),se}},oe=[];i.forEach(G=>{var W;const J=j(G.name),se=[];if(G.colliderGroups.forEach(Q=>{const I=Q.colliders[0];if(I!=null){const D=I.parent,$=H.findIndex(ee=>ee.name===D.name);$!=-1?se.push($):console.warn("No collider group for bone name: ",D.name+" was found")}else console.log("No colliders definition were present in vrm file file for: ",G.name+" spring bones")}),J===[-1]){console.warn("No bone found for spring bone "+G.name);return}let fe=N((W=G.center)==null?void 0:W.name);fe==-1&&console.warn("no center bone for spring bone "+G.name);const ve=G.settings;oe.push({bones:J,center:fe,colliderGroups:se,dragForce:ve.dragForce,gravityDir:{x:ve.gravityDir.x,y:ve.gravityDir.y,z:ve.gravityDir.z},gravityPower:ve.gravityPower,hitRadius:ve.hitRadius,stiffiness:ve.stiffness})});const ie={boneGroups:oe,colliderGroups:H};console.log(ie),U.texture=p?C.length-1:void 0;const de=[];de.push(...w.map(G=>({buffer:Ek(G.imageBitmap),type:Lt.IMAGE}))),F.forEach((G,J)=>{G.buffer?de.push({buffer:G.buffer,typeString:"",type:G.type}):G.sparse&&(de.push({buffer:G.sparse.indices,typeString:"indices",type:G.type,count:G.sparse.count}),de.push({buffer:G.sparse.values,typeString:"values",type:G.type}))}),p&&de.push({buffer:Ek(p.imageBitmap),type:Lt.IMAGE});let X=0,ne=0,ae=0,Be=0;const pe=de.map(G=>{const J={buffer:0,byteLength:G.buffer.byteLength,byteOffset:X,target:G.type===Lt.IMAGE||G.type===Lt.BIND_MATRIX?void 0:G.type===Lt.INDEX?Nn.ELEMENT_ARRAY_BUFFER:Nn.ARRAY_BUFFER};return X+=G.buffer.byteLength,G.type===Lt.IMAGE?(C[ne++].bufferView=Be,Be++):F[ae].sparse?(_[ae].sparse==null&&(_[ae].sparse={}),G.typeString==="indices"&&(_[ae].sparse.count=G.count,_[ae].sparse[G.typeString]={bufferView:Be,byteOffset:0,componentType:Nn.UNSIGNED_INT}),G.typeString==="values"&&(_[ae].sparse[G.typeString]={bufferView:Be,byteOffset:0}),G.typeString==="values"&&ae++,Be++):(F[ae].bufferIndex=Be,_[ae].bufferView=Be,ae++,Be++),J}),Fe=Lhe(t,K);Rhe(U);const rt={accessors:_,asset:f,buffers:[{byteLength:X}],bufferViews:pe,extensions:{VRM:{blendShapeMaster:{blendShapeGroups:u},firstPerson:{firstPersonBone:44,firstPersonBoneOffset:new z,lookAtHorizontalInner:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtHorizontalOuter:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtTypeName:"Bone",lookAtVerticalDown:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtVerticalUp:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10}},materialProperties:L,humanoid:T,meta:U,secondaryAnimation:ie,specVersion:"0.0"}},extensionsUsed:["KHR_materials_unlit","KHR_texture_transform","VRM"],images:C,materials:x,meshes:R,nodes:K,samplers:b,scenes:Fe,skins:k,textures:E};console.log(rt);const Oe=new Uk(aU(JSON.stringify(rt,void 0,2)),"JSON"),ke=new Uk(xg(de.map(G=>G.buffer)),"BIN\0"),Qe=xg([Oe.buffer,ke.buffer]),Ge=xg([aU("glTF"),oU(2,4),oU(Qe.byteLength+12,4)]);a(xg([Ge,Qe]))}}function Rhe(n){n.title=n.title||"Character",n.version=n.version||"1",n.author=n.author||"Anon",n.contactInformation=n.contactInformation||"",n.reference=n.reference||"",n.allowedUserName=n.allowedUserName||"Everyone",n.violentUssageName=n.violentUssageName||"Disallow",n.sexualUssageName=n.sexualUssageName||"Disallow",n.commercialUssageName=n.commercialUssageName||"Disallow",n.otherPermissionUrl=n.otherPermissionUrl||"",n.licenseName=n.licenseName||"Redistribution_Prohibited",n.otherLicenseUrl=n.otherLicenseUrl||""}function PH(n){return n.children.length<=0?[n]:[n].concat(n.children.map(e=>PH(e)).flat())}function Ek(n){const e=document.createElement("canvas");e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0);const t=e.toDataURL("image/png"),r=atob(t.split(",")[1]),i=(4-r.length%4)%4,s=new ArrayBuffer(r.length+i),o=new DataView(s);for(let a=0;a4?A=r[a*n.itemSize+l]:l===0?A=n.getX(a):l===1?A=n.getY(a):l===2?A=n.getZ(a):A=n.getW(a),e===Nn.UNSIGNED_SHORT?o.setUint16(i,A,!0):e===Nn.UNSIGNED_INT?o.setUint32(i,A,!0):o.setFloat32(i,A,!0),i+=t}return s}class Uk{constructor(e,t){this.data=e,this.type=t;const r=this.data;this.buffer=xg([oU(r.byteLength,4),aU(this.type),r])}paddingBinary(e,t){const r=Math.ceil(e.byteLength/4)*4;if(e.byteLength===r)return e;const i=new Uint8Array(r);i.set(new Uint8Array(e),0);for(let s=e.byteLength;sp%3===0)),Math.max.apply(null,Array.from(A).filter((h,p)=>p%3===1)),Math.max.apply(null,Array.from(A).filter((h,p)=>p%3===2))]:void 0,this.min=r===Lt.POSITION||r===Lt.BLEND_POSITION?[Math.min.apply(null,Array.from(A).filter((h,p)=>p%3===0)),Math.min.apply(null,Array.from(A).filter((h,p)=>p%3===1)),Math.min.apply(null,Array.from(A).filter((h,p)=>p%3===2))]:void 0}else this.buffer=p1(this.attribute,this.valueType),this.max=r===Lt.POSITION||r===Lt.BLEND_POSITION?[Math.max.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===0)),Math.max.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===1)),Math.max.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===2))]:void 0,this.min=r===Lt.POSITION||r===Lt.BLEND_POSITION?[Math.min.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===0)),Math.min.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===1)),Math.min.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===2))]:void 0}}var Fd;(function(n){n.MeshBasicMaterial="MeshBasicMaterial",n.MeshStandardMaterial="MeshStandardMaterial",n.MToonMaterial="MToonMaterial"})(Fd||(Fd={}));var ra;(function(n){n.SCALAR="SCALAR",n.VEC2="VEC2",n.VEC3="VEC3",n.VEC4="VEC4",n.MAT4="MAT4"})(ra||(ra={}));var Lt;(function(n){n.POSITION="POSITION",n.NORMAL="NORMAL",n.UV="UV",n.INDEX="INDEX",n.SKIN_WEIGHT="SKIN_WEIGHT",n.SKIN_INDEX="SKIN_INDEX",n.BLEND_POSITION="BLEND_POSITION",n.BLEND_NORMAL="BLEND_NORMAL",n.BIND_MATRIX="BIND_MATRIX",n.IMAGE="IMAGE"})(Lt||(Lt={}));var fi;(function(n){n.Group="Group",n.SkinnedMesh="SkinnedMesh",n.Object3D="Object3D",n.Bone="Bone"})(fi||(fi={}));const Mhe=(n,e,t)=>n.map(r=>{const i=r.type===fi.Group?r.children[0]:r,s=r.type===fi.Group?r.children.map(o=>o):[r];return{name:r.name,primitives:s.map(o=>{const a=e.map(A=>A.meshName===i.name?A.type:null),l=Array.isArray(o.material)?o.material[0].name:o.material.name;return{attributes:{JOINTS_0:a.indexOf(Lt.SKIN_INDEX),NORMAL:a.indexOf(Lt.NORMAL),POSITION:a.indexOf(Lt.POSITION),TEXCOORD_0:a.indexOf(Lt.UV),WEIGHTS_0:a.indexOf(Lt.SKIN_WEIGHT)},extras:{targetNames:o.geometry.userData.targetNames},indices:e.map(A=>A.type===Lt.INDEX&&A.meshName===i.name?A.name:null).indexOf(o.name),material:t.indexOf(l),mode:4,targets:i.geometry.userData.targetNames?i.geometry.userData.targetNames.map(A=>{const c=e.map(d=>d.type===Lt.BLEND_NORMAL&&d.meshName===i.name?d.name:null).indexOf(sU+A),u=e.map(d=>d.type===Lt.BLEND_POSITION&&d.meshName===i.name?d.name:null).indexOf(sU+A),f={};return u!==-1&&(f.POSITION=u),c!==-1&&(f.NORMAL=c),f}):void 0}})}}),The=(n,e,t)=>n.map(r=>{const i=r.type===fi.Group?r.children[0]:r;return{inverseBindMatrices:e.map(s=>s.type===Lt.BIND_MATRIX?s.meshName:null).indexOf(i.name),joints:i.skeleton.bones.map(s=>t.indexOf(s.name)).filter(s=>s!==-1),skeleton:t.indexOf(i.skeleton.bones[0].name)}}),Nhe=(n,e)=>n.map(t=>{let r,i=null;if(t=t.userData.vrmMaterial?t.userData.vrmMaterial:t,t.type==="ShaderMaterial")i={},i.shadeMultiplyTexture={index:e.map(h=>h.name).indexOf(t.uniforms.shadeMultiplyTexture.name)},r=t.color?[1,1,1,1]:void 0;else{const d=t;r=d.color?[d.color.r,d.color.g,d.color.b,1]:void 0}let s=-1;t.map?s=e.map(d=>d.name).indexOf(t.name):t.uniforms&&t.uniforms.map&&(s=e.map(d=>d.name).indexOf(t.uniforms.map.name));let o=-1;t.roughnessMap&&(o=e.map(d=>d.name).indexOf(t.name+"_orm"));let a=-1;t.normalMap&&(a=e.map(d=>d.name).indexOf(t.name+"_normal"));const l=s>=0?{extensions:{KHR_texture_transform:{offset:[0,0],scale:[1,1]}},index:s,texCoord:0}:void 0,A={baseColorFactor:r,baseColorTexture:l},c=o>=0?{index:o,texCoord:0}:void 0,u=a>=0?{index:a,texCoord:0}:void 0;if(c)A.metallicRoughnessTexture=c;else{const d=(()=>{switch(t.type){case Fd.MeshStandardMaterial:return t.metalness;case Fd.MeshBasicMaterial:return 0;default:return 0}})(),h=(()=>{switch(t.type){case Fd.MeshStandardMaterial:return t.roughness;case Fd.MeshBasicMaterial:return .9;default:return .9}})();A.metallicFactor=d,A.roughnessFactor=h}const f={alphaCutoff:t.alphaTest>0?t.alphaTest:void 0,alphaMode:t.transparent?"BLEND":t.alphaTest>0?"MASK":"OPAQUE",doubleSided:t.side===2,extensions:t.type==="ShaderMaterial"?{KHR_materials_unlit:{},VRMC_materials_mtoon:i}:void 0,name:t.name,pbrMetallicRoughness:A};return u&&(f.normalTexture=u),f}),Dhe=(n,e)=>(e?n.concat(e):n).filter(t=>t&&t.imageBitmap).map(t=>({bufferView:-1,mimeType:"image/png",name:t.name})),khe=n=>n.map(()=>({magFilter:Nn.LINEAR,minFilter:Nn.LINEAR,wrapS:Nn.REPEAT,wrapT:Nn.REPEAT})),Vhe=n=>n.map((e,t)=>({sampler:0,source:t})),Lhe=(n,e)=>{const t=e.map(r=>r.name);return[{nodes:n.children.filter(r=>r.type===fi.Object3D||r.type===fi.SkinnedMesh||r.type===fi.Group||r.type===fi.Bone).map(r=>t.indexOf(r.name))}]};function WH(){return(WH=Object.assign||function(n){for(var e=1;e0?u+s.byteLength:0;f%8&&(f+=8-f%8);let d=[],h=new DataView(new ArrayBuffer(24*n.levels.length)),p=(f||u+s.byteLength)+t.byteLength;for(let v=0;v0?f:0),!0),g.setBigUint64(60,BigInt(t.byteLength),!0),new Uint8Array(Hp([new Uint8Array(_r).buffer,m,h.buffer,a,s,new ArrayBuffer(f>0?f-(u+s.byteLength):0),t,...d]))}var AU,cU,Hhe={enableDebug:!1,isUASTC:!0,isKTX2File:!0,isInputSRGB:!0,generateMipmap:!0,needSupercompression:!0,isSetKTX2SRGBTransferFunc:!0},uU=new OffscreenCanvas(128,128),Rk=uU.getContext("2d",{willReadFrequently:!0}),OH=typeof document>"u";function zhe(n){return createImageBitmap(n).then(function(e){return uU.width=e.width,uU.height=e.height,Rk.drawImage(e,0,0),Rk.getImageData(0,0,e.width,e.height)})}function GH(n,e){return e===void 0&&(e={}),Xhe().then(function(t){var r=new t.BasisEncoder;return Yhe(e,r),r.setTexType(AU.cBASISTexType2D),Whe(n,ArrayBuffer)&&(n=new Blob([n])),zhe(n).then(function(i){r.setSliceSourceImage(0,new Uint8Array(i.data),i.width,i.height,cU.RAW);var s=new Uint8Array(10485760),o=r.encode(s);if(o===0)throw"encode failed";var a=new Uint8Array(s.buffer,0,o),l=Ghe(s);if(e.kvData){for(var A in e.kvData)l.keyValue[A]=e.kvData[A];a=Jhe(l,{keepWriter:!0})}return a})})}function Yhe(n,e){n===void 0&&(n={}),(n=Phe({},Hhe,n)).enableDebug!==void 0&&e.setDebug(n.enableDebug),n.isUASTC!==void 0&&e.setUASTC(n.isUASTC),n.isKTX2File!==void 0&&e.setCreateKTX2File(n.isKTX2File),n.isSetKTX2SRGBTransferFunc!==void 0&&e.setKTX2SRGBTransferFunc(n.isSetKTX2SRGBTransferFunc),n.generateMipmap!==void 0&&e.setMipGen(n.generateMipmap),n.isYFlip!==void 0&&e.setYFlip(n.isYFlip),n.qualityLevel!==void 0&&e.setQualityLevel(n.qualityLevel),n.compressionLevel!==void 0&&e.setCompressionLevel(n.compressionLevel),n.needSupercompression!==void 0&&e.setKTX2UASTCSupercompression(n.needSupercompression),n.isNormalMap!==void 0&&e.setNormalMap(n.isNormalMap)}var g1=null;function Xhe(){return g1||(g1=new Promise(function(n,e){OH?(importScripts("https://mdn.alipayobjects.com/rms/afts/file/A*SrRkQarYYl4AAAAAAAAAAAAAARQnAQ/basis_encoder.js"),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qFWbTrA0hZYAAAAAAAAAAAAAARQnAQ/basis_encoder.wasm").then(function(t){return t.arrayBuffer()}).then(function(t){BASIS({wasmBinary:t}).then(function(r){r.initializeBasis(),n(r)}).catch(e)}).catch(e)):Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*SrRkQarYYl4AAAAAAAAAAAAAARQnAQ/basis_encoder.js").then(function(t){return t.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qFWbTrA0hZYAAAAAAAAAAAAAARQnAQ/basis_encoder.wasm").then(function(t){return t.arrayBuffer()})]).then(function(t){var r=t[0],i=t[1],s=document.createElement("script");s.onload=function(){BASIS({wasmBinary:i}).then(function(o){o.initializeBasis(),n(o)}).catch(e)},s.src=URL.createObjectURL(new Blob([r])),s.onerror=e,document.body.appendChild(s)}).catch(e)})),g1}OH&&self.addEventListener("message",function(n){GH(n.data).then(function(e){self.postMessage(e)}).catch(function(e){self.postMessage({error:e})})});function ZH(n){const e=n.clone(),t=[];return n.traverse(r=>{r.userData.origIndexBuffer&&t.push(r.userData.origIndexBuffer)}),e.traverse(r=>{r.userData.origIndexBuffer&&(r.userData.origIndexBuffer=t.shift())}),e}function Khe(n){const e=ZH(n);let t;const r=[];e.traverse(s=>{if(!t&&s.isSkinnedMesh&&(t=_H(s)),s.isSkinnedMesh){if(s.geometry=s.geometry.clone(),s.skeleton=t,r.push(s),Array.isArray(s.material)){const o=s.material;s.material=new mu,s.material.map=o[0].map}s.userData.origIndexBuffer&&s.geometry.setIndex(s.userData.origIndexBuffer)}});const i=new Tr;return r.forEach(s=>{i.add(s)}),i.add(t.bones[0]),i}async function jhe(n,e,t){const r=await q_(n,t),i=await JH(r,e,t);return new Blob([i],{type:"model/gltf-binary"})}function $he(n,e,t,r){return new Promise(async(i,s)=>{const o=`${t&&t!==""?t:"AvatarCreatorModel"}`;qhe(n,e,r).then(a=>{zH(a,`${o}.vrm`),i()})})}async function qhe(n,e,t){const r=await q_(n,t);return JH(r,e,t)}function q_(n,e){const t=ZH(n),{createTextureAtlas:r=!0}=e;return r?Yde(t,e):(console.log("no atlas"),Jde(t,e))}async function epe(n,e="",t){const r=`${e&&e!==""?e:"AvatarCreatorModel"}`,{optimized:i=!0}=t,s=i?await q_(n,t):Khe(n);tpe(s).then(o=>{if(o instanceof ArrayBuffer)zH(o,`${r}.glb`);else{const a=JSON.stringify(o,null,2);rpe(a,`${r}.gltf`)}})}function tpe(n){return new Promise(e=>new V_().parse(n,r=>{e(r)},r=>{console.error("Error parsing",r)},{trs:!1,onlyVisible:!1,truncateDrawRange:!0,binary:!0,forcePowerOfTwoTextures:!1,maxTextureSize:1024}))}function npe(n){var r,i;const e=[];for(const s in n)if(((i=(r=n[s])==null?void 0:r.vrm)==null?void 0:i.springBoneManager)!=null){const o=n[s].vrm.springBoneManager.joints;for(const a of o)e.some(A=>A.name===a.bone.name)||e.push({name:a.bone.name,settings:a.settings,bone:a.bone,colliderGroups:a.colliderGroups,center:a.center})}const t=[];return e.forEach(s=>{for(const o in Lm)if(s.bone.parent.name==Lm[o]){t.push(s);break}}),t}function JH(n,e,t){const{screenshot:r=null,isVrm0:i=!1,vrmMeta:s=null,scale:o=1}=t;return new Promise(async a=>{const l=i?new Qhe:new Pfe,A={...spe(e),...Ahe(n,"CharacterCreator",s)};if(t.ktxCompression){console.log("ktx compression");for(let h=0;hw.toBlob(M)),E=await GH(b),x=new Blob(E,{type:"image/ktx2"}),S=await createImageBitmap(x);A.materials[h].map.source=S}}}}let c;n.traverse(h=>{h.isSkinnedMesh&&(c=h)}),(()=>{for(let h=0;h{h.updateMatrix(),h.updateMatrixWorld()}),c.skeleton.calculateInverses(),c.skeleton.computeBoneTexture(),c.skeleton.update()})(),c.skeleton.bones.filter(h=>h.name==="head")[0];const f=npe(e),d=[];l.parse(A,n,r,f,d,o,h=>{a(h)})})}function HH(n,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),t.href=URL.createObjectURL(n),t.download=e,t.click()}function rpe(n,e){HH(new Blob([n],{type:"text/plain"}),e)}function zH(n,e){HH(ipe(n),e)}function ipe(n){return new Blob([n],{type:"application/octet-stream"})}function spe(n){for(const e in n)if(n[e].vrm)return n[e].vrm}const ope=n=>{var e,t;(e=n.parser.json.extensions)!=null&&e.VRM?ape(n):(t=n.parser.json.extensions)!=null&&t.VRMC_vrm?lpe(n):console.warn("No valid vrm file was provided")},ape=n=>{var a,l,A;const e=n.parser.json,t=n.scene,r=e.nodes,i=(A=(l=(a=e.extensions)==null?void 0:a.VRM)==null?void 0:l.secondaryAnimation)==null?void 0:A.colliderGroups,s=[],o=r.map(c=>YH(c.name,s));i!=null&&i.forEach(c=>{const u=o[c.node],f=DH(t,u);if(f!=null){const d=c.colliders;f.userData.VRMcolliders=d.map(h=>({sphere:{radius:h.radius,offset:[h.offset.x,h.offset.y,h.offset.z]}}))}})},lpe=n=>{var l,A,c,u;const e=n.parser.json,t=n.scene,r=e.nodes,i=(A=(l=e.extensions)==null?void 0:l.VRMC_springBone)==null?void 0:A.colliderGroups,s=(u=(c=e.extensions)==null?void 0:c.VRMC_springBone)==null?void 0:u.colliders,o=[],a=r.map(f=>YH(f.name,o));i!=null&&i.forEach(f=>{const d=Yt(f.colliders);let h=-1,p=null;d.forEach(m=>{if(h!=s[m].node){h=s[m].node;const g=a[h];p=DH(t,g),p.userData.VRMcolliders=[]}if(p!=null){const g=s[m].shape;for(const v in g){const y=g[v];y!=null&&y.offset&&(y.offset[0]=-y.offset[0])}p.userData.VRMcolliders.push(g)}else console.error("no node with name "+a[h]+" was found")})})},YH=(n,e)=>{const t=Bt.sanitizeNodeName(n||"");return t in e?t+"_"+ ++e[t]:(e[t]=0,t)},Hw=[0,400,560,2400,4800],zw=[0,500,700,3e3,6e3],fU=[],il=[],eQ=1024,XH=44100;for(let n=0;n{requestAnimationFrame(t),this.update(r,i)};t()}start(e){this.audioContext=new AudioContext,this.mediaStreamSource=this.audioContext.createMediaStreamSource(e),this.meter=Yw.createAudioMeter(this.audioContext),this.mediaStreamSource.connect(this.meter)}startFromAudioFile(e){this.audioContext||(this.audioContext=new AudioContext),this.userSpeechAnalyzer||(this.userSpeechAnalyzer=this.audioContext.createAnalyser()),this.userSpeechAnalyzer.smoothingTimeConstant=.5,this.userSpeechAnalyzer.fftSize=eQ,this.mediaStreamSource&&this.mediaStreamSource.stop(),this.audioContext.decodeAudioData(e).then(t=>{this.mediaStreamSource=this.audioContext.createBufferSource(),this.mediaStreamSource.buffer=t,this.meter=Yw.createAudioMeter(this.audioContext),this.mediaStreamSource.connect(this.meter),this.mediaStreamSource.connect(this.audioContext.destination),this.mediaStreamSource.start(),this.mediaStreamSource.connect(this.userSpeechAnalyzer)})}destroy(){var e,t,r;return(e=this.meter)==null||e.shutdown(),this.meter=null,(t=this.mediaStreamSource)==null||t.disconnect(),((r=this.audioContext)==null?void 0:r.close().catch(()=>{}))||Promise.resolve()}update(e){if(this.meter){const{volume:t}=this.meter;if(t<.01)this.vrm.expressionManager.setValue(ci.Oh,0),this.vrm.expressionManager.setValue(ci.Ah,0),this.vrm.expressionManager.setValue(ci.Ee,0);else{const{ah:r,oh:i,ee:s}=this.update2();this.vrm.expressionManager.setValue(ci.Oh,i),this.vrm.expressionManager.setValue(ci.Ah,r),this.vrm.expressionManager.setValue(ci.Ee,s),this.vrm.expressionManager.update(e)}}}update2(){function e(A){const u=new Float32Array(A.length);for(let f=0;f0&&(i[A]+=r[c]);i[A]/=il[A+1]-il[A]}for(let A=0;A0&&(s[A]+=r[c]);i[A]/=il[A+1]-il[A],s[A]=s[A]/(fU[A+1]-fU[A])}const o=Math.max(s[1],i[1])>.2?1-2*Math.max(i[2],s[2]):(1-2*Math.max(i[2],s[2]))*5*Math.max(i[1],s[1]),a=3*Math.max(i[3],s[3]),l=.8*(Math.max(i[1],s[1])-Math.max(i[3],s[3]));return{oh:o,ee:l,ah:a}}static createAudioMeter(e){const t=e.createScriptProcessor(512);return t.onaudioprocess=r=>{const i=r.inputBuffer.getChannelData(0),s=i.length;let o=0,a;for(let A=0;A=t.clipLevel&&(t.clipping=!0,t.lastClip=window.performance.now()),o+=a*a;const l=Math.sqrt(o/s);t.volume=Math.max(l,t.volume*t.averaging)},t.clipping=!1,t.lastClip=0,t.volume=0,t.clipLevel=.98,t.averaging=.95,t.clipLag=750,t.connect(e.destination),t.checkClipping=()=>t.clipping?(t.lastClip+t.clipLag{t.disconnect(),t.onaudioprocess=null},t}}const m1=new z;class Ape{constructor(e,t,r){this.bonesInfo=[],this.curMousePos=new We,this.hotzoneSection=s(),this.enabled=!1,this.userActivated=!1,this.lookInterest=1,this.hasInterest=!0,this.interestSpeed=.3,this.onCanvas=!0,this.camera=r,this.maxLookPercent={neck:{maxy:15,miny:10,maxx:30,minx:10},spine:{maxy:0,miny:0,maxx:30,minx:10},left:{maxy:15,miny:20,maxx:35,minx:35},right:{maxy:15,miny:20,maxx:35,minx:35}},window.addEventListener("mousemove",o=>{this.curMousePos={x:o.clientX,y:o.clientY}});const i=document.getElementById(t);i&&(i.addEventListener("mouseleave",()=>{this.onCanvas=!1}),i.addEventListener("mouseenter",()=>{this.onCanvas=!0})),window.addEventListener("resize",()=>{this.hotzoneSection=s()});function s(){const o=window.innerWidth*e/100,a=(window.innerWidth-o)/2;return{xStart:a,xEnd:window.innerWidth-a,yStart:50,yEnd:window.innerHeight-80}}}setActive(e){console.log("is activating"),this.userActivated=e}setCamera(e){this.camera=e}addVRM(e){const t=e.data.isVRM0||!1,r=e.humanoid.humanBones;t||(r.neck.node.userData.inverseLookAt=!0,r.spine.node.userData.inverseLookAt=!0,r.leftEye&&(r.leftEye.node.userData.inverseLookAt=!0),r.rightEye&&(r.rightEye.node.userData.inverseLookAt=!0));const i={vrm:e,neckBone:r.neck.node,spineBone:r.spine.node,leftEyeBone:r.leftEye?r.leftEye.node:null,rightEyeBone:r.rightEye?r.rightEye.node:null};this.bonesInfo.push(i)}removeVRM(e){const t=this.bonesInfo.find(r=>r.vrm===e);if(t){const r=this.bonesInfo.indexOf(t);this.bonesInfo.splice(r,1)}}_getMouseDegrees(e,t,r){let i=0,s=0,o,a,l,A,c={x:window.innerWidth,y:window.innerHeight};return e<=c.x/2&&(o=c.x/2-e,a=o/(c.x/2)*100,i=r.maxx*a/100*-1),e>=c.x/2&&(o=e-c.x/2,a=o/(c.x/2)*100,i=r.minx*a/100),t<=c.y/2&&(l=c.y/2-t,A=l/(c.y/2)*100,s=r.maxy*.5*A/100*-1),t>=c.y/2&&(l=t-c.y/2,A=l/(c.y/2)*100,s=r.miny*A/100),{x:i,y:s}}lerp(e,t,r){return(1-r)*e+r*t}_moveJoint(e,t){const r=e.userData.inverseLookAt===!0?1:-1;if(Object.keys(e).length!==0){const i=(this.camera.position.y-1.8)*window.innerHeight/2;let s=this._getMouseDegrees(this.curMousePos.x,this.curMousePos.y-i,t);const o=.8;e.rotation.y=this.lerp(Wt.degToRad(s.x),e.rotation.y,o),e.rotation.x=this.lerp(Wt.degToRad(s.y*r),e.rotation.x,o)}}update(){m1.set(0,0,1),m1.applyQuaternion(this.camera.quaternion);const e=m1.z>0;this.curMousePos.x>this.hotzoneSection.xStart&&this.curMousePos.xthis.hotzoneSection.yStart&&this.curMousePos.y{this._moveJoint(t.neckBone,this.maxLookPercent.neck),this._moveJoint(t.spineBone,this.maxLookPercent.spine),this._moveJoint(t.leftEyeBone,this.maxLookPercent.left),this._moveJoint(t.rightEyeBone,this.maxLookPercent.right)})}}class v1{constructor(e){const{assetsLocation:t,traitsDirectory:r,thumbnailsDirectory:i,traitIconsDirectorySvg:s,animationPath:o,exportScale:a,displayScale:l,initialTraits:A,requiredTraits:c,randomTraits:u,colliderTraits:f,lipSyncTraits:d,blinkerTraits:h,typeRestrictions:p,defaultCullingLayer:m,defaultCullingDistance:g,offset:v,vrmMeta:y,traits:w,textureCollections:C,colorCollections:b,canDownload:E=!0,downloadOptions:x={}}=e;this.assetsLocation=t,this.traitsDirectory=r,this.thumbnailsDirectory=i,this.traitIconsDirectorySvg=s,this.displayScale=l||a||1,this.animationPath=Yt(o),this.requiredTraits=Yt(c),this.randomTraits=Yt(u),this.initialTraits=A||[...new Set(this.requiredTraits.concat(this.randomTraits))],this.colliderTraits=Yt(f),this.lipSyncTraits=Yt(d),this.blinkerTraits=Yt(h),this.typeRestrictions=p,this.defaultCullingLayer=m,this.defaultCullingDistance=g,this.offset=v,this.canDownload=E,this.downloadOptions=x;const S=()=>{const K=[];for(const _ in w)K.push(w[_].trait);return K};this.allTraits=S(),S(),(()=>{if(this.typeRestrictions)for(const K in this.typeRestrictions)Yt(this.typeRestrictions[K]).forEach(B=>{this.typeRestrictions[B]==null&&(this.typeRestrictions[B]=[]),this.typeRestrictions[B].indexOf(K)==-1&&this.typeRestrictions[B].push(K)})})(),(()=>{x.vrmMeta=x.vrmMeta||y,x.scale=x.scale||a||1,x.mToonAtlasSize=x.mToonAtlasSize||2048,x.mToonAtlasSizeTransp=x.mToonAtlasSizeTransp||1024,x.stdAtlasSize=x.stdAtlasSize||2048,x.stdAtlasSizeTransp=x.stdAtlasSizeTransp||1024,x.exportStdAtlas=x.exportStdAtlas||!1,x.exportMtoonAtlas=x.exportMtoonAtlas||!0,x.screenshotFaceDistance=x.screenshotFaceDistance||1,x.screenshotFaceOffset=x.screenshotFaceOffset||[0,0,0],x.screenshotResolution=x.screenshotResolution||[512,512],x.screenshotBackground=x.screenshotBackground||[.1,.1,.1],x.screenshotFOV=x.screenshotFOV||75,!x.exportStdAtlas&&!x.exportMtoonAtlas&&(x.exportMtoonAtlas=!0)})(),this.textureTraits=[],this.textureTraitsMap=null,this.createTextureTraits(C),this.colorTraits=[],this.colorTraitsMap=null,this.createColorTraits(b),this.modelTraits=[],this.modelTraitsMap=null,this.createModelTraits(w)}appendManifestData(e,t){e.textureTraits.forEach(r=>{const i=this.getTextureGroup(r.trait);i!=null?i.appendCollection(r,t):(this.textureTraits.push(r),this.textureTraitsMap.set(r.trait,r))}),e.colorTraits.forEach(r=>{const i=this.getColorGroup(r.trait);i!=null?i.appendCollection(r,t):(this.colorTraits.push(r),this.colorTraitsMap.set(r.trait,r))}),e.modelTraits.forEach(r=>{const i=this.getModelGroup(r.trait);i!=null?i.appendCollection(r,t):(this.modelTraits.push(r),this.modelTraitsMap.set(r.trait,r))}),console.log(e)}getExportOptions(){return this.downloadOptions}getGroupModelTraits(){return this.modelTraits}getInitialTraits(){return this.getRandomTraits(this.initialTraits)}getAllTraits(){return this.getRandomTraits(this.allTraits)}isColliderRequired(e){return this.colliderTraits.indexOf(e)!=-1}isLipsyncTrait(e){return this.lipSyncTraits.indexOf(e)!=-1}async getNFTraitOptionsFromURL(e,t){const r=await this._fetchJson(e);return this.getNFTraitOptionsFromObject(r,t)}getNFTraitOptionsFromObject(e,t){const r=e.attributes;if(r){t=Yt(t);const i=[];return r.forEach(s=>{if(t.indexOf(s.trait_type)==-1){const o=this.getTraitOption(s.trait_type,s.value);o&&i.push(o)}}),i}else return console.warn("No attiributes parameter was found in ",e),null}getRandomTraits(e){const t=[];return(e||this.randomTraits).forEach(i=>{const s=this.getRandomTrait(i);s&&t.push(s)}),this._filterTraitOptions(t)}getRandomTrait(e){var r,i;const t=this.getModelGroup(e);if(t){const s=t.getRandomTrait();if(s){const o=(r=s.targetTextureCollection)==null?void 0:r.getRandomTrait(),a=(i=s.targetColorCollection)==null?void 0:i.getRandomTrait();return new y1(s,o,a)}else return null}else return console.warn("No trait group with name "+e+" was found."),null}async _fetchJson(e){return await(await fetch(e)).json()}getTraitOption(e,t){var i,s;const r=this.getModelTrait(e,t);if(r){const o=(i=r.targetTextureCollection)==null?void 0:i.getRandomTrait(),a=(s=r.targetColorCollection)==null?void 0:s.getRandomTrait();return new y1(r,o,a)}return null}_filterTraitOptions(e){const t=[],r=[];for(let i=0;i0&&console.log("options were filtered to fullfill restrictions: ",r),t}getCustomTraitOption(e,t){const r=this.getCustomModelTrait(e,t);return r?new y1(r,null,null):null}getCustomModelTrait(e,t){var r;return(r=this.getModelGroup(e))==null?void 0:r.getCustomTrait(t)}getModelTrait(e,t){var r;return(r=this.getModelGroup(e))==null?void 0:r.getTrait(t)}getModelTraits(e){const t=this.getModelGroup(e);return t?t.getCollection():(console.warn("No model group with name "+e),null)}getModelGroup(e){return this.modelTraitsMap.get(e)}getTextureTrait(e,t){var r;return(r=this.getTextureGroup(e))==null?void 0:r.getTrait(t)}getTextureGroup(e){return this.textureTraitsMap.get(e)}getColorTrait(e,t){var r;return(r=this.getColorGroup(e))==null?void 0:r.getTrait(t)}getColorGroup(e){return this.colorTraitsMap.get(e)}getTraitsDirectory(){let e=(this.assetsLocation||"")+(this.traitsDirectory||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getThumbnailsDirectory(){let e=(this.assetsLocation||"")+(this.thumbnailsDirectory||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getTraitIconsDirectorySvg(){let e=(this.assetsLocation||"")+(this.traitIconsDirectorySvg||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getAssetsDirectory(){let e=this.assetsLocation||"";return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}createModelTraits(e,t=!1){t&&(this.modelTraits=[]),Yt(e).forEach(r=>{this.modelTraits.push(new cpe(this,r))}),this.modelTraitsMap=new Map(this.modelTraits.map(r=>[r.trait,r])),this.modelTraits.forEach(r=>{r.restrictedTraits.forEach(i=>{const s=this.getModelGroup(i);console.log(s),s&&s.addTraitRestriction(r.trait)})})}createTextureTraits(e,t=!1){t&&(this.textureTraits=[]),Yt(e).forEach(r=>{this.textureTraits.push(new upe(this,r))}),this.textureTraitsMap=new Map(this.textureTraits.map(r=>[r.trait,r]))}createColorTraits(e,t=!1){t&&(this.colorTraits=[]),Yt(e).forEach(r=>{this.colorTraits.push(new fpe(this,r))}),this.colorTraitsMap=new Map(this.colorTraits.map(r=>[r.trait,r]))}}class cpe{constructor(e,t){const{trait:r,name:i,iconSvg:s,cameraTarget:o={distance:3,height:1},cullingDistance:a,cullingLayer:l,collection:A,restrictedTraits:c=[],restrictedTypes:u=[]}=t;this.manifestData=e,this.isRequired=e.requiredTraits.indexOf(r)!==-1,this.trait=r,this.name=i,this.iconSvg=s,this.fullIconSvg=e.getTraitIconsDirectorySvg()+s,this.restrictedTraits=c,this.restrictedTypes=u,this.cameraTarget=o,this.cullingDistance=a,this.cullingLayer=l,this.collection=[],this.collectionMap=null,this.createCollection(A)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Model with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Model with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}addTraitRestriction(e){this.restrictedTraits.indexOf(e)==-1&&this.restrictedTraits.push(e)}createCollection(e,t=!1){t&&(this.collection=[]),Yt(e).forEach(r=>{this.collection.push(new Mk(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getCustomTrait(e){return new Mk(this,{directory:e,fullDirectory:e,id:"_custom",name:"Custom"})}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}getCollection(){return this.collection}}class upe{constructor(e,t){const{trait:r,collection:i}=t;this.manifestData=e,this.trait=r,this.collection=[],this.collectionMap=null,this.createCollection(i)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Texture with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Texture with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}createCollection(e,t=!1){t&&(this.collection=[]),Yt(e).forEach(r=>{this.collection.push(new dpe(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}}class fpe{constructor(e,t){const{trait:r,collection:i}=t;this.manifestData=e,this.trait=r,this.collection=[],this.collectionMap=null,this.createCollection(i)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Color with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Color with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}createCollection(e,t=!1){t&&(this.collection=[]),Yt(e).forEach(r=>{this.collection.push(new hpe(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}}class Mk{constructor(e,t){const{id:r,directory:i,name:s,thumbnail:o,cullingDistance:a,cullingLayer:l,type:A=[],textureCollection:c,colorCollection:u,fullDirectory:f,fullThumbnail:d}=t;if(this.manifestData=e.manifestData,this.traitGroup=e,this.id=r,this.directory=i,f)this.fullDirectory=f;else if(Array.isArray(i)){this.fullDirectory=[];for(let h=0;h0&&this.manifestData.restrictedTypes>0){haveCommonValue=(i,s)=>{if(i==null||s==null)return!1;for(let o=0;ohaveCommonValue(r[i],traitTypes))}return!1}}class dpe{constructor(e,t){const{id:r,directory:i,fullDirectory:s,name:o,thumbnail:a}=t;if(this.traitGroup=e,this.id=r,this.directory=i,s)this.fullDirectory=s;else if(Array.isArray(i)){this.fullDirectory=[];for(let l=0;l{o.isSkinnedMesh&&o.skeleton.bones.filter(l=>l.name==="head")[0].getWorldPosition(el)}),el.z+=.3,el.y+=s,this.screenshotManager.setCamera(el,i),this.screenshotManager.saveScreenshot(e,t,r),this.blinkManager.disableScreenshot()}cameraRaycastCulling(e,t,r=!0){if(this.renderCamera==null){console.warn("No camera was set in character manager. Please call setRenderCamera(camera) before calling this function");return}const i=()=>{this.characterModel.traverse(A=>{A.isMesh&&A.userData.origIndexBuffer&&(A.userData.clippedIndexGeometry=A.geometry.index.clone(),A.geometry.setIndex(A.userData.origIndexBuffer))})},s=()=>{this.characterModel.traverse(A=>{A.isMesh&&A.userData.origIndexBuffer&&A.geometry.setIndex(A.userData.clippedIndexGeometry)})},o=(A,c)=>{for(let u=0;u{var p,m;const u=A.object,f=A.face,d=[f.a,f.b,f.c],h=(m=(p=u.userData)==null?void 0:p.clippedIndexGeometry)==null?void 0:m.array;if(h!=null){const g=o(h,d),v=Array.from(h);if(g==-1&&!c){const y=[...v,...d];u.userData.clippedIndexGeometry=new At(new Uint32Array(y),1,!1)}g!=1&&c&&(v.splice(g,3),u.userData.clippedIndexGeometry=new At(new Uint32Array(v),1,!1))}};B1.x=e,B1.y=t,i(),Tk.setFromCamera(B1,this.renderCamera);const l=Tk.intersectObjects(this.characterModel.children);if(l.length>0){const A=l[0];a(A,r)}s()}removeCurrentCharacter(){const e=[];for(const t in this.avatar)e.push(new mB({traitGroupID:t,traitModel:null}));e.forEach(t=>{this._addLoadedData(t)}),this.avatar={}}removeCurrentManifest(){this.removeCurrentCharacter(),this.manifest=null,this.manifestData=null,this.animationManager&&this.animationManager.clearCurrentAnimations()}canDownload(){var e;return((e=this.manifestData)==null?void 0:e.canDownload)||!0}downloadVRM(e,t=null){return new Promise(async(r,i)=>{if(this.canDownload())try{t=t||{};const o={...this.manifestData.getExportOptions(),...t};o.isVrm0=!0,o.screenshot=this._getPortaitScreenshotTexture(!1,o),console.log(o),await $he(this.characterModel,this.avatar,e,o),r()}catch(s){console.error("Error downloading VRM:",s.message),i(new Error("Failed to download VRM."))}else{const s="Download not supported.";console.error(s),i(new Error(s))}})}downloadGLB(e,t=null){if(console.log("XXX fix glb downloader"),this.canDownload()){t=t||{};const r={...this.manifestData.getExportOptions(),...t};epe(this.characterModel,e,r)}else console.error("Download not supported")}getAvatarSelection(){var t;var e={};for(const r in this.avatar)e[r]={name:this.avatar[r].name,id:(t=this.avatar[r].traitInfo)==null?void 0:t.id};return e}getGroupTraits(){if(this.manifestData)return this.manifestData.getGroupModelTraits()}getCurrentCharacterModel(){return this.characterModel}isTraitGroupRequired(e){const t=this.manifestData.getModelGroup(e);return!!(t!=null&&t.isRequired)}getTraits(e){return this.manifestData?this.manifestData.getModelTraits(e):(console.warn("No manifest file has been loaded, please load it before trait models."),null)}getCurrentTraitID(e){var t,r;return(r=(t=this.avatar[e])==null?void 0:t.traitInfo)==null?void 0:r.id}getCurrentTraitData(e){var t;return(t=this.avatar[e])==null?void 0:t.traitInfo}getCurrentTraitVRM(e){var t;return(t=this.avatar[e])==null?void 0:t.vrm}setParentModel(e){e.add(this.rootModel),this.parentModel=e,this.screenshotManager&&this.screenshotManager.setScene(this.parentModel)}setRenderCamera(e){this.renderCamera=e}loadRandomTraits(){return new Promise(async(e,t)=>{if(this.manifestData){const r=this.manifestData.getRandomTraits();await this._loadTraits(r),e()}else{const r="No manifest was loaded, random traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadRandomTrait(e){return new Promise(async(t,r)=>{if(this.manifestData){const i=this.manifestData.getRandomTrait(e);await this._loadTraits(Yt(i)),t()}else{const i="No manifest was loaded, random traits cannot be loaded.";console.error(i),r(new Error(i))}})}loadTraitsFromNFT(e,t=!0,r=null){return new Promise(async(i,s)=>{try{if(this.manifestData){const o=this.manifestData.getNFTraitOptionsFromURL(e,r);await this._loadTraits(o,t),i()}else{const o="No manifest was loaded, NFT traits cannot be loaded.";console.error(o),s(new Error(o))}}catch(o){s(o)}})}loadTraitsFromNFTObject(e,t=!0,r=null){return new Promise(async(i,s)=>{if(this.manifestData)try{const o=this.manifestData.getNFTraitOptionsFromObject(e,r);await this._loadTraits(o,t),i()}catch(o){console.error("Error loading traits from NFT object:",o.message),s(new Error("Failed to load traits from NFT object."))}else{const o="No manifest was loaded, NFT traits cannot be loaded.";console.error(o),s(new Error(o))}})}loadInitialTraits(){return new Promise(async(e,t)=>{if(this.manifestData)await this._loadTraits(this.manifestData.getInitialTraits()),e();else{const r="No manifest was loaded, initial traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadAllTraits(){return console.log("load all"),new Promise(async(e,t)=>{if(this.manifestData)await this._loadTraits(this.manifestData.getAllTraits()),e();else{const r="No manifest was loaded, initial traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadTrait(e,t){return new Promise(async(r,i)=>{if(this.manifestData)try{const s=this.manifestData.getTraitOption(e,t);s&&(await this._loadTraits(Yt(s)),r())}catch(s){console.error("Error loading specific trait:",s.message),i(new Error("Failed to load specific trait."))}else{const s="No manifest was loaded, specific trait cannot be loaded.";console.error(s),i(new Error(s))}})}loadCustomTrait(e,t){return new Promise(async(r,i)=>{if(this.manifestData)try{const s=this.manifestData.getCustomTraitOption(e,t);s&&(await this._loadTraits(Yt(s)),r())}catch(s){console.error("Error loading custom trait:",s.message),i(new Error("Failed to load custom trait."))}else{const s="No manifest was loaded, custom trait cannot be loaded.";console.error(s),i(new Error(s))}})}loadCustomTexture(e,t){return new Promise(async(r,i)=>{var o;const s=(o=this.avatar[e])==null?void 0:o.model;if(s)await qde(s,t),r();else{const a="No Group Trait with name "+e+" was found.";console.warn(a),i(new Error(a))}})}setTraitColor(e,t){var i;const r=(i=this.avatar[e])==null?void 0:i.model;if(r)try{const s=new Re(t);r.traverse(o=>{o.isMesh&&(o.material.type==="MeshStandardMaterial"?Array.isArray(o.material)?o.material.forEach(a=>{a.color=s}):o.material.color=s:(o.material[0].uniforms.litFactor.value=s,o.material[0].uniforms.shadeColorFactor.value=new Re(s.r*.8,s.g*.8,s.b*.8)))})}catch(s){throw console.error("Error setting trait color:",s.message),new Error("Failed to set trait color.")}else{const s="No Group Trait with name "+e+" was found.";throw console.warn(s),new Error(s)}}removeTrait(e,t=!1){if(this.isTraitGroupRequired(e)&&!t){console.warn(`No trait with name: ${e} is not removable.`);return}if(this.manifestData.getModelGroup(e)){const i=new mB({traitGroupID:e,traitModel:null});this._addLoadedData(i),d1(this.avatar)}else console.warn(`No trait with name: ${e} was found.`)}updateCullHiddenMeshes(){d1(this.avatar)}loadOptimizerManifest(){this.manifest={colliderTraits:["CUSTOM"],traits:[{name:"Custom",trait:"CUSTOM",collection:[]}]},this.manifestData=new v1(this.manifest)}getCurrentOptimizerCharacterModel(){var e;return(e=this.avatar.CUSTOM)==null?void 0:e.vrm}loadOptimizerCharacter(e){return this.loadCustomTrait("CUSTOM",e)}setManifest(e){return this.removeCurrentCharacter(),new Promise(async(t,r)=>{try{if(this.manifest=e,this.manifest){if(this.manifestData=new v1(this.manifest),this.animationManager)try{await this._animationManagerSetup(this.manifest.animationPath,this.manifest.assetsLocation,this.manifestData.displayScale)}catch(i){console.error("Error loading animations: "+i)}t()}else{const i="Failed to fetch or parse the manifest.";console.error(i),r(new Error(i))}}catch(i){console.error("Error setting manifest:",i.message),r(new Error("Failed to set the manifest."))}})}appendManifest(e,t){return new Promise(async(r,i)=>{try{t?this.manifest={...this.manifest||{},manifest:e}:this.manifest={manifest:e,...this.manifest||{}};const s=new v1(e);this.manifestData.appendManifestData(s),r()}catch(s){console.error("Error setting manifest:",s.message),i(new Error("Failed to set the manifest."))}})}loadManifest(e){return new Promise(async(t,r)=>{try{const i=await this._fetchManifest(e);this.setManifest(i).then(()=>{t()})}catch(i){console.error("Error loading manifest:",i.message),r(new Error("Failed to load the manifest."))}})}loadAppendManifest(e,t){return new Promise(async(r,i)=>{try{const s=await this._fetchManifest(e);this.appendManifest(s,t).then(()=>{r()})}catch(s){console.error("Error loading manifest:",s.message),i(new Error("Failed to load the manifest."))}})}async _loadTraits(e,t=!1){await this.traitLoadManager.loadTraitOptions(Yt(e)).then(r=>{t&&this.getGroupTraits().forEach(s=>{r.some(a=>{var l;return((l=a.traitModel)==null?void 0:l.traitGroup.trait)===s.trait})||this.avatar[s.trait]!=null&&r.push(new mB({traitGroupID:s.trait,traitModel:null}))}),r.forEach(i=>{this._addLoadedData(i)}),d1(this.avatar)})}async _animationManagerSetup(e,t,r){const i=Yt(e);this.animationManager&&(this.animationManager.setScale(r),e.length>0&&(this.animationManager.storeAnimationPaths(i,t||""),await this.animationManager.loadAnimation(i,!1,0,i[0].endsWith(".fbx"),t||"")))}async _fetchManifest(e){return await(await fetch(e)).json()}_getPortaitScreenshotTexture(e,t){this.blinkManager.enableScreenshot(),this.characterModel.traverse(u=>{u.isSkinnedMesh&&u.skeleton.bones.filter(d=>d.name==="head")[0].getWorldPosition(el)});const{screenshotResolution:r,screenshotFaceDistance:i,screenshotFaceOffset:s,screenshotBackground:o,screenshotFOV:a}=t,l=r[0],A=r[1];el.x+=s[0],el.y+=s[1],el.z+=s[2],this.screenshotManager.setBackground(o),this.screenshotManager.setCamera(el,i,a);const c=e?this.screenshotManager.getScreenshotBlob(l,A):this.screenshotManager.getScreenshotTexture(l,A);return this.blinkManager.disableScreenshot(),c}_setupWireframeMaterial(e){e.origMat=e.material;const t=()=>{const o=.1+Math.random()*.9,a=.1+Math.random()*(1-.1),l=.1+Math.random()*(1-.1);return new Re(o,a,l)},r=new Qi({color:t(),wireframe:!0,wireframeLinewidth:.2}),i=e.material;e.setDebugMode=s=>{s?e.material.length?(e.material[0]=r,e.material[1]=r):e.material=r:e.material=i}}_VRMBaseSetup(e,t,r,i,s){var a,l;let o=e.userData.vrm;return e.userData.vrm==null?(console.error("No valid VRM was provided for "+r+" trait, skipping file."),null):(wk(o,{isVRM0:((a=o.meta)==null?void 0:a.metaVersion)==="0"}),this.manifestData.isColliderRequired(r)&&ope(e),lhe(o),this.manifestData.isLipsyncTrait(r)&&(this.lipSync=new Yw(o)),this._modelBaseSetup(o,t,r,i,s),((l=o.meta)==null?void 0:l.metaVersion)==="0"&&o.scene.traverse(A=>{if(A.isSkinnedMesh){Xh.rotateVRM0(o),console.log("Loaded VRM0 file ",o);for(let c=0;c{const f=e.scene.getObjectByName(u);f!=null&&f.isMesh&&o.push(f)}),e.scene.traverse(u=>{!t.meshTargets&&u.isMesh&&o.push(u),u.frustumCulled=!1,u.isMesh&&(this._setupWireframeMaterial(u),a.indexOf(u.name)===-1&&l.push(u))});const A=this.manifest,c=this.manifestData.getModelGroup(r);wk(e,{cullingLayer:t.cullingLayer!=null?t.cullingLayer:c.cullingLayer!=null?c.cullingLayer:A.defaultCullingLayer!=null?A.defaultCullingLayer:-1,cullingDistance:t.cullingDistance!=null?t.cullingDistance:c.cullingDistance!=null?c.cullingDistance:A.defaultCullingDistance!=null?A.defaultCullingDistance:null,maxCullingDistance:t.maxCullingDistance!=null?t.maxCullingDistance:c.maxCullingDistance!=null?c.maxCullingDistance:A.maxCullingDistance!=null?A.maxCullingDistance:1/0,cullingMeshes:l}),o.map((u,f)=>{if(i){const d=i[f]||i[0];d!=null&&(u.material.type==="MeshStandardMaterial"?Array.isArray(u.material)?u.material.forEach(h=>{h.map=d}):u.material.map=d:console.warn("XXX set material texture to shader material",u.material))}if(s){const d=s[f]||s[0];d!=null&&(u.material[0].uniforms.litFactor.value=d,u.material[0].uniforms.shadeColorFactor.value=new Re(d.r*.8,d.g*.8,d.b*.8))}})}_applyManagers(e){this.blinkManager.addVRM(e),this.lookAtManager&&this.lookAtManager.addVRM(e),this.animationManager&&this.animationManager.addVRM(e)}_displayModel(e){if(e){const t=e.scene;this.characterModel.attach(t)}}_positionModel(e){const t=this.manifestData.displayScale;e.scene.scale.set(t,t,t)}_disposeTrait(e){this.blinkManager.removeVRM(e),this.lookAtManager&&this.lookAtManager.removeVRM(e),this.animationManager&&this.animationManager.removeVRM(e),ohe(e)}_addLoadedData(e){const{traitGroupID:t,traitModel:r,textureTrait:i,colorTrait:s,models:o,textures:a,colors:l}=e;if(r==null){this.avatar[t]&&this.avatar[t].vrm&&(this._disposeTrait(this.avatar[t].vrm),this.avatar[t]={});return}let A=null;o.map(c=>{c!=null&&(A=this._VRMBaseSetup(c,r,t,a,l))}),A!=null&&(this.avatar[t]&&this.avatar[t].vrm&&this._disposeTrait(this.avatar[t].vrm),this._positionModel(A),this._displayModel(A),this._applyManagers(A),console.log(this.characterModel),this.avatar[t]={traitInfo:r,textureInfo:i,colorInfo:s,name:r.name,model:A&&A.scene,vrm:A})}}class gpe{constructor(){const e=new BZ;e.onProgress=(i,s,o)=>{this.setLoadPercentage(Math.round(s/o*100))};const t=new x_(e);t.crossOrigin="anonymous",t.register(i=>new Tfe(i,{autoUpdateHumanBones:!0}));const r=new Nu(e);this.loadPercentager=0,this.loadingManager=e,this.gltfLoader=t,this.textureLoader=r,this.isLoading=!1}setLoadPercentage(e){this.loadPercentager=e}loadTraitOptions(e){return new Promise(t=>{this.isLoading=!0;const r=[],i=e.map(async(s,o)=>{var c,u,f;if(s==null){r[o]=null;return}const a=await Promise.all(Yt((c=s==null?void 0:s.traitModel)==null?void 0:c.fullDirectory).map(async d=>{try{return await this.gltfLoader.loadAsync(d)}catch(h){return console.error(`Error loading modelsss ${d}:`,h),null}})),l=await Promise.all(Yt((u=s==null?void 0:s.traitTexture)==null?void 0:u.fullDirectory).map(d=>new Promise(h=>{this.textureLoader.load(d,p=>{p.flipY=!1,p.encoding=ht,h(p)},null,p=>{console.error("error loading texture: ",p),h(null)})}))),A=Yt((f=s==null?void 0:s.traitColor)==null?void 0:f.value).map(d=>new Re(d));r[o]=new mB({traitGroupID:s==null?void 0:s.traitModel.traitGroup.trait,traitModel:s==null?void 0:s.traitModel,textureTrait:s==null?void 0:s.traitTexture,colorTrait:s==null?void 0:s.traitColor,models:a,textures:l,colors:A})});Promise.allSettled(i).then(()=>{this.setLoadPercentage(100),t(r),this.isLoading=!1}).catch(s=>{this.setLoadPercentage(100),console.error("An error occurred:",s),t(r),this.isLoading=!1})})}}class mB{constructor(e){const{traitGroupID:t,traitModel:r,textureTrait:i,colorTrait:s,models:o,textures:a,colors:l}=e;this.traitGroupID=t,this.traitModel=r,this.textureTrait=i,this.colorTrait=s,this.models=o,this.textures=a,this.colors=l}}function mpe(n){const e=new yw,t=new bZ(16777215,.5);e.add(t);const r=new w_(16777215,.5);r.position.set(0,1,1),e.add(r);const i=new kt;e.add(i);const s=new Mr(30,window.innerWidth/window.innerHeight,.1,1e3);s.position.set(0,1.3,2);const o=new ppe({parentModel:e,createAnimationManager:!0,renderCamera:s});o.addLookAtMouse(80,n,s,!0);const a=document.getElementById(n),l=new c0({canvas:a,antialias:!0,alpha:!0,preserveDrawingBuffer:!0}),A=new bie(s,l.domElement);A.minDistance=1,A.maxDistance=4,A.maxPolarAngle=Math.PI/2,A.enablePan=!0,A.target=new z(0,1,0),A.enableDamping=!0,A.dampingFactor=.1;const c=new z(-.5,0,-.5),u=new z(.5,1.5,.5),f=()=>{l.setSize(window.innerWidth,window.innerHeight),s.aspect=window.innerWidth/window.innerHeight,s.updateProjectionMatrix()};window.addEventListener("resize",f),l.setSize(window.innerWidth,window.innerHeight),l.setPixelRatio(window.devicePixelRatio),l.outputEncoding=ht;const d=()=>{requestAnimationFrame(d),A.target.clamp(c,u),A==null||A.update(),o.update(),l.render(e,s)};d();const h=m=>{const g=m.ctrlKey,v=a.getBoundingClientRect(),y=(m.clientX-v.left)/v.width*2-1,w=-((m.clientY-v.top)/v.height)*2+1;o.cameraRaycastCulling(y,w,g)};async function p(){const m="./3d/Platform.glb",v=await new x_().loadAsync(m);i.add(v.scene)}return p(),a.addEventListener("click",h),{scene:e,camera:s,controls:A,characterManager:o,sceneElements:i}}new z;class vpe{constructor(e){this.characterManager=e,this.screenshotManager=e.screenshotManager,this.blinkManager=e.blinkManager,this.animationManager=this.characterManager.animationManager,console.log(this.characterManager),console.log(this.screenshotManager),this.temptime=0}async createLoraData(e,t){const r=await this._fetchManifest(e),{assetsLocation:i="",animationsDirectory:s="",backgroundGrayscale:o=1,topFrameOffsetPixels:a=64,bottomFrameOffsetPixels:l=64,backgroundDescription:A="",width:c=512,height:u=512,dataCollection:f}=r,d=i+s+"/";this.screenshotManager.setBackground([o,o,o]),this.blinkManager.enableScreenshot(),this.screenshotManager._setBonesOffset(.2);const h=g=>new Promise(v=>setTimeout(v,g));let p=0;const m=this;Array.isArray(f)&&await(async()=>{if(Array.isArray(f))for(let v=0;vnew Promise(v=>setTimeout(v,g));this.screenshotManager.setBottomFrameOffset(l),this.screenshotManager.setTopFrameOffset(a),this.screenshotManager.setBackground(s),this.blinkManager.enableScreenshot(),this.screenshotManager._setBonesOffset(.2);let p=0;console.log(t);const m=this;if(Array.isArray(f)){console.log("e");async function g(){var v;if(Array.isArray(f))for(const y of f){const{animationName:w,animationPath:C,framesNumber:b,lookAtCamera:E,expression:x,cameraPosition:S,cameraFrame:M}=y;p++;const Z=w||p.toString().padStart(2,"0");await m.animationManager.loadAnimation(d+C,!0,0);const K=TH(S);m.screenshotManager.setCameraFrameWithName(M,K);const _=(v=m.animationManager.getCurrentClip())==null?void 0:v.duration;if(_){console.log(_);const B=_/b;for(let F=0;F{const[e,t]=me.useState(null),[r,i]=me.useState(null),[s,o]=me.useState(null),[a,l]=me.useState(null),[A,c]=me.useState(null),[u,f]=me.useState(null),[d,h]=me.useState(null),[p,m]=me.useState(null),[g,v]=me.useState(null),[y,w]=me.useState(null),[C,b]=me.useState(!1);let E=!1,[x,S]=me.useState(!1);me.useEffect(()=>{if(E||x)return;S(!0),E=!0;const{scene:_,camera:B,controls:F,characterManager:R,sceneElements:k}=mpe("editor-scene");m(B),h(_),t(R),l(k),c(R.animationManager),f(R.lookAtManager),v(F),i(new vpe(R)),o(new ype(R))},[]);const M=_=>{_==null&&(_=!C),b(_),d.traverse(B=>{B.isMesh&&B.setDebugMode&&B.setDebugMode(_)})},Z=_=>{_?d.add(a):d.remove(a)},K=_=>{g&&(fE.to(g.target,{x:_.targetX??0,y:_.targetY??0,z:_.targetZ??0,duration:1}),fE.fromTo(g,{maxDistance:g.getDistance(),minDistance:g.getDistance(),minPolarAngle:g.getPolarAngle(),maxPolarAngle:g.getPolarAngle(),minAzimuthAngle:g.getAzimuthalAngle(),maxAzimuthAngle:g.getAzimuthalAngle()},{maxDistance:_.distance,minDistance:_.distance,minPolarAngle:Math.PI/2-.11,maxPolarAngle:Math.PI/2-.11,minAzimuthAngle:-.78,maxAzimuthAngle:-.78,duration:1}).then(()=>{g.minPolarAngle=0,g.maxPolarAngle=3.1415,g.minDistance=.5,g.maxDistance=10,g.minAzimuthAngle=1/0,g.maxAzimuthAngle=1/0}))};return P.jsx(ni.Provider,{value:{manifest:y,setManifest:w,scene:d,characterManager:e,loraDataGenerator:r,spriteAtlasGenerator:s,showEnvironmentModels:Z,debugMode:C,toggleDebugMode:M,animationManager:A,lookAtManager:u,camera:p,moveCamera:K,controls:g,sceneElements:a},children:n.children})},wpe={NORMAL:"NORMAL",AR:"AR",AR_FRONT:"AR_FRONT",VR:"VR"},ot={LANDING:"LANDING",CREATE:"CREATE",CLAIM:"CLAIM",LOAD:"LOAD",APPEARANCE:"APPEARANCE",BATCHDOWNLOAD:"BATCHDOWNLOAD",BIO:"BIO",SAVE:"SAVE",MINT:"MINT",CHAT:"CHAT",OPTIMIZER:"OPTIMIZER",BATCHMANIFEST:"BATCHMANIFEST",WALLET:"WALLET"},Bi=Y.createContext(),Cpe=n=>{const[e,t]=Y.useState(wpe.NORMAL),[r,i]=Y.useState(ot.LANDING),[s,o]=Y.useState(!1),[a,l]=Y.useState(!1);return P.jsx(Bi.Provider,{value:{viewMode:r,setViewMode:i,isLoading:s,setIsLoading:o,mouseIsOverUI:a,setMouseIsOverUI:l,currentCameraMode:e,setCurrentCameraMode:t},children:n.children})},bpe="modulepreload",xpe=function(n){return"/CharacterStudio/"+n},Nk={},Ipe=function(e,t,r){if(!t||t.length===0)return e();const i=document.getElementsByTagName("link");return Promise.all(t.map(s=>{if(s=xpe(s),s in Nk)return;Nk[s]=!0;const o=s.endsWith(".css"),a=o?'[rel="stylesheet"]':"";if(!!r)for(let c=i.length-1;c>=0;c--){const u=i[c];if(u.href===s&&(!o||u.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${a}`))return;const A=document.createElement("link");if(A.rel=o?"stylesheet":bpe,o||(A.as="script",A.crossOrigin=""),A.href=s,document.head.appendChild(A),o)return new Promise((c,u)=>{A.addEventListener("load",c),A.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${s}`)))})})).then(()=>e()).catch(s=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s})};function Xw(){return Xw=Object.assign||function(n){for(var e=1;e=0)&&(t[i]=n[i]);return t}function Epe(n){me.useEffect(n,[])}function Upe(n,e){e===void 0&&(e={});var t=e,r=t.volume,i=r===void 0?1:r,s=t.playbackRate,o=s===void 0?1:s,a=t.soundEnabled,l=a===void 0?!0:a,A=t.interrupt,c=A===void 0?!1:A,u=t.onload,f=Fpe(t,["id","volume","playbackRate","soundEnabled","interrupt","onload"]),d=Y.useRef(null),h=Y.useRef(!1),p=Y.useState(null),m=p[0],g=p[1],v=Y.useState(null),y=v[0],w=v[1],C=function(){typeof u=="function"&&u.call(this),h.current&&g(this.duration()*1e3),w(this)};Epe(function(){return Ipe(()=>import("./howler-2601a619.js").then(M=>M.h),[]).then(function(M){if(!h.current){var Z;d.current=(Z=M.Howl)!==null&&Z!==void 0?Z:M.default.Howl,h.current=!0,new d.current(Xw({src:Array.isArray(n)?n:[n],volume:i,rate:o,onload:C},f))}}),function(){h.current=!1}}),Y.useEffect(function(){d.current&&y&&w(new d.current(Xw({src:Array.isArray(n)?n:[n],volume:i,onload:C},f)))},[JSON.stringify(n)]),Y.useEffect(function(){y&&(y.volume(i),y.rate(o))},[i,o]);var b=Y.useCallback(function(M){typeof M>"u"&&(M={}),!(!y||!l&&!M.forceSoundEnabled)&&(c&&y.stop(),M.playbackRate&&y.rate(M.playbackRate),y.play(M.id))},[y,l,c]),E=Y.useCallback(function(M){y&&y.stop(M)},[y]),x=Y.useCallback(function(M){y&&y.pause(M)},[y]),S=[b,{sound:y,stop:E,pause:x,duration:m}];return S}const Spe=[{name:"background/cc_bgm.wav",offset:0,duration:123458.58333333334},{name:"background/cc_bgm_balanced.wav",offset:123458.58333333334,duration:123458.60416666666},{name:"effect/character-load.wav",offset:246917.1875,duration:3030},{name:"effect/class-select.wav",offset:249947.1875,duration:2780},{name:"effect/switchingItem.wav",offset:252727.1875,duration:623.75},{name:"ui/back-next-button.wav",offset:253350.9375,duration:155.02083333333334},{name:"ui/class-mouse-over.wav",offset:253505.95833333334,duration:217.52083333333334},{name:"ui/class_click.wav",offset:253723.4791666667,duration:3123.75},{name:"ui/class_pass.wav",offset:256847.2291666667,duration:155},{name:"ui/option_click.wav",offset:257002.2291666667,duration:155.02083333333334},{name:"ui/randomize-button.wav",offset:257157.25000000003,duration:342.5208333333333},{name:"ui/section_click.wav",offset:257499.77083333337,duration:155}],_pe="/CharacterStudio/assets/sounds-3322d50e.mp3",Cs=me.createContext(),Qpe=n=>{const e=i=>Spe.find(s=>i.test(s.name)),[t]=Upe(_pe,{sprite:{switchItem:[e(/switchingItem/).offset,e(/switchingItem/).duration],classSelect:[e(/class-select/).offset,e(/class-select/).duration],characterLoad:[e(/character-load/).offset,e(/character-load/).duration],randomizeButton:[e(/randomize-button/).offset,e(/randomize-button/).duration],classMouseOver:[e(/class-mouse-over/).offset,e(/class-mouse-over/).duration],backNextButton:[e(/back-next-button/).offset,e(/back-next-button/).duration]}}),r=(i,s=0)=>{s===0?t({id:i}):setTimeout(()=>{t({id:i})},s)};return P.jsx(Cs.Provider,{value:{playSound:r},children:n.children})};function $s(n){"@babel/helpers - typeof";return $s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$s(n)}function lo(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Rpe(n,e){if($s(n)!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if($s(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function KH(n){var e=Rpe(n,"string");return $s(e)=="symbol"?e:String(e)}function Dk(n,e){for(var t=0;tn.length)&&(e=n.length);for(var t=0,r=new Array(e);t1&&arguments[1]!==void 0?arguments[1]:{};lo(this,n),this.init(e,t)}return Ao(n,[{key:"init",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=t||Npe,this.options=r,this.debug=r.debug}},{key:"setDebug",value:function(t){this.debug=t}},{key:"log",value:function(){for(var t=arguments.length,r=new Array(t),i=0;i1?r-1:0),s=1;s-1?a.replace(/###/g,"."):a}function i(){return!n||typeof n=="string"}for(var s=typeof e!="string"?[].concat(e):e.split(".");s.length>1;){if(i())return{};var o=r(s.shift());!n[o]&&t&&(n[o]=new t),Object.prototype.hasOwnProperty.call(n,o)?n=n[o]:n={}}return i()?{}:{obj:n,k:r(s.shift())}}function Wk(n,e,t){var r=tQ(n,e,Object),i=r.obj,s=r.k;i[s]=t}function Vpe(n,e,t,r){var i=tQ(n,e,Object),s=i.obj,o=i.k;s[o]=s[o]||[],r&&(s[o]=s[o].concat(t)),r||s[o].push(t)}function Kw(n,e){var t=tQ(n,e),r=t.obj,i=t.k;if(r)return r[i]}function Ok(n,e,t){var r=Kw(n,t);return r!==void 0?r:Kw(e,t)}function e4(n,e,t){for(var r in e)r!=="__proto__"&&r!=="constructor"&&(r in n?typeof n[r]=="string"||n[r]instanceof String||typeof e[r]=="string"||e[r]instanceof String?t&&(n[r]=e[r]):e4(n[r],e[r],t):n[r]=e[r]);return n}function Ff(n){return n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var Lpe={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function Ppe(n){return typeof n=="string"?n.replace(/[&<>"'\/]/g,function(e){return Lpe[e]}):n}var pb=typeof window<"u"&&window.navigator&&typeof window.navigator.userAgentData>"u"&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Wpe=[" ",",","?","!",";"];function Ope(n,e,t){e=e||"",t=t||"";var r=Wpe.filter(function(a){return e.indexOf(a)<0&&t.indexOf(a)<0});if(r.length===0)return!0;var i=new RegExp("(".concat(r.map(function(a){return a==="?"?"\\?":a}).join("|"),")")),s=!i.test(n);if(!s){var o=n.indexOf(t);o>0&&!i.test(n.substring(0,o))&&(s=!0)}return s}function Gk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function my(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function t4(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(n){if(n[e])return n[e];for(var r=e.split(t),i=n,s=0;ss+o;)o++,a=r.slice(s,s+o).join(t),l=i[a];if(l===void 0)return;if(l===null)return null;if(e.endsWith(a)){if(typeof l=="string")return l;if(a&&typeof l[a]=="string")return l[a]}var A=r.slice(s+o).join(t);return A?t4(l,A,t):void 0}i=i[r[s]]}return i}}var Jpe=function(n){hb(t,n);var e=Gpe(t);function t(r){var i,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};return lo(this,t),i=e.call(this),pb&&ic.call(HA(i)),i.data=r||{},i.options=s,i.options.keySeparator===void 0&&(i.options.keySeparator="."),i.options.ignoreJSONStructure===void 0&&(i.options.ignoreJSONStructure=!0),i}return Ao(t,[{key:"addNamespaces",value:function(i){this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}},{key:"removeNamespaces",value:function(i){var s=this.options.ns.indexOf(i);s>-1&&this.options.ns.splice(s,1)}},{key:"getResource",value:function(i,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},l=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,A=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,c=[i,s];o&&typeof o!="string"&&(c=c.concat(o)),o&&typeof o=="string"&&(c=c.concat(l?o.split(l):o)),i.indexOf(".")>-1&&(c=i.split("."));var u=Kw(this.data,c);return u||!A||typeof o!="string"?u:t4(this.data&&this.data[i]&&this.data[i][s],o,l)}},{key:"addResource",value:function(i,s,o,a){var l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},A=this.options.keySeparator;A===void 0&&(A=".");var c=[i,s];o&&(c=c.concat(A?o.split(A):o)),i.indexOf(".")>-1&&(c=i.split("."),a=s,s=c[1]),this.addNamespaces(s),Wk(this.data,c,a),l.silent||this.emit("added",i,s,o,a)}},{key:"addResources",value:function(i,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(var l in o)(typeof o[l]=="string"||Object.prototype.toString.apply(o[l])==="[object Array]")&&this.addResource(i,s,l,o[l],{silent:!0});a.silent||this.emit("added",i,s,o)}},{key:"addResourceBundle",value:function(i,s,o,a,l){var A=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},c=[i,s];i.indexOf(".")>-1&&(c=i.split("."),a=o,o=s,s=c[1]),this.addNamespaces(s);var u=Kw(this.data,c)||{};a?e4(u,o,l):u=my(my({},u),o),Wk(this.data,c,u),A.silent||this.emit("added",i,s,o)}},{key:"removeResourceBundle",value:function(i,s){this.hasResourceBundle(i,s)&&delete this.data[i][s],this.removeNamespaces(s),this.emit("removed",i,s)}},{key:"hasResourceBundle",value:function(i,s){return this.getResource(i,s)!==void 0}},{key:"getResourceBundle",value:function(i,s){return s||(s=this.options.defaultNS),this.options.compatibilityAPI==="v1"?my(my({},{}),this.getResource(i,s)):this.getResource(i,s)}},{key:"getDataByLanguage",value:function(i){return this.data[i]}},{key:"hasLanguageSomeTranslations",value:function(i){var s=this.getDataByLanguage(i),o=s&&Object.keys(s)||[];return!!o.find(function(a){return s[a]&&Object.keys(s[a]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),t}(ic),n4={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,r,i,s){var o=this;return e.forEach(function(a){o.processors[a]&&(t=o.processors[a].process(t,r,i,s))}),t}};function Zk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function si(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Jk={},Hk=function(n){hb(t,n);var e=Hpe(t);function t(r){var i,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return lo(this,t),i=e.call(this),pb&&ic.call(HA(i)),kpe(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r,HA(i)),i.options=s,i.options.keySeparator===void 0&&(i.options.keySeparator="."),i.logger=pa.create("translator"),i}return Ao(t,[{key:"changeLanguage",value:function(i){i&&(this.language=i)}},{key:"exists",value:function(i){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(i==null)return!1;var o=this.resolve(i,s);return o&&o.res!==void 0}},{key:"extractFromKey",value:function(i,s){var o=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");var a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,l=s.ns||this.options.defaultNS||[],A=o&&i.indexOf(o)>-1,c=!this.options.userDefinedKeySeparator&&!s.keySeparator&&!this.options.userDefinedNsSeparator&&!s.nsSeparator&&!Ope(i,o,a);if(A&&!c){var u=i.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:i,namespaces:l};var f=i.split(o);(o!==a||o===a&&this.options.ns.indexOf(f[0])>-1)&&(l=f.shift()),i=f.join(a)}return typeof l=="string"&&(l=[l]),{key:i,namespaces:l}}},{key:"translate",value:function(i,s,o){var a=this;if($s(s)!=="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),s||(s={}),i==null)return"";Array.isArray(i)||(i=[String(i)]);var l=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,A=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,c=this.extractFromKey(i[i.length-1],s),u=c.key,f=c.namespaces,d=f[f.length-1],h=s.lng||this.language,p=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h&&h.toLowerCase()==="cimode"){if(p){var m=s.nsSeparator||this.options.nsSeparator;return l?{res:"".concat(d).concat(m).concat(u),usedKey:u,exactUsedKey:u,usedLng:h,usedNS:d}:"".concat(d).concat(m).concat(u)}return l?{res:u,usedKey:u,exactUsedKey:u,usedLng:h,usedNS:d}:u}var g=this.resolve(i,s),v=g&&g.res,y=g&&g.usedKey||u,w=g&&g.exactUsedKey||u,C=Object.prototype.toString.apply(v),b=["[object Number]","[object Function]","[object RegExp]"],E=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,x=!this.i18nFormat||this.i18nFormat.handleAsObject,S=typeof v!="string"&&typeof v!="boolean"&&typeof v!="number";if(x&&v&&S&&b.indexOf(C)<0&&!(typeof E=="string"&&C==="[object Array]")){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var M=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,v,si(si({},s),{},{ns:f})):"key '".concat(u," (").concat(this.language,")' returned an object instead of string.");return l?(g.res=M,g):M}if(A){var Z=C==="[object Array]",K=Z?[]:{},_=Z?w:y;for(var B in v)if(Object.prototype.hasOwnProperty.call(v,B)){var F="".concat(_).concat(A).concat(B);K[B]=this.translate(F,si(si({},s),{joinArrays:!1,ns:f})),K[B]===F&&(K[B]=v[B])}v=K}}else if(x&&typeof E=="string"&&C==="[object Array]")v=v.join(E),v&&(v=this.extendTranslation(v,i,s,o));else{var R=!1,k=!1,T=s.count!==void 0&&typeof s.count!="string",V=t.hasDefaultValue(s),O=T?this.pluralResolver.getSuffix(h,s.count,s):"",L=s["defaultValue".concat(O)]||s.defaultValue;!this.isValidLookup(v)&&V&&(R=!0,v=L),this.isValidLookup(v)||(k=!0,v=u);var U=s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey,H=U&&k?void 0:v,Ae=V&&L!==v&&this.options.updateMissing;if(k||R||Ae){if(this.logger.log(Ae?"updateKey":"missingKey",h,d,u,Ae?L:v),A){var N=this.resolve(u,si(si({},s),{},{keySeparator:!1}));N&&N.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var j=[],oe=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&oe&&oe[0])for(var ie=0;ie1&&arguments[1]!==void 0?arguments[1]:{},a,l,A,c,u;return typeof i=="string"&&(i=[i]),i.forEach(function(f){if(!s.isValidLookup(a)){var d=s.extractFromKey(f,o),h=d.key;l=h;var p=d.namespaces;s.options.fallbackNS&&(p=p.concat(s.options.fallbackNS));var m=o.count!==void 0&&typeof o.count!="string",g=m&&!o.ordinal&&o.count===0&&s.pluralResolver.shouldUseIntlApi(),v=o.context!==void 0&&(typeof o.context=="string"||typeof o.context=="number")&&o.context!=="",y=o.lngs?o.lngs:s.languageUtils.toResolveHierarchy(o.lng||s.language,o.fallbackLng);p.forEach(function(w){s.isValidLookup(a)||(u=w,!Jk["".concat(y[0],"-").concat(w)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(u)&&(Jk["".concat(y[0],"-").concat(w)]=!0,s.logger.warn('key "'.concat(l,'" for languages "').concat(y.join(", "),`" won't get resolved as namespace "`).concat(u,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(function(C){if(!s.isValidLookup(a)){c=C;var b=[h];if(s.i18nFormat&&s.i18nFormat.addLookupKeys)s.i18nFormat.addLookupKeys(b,h,C,w,o);else{var E;m&&(E=s.pluralResolver.getSuffix(C,o.count,o));var x="".concat(s.options.pluralSeparator,"zero");if(m&&(b.push(h+E),g&&b.push(h+x)),v){var S="".concat(h).concat(s.options.contextSeparator).concat(o.context);b.push(S),m&&(b.push(S+E),g&&b.push(S+x))}}for(var M;M=b.pop();)s.isValidLookup(a)||(A=M,a=s.getResource(C,w,M,o))}}))})}}),{res:a,usedKey:l,exactUsedKey:A,usedLng:c,usedNS:u}}},{key:"isValidLookup",value:function(i){return i!==void 0&&!(!this.options.returnNull&&i===null)&&!(!this.options.returnEmptyString&&i==="")}},{key:"getResource",value:function(i,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(i,s,o,a):this.resourceStore.getResource(i,s,o,a)}}],[{key:"hasDefaultValue",value:function(i){var s="defaultValue";for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o)&&s===o.substring(0,s.length)&&i[o]!==void 0)return!0;return!1}}]),t}(ic);function w1(n){return n.charAt(0).toUpperCase()+n.slice(1)}var zk=function(){function n(e){lo(this,n),this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=pa.create("languageUtils")}return Ao(n,[{key:"getScriptPartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return null;var r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}},{key:"getLanguagePartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return t;var r=t.split("-");return this.formatLanguageCode(r[0])}},{key:"formatLanguageCode",value:function(t){if(typeof t=="string"&&t.indexOf("-")>-1){var r=["hans","hant","latn","cyrl","cans","mong","arab"],i=t.split("-");return this.options.lowerCaseLng?i=i.map(function(s){return s.toLowerCase()}):i.length===2?(i[0]=i[0].toLowerCase(),i[1]=i[1].toUpperCase(),r.indexOf(i[1].toLowerCase())>-1&&(i[1]=w1(i[1].toLowerCase()))):i.length===3&&(i[0]=i[0].toLowerCase(),i[1].length===2&&(i[1]=i[1].toUpperCase()),i[0]!=="sgn"&&i[2].length===2&&(i[2]=i[2].toUpperCase()),r.indexOf(i[1].toLowerCase())>-1&&(i[1]=w1(i[1].toLowerCase())),r.indexOf(i[2].toLowerCase())>-1&&(i[2]=w1(i[2].toLowerCase()))),i.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}},{key:"isSupportedCode",value:function(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}},{key:"getBestMatchFromCodes",value:function(t){var r=this;if(!t)return null;var i;return t.forEach(function(s){if(!i){var o=r.formatLanguageCode(s);(!r.options.supportedLngs||r.isSupportedCode(o))&&(i=o)}}),!i&&this.options.supportedLngs&&t.forEach(function(s){if(!i){var o=r.getLanguagePartFromCode(s);if(r.isSupportedCode(o))return i=o;i=r.options.supportedLngs.find(function(a){if(a.indexOf(o)===0)return a})}}),i||(i=this.getFallbackCodes(this.options.fallbackLng)[0]),i}},{key:"getFallbackCodes",value:function(t,r){if(!t)return[];if(typeof t=="function"&&(t=t(r)),typeof t=="string"&&(t=[t]),Object.prototype.toString.apply(t)==="[object Array]")return t;if(!r)return t.default||[];var i=t[r];return i||(i=t[this.getScriptPartFromCode(r)]),i||(i=t[this.formatLanguageCode(r)]),i||(i=t[this.getLanguagePartFromCode(r)]),i||(i=t.default),i||[]}},{key:"toResolveHierarchy",value:function(t,r){var i=this,s=this.getFallbackCodes(r||this.options.fallbackLng||[],t),o=[],a=function(A){A&&(i.isSupportedCode(A)?o.push(A):i.logger.warn("rejecting language code not found in supportedLngs: ".concat(A)))};return typeof t=="string"&&t.indexOf("-")>-1?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):typeof t=="string"&&a(this.formatLanguageCode(t)),s.forEach(function(l){o.indexOf(l)<0&&a(i.formatLanguageCode(l))}),o}}]),n}(),Ype=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Xpe={1:function(e){return+(e>1)},2:function(e){return+(e!=1)},3:function(e){return 0},4:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},5:function(e){return e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5},6:function(e){return e==1?0:e>=2&&e<=4?1:2},7:function(e){return e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},8:function(e){return e==1?0:e==2?1:e!=8&&e!=11?2:3},9:function(e){return+(e>=2)},10:function(e){return e==1?0:e==2?1:e<7?2:e<11?3:4},11:function(e){return e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3},12:function(e){return+(e%10!=1||e%100==11)},13:function(e){return+(e!==0)},14:function(e){return e==1?0:e==2?1:e==3?2:3},15:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2},16:function(e){return e%10==1&&e%100!=11?0:e!==0?1:2},17:function(e){return e==1||e%10==1&&e%100!=11?0:1},18:function(e){return e==0?0:e==1?1:2},19:function(e){return e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3},20:function(e){return e==1?0:e==0||e%100>0&&e%100<20?1:2},21:function(e){return e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0},22:function(e){return e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3}},Kpe=["v1","v2","v3"],Yk={zero:0,one:1,two:2,few:3,many:4,other:5};function jpe(){var n={};return Ype.forEach(function(e){e.lngs.forEach(function(t){n[t]={numbers:e.nr,plurals:Xpe[e.fc]}})}),n}var $pe=function(){function n(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};lo(this,n),this.languageUtils=e,this.options=t,this.logger=pa.create("pluralResolver"),(!this.options.compatibilityJSON||this.options.compatibilityJSON==="v4")&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=jpe()}return Ao(n,[{key:"addRule",value:function(t,r){this.rules[t]=r}},{key:"getRule",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(t,{type:r.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}},{key:"needsPlural",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(t,r);return this.shouldUseIntlApi()?i&&i.resolvedOptions().pluralCategories.length>1:i&&i.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(t,r){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,i).map(function(s){return"".concat(r).concat(s)})}},{key:"getSuffixes",value:function(t){var r=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=this.getRule(t,i);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(function(o,a){return Yk[o]-Yk[a]}).map(function(o){return"".concat(r.options.prepend).concat(o)}):s.numbers.map(function(o){return r.getSuffix(t,o,i)}):[]}},{key:"getSuffix",value:function(t,r){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=this.getRule(t,i);return s?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(s.select(r)):this.getSuffixRetroCompatible(s,r):(this.logger.warn("no plural rule found for: ".concat(t)),"")}},{key:"getSuffixRetroCompatible",value:function(t,r){var i=this,s=t.noAbs?t.plurals(r):t.plurals(Math.abs(r)),o=t.numbers[s];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(o===2?o="plural":o===1&&(o=""));var a=function(){return i.options.prepend&&o.toString()?i.options.prepend+o.toString():o.toString()};return this.options.compatibilityJSON==="v1"?o===1?"":typeof o=="number"?"_plural_".concat(o.toString()):a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}},{key:"shouldUseIntlApi",value:function(){return!Kpe.includes(this.options.compatibilityJSON)}}]),n}();function Xk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Bo(n){for(var e=1;e0&&arguments[0]!==void 0?arguments[0]:{};lo(this,n),this.logger=pa.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||function(t){return t},this.init(e)}return Ao(n,[{key:"init",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});var r=t.interpolation;this.escape=r.escape!==void 0?r.escape:Ppe,this.escapeValue=r.escapeValue!==void 0?r.escapeValue:!0,this.useRawValueToEscape=r.useRawValueToEscape!==void 0?r.useRawValueToEscape:!1,this.prefix=r.prefix?Ff(r.prefix):r.prefixEscaped||"{{",this.suffix=r.suffix?Ff(r.suffix):r.suffixEscaped||"}}",this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||",",this.unescapePrefix=r.unescapeSuffix?"":r.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":r.unescapeSuffix||"",this.nestingPrefix=r.nestingPrefix?Ff(r.nestingPrefix):r.nestingPrefixEscaped||Ff("$t("),this.nestingSuffix=r.nestingSuffix?Ff(r.nestingSuffix):r.nestingSuffixEscaped||Ff(")"),this.nestingOptionsSeparator=r.nestingOptionsSeparator?r.nestingOptionsSeparator:r.nestingOptionsSeparator||",",this.maxReplaces=r.maxReplaces?r.maxReplaces:1e3,this.alwaysFormat=r.alwaysFormat!==void 0?r.alwaysFormat:!1,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var t="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(t,"g");var r="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(r,"g");var i="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(i,"g")}},{key:"interpolate",value:function(t,r,i,s){var o=this,a,l,A,c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(m){return m.replace(/\$/g,"$$$$")}var f=function(g){if(g.indexOf(o.formatSeparator)<0){var v=Ok(r,c,g);return o.alwaysFormat?o.format(v,void 0,i,Bo(Bo(Bo({},s),r),{},{interpolationkey:g})):v}var y=g.split(o.formatSeparator),w=y.shift().trim(),C=y.join(o.formatSeparator).trim();return o.format(Ok(r,c,w),C,i,Bo(Bo(Bo({},s),r),{},{interpolationkey:w}))};this.resetRegExp();var d=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,h=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables,p=[{regex:this.regexpUnescape,safeValue:function(g){return u(g)}},{regex:this.regexp,safeValue:function(g){return o.escapeValue?u(o.escape(g)):u(g)}}];return p.forEach(function(m){for(A=0;a=m.regex.exec(t);){var g=a[1].trim();if(l=f(g),l===void 0)if(typeof d=="function"){var v=d(t,a,s);l=typeof v=="string"?v:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))l="";else if(h){l=a[0];continue}else o.logger.warn("missed to pass in variable ".concat(g," for interpolating ").concat(t)),l="";else typeof l!="string"&&!o.useRawValueToEscape&&(l=Pk(l));var y=m.safeValue(l);if(t=t.replace(a[0],y),h?(m.regex.lastIndex+=l.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,A++,A>=o.maxReplaces)break}}),t}},{key:"nest",value:function(t,r){var i=this,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o,a,l;function A(d,h){var p=this.nestingOptionsSeparator;if(d.indexOf(p)<0)return d;var m=d.split(new RegExp("".concat(p,"[ ]*{"))),g="{".concat(m[1]);d=m[0],g=this.interpolate(g,l);var v=g.match(/'/g),y=g.match(/"/g);(v&&v.length%2===0&&!y||y.length%2!==0)&&(g=g.replace(/'/g,'"'));try{l=JSON.parse(g),h&&(l=Bo(Bo({},h),l))}catch(w){return this.logger.warn("failed parsing options string in nesting for key ".concat(d),w),"".concat(d).concat(p).concat(g)}return delete l.defaultValue,d}for(;o=this.nestingRegexp.exec(t);){var c=[];l=Bo({},s),l=l.replace&&typeof l.replace!="string"?l.replace:l,l.applyPostProcessor=!1,delete l.defaultValue;var u=!1;if(o[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(o[1])){var f=o[1].split(this.formatSeparator).map(function(d){return d.trim()});o[1]=f.shift(),c=f,u=!0}if(a=r(A.call(this,o[1].trim(),l),l),a&&o[0]===t&&typeof a!="string")return a;typeof a!="string"&&(a=Pk(a)),a||(this.logger.warn("missed to resolve ".concat(o[1]," for nesting ").concat(t)),a=""),u&&(a=c.reduce(function(d,h){return i.format(d,h,s.lng,Bo(Bo({},s),{},{interpolationkey:o[1].trim()}))},a.trim())),t=t.replace(o[0],a),this.regexp.lastIndex=0}return t}}]),n}();function Kk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function tl(n){for(var e=1;e-1){var r=n.split("(");e=r[0].toLowerCase().trim();var i=r[1].substring(0,r[1].length-1);if(e==="currency"&&i.indexOf(":")<0)t.currency||(t.currency=i.trim());else if(e==="relativetime"&&i.indexOf(":")<0)t.range||(t.range=i.trim());else{var s=i.split(";");s.forEach(function(o){if(o){var a=o.split(":"),l=Tpe(a),A=l[0],c=l.slice(1),u=c.join(":").trim().replace(/^'+|'+$/g,"");t[A.trim()]||(t[A.trim()]=u),u==="false"&&(t[A.trim()]=!1),u==="true"&&(t[A.trim()]=!0),isNaN(u)||(t[A.trim()]=parseInt(u,10))}})}}return{formatName:e,formatOptions:t}}function Ef(n){var e={};return function(r,i,s){var o=i+JSON.stringify(s),a=e[o];return a||(a=n(i,s),e[o]=a),a(r)}}var tge=function(){function n(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};lo(this,n),this.logger=pa.create("formatter"),this.options=e,this.formats={number:Ef(function(t,r){var i=new Intl.NumberFormat(t,tl({},r));return function(s){return i.format(s)}}),currency:Ef(function(t,r){var i=new Intl.NumberFormat(t,tl(tl({},r),{},{style:"currency"}));return function(s){return i.format(s)}}),datetime:Ef(function(t,r){var i=new Intl.DateTimeFormat(t,tl({},r));return function(s){return i.format(s)}}),relativetime:Ef(function(t,r){var i=new Intl.RelativeTimeFormat(t,tl({},r));return function(s){return i.format(s,r.range||"day")}}),list:Ef(function(t,r){var i=new Intl.ListFormat(t,tl({},r));return function(s){return i.format(s)}})},this.init(e)}return Ao(n,[{key:"init",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}},i=r.interpolation;this.formatSeparator=i.formatSeparator?i.formatSeparator:i.formatSeparator||","}},{key:"add",value:function(t,r){this.formats[t.toLowerCase().trim()]=r}},{key:"addCached",value:function(t,r){this.formats[t.toLowerCase().trim()]=Ef(r)}},{key:"format",value:function(t,r,i){var s=this,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=r.split(this.formatSeparator),l=a.reduce(function(A,c){var u=ege(c),f=u.formatName,d=u.formatOptions;if(s.formats[f]){var h=A;try{var p=o&&o.formatParams&&o.formatParams[o.interpolationkey]||{},m=p.locale||p.lng||o.locale||o.lng||i;h=s.formats[f](A,m,tl(tl(tl({},d),o),p))}catch(g){s.logger.warn(g)}return h}else s.logger.warn("there was no format function for ".concat(f));return A},t);return l}}]),n}();function jk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function $k(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ige(n,e){n.pending[e]!==void 0&&(delete n.pending[e],n.pendingCount--)}var sge=function(n){hb(t,n);var e=nge(t);function t(r,i,s){var o,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return lo(this,t),o=e.call(this),pb&&ic.call(HA(o)),o.backend=r,o.store=i,o.services=s,o.languageUtils=s.languageUtils,o.options=a,o.logger=pa.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=a.maxParallelReads||10,o.readingCalls=0,o.maxRetries=a.maxRetries>=0?a.maxRetries:5,o.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(s,a.backend,a),o}return Ao(t,[{key:"queueLoad",value:function(i,s,o,a){var l=this,A={},c={},u={},f={};return i.forEach(function(d){var h=!0;s.forEach(function(p){var m="".concat(d,"|").concat(p);!o.reload&&l.store.hasResourceBundle(d,p)?l.state[m]=2:l.state[m]<0||(l.state[m]===1?c[m]===void 0&&(c[m]=!0):(l.state[m]=1,h=!1,c[m]===void 0&&(c[m]=!0),A[m]===void 0&&(A[m]=!0),f[p]===void 0&&(f[p]=!0)))}),h||(u[d]=!0)}),(Object.keys(A).length||Object.keys(c).length)&&this.queue.push({pending:c,pendingCount:Object.keys(c).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(A),pending:Object.keys(c),toLoadLanguages:Object.keys(u),toLoadNamespaces:Object.keys(f)}}},{key:"loaded",value:function(i,s,o){var a=i.split("|"),l=a[0],A=a[1];s&&this.emit("failedLoading",l,A,s),o&&this.store.addResourceBundle(l,A,o),this.state[i]=s?-1:2;var c={};this.queue.forEach(function(u){Vpe(u.loaded,[l],A),ige(u,i),s&&u.errors.push(s),u.pendingCount===0&&!u.done&&(Object.keys(u.loaded).forEach(function(f){c[f]||(c[f]={});var d=u.loaded[f];d.length&&d.forEach(function(h){c[f][h]===void 0&&(c[f][h]=!0)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(function(u){return!u.done})}},{key:"read",value:function(i,s,o){var a=this,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,A=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,c=arguments.length>5?arguments[5]:void 0;if(!i.length)return c(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:i,ns:s,fcName:o,tried:l,wait:A,callback:c});return}this.readingCalls++;var u=function(p,m){if(a.readingCalls--,a.waitingReads.length>0){var g=a.waitingReads.shift();a.read(g.lng,g.ns,g.fcName,g.tried,g.wait,g.callback)}if(p&&m&&l2&&arguments[2]!==void 0?arguments[2]:{},l=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),l&&l();typeof i=="string"&&(i=this.languageUtils.toResolveHierarchy(i)),typeof s=="string"&&(s=[s]);var A=this.queueLoad(i,s,a,l);if(!A.toLoad.length)return A.pending.length||l(),null;A.toLoad.forEach(function(c){o.loadOne(c)})}},{key:"load",value:function(i,s,o){this.prepareLoading(i,s,{},o)}},{key:"reload",value:function(i,s,o){this.prepareLoading(i,s,{reload:!0},o)}},{key:"loadOne",value:function(i){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",a=i.split("|"),l=a[0],A=a[1];this.read(l,A,"read",void 0,void 0,function(c,u){c&&s.logger.warn("".concat(o,"loading namespace ").concat(A," for language ").concat(l," failed"),c),!c&&u&&s.logger.log("".concat(o,"loaded namespace ").concat(A," for language ").concat(l),u),s.loaded(i,c,u)})}},{key:"saveMissing",value:function(i,s,o,a,l){var A=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(s)){this.logger.warn('did not save key "'.concat(o,'" as the namespace "').concat(s,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend&&this.backend.create){var u=$k($k({},A),{},{isUpdate:l}),f=this.backend.create.bind(this.backend);if(f.length<6)try{var d;f.length===5?d=f(i,s,o,a,u):d=f(i,s,o,a),d&&typeof d.then=="function"?d.then(function(h){return c(null,h)}).catch(c):c(null,d)}catch(h){c(h)}else f(i,s,o,a,c,u)}!i||!i[0]||this.store.addResource(i[0],s,o,a)}}}]),t}(ic);function qk(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if($s(e[1])==="object"&&(t=e[1]),typeof e[1]=="string"&&(t.defaultValue=e[1]),typeof e[2]=="string"&&(t.tDescription=e[2]),$s(e[2])==="object"||$s(e[3])==="object"){var r=e[3]||e[2];Object.keys(r).forEach(function(i){t[i]=r[i]})}return t},interpolation:{escapeValue:!0,format:function(e,t,r,i){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function eV(n){return typeof n.ns=="string"&&(n.ns=[n.ns]),typeof n.fallbackLng=="string"&&(n.fallbackLng=[n.fallbackLng]),typeof n.fallbackNS=="string"&&(n.fallbackNS=[n.fallbackNS]),n.supportedLngs&&n.supportedLngs.indexOf("cimode")<0&&(n.supportedLngs=n.supportedLngs.concat(["cimode"])),n}function tV(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Ko(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function vy(){}function lge(n){var e=Object.getOwnPropertyNames(Object.getPrototypeOf(n));e.forEach(function(t){typeof n[t]=="function"&&(n[t]=n[t].bind(n))})}var jw=function(n){hb(t,n);var e=oge(t);function t(){var r,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(lo(this,t),r=e.call(this),pb&&ic.call(HA(r)),r.options=eV(i),r.services={},r.logger=pa,r.modules={external:[]},lge(HA(r)),s&&!r.isInitialized&&!i.isClone){if(!r.options.initImmediate)return r.init(i,s),y0(r,HA(r));setTimeout(function(){r.init(i,s)},0)}return r}return Ao(t,[{key:"init",value:function(){var i=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;typeof s=="function"&&(o=s,s={}),!s.defaultNS&&s.defaultNS!==!1&&s.ns&&(typeof s.ns=="string"?s.defaultNS=s.ns:s.ns.indexOf("translation")<0&&(s.defaultNS=s.ns[0]));var a=qk();this.options=Ko(Ko(Ko({},a),this.options),eV(s)),this.options.compatibilityAPI!=="v1"&&(this.options.interpolation=Ko(Ko({},a.interpolation),this.options.interpolation)),s.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=s.keySeparator),s.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=s.nsSeparator);function l(g){return g?typeof g=="function"?new g:g:null}if(!this.options.isClone){this.modules.logger?pa.init(l(this.modules.logger),this.options):pa.init(null,this.options);var A;this.modules.formatter?A=this.modules.formatter:typeof Intl<"u"&&(A=tge);var c=new zk(this.options);this.store=new Jpe(this.options.resources,this.options);var u=this.services;u.logger=pa,u.resourceStore=this.store,u.languageUtils=c,u.pluralResolver=new $pe(c,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),A&&(!this.options.interpolation.format||this.options.interpolation.format===a.interpolation.format)&&(u.formatter=l(A),u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new qpe(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new sge(l(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",function(g){for(var v=arguments.length,y=new Array(v>1?v-1:0),w=1;w1?v-1:0),w=1;w0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined");var d=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];d.forEach(function(g){i[g]=function(){var v;return(v=i.store)[g].apply(v,arguments)}});var h=["addResource","addResources","addResourceBundle","removeResourceBundle"];h.forEach(function(g){i[g]=function(){var v;return(v=i.store)[g].apply(v,arguments),i}});var p=zp(),m=function(){var v=function(w,C){i.isInitialized&&!i.initializedStoreOnce&&i.logger.warn("init: i18next is already initialized. You should call init just once!"),i.isInitialized=!0,i.options.isClone||i.logger.log("initialized",i.options),i.emit("initialized",i.options),p.resolve(C),o(w,C)};if(i.languages&&i.options.compatibilityAPI!=="v1"&&!i.isInitialized)return v(null,i.t.bind(i));i.changeLanguage(i.options.lng,v)};return this.options.resources||!this.options.initImmediate?m():setTimeout(m,0),p}},{key:"loadResources",value:function(i){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vy,a=o,l=typeof i=="string"?i:this.language;if(typeof i=="function"&&(a=i),!this.options.resources||this.options.partialBundledLanguages){if(l&&l.toLowerCase()==="cimode")return a();var A=[],c=function(d){if(d){var h=s.services.languageUtils.toResolveHierarchy(d);h.forEach(function(p){A.indexOf(p)<0&&A.push(p)})}};if(l)c(l);else{var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.forEach(function(f){return c(f)})}this.options.preload&&this.options.preload.forEach(function(f){return c(f)}),this.services.backendConnector.load(A,this.options.ns,function(f){!f&&!s.resolvedLanguage&&s.language&&s.setResolvedLanguage(s.language),a(f)})}else a(null)}},{key:"reloadResources",value:function(i,s,o){var a=zp();return i||(i=this.languages),s||(s=this.options.ns),o||(o=vy),this.services.backendConnector.reload(i,s,function(l){a.resolve(),o(l)}),a}},{key:"use",value:function(i){if(!i)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!i.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return i.type==="backend"&&(this.modules.backend=i),(i.type==="logger"||i.log&&i.warn&&i.error)&&(this.modules.logger=i),i.type==="languageDetector"&&(this.modules.languageDetector=i),i.type==="i18nFormat"&&(this.modules.i18nFormat=i),i.type==="postProcessor"&&n4.addPostProcessor(i),i.type==="formatter"&&(this.modules.formatter=i),i.type==="3rdParty"&&this.modules.external.push(i),this}},{key:"setResolvedLanguage",value:function(i){if(!(!i||!this.languages)&&!(["cimode","dev"].indexOf(i)>-1))for(var s=0;s-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}}},{key:"changeLanguage",value:function(i,s){var o=this;this.isLanguageChangingTo=i;var a=zp();this.emit("languageChanging",i);var l=function(f){o.language=f,o.languages=o.services.languageUtils.toResolveHierarchy(f),o.resolvedLanguage=void 0,o.setResolvedLanguage(f)},A=function(f,d){d?(l(d),o.translator.changeLanguage(d),o.isLanguageChangingTo=void 0,o.emit("languageChanged",d),o.logger.log("languageChanged",d)):o.isLanguageChangingTo=void 0,a.resolve(function(){return o.t.apply(o,arguments)}),s&&s(f,function(){return o.t.apply(o,arguments)})},c=function(f){!i&&!f&&o.services.languageDetector&&(f=[]);var d=typeof f=="string"?f:o.services.languageUtils.getBestMatchFromCodes(f);d&&(o.language||l(d),o.translator.language||o.translator.changeLanguage(d),o.services.languageDetector&&o.services.languageDetector.cacheUserLanguage&&o.services.languageDetector.cacheUserLanguage(d)),o.loadResources(d,function(h){A(h,d)})};return!i&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!i&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(i),a}},{key:"getFixedT",value:function(i,s,o){var a=this,l=function A(c,u){var f;if($s(u)!=="object"){for(var d=arguments.length,h=new Array(d>2?d-2:0),p=2;p1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var a=this.resolvedLanguage||this.languages[0],l=this.options?this.options.fallbackLng:!1,A=this.languages[this.languages.length-1];if(a.toLowerCase()==="cimode")return!0;var c=function(d,h){var p=s.services.backendConnector.state["".concat(d,"|").concat(h)];return p===-1||p===2};if(o.precheck){var u=o.precheck(this,c);if(u!==void 0)return u}return!!(this.hasResourceBundle(a,i)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||c(a,i)&&(!l||c(A,i)))}},{key:"loadNamespaces",value:function(i,s){var o=this,a=zp();return this.options.ns?(typeof i=="string"&&(i=[i]),i.forEach(function(l){o.options.ns.indexOf(l)<0&&o.options.ns.push(l)}),this.loadResources(function(l){a.resolve(),s&&s(l)}),a):(s&&s(),Promise.resolve())}},{key:"loadLanguages",value:function(i,s){var o=zp();typeof i=="string"&&(i=[i]);var a=this.options.preload||[],l=i.filter(function(A){return a.indexOf(A)<0});return l.length?(this.options.preload=a.concat(l),this.loadResources(function(A){o.resolve(),s&&s(A)}),o):(s&&s(),Promise.resolve())}},{key:"dir",value:function(i){if(i||(i=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!i)return"rtl";var s=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services&&this.services.languageUtils||new zk(qk());return s.indexOf(o.getLanguagePartFromCode(i))>-1||i.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var i=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vy,a=Ko(Ko(Ko({},this.options),s),{isClone:!0}),l=new t(a);(s.debug!==void 0||s.prefix!==void 0)&&(l.logger=l.logger.clone(s));var A=["store","services","language"];return A.forEach(function(c){l[c]=i[c]}),l.services=Ko({},this.services),l.services.utils={hasLoadedNamespace:l.hasLoadedNamespace.bind(l)},l.translator=new Hk(l.services,l.options),l.translator.on("*",function(c){for(var u=arguments.length,f=new Array(u>1?u-1:0),d=1;d0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;return new jw(n,e)});var ri=jw.createInstance();ri.createInstance=jw.createInstance;ri.createInstance;ri.dir;ri.init;ri.loadResources;ri.reloadResources;ri.use;ri.changeLanguage;ri.getFixedT;ri.t;ri.exists;ri.setDefaultNamespace;ri.hasLoadedNamespace;ri.loadNamespaces;ri.loadLanguages;function Age(){if(console&&console.warn){for(var n,e=arguments.length,t=new Array(e),r=0;r2&&arguments[2]!==void 0?arguments[2]:{},r=e.languages[0],i=e.options?e.options.fallbackLng:!1,s=e.languages[e.languages.length-1];if(r.toLowerCase()==="cimode")return!0;var o=function(l,A){var c=e.services.backendConnector.state["".concat(l,"|").concat(A)];return c===-1||c===2};return t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&e.services.backendConnector.backend&&e.isLanguageChangingTo&&!o(e.isLanguageChangingTo,n)?!1:!!(e.hasResourceBundle(r,n)||!e.services.backendConnector.backend||e.options.resources&&!e.options.partialBundledLanguages||o(r,n)&&(!i||o(s,n)))}function uge(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!e.languages||!e.languages.length)return hU("i18n.languages were undefined or empty",e.languages),!0;var r=e.options.ignoreJSONStructure!==void 0;return r?e.hasLoadedNamespace(n,{precheck:function(s,o){if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!o(s.isLanguageChangingTo,n))return!1}}):cge(n,e,t)}var fge=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,dge={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},hge=function(e){return dge[e]},pge=function(e){return e.replace(fge,hge)};function iV(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function sV(n){for(var e=1;e0&&arguments[0]!==void 0?arguments[0]:{};pU=sV(sV({},pU),n)}function mge(){return pU}var r4;function vge(n){r4=n}function yge(){return r4}var Bge={type:"3rdParty",init:function(e){gge(e.options.react),vge(e)}},wge=me.createContext(),Cge=function(){function n(){lo(this,n),this.usedNamespaces={}}return Ao(n,[{key:"addUsedNamespaces",value:function(t){var r=this;t.forEach(function(i){r.usedNamespaces[i]||(r.usedNamespaces[i]=!0)})}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}]),n}();function bge(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var r,i,s,o,a=[],l=!0,A=!1;try{if(s=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(r=s.call(t)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(c){A=!0,i=c}finally{try{if(!l&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(A)throw i}}return a}}function xge(n,e){return jH(n)||bge(n,e)||$H(n,e)||qH()}function oV(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function C1(n){for(var e=1;e1&&arguments[1]!==void 0?arguments[1]:{},t=e.i18n,r=me.useContext(wge)||{},i=r.i18n,s=r.defaultNS,o=t||i||yge();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new Cge),!o){hU("You will need to pass in an i18next instance by using initReactI18next");var a=function(S,M){return typeof M=="string"?M:M&&$s(M)==="object"&&typeof M.defaultValue=="string"?M.defaultValue:Array.isArray(S)?S[S.length-1]:S},l=[a,{},!1];return l.t=a,l.i18n={},l.ready=!1,l}o.options.react&&o.options.react.wait!==void 0&&hU("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var A=C1(C1(C1({},mge()),o.options.react),e),c=A.useSuspense,u=A.keyPrefix,f=n||s||o.options&&o.options.defaultNS;f=typeof f=="string"?[f]:f||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(f);var d=(o.isInitialized||o.initializedStoreOnce)&&f.every(function(x){return uge(x,o,A)});function h(){return o.getFixedT(null,A.nsMode==="fallback"?f:f[0],u)}var p=me.useState(h),m=xge(p,2),g=m[0],v=m[1],y=f.join(),w=Ige(y),C=me.useRef(!0);me.useEffect(function(){var x=A.bindI18n,S=A.bindI18nStore;C.current=!0,!d&&!c&&rV(o,f,function(){C.current&&v(h)}),d&&w&&w!==y&&C.current&&v(h);function M(){C.current&&v(h)}return x&&o&&o.on(x,M),S&&o&&o.store.on(S,M),function(){C.current=!1,x&&o&&x.split(" ").forEach(function(Z){return o.off(Z,M)}),S&&o&&S.split(" ").forEach(function(Z){return o.store.off(Z,M)})}},[o,y]);var b=me.useRef(!0);me.useEffect(function(){C.current&&!b.current&&v(h),b.current=!1},[o,u]);var E=[g,o,d];if(E.t=g,E.i18n=o,E.ready=d,d||!d&&!c)return E;throw new Promise(function(x){rV(o,f,function(){x()})})}var s4=[],Fge=s4.forEach,Ege=s4.slice;function Uge(n){return Fge.call(Ege.call(arguments,1),function(e){if(e)for(var t in e)n[t]===void 0&&(n[t]=e[t])}),n}var aV=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Sge=function(e,t,r){var i=r||{};i.path=i.path||"/";var s=encodeURIComponent(t),o="".concat(e,"=").concat(s);if(i.maxAge>0){var a=i.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");o+="; Max-Age=".concat(Math.floor(a))}if(i.domain){if(!aV.test(i.domain))throw new TypeError("option domain is invalid");o+="; Domain=".concat(i.domain)}if(i.path){if(!aV.test(i.path))throw new TypeError("option path is invalid");o+="; Path=".concat(i.path)}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");o+="; Expires=".concat(i.expires.toUTCString())}if(i.httpOnly&&(o+="; HttpOnly"),i.secure&&(o+="; Secure"),i.sameSite){var l=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite;switch(l){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o},lV={create:function(e,t,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(s.expires=new Date,s.expires.setTime(s.expires.getTime()+r*60*1e3)),i&&(s.domain=i),document.cookie=Sge(e,encodeURIComponent(t),s)},read:function(e){for(var t="".concat(e,"="),r=document.cookie.split(";"),i=0;i-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var i=r.substring(1),s=i.split("&"),o=0;o0){var l=s[o].substring(0,a);l===e.lookupQuerystring&&(t=s[o].substring(a+1))}}}return t}},Yp=null,AV=function(){if(Yp!==null)return Yp;try{Yp=window!=="undefined"&&window.localStorage!==null;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch{Yp=!1}return Yp},Rge={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&AV()){var r=window.localStorage.getItem(e.lookupLocalStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&AV()&&window.localStorage.setItem(t.lookupLocalStorage,e)}},Xp=null,cV=function(){if(Xp!==null)return Xp;try{Xp=window!=="undefined"&&window.sessionStorage!==null;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch{Xp=!1}return Xp},Mge={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&cV()){var r=window.sessionStorage.getItem(e.lookupSessionStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&cV()&&window.sessionStorage.setItem(t.lookupSessionStorage,e)}},Tge={name:"navigator",lookup:function(e){var t=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r0?t:void 0}},Nge={name:"htmlTag",lookup:function(e){var t,r=e.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(t=r.getAttribute("lang")),t}},Dge={name:"path",lookup:function(e){var t;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof e.lookupFromPathIndex=="number"){if(typeof r[e.lookupFromPathIndex]!="string")return;t=r[e.lookupFromPathIndex].replace("/","")}else t=r[0].replace("/","")}return t}},kge={name:"subdomain",lookup:function(e){var t=typeof e.lookupFromSubdomainIndex=="number"?e.lookupFromSubdomainIndex+1:1,r=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[t]}};function Vge(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"]}}var o4=function(){function n(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};lo(this,n),this.type="languageDetector",this.detectors={},this.init(e,t)}return Ao(n,[{key:"init",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=t,this.options=Uge(r,this.options||{},Vge()),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(_ge),this.addDetector(Qge),this.addDetector(Rge),this.addDetector(Mge),this.addDetector(Tge),this.addDetector(Nge),this.addDetector(Dge),this.addDetector(kge)}},{key:"addDetector",value:function(t){this.detectors[t.name]=t}},{key:"detect",value:function(t){var r=this;t||(t=this.options.order);var i=[];return t.forEach(function(s){if(r.detectors[s]){var o=r.detectors[s].lookup(r.options);o&&typeof o=="string"&&(o=[o]),o&&(i=i.concat(o))}}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(t,r){var i=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||r.forEach(function(s){i.detectors[s]&&i.detectors[s].cacheUserLanguage(t,i.options)}))}}]),n}();o4.type="languageDetector";const Lge={translation:{pageTitles:{chooseClass:"Choose Character Class",chooseAppearance:"Choose Appearance",createBio:"Create Bio",saveCharacter:"Save Your Character",chat:"Chat With Your Character"},classes:{beastPainter:{name:"Beast Painter",description:"Paints beasts"},engineer:{name:"Engineer",description:"Builds things"},dropHunter:{name:"Drop Hunter",description:"Hunts drops"},theDegen:{name:"The Degen",description:"Degens"},neuralHacker:{name:"Neural Hacker",description:"Hacks neural networks"},liskWitch:{name:"Lisk Witch",description:"Witches lisk"},bruiser:{name:"Bruiser",description:"Bruises things"}},callToAction:{next:"Next",back:"Back",randomize:"Randomize",chat:"Chat",send:"Send"},editor:{title:"Appearance",head:"Head",body:"Body",eyes:"Eyes",outer:"Outer",chest:"Chest",legs:"Legs",feet:"Feet",accessories:"Accessories"},labels:{name:"Name",voice:"Voice",favoriteColor:"Favorite Color",preferredGreeting:"Preferred Greeting",bio:"Bio",question:"Question",yourName:"Your Name",conversation:"Conversation"},text:{unoptimized:"Unoptimized",apiUnderMaintnance:"Voice generation API is temporarily disabled for maintenance!"}}},Pge={translation:{pageTitles:{chooseClass:"Выбрать Класс Персонажа",chooseAppearance:"Выбрать Внешность",createBio:"Создать Биографию",saveCharacter:"Сохранить Персонажа",chat:"Общаться Со Своим Персонажем"},classes:{beastPainter:{name:"Анималист",description:"Рисует зверей"},engineer:{name:"Инженер",description:"Строит вещи"},dropHunter:{name:"Охотник за дропами",description:"Охотится на дропы"},theDegen:{name:"Деген",description:"Дегены"},neuralHacker:{name:"Нейронный Хакер",description:"Взламывает нейр. сети"},liskWitch:{name:"Лиск Ведьма",description:"Лиск Ведьмы"},bruiser:{name:"Громила",description:"Громит вещи"}},callToAction:{next:"Далее",back:"Назад",randomize:"Рандомизировать",chat:"Чат",send:"Отправить"},editor:{title:"Внешность",head:"Голова",body:"Тело",eyes:"Глаза",outer:"Внешний",chest:"Грудь",legs:"Ноги",feet:"Стопы",accessories:"Аксессуары"},labels:{name:"Имя",voice:"Голос",favoriteColor:"Любимый Цвет",preferredGreeting:"Предпочитаемое Приветствие",bio:"Биография",question:"Вопрос",yourName:"Ваше Имя",conversation:"Разговор"},text:{unoptimized:"Неоптимизи­рованный",apiUnderMaintnance:"API генерации голоса временно отключен на техническое обслуживание."}}},Wge={translation:{pageTitles:{chooseClass:"选择角色类型",chooseAppearance:"选择外观",createBio:"创建简介",saveCharacter:"保存角色",chat:"与你的角色聊天"},classes:{beastPainter:{name:"野兽画家",description:"画野兽"},engineer:{name:"工程师",description:"建造物品"},dropHunter:{name:"投放猎手",description:"猎取投放品"},theDegen:{name:"豪赌家",description:"资深赌徒"},neuralHacker:{name:"神经黑客",description:"侵入神经网络"},liskWitch:{name:"Lisk 巫师",description:"施法于 Lisk"},bruiser:{name:"碾压者",description:"碾碎一切"}},callToAction:{next:"下一步",back:"返回",randomize:"随机",chat:"聊天",send:"发送"},editor:{title:"外观",head:"头部",body:"身体",eyes:"眼睛",outer:"外套",chest:"上身",legs:"腿部",feet:"脚部",accessories:"配件"},labels:{name:"名字",voice:"语音",favoriteColor:"颜色偏好",preferredGreeting:"首选问候语",bio:"简介",question:"问题",yourName:"你的名字",conversation:"对话"},text:{unoptimized:"未优化",apiUnderMaintnance:"语音生成API暂时关闭进行维护!"}}},Oge={en:Lge,ru:Pge,zh:Wge};ri.use(o4).use(Bge).init({debug:!0,fallbackLng:"en",interpolation:{escapeValue:!1},resources:Oge});const bs=me.createContext(),Gge=n=>{const{t:e}=i4();return P.jsx(bs.Provider,{value:{t:e},children:n.children})},Zge=` + `})}}const Jw=4096,Zp=new z;class bhe{constructor(e,t,r){const i=new c0({preserveDrawingBuffer:!0,antialias:!1,alpha:!0});this.pixelSize=r,this.domElement=i.domElement;const s=new We(Jw,Jw);i.setClearColor(0,0),i.outputEncoding=ps,i.setSize(s.x,s.y),i.setPixelRatio(window.devicePixelRatio);let o=s.clone().divideScalar(r);o.x|=0,o.y|=0;const a=new yhe(i);a.addPass(new Bhe(e,t)),this._renderPixelPass=new whe(o,e,t),this._pixelPass=new Che(o),a.addPass(this._renderPixelPass),a.addPass(this._pixelPass),this.renderer=i,this.composer=a}setSize(e,t){let i=new We(e,t).clone().divideScalar(this.pixelSize);i.x|=0,i.y|=0,this.renderer.setSize(e,t),this._renderPixelPass.setResolution(i),this._pixelPass.setResolution(i)}setPixelSize(e){this.pixelSize=e}render(){this.composer.render()}}class xhe{constructor(e,t){this.renderer=new c0({preserveDrawingBuffer:!0,antialias:!0,alpha:!0}),this.renderer.setClearAlpha(0),this.renderer.premultipliedAlpha=!1,this.scene=t,this.characterManager=e,this.renderer.outputEncoding=ht,this.renderer.setSize(Jw,Jw),this.camera=new Mr(30,1,.1,1e3),this.textureLoader=new Nu,this.sceneBackground=new Re(.1,.1,.1),this.sceneBackgroundAlpha=1,this.frameOffset={min:.2,max:.2},this.usesBackgroundImage=!1,this.backgroundMaterial=new Qi({color:16777215,transparent:!0,opacity:.5});const r=new Ru(1e3,1e3),i=new In(r,this.backgroundMaterial);i.renderOrder=-1,this.backgroundPlane=i,this.pixelRenderer=new bhe(t,this.camera,20),this.boneOffsets={head:null,chest:null,hips:null,leftUpperLeg:null,leftFoot:null,rightUpperLeg:null,rightFoot:null}}setScene(e){this.scene=e}setupCamera(e,t,r=30){this.camera.position.copy(e),this.camera.lookAt(t),this.camera.fov=r}_getCharacterMinMax(){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY;return this.characterManager.characterModel.traverse(r=>{r.geometry&&(r.geometry.computeBoundingBox(),r.geometry.boundingBox&&(r.geometry.boundingBox.applyMatrix4(r.matrixWorld),r.geometry.boundingBox.min.yt&&(t=r.geometry.boundingBox.max.y)))}),{minY:e,maxY:t}}frameCloseupShot(){this.frameShot("head","head")}frameMediumShot(){this.frameShot("chest","head")}frameCowboyShot(){this.frameShot("hips","head")}frameFullShot(){this.frameShot("leftFoot","head")}frameShot(e,t,r=null,i=!1,s=!0){const o=this._getBoneWorldPositionWithOffset(e,i),a=this._getBoneWorldPositionWithOffset(t,s);o.y-=this.frameOffset.max,a.y+=this.frameOffset.min,r=r||new z(0,0,0),this.positionCameraBetweenPoints(o,a,r)}setBottomFrameOffset(e){this.frameOffset.min=e}setTopFrameOffset(e){this.frameOffset.max=e}_setBonesOffset(e){for(const t in this.boneOffsets){const r=this._getMinMaxOffsetByBone(this.characterManager.characterModel,t,e);this.boneOffsets[t]=r}}_getBoneWorldPositionWithOffset(e,t){const r=this._getFirstBoneWithName(e);if(!r||!this.boneOffsets[e])return new z;const i=new z;r.getWorldPosition(i);const s=t?this.boneOffsets[e].max:this.boneOffsets[e].min;return i.y+=s.y,i}_getBoneWorldPosition(e){const t=this._getFirstBoneWithName(e);return t!=null?new z().setFromMatrixPosition(t.matrixWorld):(console.warn(`Bone with name '${e}' not found in one of the skinned meshes.`),new z(0,0,0))}_getFirstBoneWithName(e){let t=null;return this.characterManager.characterModel.traverse(r=>{if(r instanceof qA){if(!r.geometry){console.error("Invalid skinned mesh found in children.");return}const i=r.skeleton.bones.findIndex(s=>s.name===e);if(i!==-1){t=r.skeleton.bones[i];return}}}),t}setCameraFrameWithName(e,t){switch(e.toLowerCase()){case"fullshot":this.frameShot("leftFoot","head",t);break;case"cowboyshot":this.frameShot("hips","head",t);break;case"mediumshot":this.frameShot("chest","head",t);break;case"mediumcloseup":case"mediumcloseupshot":this.frameShot("chest","head",t,!0);break;case"closeup":case"closeupshot":this.frameShot("head","head",t);break;default:console.warn("unkown cameraFrame: "+e+". Please use fullShot, cowboyShot, mediumShot, mediumCloseup or closeup"),this.frameShot("leftFoot","head",t);break}}_getMinMaxOffsetByBone(e,t,r){if(!e||!e.traverse)return console.error("Invalid parent object provided."),null;const i=new z(1/0,1/0,1/0),s=new z(-1/0,-1/0,-1/0);return e.traverse(async o=>{if(o instanceof qA){const a=this._saveBonesPos(o.skeleton),l=d=>new Promise(h=>setTimeout(h,d));if(o.skeleton.pose(),await l(10),!o.geometry){console.error("Invalid skinned mesh found in children.");return}const A=o.skeleton.bones.findIndex(d=>d.name===t);if(A===-1){console.error(`Bone with name '${t}' not found in one of the skinned meshes.`);return}const c=o.geometry.getAttribute("position"),u=o.geometry.getAttribute("skinWeight"),f=o.geometry.getAttribute("skinIndex");for(let d=0;d=r){const g=o.skeleton.bones[A],v=new z().setFromMatrixPosition(g.matrixWorld),y=h.clone().sub(v);i.min(y),s.max(y)}}this._restoreSavedPose(a,o.skeleton)}}),{min:i,max:s}}_saveBonesPos(e){let t=[];return e.bones.forEach(r=>{t.push({position:r.position.clone(),rotation:r.rotation.clone(),scale:r.scale.clone()})}),t}_restoreSavedPose(e,t){e&&t.bones.forEach((r,i)=>{r.position.copy(e[i].position),r.rotation.copy(e[i].rotation),r.scale.copy(e[i].scale)})}positionCameraBetweenPoints(e,t,r,i=30){const s=new ws;s.expandByPoint(e),s.expandByPoint(t),this.camera.fov=i;const o=this.camera.fov*(Math.PI/180),l=s.getSize(new z).length()/(2*Math.tan(o/2));s.getCenter(Zp),this.camera.position.copy(Zp),r.y*=.5,this.camera.lookAt(Zp.clone().sub(r));const A=new z;this.camera.getWorldDirection(A),this.camera.position.addScaledVector(A,-l),this.camera.updateProjectionMatrix()}setCamera(e,t,r=30){this.camera.position.copy(e),this.camera.fov=r,Zp.set(0,0,-1),this.cameraDir=Zp.applyQuaternion(this.camera.quaternion),this.cameraDir.normalize(),this.camera.position.x-=this.cameraDir.x*t,this.camera.position.z-=this.cameraDir.z*t}setBackground(e){if(Array.isArray(e)){const t=e[3]==null?1:e[3];this.setBackgroundColor(e[0],e[1],e[2],t)}else this.setBackgroundImage(e)}setBackgroundColor(e,t,r,i){const s=new Re(e,t,r,i);this.sceneBackground=s,i==null&&(i=1),i>1&&(i=1),i<0&&(i=0),this.sceneBackgroundAlpha=i,this.backgroundMaterial.color=s,this.usesBackgroundImage=!1}setBackgroundImage(e){return new Promise(async(t,r)=>{try{const i=await this.texureLoader.load(e);i&&(i.wrapS=i.wrapT=hs,this.sceneBackground=i,this.usesBackgroundImage=!0,this.sceneBackgroundAlpha=1,t())}catch(i){console.error("Error loading background image: ",i),r(i)}})}_setBackground(){if(this.usesBackgroundImage==!1&&this.sceneBackgroundAlpha!=1)if(this.sceneBackgroundAlpha==0)this.scene.background=null;else{this.scene.background=null,this.scene.add(this.backgroundPlane),this.backgroundPlane.position.copy(this.camera.position);var e=new z(0,0,-1);e.applyQuaternion(this.camera.quaternion);var t=100;this.backgroundPlane.position.addScaledVector(e,t),this.backgroundPlane.lookAt(this.camera.position)}else this.scene.background=this.sceneBackground}_restoreBackground(){this.scene.background=null,this.usesBackgroundImage==!1&&this.sceneBackgroundAlpha!=1&&this.scene.remove(this.backgroundPlane)}_createImage(e,t,r=!1){const i=e/t;this.renderer.setSize(e,t);const s="image/png";this.camera.aspect=i,this.camera.updateProjectionMatrix();const o=r?this.pixelRenderer:this.renderer;try{this._setBackground(),o.render(this.scene,this.camera);let a=o.domElement.toDataURL(s);return this._restoreBackground(),a}catch(a){return console.error(a),null}}savePixelScreenshot(e,t,r,i){this.pixelRenderer.setPixelSize(i),this.pixelRenderer.setSize(t,r);const s=this._createImage(t,r,!0),o="image/octet-stream",a="image/png";this.saveFile(s.replace(a,o),e+".png")}saveScreenshot(e,t,r){const i=this._createImage(t,r),s="image/octet-stream",o="image/png";this.saveFile(i.replace(o,s),e+".png")}getScreenshotImage(e,t){const r=this._createImage(e,t),i=new Image;return i.src=r,i}getScreenshotTexture(e,t){const r=this.getScreenshotImage(e,t),i=new ir(r);return i.needsUpdate=!0,i}getScreenshotBlob(e,t){const r=this._createImage(e,t),i=hJ.Buffer.from(r.replace(/^data:image\/\w+;base64,/,""),"base64");return new Blob([i],{type:"image/jpeg"})}saveFile(e,t){const r=document.createElement("a");typeof r.download=="string"?(document.body.appendChild(r),r.download=t,r.href=e,r.click(),document.body.removeChild(r)):window.open(e,"_blank").document.write(""+t+"")}}const Ihe=2;class Fhe{constructor(e=.5,t=.5,r=1,i=5){this.vrmBlinkers=[],this.mode="ready",this.clock=new xZ,this.closeTime=e,this.openTime=t,this.continuity=r,this.randomness=i,this._eyeOpen=1,this._blinkCounter=0,this.isTakingScreenShot=!1,this.update()}addVRM(e){this.vrmBlinkers.push(e)}removeVRM(e){const t=this.vrmBlinkers.indexOf(e);t!==-1&&this.vrmBlinkers.splice(t,1)}enableScreenshot(){this.isTakingScreenShot=!0,this._eyeOpen=Ihe,this._updateBlinkers()}disableScreenshot(){this.isTakingScreenShot=!1}update(){setInterval(()=>{if(this.isTakingScreenShot)return;const e=this.clock.getDelta();switch(this.mode){case"closing":this._eyeOpen>0?this._eyeOpen-=e/this.closeTime:(this._eyeOpen=0,this.mode="open"),this._updateBlinkers();break;case"open":this._eyeOpen<1?this._eyeOpen+=e/this.openTime:(this._eyeOpen=1,this.mode="ready"),this._updateBlinkers();break;case"ready":this._blinkCounter+=e,this._blinkCounter>=this.continuity&&(Math.floor(Math.random()*this.randomness)===0&&(this.mode="closing"),this._blinkCounter=0);break}},1e3/30)}_updateBlinkers(){this.vrmBlinkers.forEach(e=>{e.expressionManager.setValue(ci.Blink,1-this._eyeOpen),e.expressionManager.update()})}}var Nn;(function(n){n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.LINEAR=9729]="LINEAR",n[n.REPEAT=10497]="REPEAT"})(Nn||(Nn={}));const sU="blend_",Fk="vrmColliderSphere";function Ehe(n){return{title:n.name,version:"v0",author:n.authors[0]||"",contactInformation:n.contactInformation,allowedUserName:n.allowedUserName,violentUssageName:n.allowExcessivelyViolentUsage?"Allow":"Disallow",sexualUssageName:n.allowExcessivelySexualUsage?"Allow":"Disallow",commercialUssageName:"Disallow"}}function Uhe(n){const e=[];for(const t in n.humanBones)e.push({bone:t,node:n.humanBones[t].node});return{humanBones:e}}function She(n){switch(n){case"happy":return"joy";case"sad":return"sorrow";case"relaxed":return"fun";case"aa":return"a";case"ih":return"i";case"ou":return"u";case"ee":return"e";case"oh":return"o";default:return n}}function _he(n){if(n.includes("Thumb")){if(n.includes("Metacarpal"))return n.replace("Metacarpal","Proximal");if(n.includes("Proximal"))return n.replace("Proximal","Intermediate")}return n}class Qhe{parse(e,t,r,i,s,o,a){var Xe;const l=Ehe(e.meta),A=Uhe(e.humanoid),c=e.materials,u=[],f={generator:"UniGLTF-2.0.0",version:"2.0"};if(t)if(A)if(l){if(!c)throw new Error("materials is undefined or null")}else throw new Error("meta is undefined or null");else throw new Error("humanoid is undefined or null");else throw new Error("avatar is undefined or null");const d=c.filter((G,J,se)=>se.findIndex(fe=>fe.name===G.name.replace(" (Outline)",""))===J).map(G=>G),h=d.map(G=>G.name),p=r?{name:"icon",imageBitmap:r.image}:null,m=d.filter(G=>G.map).map(G=>{if(!G.map)throw new Error(G.name+" map is null");return{name:G.name,imageBitmap:G.map.image}}),g=d.filter(G=>G.userData.shadeTexture).map(G=>{if(!G.userData.shadeTexture)throw new Error(G.userData.shadeTexture+" map is null");return{name:G.name+"_shade",imageBitmap:G.userData.shadeTexture.image}}),v=d.filter(G=>G.roughnessMap).map(G=>G.roughnessMap?{name:G.name+"_orm",imageBitmap:G.roughnessMap.image}:null),y=d.filter(G=>G.roughnessMap).map(G=>G.normalMap?{name:G.name+"_normal",imageBitmap:G.normalMap.image}:null),w=[...m,...g,...v,...y].filter(G=>G!==null),C=Dhe(w,p),b=khe(C),E=Vhe(C),x=Nhe(d,w),S=t.children.filter(G=>G.children.length>0&&G.children[0].type===fi.Bone)[0],M=PH(S).filter(G=>G.name!==Fk),Z=M.map(G=>G.name),K=M.map(G=>({children:G.children.filter(J=>J.name!==Fk).map(J=>Z.indexOf(J.name)),name:G.name,rotation:[G.quaternion.x,G.quaternion.y,G.quaternion.z,G.quaternion.w],scale:[G.scale.x,G.scale.y,G.scale.z],translation:[G.position.x,G.position.y,G.position.z]})),_=[],B=t.children.filter(G=>G.type===fi.Group||G.type===fi.SkinnedMesh),F=[];B.forEach(G=>{const J=G.type===fi.Group?G.children[0]:G,se=J.geometry.attributes,fe=new aA(se.position,Nn.FLOAT,Lt.POSITION,ra.VEC3,J.name,void 0);F.push(fe);const ve=F.length-1,W=new aA(se.normal,Nn.FLOAT,Lt.NORMAL,ra.VEC3,J.name,void 0);F.push(W),F.push(new aA(se.uv,Nn.FLOAT,Lt.UV,ra.VEC2,J.name,void 0)),F.push(new aA(se.skinWeight,Nn.FLOAT,Lt.SKIN_WEIGHT,ra.VEC4,J.name,void 0)),F.push(new aA(se.skinIndex,Nn.UNSIGNED_SHORT,Lt.SKIN_INDEX,ra.VEC4,J.name,void 0)),(G.type===fi.Group?G.children.map(D=>D):[G]).forEach(D=>{if(!D.geometry.index)throw new Error(D.name+" geometry.index is null");F.push(new aA(D.geometry.index,Nn.UNSIGNED_INT,Lt.INDEX,ra.SCALAR,J.name,D.name))}),J.morphTargetDictionary||(J.morphTargetDictionary={},J.morphTargetInfluences=[],J.geometry.morphAttributes={},J.updateMorphTargets()),J.geometry.userData.targetNames=[],console.warn("taking only mesh 0 for morph targets now, take the correct mesh");for(const D in e.expressionManager.expressionMap){const $=e.expressionManager.expressionMap[D],ee=$._binds.map(te=>({mesh:0,index:te.index,weight:te.weight*100}));if(ee.length>0){let te=!1;for(const we in ci)if(D===ci[we]&&D!=="surprised"){u.push({name:D,presetName:She(D),binds:ee,isBinary:$.isBinary}),te=!0;break}te===!1&&u.push({name:D,presetName:"unknown",binds:ee,isBinary:$.isBinary})}}const I=(D,$,ee,te)=>{const we=[],Ce=[];for(let Ee=0;Ee0){const Ve=we.length%4,_e=Ve===0?0:4-Ve;if(_e>0)for(let ye=0;ye<_e;ye++)we.push(0),Ce.push(0,0,0);const re={targetMeshDataIndex:ve,count:we.length,indices:new Uint32Array(we),values:new Float32Array(Ce)};F.push(new aA(te,Nn.FLOAT,ee,ra.VEC3,J.name,sU+$,re))}};for(const D in J.morphTargetDictionary){J.geometry.userData.targetNames.push(D);const $=J.morphTargetDictionary[D],ee=J.geometry.morphAttributes;I(ee.position[$].array,D,Lt.BLEND_POSITION,se.position),ee.normal&&I(ee.normal[$].array,D,Lt.BLEND_NORMAL,se.normal)}}),B.forEach(G=>{const J=G.type===fi.Group?G.children[0]:G,se=new Float32Array(J.skeleton.boneInverses.map(fe=>fe.elements).flat());F.push(new aA(new At(se,16),Nn.FLOAT,Lt.BIND_MATRIX,ra.MAT4,J.name,J.name))}),_.push(...F.map(G=>({byteOffset:0,componentType:G.valueType,count:G.attribute.count,max:G.max,min:G.min,normalized:!1,type:G.accessorsType})));const R=Mhe(B,F,h);B.forEach((G,J)=>{K.push({mesh:J,name:G.name,rotation:[G.quaternion.x,G.quaternion.y,G.quaternion.z,G.quaternion.w],scale:[G.scale.x,G.scale.y,G.scale.z],skin:J,translation:[G.position.x,G.position.y,G.position.z]})});const k=The(B,F,Z),T={humanBones:[]};A.humanBones.forEach(G=>{Z.indexOf(G.node.name)!=-1&&T.humanBones.push({bone:_he(G.bone),node:Z.indexOf(G.node.name),useDefaultValues:!0})});const V={floatProperties:{_DstBlend:.5,_ShadeShift:.5,_ShadeToony:.5,_ShadingGradeRate:.5},keywordMap:{_NORMALMAP:!1,MTOON_OUTLINE_COLOR_FIXED:!0,MTOON_OUTLINE_WIDTH_WORLD:!0},name:"VRMCombinedMat",renderQueue:2e3,shader:"VRM/MToon",tagMap:{RenderType:"Opaque"},textureProperties:{_MainTex:0,_ShadeTexture:0},vectorProperties:{_Color:[1,1,1,1],_EmissionColor:[0,0,0,1],_EmissionMap:[0,0,1,1],_MainTex:[0,0,1,1],_OutlineColor:[0,0,0,1],_OutlineWidthTexture:[0,0,1,1],_ReceiveShadowTexture:[0,0,1,1],_RimColor:[0,0,0,1],_RimTexture:[0,0,1,1],_ShadeColor:[.9,.9,.9,1]}},O={name:"STDCombinedMat",shader:"VRM_USE_GLTFSHADER"},L=[];d.forEach(G=>{G.type=="ShaderMaterial"?L.push(L.push(Object.assign({},V))):L.push(L.push(Object.assign({},O)))});const U=l;i.forEach(G=>{for(let J=0;JG.isSkinnedMesh))==null?void 0:Xe.skeleton)||null;for(let G=0;G{const ve=fe.sphere;se.colliders.push({radius:ve.radius*o,offset:{x:ve.offset[0]*o,y:ve.offset[1]*o,z:ve.offset[2]*o}})}),H.push(se)}}console.log("COLLIDER GROUPS",H);const N=G=>{for(let J=0;J{const J=N(G);if(J==-1)return[-1];{const se=[];return M[J].traverse(ve=>{ve.isBone&&se.push(N(ve.name))}),se}},oe=[];i.forEach(G=>{var W;const J=j(G.name),se=[];if(G.colliderGroups.forEach(Q=>{const I=Q.colliders[0];if(I!=null){const D=I.parent,$=H.findIndex(ee=>ee.name===D.name);$!=-1?se.push($):console.warn("No collider group for bone name: ",D.name+" was found")}else console.log("No colliders definition were present in vrm file file for: ",G.name+" spring bones")}),J===[-1]){console.warn("No bone found for spring bone "+G.name);return}let fe=N((W=G.center)==null?void 0:W.name);fe==-1&&console.warn("no center bone for spring bone "+G.name);const ve=G.settings;oe.push({bones:J,center:fe,colliderGroups:se,dragForce:ve.dragForce,gravityDir:{x:ve.gravityDir.x,y:ve.gravityDir.y,z:ve.gravityDir.z},gravityPower:ve.gravityPower,hitRadius:ve.hitRadius,stiffiness:ve.stiffness})});const ie={boneGroups:oe,colliderGroups:H};console.log(ie),U.texture=p?C.length-1:void 0;const de=[];de.push(...w.map(G=>({buffer:Ek(G.imageBitmap),type:Lt.IMAGE}))),F.forEach((G,J)=>{G.buffer?de.push({buffer:G.buffer,typeString:"",type:G.type}):G.sparse&&(de.push({buffer:G.sparse.indices,typeString:"indices",type:G.type,count:G.sparse.count}),de.push({buffer:G.sparse.values,typeString:"values",type:G.type}))}),p&&de.push({buffer:Ek(p.imageBitmap),type:Lt.IMAGE});let X=0,ne=0,ae=0,Be=0;const pe=de.map(G=>{const J={buffer:0,byteLength:G.buffer.byteLength,byteOffset:X,target:G.type===Lt.IMAGE||G.type===Lt.BIND_MATRIX?void 0:G.type===Lt.INDEX?Nn.ELEMENT_ARRAY_BUFFER:Nn.ARRAY_BUFFER};return X+=G.buffer.byteLength,G.type===Lt.IMAGE?(C[ne++].bufferView=Be,Be++):F[ae].sparse?(_[ae].sparse==null&&(_[ae].sparse={}),G.typeString==="indices"&&(_[ae].sparse.count=G.count,_[ae].sparse[G.typeString]={bufferView:Be,byteOffset:0,componentType:Nn.UNSIGNED_INT}),G.typeString==="values"&&(_[ae].sparse[G.typeString]={bufferView:Be,byteOffset:0}),G.typeString==="values"&&ae++,Be++):(F[ae].bufferIndex=Be,_[ae].bufferView=Be,ae++,Be++),J}),Fe=Lhe(t,K);Rhe(U);const rt={accessors:_,asset:f,buffers:[{byteLength:X}],bufferViews:pe,extensions:{VRM:{blendShapeMaster:{blendShapeGroups:u},firstPerson:{firstPersonBone:44,firstPersonBoneOffset:new z,lookAtHorizontalInner:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtHorizontalOuter:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtTypeName:"Bone",lookAtVerticalDown:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtVerticalUp:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10}},materialProperties:L,humanoid:T,meta:U,secondaryAnimation:ie,specVersion:"0.0"}},extensionsUsed:["KHR_materials_unlit","KHR_texture_transform","VRM"],images:C,materials:x,meshes:R,nodes:K,samplers:b,scenes:Fe,skins:k,textures:E};console.log(rt);const Oe=new Uk(aU(JSON.stringify(rt,void 0,2)),"JSON"),ke=new Uk(xg(de.map(G=>G.buffer)),"BIN\0"),Qe=xg([Oe.buffer,ke.buffer]),Ge=xg([aU("glTF"),oU(2,4),oU(Qe.byteLength+12,4)]);a(xg([Ge,Qe]))}}function Rhe(n){n.title=n.title||"Character",n.version=n.version||"1",n.author=n.author||"Anon",n.contactInformation=n.contactInformation||"",n.reference=n.reference||"",n.allowedUserName=n.allowedUserName||"Everyone",n.violentUssageName=n.violentUssageName||"Disallow",n.sexualUssageName=n.sexualUssageName||"Disallow",n.commercialUssageName=n.commercialUssageName||"Disallow",n.otherPermissionUrl=n.otherPermissionUrl||"",n.licenseName=n.licenseName||"Redistribution_Prohibited",n.otherLicenseUrl=n.otherLicenseUrl||""}function PH(n){return n.children.length<=0?[n]:[n].concat(n.children.map(e=>PH(e)).flat())}function Ek(n){const e=document.createElement("canvas");e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0);const t=e.toDataURL("image/png"),r=atob(t.split(",")[1]),i=(4-r.length%4)%4,s=new ArrayBuffer(r.length+i),o=new DataView(s);for(let a=0;a4?A=r[a*n.itemSize+l]:l===0?A=n.getX(a):l===1?A=n.getY(a):l===2?A=n.getZ(a):A=n.getW(a),e===Nn.UNSIGNED_SHORT?o.setUint16(i,A,!0):e===Nn.UNSIGNED_INT?o.setUint32(i,A,!0):o.setFloat32(i,A,!0),i+=t}return s}class Uk{constructor(e,t){this.data=e,this.type=t;const r=this.data;this.buffer=xg([oU(r.byteLength,4),aU(this.type),r])}paddingBinary(e,t){const r=Math.ceil(e.byteLength/4)*4;if(e.byteLength===r)return e;const i=new Uint8Array(r);i.set(new Uint8Array(e),0);for(let s=e.byteLength;sp%3===0)),Math.max.apply(null,Array.from(A).filter((h,p)=>p%3===1)),Math.max.apply(null,Array.from(A).filter((h,p)=>p%3===2))]:void 0,this.min=r===Lt.POSITION||r===Lt.BLEND_POSITION?[Math.min.apply(null,Array.from(A).filter((h,p)=>p%3===0)),Math.min.apply(null,Array.from(A).filter((h,p)=>p%3===1)),Math.min.apply(null,Array.from(A).filter((h,p)=>p%3===2))]:void 0}else this.buffer=p1(this.attribute,this.valueType),this.max=r===Lt.POSITION||r===Lt.BLEND_POSITION?[Math.max.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===0)),Math.max.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===1)),Math.max.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===2))]:void 0,this.min=r===Lt.POSITION||r===Lt.BLEND_POSITION?[Math.min.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===0)),Math.min.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===1)),Math.min.apply(null,Array.from(this.attribute.array).filter((l,A)=>A%3===2))]:void 0}}var Fd;(function(n){n.MeshBasicMaterial="MeshBasicMaterial",n.MeshStandardMaterial="MeshStandardMaterial",n.MToonMaterial="MToonMaterial"})(Fd||(Fd={}));var ra;(function(n){n.SCALAR="SCALAR",n.VEC2="VEC2",n.VEC3="VEC3",n.VEC4="VEC4",n.MAT4="MAT4"})(ra||(ra={}));var Lt;(function(n){n.POSITION="POSITION",n.NORMAL="NORMAL",n.UV="UV",n.INDEX="INDEX",n.SKIN_WEIGHT="SKIN_WEIGHT",n.SKIN_INDEX="SKIN_INDEX",n.BLEND_POSITION="BLEND_POSITION",n.BLEND_NORMAL="BLEND_NORMAL",n.BIND_MATRIX="BIND_MATRIX",n.IMAGE="IMAGE"})(Lt||(Lt={}));var fi;(function(n){n.Group="Group",n.SkinnedMesh="SkinnedMesh",n.Object3D="Object3D",n.Bone="Bone"})(fi||(fi={}));const Mhe=(n,e,t)=>n.map(r=>{const i=r.type===fi.Group?r.children[0]:r,s=r.type===fi.Group?r.children.map(o=>o):[r];return{name:r.name,primitives:s.map(o=>{const a=e.map(A=>A.meshName===i.name?A.type:null),l=Array.isArray(o.material)?o.material[0].name:o.material.name;return{attributes:{JOINTS_0:a.indexOf(Lt.SKIN_INDEX),NORMAL:a.indexOf(Lt.NORMAL),POSITION:a.indexOf(Lt.POSITION),TEXCOORD_0:a.indexOf(Lt.UV),WEIGHTS_0:a.indexOf(Lt.SKIN_WEIGHT)},extras:{targetNames:o.geometry.userData.targetNames},indices:e.map(A=>A.type===Lt.INDEX&&A.meshName===i.name?A.name:null).indexOf(o.name),material:t.indexOf(l),mode:4,targets:i.geometry.userData.targetNames?i.geometry.userData.targetNames.map(A=>{const c=e.map(d=>d.type===Lt.BLEND_NORMAL&&d.meshName===i.name?d.name:null).indexOf(sU+A),u=e.map(d=>d.type===Lt.BLEND_POSITION&&d.meshName===i.name?d.name:null).indexOf(sU+A),f={};return u!==-1&&(f.POSITION=u),c!==-1&&(f.NORMAL=c),f}):void 0}})}}),The=(n,e,t)=>n.map(r=>{const i=r.type===fi.Group?r.children[0]:r;return{inverseBindMatrices:e.map(s=>s.type===Lt.BIND_MATRIX?s.meshName:null).indexOf(i.name),joints:i.skeleton.bones.map(s=>t.indexOf(s.name)).filter(s=>s!==-1),skeleton:t.indexOf(i.skeleton.bones[0].name)}}),Nhe=(n,e)=>n.map(t=>{let r,i=null;if(t=t.userData.vrmMaterial?t.userData.vrmMaterial:t,t.type==="ShaderMaterial")i={},i.shadeMultiplyTexture={index:e.map(h=>h.name).indexOf(t.uniforms.shadeMultiplyTexture.name)},r=t.color?[1,1,1,1]:void 0;else{const d=t;r=d.color?[d.color.r,d.color.g,d.color.b,1]:void 0}let s=-1;t.map?s=e.map(d=>d.name).indexOf(t.name):t.uniforms&&t.uniforms.map&&(s=e.map(d=>d.name).indexOf(t.uniforms.map.name));let o=-1;t.roughnessMap&&(o=e.map(d=>d.name).indexOf(t.name+"_orm"));let a=-1;t.normalMap&&(a=e.map(d=>d.name).indexOf(t.name+"_normal"));const l=s>=0?{extensions:{KHR_texture_transform:{offset:[0,0],scale:[1,1]}},index:s,texCoord:0}:void 0,A={baseColorFactor:r,baseColorTexture:l},c=o>=0?{index:o,texCoord:0}:void 0,u=a>=0?{index:a,texCoord:0}:void 0;if(c)A.metallicRoughnessTexture=c;else{const d=(()=>{switch(t.type){case Fd.MeshStandardMaterial:return t.metalness;case Fd.MeshBasicMaterial:return 0;default:return 0}})(),h=(()=>{switch(t.type){case Fd.MeshStandardMaterial:return t.roughness;case Fd.MeshBasicMaterial:return .9;default:return .9}})();A.metallicFactor=d,A.roughnessFactor=h}const f={alphaCutoff:t.alphaTest>0?t.alphaTest:void 0,alphaMode:t.transparent?"BLEND":t.alphaTest>0?"MASK":"OPAQUE",doubleSided:t.side===2,extensions:t.type==="ShaderMaterial"?{KHR_materials_unlit:{},VRMC_materials_mtoon:i}:void 0,name:t.name,pbrMetallicRoughness:A};return u&&(f.normalTexture=u),f}),Dhe=(n,e)=>(e?n.concat(e):n).filter(t=>t&&t.imageBitmap).map(t=>({bufferView:-1,mimeType:"image/png",name:t.name})),khe=n=>n.map(()=>({magFilter:Nn.LINEAR,minFilter:Nn.LINEAR,wrapS:Nn.REPEAT,wrapT:Nn.REPEAT})),Vhe=n=>n.map((e,t)=>({sampler:0,source:t})),Lhe=(n,e)=>{const t=e.map(r=>r.name);return[{nodes:n.children.filter(r=>r.type===fi.Object3D||r.type===fi.SkinnedMesh||r.type===fi.Group||r.type===fi.Bone).map(r=>t.indexOf(r.name))}]};function WH(){return(WH=Object.assign||function(n){for(var e=1;e0?u+s.byteLength:0;f%8&&(f+=8-f%8);let d=[],h=new DataView(new ArrayBuffer(24*n.levels.length)),p=(f||u+s.byteLength)+t.byteLength;for(let v=0;v0?f:0),!0),g.setBigUint64(60,BigInt(t.byteLength),!0),new Uint8Array(Hp([new Uint8Array(_r).buffer,m,h.buffer,a,s,new ArrayBuffer(f>0?f-(u+s.byteLength):0),t,...d]))}var AU,cU,Hhe={enableDebug:!1,isUASTC:!0,isKTX2File:!0,isInputSRGB:!0,generateMipmap:!0,needSupercompression:!0,isSetKTX2SRGBTransferFunc:!0},uU=new OffscreenCanvas(128,128),Rk=uU.getContext("2d",{willReadFrequently:!0}),OH=typeof document>"u";function zhe(n){return createImageBitmap(n).then(function(e){return uU.width=e.width,uU.height=e.height,Rk.drawImage(e,0,0),Rk.getImageData(0,0,e.width,e.height)})}function GH(n,e){return e===void 0&&(e={}),Xhe().then(function(t){var r=new t.BasisEncoder;return Yhe(e,r),r.setTexType(AU.cBASISTexType2D),Whe(n,ArrayBuffer)&&(n=new Blob([n])),zhe(n).then(function(i){r.setSliceSourceImage(0,new Uint8Array(i.data),i.width,i.height,cU.RAW);var s=new Uint8Array(10485760),o=r.encode(s);if(o===0)throw"encode failed";var a=new Uint8Array(s.buffer,0,o),l=Ghe(s);if(e.kvData){for(var A in e.kvData)l.keyValue[A]=e.kvData[A];a=Jhe(l,{keepWriter:!0})}return a})})}function Yhe(n,e){n===void 0&&(n={}),(n=Phe({},Hhe,n)).enableDebug!==void 0&&e.setDebug(n.enableDebug),n.isUASTC!==void 0&&e.setUASTC(n.isUASTC),n.isKTX2File!==void 0&&e.setCreateKTX2File(n.isKTX2File),n.isSetKTX2SRGBTransferFunc!==void 0&&e.setKTX2SRGBTransferFunc(n.isSetKTX2SRGBTransferFunc),n.generateMipmap!==void 0&&e.setMipGen(n.generateMipmap),n.isYFlip!==void 0&&e.setYFlip(n.isYFlip),n.qualityLevel!==void 0&&e.setQualityLevel(n.qualityLevel),n.compressionLevel!==void 0&&e.setCompressionLevel(n.compressionLevel),n.needSupercompression!==void 0&&e.setKTX2UASTCSupercompression(n.needSupercompression),n.isNormalMap!==void 0&&e.setNormalMap(n.isNormalMap)}var g1=null;function Xhe(){return g1||(g1=new Promise(function(n,e){OH?(importScripts("https://mdn.alipayobjects.com/rms/afts/file/A*SrRkQarYYl4AAAAAAAAAAAAAARQnAQ/basis_encoder.js"),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qFWbTrA0hZYAAAAAAAAAAAAAARQnAQ/basis_encoder.wasm").then(function(t){return t.arrayBuffer()}).then(function(t){BASIS({wasmBinary:t}).then(function(r){r.initializeBasis(),n(r)}).catch(e)}).catch(e)):Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*SrRkQarYYl4AAAAAAAAAAAAAARQnAQ/basis_encoder.js").then(function(t){return t.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qFWbTrA0hZYAAAAAAAAAAAAAARQnAQ/basis_encoder.wasm").then(function(t){return t.arrayBuffer()})]).then(function(t){var r=t[0],i=t[1],s=document.createElement("script");s.onload=function(){BASIS({wasmBinary:i}).then(function(o){o.initializeBasis(),n(o)}).catch(e)},s.src=URL.createObjectURL(new Blob([r])),s.onerror=e,document.body.appendChild(s)}).catch(e)})),g1}OH&&self.addEventListener("message",function(n){GH(n.data).then(function(e){self.postMessage(e)}).catch(function(e){self.postMessage({error:e})})});function ZH(n){const e=n.clone(),t=[];return n.traverse(r=>{r.userData.origIndexBuffer&&t.push(r.userData.origIndexBuffer)}),e.traverse(r=>{r.userData.origIndexBuffer&&(r.userData.origIndexBuffer=t.shift())}),e}function Khe(n){const e=ZH(n);let t;const r=[];e.traverse(s=>{if(!t&&s.isSkinnedMesh&&(t=_H(s)),s.isSkinnedMesh){if(s.geometry=s.geometry.clone(),s.skeleton=t,r.push(s),Array.isArray(s.material)){const o=s.material;s.material=new mu,s.material.map=o[0].map}s.userData.origIndexBuffer&&s.geometry.setIndex(s.userData.origIndexBuffer)}});const i=new Tr;return r.forEach(s=>{i.add(s)}),i.add(t.bones[0]),i}async function jhe(n,e,t){const r=await q_(n,t),i=await JH(r,e,t);return new Blob([i],{type:"model/gltf-binary"})}function $he(n,e,t,r){return new Promise(async(i,s)=>{const o=`${t&&t!==""?t:"AvatarCreatorModel"}`;qhe(n,e,r).then(a=>{zH(a,`${o}.vrm`),i()})})}async function qhe(n,e,t){const r=await q_(n,t);return JH(r,e,t)}function q_(n,e){const t=ZH(n),{createTextureAtlas:r=!0}=e;return r?Yde(t,e):(console.log("no atlas"),Jde(t,e))}async function epe(n,e="",t){const r=`${e&&e!==""?e:"AvatarCreatorModel"}`,{optimized:i=!0}=t,s=i?await q_(n,t):Khe(n);tpe(s).then(o=>{if(o instanceof ArrayBuffer)zH(o,`${r}.glb`);else{const a=JSON.stringify(o,null,2);rpe(a,`${r}.gltf`)}})}function tpe(n){return new Promise(e=>new V_().parse(n,r=>{e(r)},r=>{console.error("Error parsing",r)},{trs:!1,onlyVisible:!1,truncateDrawRange:!0,binary:!0,forcePowerOfTwoTextures:!1,maxTextureSize:1024}))}function npe(n){var r,i;const e=[];for(const s in n)if(((i=(r=n[s])==null?void 0:r.vrm)==null?void 0:i.springBoneManager)!=null){const o=n[s].vrm.springBoneManager.joints;for(const a of o)e.some(A=>A.name===a.bone.name)||e.push({name:a.bone.name,settings:a.settings,bone:a.bone,colliderGroups:a.colliderGroups,center:a.center})}const t=[];return e.forEach(s=>{for(const o in Lm)if(s.bone.parent.name==Lm[o]){t.push(s);break}}),t}function JH(n,e,t){const{screenshot:r=null,isVrm0:i=!1,vrmMeta:s=null,scale:o=1}=t;return new Promise(async a=>{const l=i?new Qhe:new Pfe,A={...spe(e),...Ahe(n,"CharacterCreator",s)};if(t.ktxCompression){console.log("ktx compression");for(let h=0;hw.toBlob(M)),E=await GH(b),x=new Blob(E,{type:"image/ktx2"}),S=await createImageBitmap(x);A.materials[h].map.source=S}}}}let c;n.traverse(h=>{h.isSkinnedMesh&&(c=h)}),(()=>{for(let h=0;h{h.updateMatrix(),h.updateMatrixWorld()}),c.skeleton.calculateInverses(),c.skeleton.computeBoneTexture(),c.skeleton.update()})(),c.skeleton.bones.filter(h=>h.name==="head")[0];const f=npe(e),d=[];l.parse(A,n,r,f,d,o,h=>{a(h)})})}function HH(n,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),t.href=URL.createObjectURL(n),t.download=e,t.click()}function rpe(n,e){HH(new Blob([n],{type:"text/plain"}),e)}function zH(n,e){HH(ipe(n),e)}function ipe(n){return new Blob([n],{type:"application/octet-stream"})}function spe(n){for(const e in n)if(n[e].vrm)return n[e].vrm}const ope=n=>{var e,t;(e=n.parser.json.extensions)!=null&&e.VRM?ape(n):(t=n.parser.json.extensions)!=null&&t.VRMC_vrm?lpe(n):console.warn("No valid vrm file was provided")},ape=n=>{var a,l,A;const e=n.parser.json,t=n.scene,r=e.nodes,i=(A=(l=(a=e.extensions)==null?void 0:a.VRM)==null?void 0:l.secondaryAnimation)==null?void 0:A.colliderGroups,s=[],o=r.map(c=>YH(c.name,s));i!=null&&i.forEach(c=>{const u=o[c.node],f=DH(t,u);if(f!=null){const d=c.colliders;f.userData.VRMcolliders=d.map(h=>({sphere:{radius:h.radius,offset:[h.offset.x,h.offset.y,h.offset.z]}}))}})},lpe=n=>{var l,A,c,u;const e=n.parser.json,t=n.scene,r=e.nodes,i=(A=(l=e.extensions)==null?void 0:l.VRMC_springBone)==null?void 0:A.colliderGroups,s=(u=(c=e.extensions)==null?void 0:c.VRMC_springBone)==null?void 0:u.colliders,o=[],a=r.map(f=>YH(f.name,o));i!=null&&i.forEach(f=>{const d=Yt(f.colliders);let h=-1,p=null;d.forEach(m=>{if(h!=s[m].node){h=s[m].node;const g=a[h];p=DH(t,g),p.userData.VRMcolliders=[]}if(p!=null){const g=s[m].shape;for(const v in g){const y=g[v];y!=null&&y.offset&&(y.offset[0]=-y.offset[0])}p.userData.VRMcolliders.push(g)}else console.error("no node with name "+a[h]+" was found")})})},YH=(n,e)=>{const t=Bt.sanitizeNodeName(n||"");return t in e?t+"_"+ ++e[t]:(e[t]=0,t)},Hw=[0,400,560,2400,4800],zw=[0,500,700,3e3,6e3],fU=[],il=[],eQ=1024,XH=44100;for(let n=0;n{requestAnimationFrame(t),this.update(r,i)};t()}start(e){this.audioContext=new AudioContext,this.mediaStreamSource=this.audioContext.createMediaStreamSource(e),this.meter=Yw.createAudioMeter(this.audioContext),this.mediaStreamSource.connect(this.meter)}startFromAudioFile(e){this.audioContext||(this.audioContext=new AudioContext),this.userSpeechAnalyzer||(this.userSpeechAnalyzer=this.audioContext.createAnalyser()),this.userSpeechAnalyzer.smoothingTimeConstant=.5,this.userSpeechAnalyzer.fftSize=eQ,this.mediaStreamSource&&this.mediaStreamSource.stop(),this.audioContext.decodeAudioData(e).then(t=>{this.mediaStreamSource=this.audioContext.createBufferSource(),this.mediaStreamSource.buffer=t,this.meter=Yw.createAudioMeter(this.audioContext),this.mediaStreamSource.connect(this.meter),this.mediaStreamSource.connect(this.audioContext.destination),this.mediaStreamSource.start(),this.mediaStreamSource.connect(this.userSpeechAnalyzer)})}destroy(){var e,t,r;return(e=this.meter)==null||e.shutdown(),this.meter=null,(t=this.mediaStreamSource)==null||t.disconnect(),((r=this.audioContext)==null?void 0:r.close().catch(()=>{}))||Promise.resolve()}update(e){if(this.meter){const{volume:t}=this.meter;if(t<.01)this.vrm.expressionManager.setValue(ci.Oh,0),this.vrm.expressionManager.setValue(ci.Ah,0),this.vrm.expressionManager.setValue(ci.Ee,0);else{const{ah:r,oh:i,ee:s}=this.update2();this.vrm.expressionManager.setValue(ci.Oh,i),this.vrm.expressionManager.setValue(ci.Ah,r),this.vrm.expressionManager.setValue(ci.Ee,s),this.vrm.expressionManager.update(e)}}}update2(){function e(A){const u=new Float32Array(A.length);for(let f=0;f0&&(i[A]+=r[c]);i[A]/=il[A+1]-il[A]}for(let A=0;A0&&(s[A]+=r[c]);i[A]/=il[A+1]-il[A],s[A]=s[A]/(fU[A+1]-fU[A])}const o=Math.max(s[1],i[1])>.2?1-2*Math.max(i[2],s[2]):(1-2*Math.max(i[2],s[2]))*5*Math.max(i[1],s[1]),a=3*Math.max(i[3],s[3]),l=.8*(Math.max(i[1],s[1])-Math.max(i[3],s[3]));return{oh:o,ee:l,ah:a}}static createAudioMeter(e){const t=e.createScriptProcessor(512);return t.onaudioprocess=r=>{const i=r.inputBuffer.getChannelData(0),s=i.length;let o=0,a;for(let A=0;A=t.clipLevel&&(t.clipping=!0,t.lastClip=window.performance.now()),o+=a*a;const l=Math.sqrt(o/s);t.volume=Math.max(l,t.volume*t.averaging)},t.clipping=!1,t.lastClip=0,t.volume=0,t.clipLevel=.98,t.averaging=.95,t.clipLag=750,t.connect(e.destination),t.checkClipping=()=>t.clipping?(t.lastClip+t.clipLag{t.disconnect(),t.onaudioprocess=null},t}}const m1=new z;class Ape{constructor(e,t,r){this.bonesInfo=[],this.curMousePos=new We,this.hotzoneSection=s(),this.enabled=!1,this.userActivated=!1,this.lookInterest=1,this.hasInterest=!0,this.interestSpeed=.3,this.onCanvas=!0,this.camera=r,this.maxLookPercent={neck:{maxy:15,miny:10,maxx:30,minx:10},spine:{maxy:0,miny:0,maxx:30,minx:10},left:{maxy:15,miny:20,maxx:35,minx:35},right:{maxy:15,miny:20,maxx:35,minx:35}},window.addEventListener("mousemove",o=>{this.curMousePos={x:o.clientX,y:o.clientY}});const i=document.getElementById(t);i&&(i.addEventListener("mouseleave",()=>{this.onCanvas=!1}),i.addEventListener("mouseenter",()=>{this.onCanvas=!0})),window.addEventListener("resize",()=>{this.hotzoneSection=s()});function s(){const o=window.innerWidth*e/100,a=(window.innerWidth-o)/2;return{xStart:a,xEnd:window.innerWidth-a,yStart:50,yEnd:window.innerHeight-80}}}setActive(e){console.log("is activating"),this.userActivated=e}setCamera(e){this.camera=e}addVRM(e){const t=e.data.isVRM0||!1,r=e.humanoid.humanBones;t||(r.neck.node.userData.inverseLookAt=!0,r.spine.node.userData.inverseLookAt=!0,r.leftEye&&(r.leftEye.node.userData.inverseLookAt=!0),r.rightEye&&(r.rightEye.node.userData.inverseLookAt=!0));const i={vrm:e,neckBone:r.neck.node,spineBone:r.spine.node,leftEyeBone:r.leftEye?r.leftEye.node:null,rightEyeBone:r.rightEye?r.rightEye.node:null};this.bonesInfo.push(i)}removeVRM(e){const t=this.bonesInfo.find(r=>r.vrm===e);if(t){const r=this.bonesInfo.indexOf(t);this.bonesInfo.splice(r,1)}}_getMouseDegrees(e,t,r){let i=0,s=0,o,a,l,A,c={x:window.innerWidth,y:window.innerHeight};return e<=c.x/2&&(o=c.x/2-e,a=o/(c.x/2)*100,i=r.maxx*a/100*-1),e>=c.x/2&&(o=e-c.x/2,a=o/(c.x/2)*100,i=r.minx*a/100),t<=c.y/2&&(l=c.y/2-t,A=l/(c.y/2)*100,s=r.maxy*.5*A/100*-1),t>=c.y/2&&(l=t-c.y/2,A=l/(c.y/2)*100,s=r.miny*A/100),{x:i,y:s}}lerp(e,t,r){return(1-r)*e+r*t}_moveJoint(e,t){const r=e.userData.inverseLookAt===!0?1:-1;if(Object.keys(e).length!==0){const i=(this.camera.position.y-1.8)*window.innerHeight/2;let s=this._getMouseDegrees(this.curMousePos.x,this.curMousePos.y-i,t);const o=.8;e.rotation.y=this.lerp(Wt.degToRad(s.x),e.rotation.y,o),e.rotation.x=this.lerp(Wt.degToRad(s.y*r),e.rotation.x,o)}}update(){m1.set(0,0,1),m1.applyQuaternion(this.camera.quaternion);const e=m1.z>0;this.curMousePos.x>this.hotzoneSection.xStart&&this.curMousePos.xthis.hotzoneSection.yStart&&this.curMousePos.y{this._moveJoint(t.neckBone,this.maxLookPercent.neck),this._moveJoint(t.spineBone,this.maxLookPercent.spine),this._moveJoint(t.leftEyeBone,this.maxLookPercent.left),this._moveJoint(t.rightEyeBone,this.maxLookPercent.right)})}}class v1{constructor(e){const{assetsLocation:t,traitsDirectory:r,thumbnailsDirectory:i,traitIconsDirectorySvg:s,animationPath:o,exportScale:a,displayScale:l,initialTraits:A,requiredTraits:c,randomTraits:u,colliderTraits:f,lipSyncTraits:d,blinkerTraits:h,typeRestrictions:p,defaultCullingLayer:m,defaultCullingDistance:g,offset:v,vrmMeta:y,traits:w,textureCollections:C,colorCollections:b,canDownload:E=!0,downloadOptions:x={}}=e;this.assetsLocation=t,this.traitsDirectory=r,this.thumbnailsDirectory=i,this.traitIconsDirectorySvg=s,this.displayScale=l||a||1,this.animationPath=Yt(o),this.requiredTraits=Yt(c),this.randomTraits=Yt(u),this.initialTraits=A||[...new Set(this.requiredTraits.concat(this.randomTraits))],this.colliderTraits=Yt(f),this.lipSyncTraits=Yt(d),this.blinkerTraits=Yt(h),this.typeRestrictions=p,this.defaultCullingLayer=m,this.defaultCullingDistance=g,this.offset=v,this.canDownload=E,this.downloadOptions=x;const S=()=>{const K=[];for(const _ in w)K.push(w[_].trait);return K};this.allTraits=S(),S(),(()=>{if(this.typeRestrictions)for(const K in this.typeRestrictions)Yt(this.typeRestrictions[K]).forEach(B=>{this.typeRestrictions[B]==null&&(this.typeRestrictions[B]=[]),this.typeRestrictions[B].indexOf(K)==-1&&this.typeRestrictions[B].push(K)})})(),(()=>{x.vrmMeta=x.vrmMeta||y,x.scale=x.scale||a||1,x.mToonAtlasSize=x.mToonAtlasSize||2048,x.mToonAtlasSizeTransp=x.mToonAtlasSizeTransp||1024,x.stdAtlasSize=x.stdAtlasSize||2048,x.stdAtlasSizeTransp=x.stdAtlasSizeTransp||1024,x.exportStdAtlas=x.exportStdAtlas||!1,x.exportMtoonAtlas=x.exportMtoonAtlas||!0,x.screenshotFaceDistance=x.screenshotFaceDistance||1,x.screenshotFaceOffset=x.screenshotFaceOffset||[0,0,0],x.screenshotResolution=x.screenshotResolution||[512,512],x.screenshotBackground=x.screenshotBackground||[.1,.1,.1],x.screenshotFOV=x.screenshotFOV||75,!x.exportStdAtlas&&!x.exportMtoonAtlas&&(x.exportMtoonAtlas=!0)})(),this.textureTraits=[],this.textureTraitsMap=null,this.createTextureTraits(C),this.colorTraits=[],this.colorTraitsMap=null,this.createColorTraits(b),this.modelTraits=[],this.modelTraitsMap=null,this.createModelTraits(w)}appendManifestData(e,t){e.textureTraits.forEach(r=>{const i=this.getTextureGroup(r.trait);i!=null?i.appendCollection(r,t):(this.textureTraits.push(r),this.textureTraitsMap.set(r.trait,r))}),e.colorTraits.forEach(r=>{const i=this.getColorGroup(r.trait);i!=null?i.appendCollection(r,t):(this.colorTraits.push(r),this.colorTraitsMap.set(r.trait,r))}),e.modelTraits.forEach(r=>{const i=this.getModelGroup(r.trait);i!=null?i.appendCollection(r,t):(this.modelTraits.push(r),this.modelTraitsMap.set(r.trait,r))}),console.log(e)}getExportOptions(){return this.downloadOptions}getGroupModelTraits(){return this.modelTraits}getInitialTraits(){return this.getRandomTraits(this.initialTraits)}getAllTraits(){return this.getRandomTraits(this.allTraits)}isColliderRequired(e){return this.colliderTraits.indexOf(e)!=-1}isLipsyncTrait(e){return this.lipSyncTraits.indexOf(e)!=-1}async getNFTraitOptionsFromURL(e,t){const r=await this._fetchJson(e);return this.getNFTraitOptionsFromObject(r,t)}getNFTraitOptionsFromObject(e,t){const r=e.attributes;if(r){t=Yt(t);const i=[];return r.forEach(s=>{if(t.indexOf(s.trait_type)==-1){const o=this.getTraitOption(s.trait_type,s.value);o&&i.push(o)}}),i}else return console.warn("No attiributes parameter was found in ",e),null}getRandomTraits(e){const t=[];return(e||this.randomTraits).forEach(i=>{const s=this.getRandomTrait(i);s&&t.push(s)}),this._filterTraitOptions(t)}getRandomTrait(e){var r,i;const t=this.getModelGroup(e);if(t){const s=t.getRandomTrait();if(s){const o=(r=s.targetTextureCollection)==null?void 0:r.getRandomTrait(),a=(i=s.targetColorCollection)==null?void 0:i.getRandomTrait();return new y1(s,o,a)}else return null}else return console.warn("No trait group with name "+e+" was found."),null}async _fetchJson(e){return await(await fetch(e)).json()}getTraitOption(e,t){var i,s;const r=this.getModelTrait(e,t);if(r){const o=(i=r.targetTextureCollection)==null?void 0:i.getRandomTrait(),a=(s=r.targetColorCollection)==null?void 0:s.getRandomTrait();return new y1(r,o,a)}return null}_filterTraitOptions(e){const t=[],r=[];for(let i=0;i0&&console.log("options were filtered to fullfill restrictions: ",r),t}getCustomTraitOption(e,t){const r=this.getCustomModelTrait(e,t);return r?new y1(r,null,null):null}getCustomModelTrait(e,t){var r;return(r=this.getModelGroup(e))==null?void 0:r.getCustomTrait(t)}getModelTrait(e,t){var r;return(r=this.getModelGroup(e))==null?void 0:r.getTrait(t)}getModelTraits(e){const t=this.getModelGroup(e);return t?t.getCollection():(console.warn("No model group with name "+e),null)}getModelGroup(e){return this.modelTraitsMap.get(e)}getTextureTrait(e,t){var r;return(r=this.getTextureGroup(e))==null?void 0:r.getTrait(t)}getTextureGroup(e){return this.textureTraitsMap.get(e)}getColorTrait(e,t){var r;return(r=this.getColorGroup(e))==null?void 0:r.getTrait(t)}getColorGroup(e){return this.colorTraitsMap.get(e)}getTraitsDirectory(){let e=(this.assetsLocation||"")+(this.traitsDirectory||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getThumbnailsDirectory(){let e=(this.assetsLocation||"")+(this.thumbnailsDirectory||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getTraitIconsDirectorySvg(){let e=(this.assetsLocation||"")+(this.traitIconsDirectorySvg||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getAssetsDirectory(){let e=this.assetsLocation||"";return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}createModelTraits(e,t=!1){t&&(this.modelTraits=[]),Yt(e).forEach(r=>{this.modelTraits.push(new cpe(this,r))}),this.modelTraitsMap=new Map(this.modelTraits.map(r=>[r.trait,r])),this.modelTraits.forEach(r=>{r.restrictedTraits.forEach(i=>{const s=this.getModelGroup(i);console.log(s),s&&s.addTraitRestriction(r.trait)})})}createTextureTraits(e,t=!1){t&&(this.textureTraits=[]),Yt(e).forEach(r=>{this.textureTraits.push(new upe(this,r))}),this.textureTraitsMap=new Map(this.textureTraits.map(r=>[r.trait,r]))}createColorTraits(e,t=!1){t&&(this.colorTraits=[]),Yt(e).forEach(r=>{this.colorTraits.push(new fpe(this,r))}),this.colorTraitsMap=new Map(this.colorTraits.map(r=>[r.trait,r]))}}class cpe{constructor(e,t){const{trait:r,name:i,iconSvg:s,cameraTarget:o={distance:3,height:1},cullingDistance:a,cullingLayer:l,collection:A,restrictedTraits:c=[],restrictedTypes:u=[]}=t;this.manifestData=e,this.isRequired=e.requiredTraits.indexOf(r)!==-1,this.trait=r,this.name=i,this.iconSvg=s,this.fullIconSvg=e.getTraitIconsDirectorySvg()+s,this.restrictedTraits=c,this.restrictedTypes=u,this.cameraTarget=o,this.cullingDistance=a,this.cullingLayer=l,this.collection=[],this.collectionMap=null,this.createCollection(A)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Model with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Model with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}addTraitRestriction(e){this.restrictedTraits.indexOf(e)==-1&&this.restrictedTraits.push(e)}createCollection(e,t=!1){t&&(this.collection=[]),Yt(e).forEach(r=>{this.collection.push(new Mk(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getCustomTrait(e){return new Mk(this,{directory:e,fullDirectory:e,id:"_custom",name:"Custom"})}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}getCollection(){return this.collection}}class upe{constructor(e,t){const{trait:r,collection:i}=t;this.manifestData=e,this.trait=r,this.collection=[],this.collectionMap=null,this.createCollection(i)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Texture with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Texture with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}createCollection(e,t=!1){t&&(this.collection=[]),Yt(e).forEach(r=>{this.collection.push(new dpe(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}}class fpe{constructor(e,t){const{trait:r,collection:i}=t;this.manifestData=e,this.trait=r,this.collection=[],this.collectionMap=null,this.createCollection(i)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Color with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Color with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}createCollection(e,t=!1){t&&(this.collection=[]),Yt(e).forEach(r=>{this.collection.push(new hpe(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}}class Mk{constructor(e,t){const{id:r,directory:i,name:s,thumbnail:o,cullingDistance:a,cullingLayer:l,type:A=[],textureCollection:c,colorCollection:u,fullDirectory:f,fullThumbnail:d}=t;if(this.manifestData=e.manifestData,this.traitGroup=e,this.id=r,this.directory=i,f)this.fullDirectory=f;else if(Array.isArray(i)){this.fullDirectory=[];for(let h=0;h0&&this.manifestData.restrictedTypes>0){haveCommonValue=(i,s)=>{if(i==null||s==null)return!1;for(let o=0;ohaveCommonValue(r[i],traitTypes))}return!1}}class dpe{constructor(e,t){const{id:r,directory:i,fullDirectory:s,name:o,thumbnail:a}=t;if(this.traitGroup=e,this.id=r,this.directory=i,s)this.fullDirectory=s;else if(Array.isArray(i)){this.fullDirectory=[];for(let l=0;l{o.isSkinnedMesh&&o.skeleton.bones.filter(l=>l.name==="head")[0].getWorldPosition(el)}),el.z+=.3,el.y+=s,this.screenshotManager.setCamera(el,i),this.screenshotManager.saveScreenshot(e,t,r),this.blinkManager.disableScreenshot()}cameraRaycastCulling(e,t,r=!0){if(this.renderCamera==null){console.warn("No camera was set in character manager. Please call setRenderCamera(camera) before calling this function");return}const i=()=>{this.characterModel.traverse(A=>{A.isMesh&&A.userData.origIndexBuffer&&(A.userData.clippedIndexGeometry=A.geometry.index.clone(),A.geometry.setIndex(A.userData.origIndexBuffer))})},s=()=>{this.characterModel.traverse(A=>{A.isMesh&&A.userData.origIndexBuffer&&A.geometry.setIndex(A.userData.clippedIndexGeometry)})},o=(A,c)=>{for(let u=0;u{var p,m;const u=A.object,f=A.face,d=[f.a,f.b,f.c],h=(m=(p=u.userData)==null?void 0:p.clippedIndexGeometry)==null?void 0:m.array;if(h!=null){const g=o(h,d),v=Array.from(h);if(g==-1&&!c){const y=[...v,...d];u.userData.clippedIndexGeometry=new At(new Uint32Array(y),1,!1)}g!=1&&c&&(v.splice(g,3),u.userData.clippedIndexGeometry=new At(new Uint32Array(v),1,!1))}};B1.x=e,B1.y=t,i(),Tk.setFromCamera(B1,this.renderCamera);const l=Tk.intersectObjects(this.characterModel.children);if(l.length>0){const A=l[0];a(A,r)}s()}removeCurrentCharacter(){const e=[];for(const t in this.avatar)e.push(new mB({traitGroupID:t,traitModel:null}));e.forEach(t=>{this._addLoadedData(t)}),this.avatar={}}removeCurrentManifest(){this.removeCurrentCharacter(),this.manifest=null,this.manifestData=null,this.animationManager&&this.animationManager.clearCurrentAnimations()}canDownload(){var e;return((e=this.manifestData)==null?void 0:e.canDownload)||!0}downloadVRM(e,t=null){return new Promise(async(r,i)=>{if(this.canDownload())try{t=t||{};const o={...this.manifestData.getExportOptions(),...t};o.isVrm0=!0,o.screenshot=this._getPortaitScreenshotTexture(!1,o),console.log(o),await $he(this.characterModel,this.avatar,e,o),r()}catch(s){console.error("Error downloading VRM:",s.message),i(new Error("Failed to download VRM."))}else{const s="Download not supported.";console.error(s),i(new Error(s))}})}downloadGLB(e,t=null){if(console.log("XXX fix glb downloader"),this.canDownload()){t=t||{};const r={...this.manifestData.getExportOptions(),...t};epe(this.characterModel,e,r)}else console.error("Download not supported")}getAvatarSelection(){var t;var e={};for(const r in this.avatar)e[r]={name:this.avatar[r].name,id:(t=this.avatar[r].traitInfo)==null?void 0:t.id};return e}getGroupTraits(){if(this.manifestData)return this.manifestData.getGroupModelTraits()}getCurrentCharacterModel(){return this.characterModel}isTraitGroupRequired(e){const t=this.manifestData.getModelGroup(e);return!!(t!=null&&t.isRequired)}getTraits(e){return this.manifestData?this.manifestData.getModelTraits(e):(console.warn("No manifest file has been loaded, please load it before trait models."),null)}getCurrentTraitID(e){var t,r;return(r=(t=this.avatar[e])==null?void 0:t.traitInfo)==null?void 0:r.id}getCurrentTraitData(e){var t;return(t=this.avatar[e])==null?void 0:t.traitInfo}getCurrentTraitVRM(e){var t;return(t=this.avatar[e])==null?void 0:t.vrm}setParentModel(e){e.add(this.rootModel),this.parentModel=e,this.screenshotManager&&this.screenshotManager.setScene(this.parentModel)}setRenderCamera(e){this.renderCamera=e}loadRandomTraits(){return new Promise(async(e,t)=>{if(this.manifestData){const r=this.manifestData.getRandomTraits();await this._loadTraits(r),e()}else{const r="No manifest was loaded, random traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadRandomTrait(e){return new Promise(async(t,r)=>{if(this.manifestData){const i=this.manifestData.getRandomTrait(e);await this._loadTraits(Yt(i)),t()}else{const i="No manifest was loaded, random traits cannot be loaded.";console.error(i),r(new Error(i))}})}loadTraitsFromNFT(e,t=!0,r=null){return new Promise(async(i,s)=>{try{if(this.manifestData){const o=this.manifestData.getNFTraitOptionsFromURL(e,r);await this._loadTraits(o,t),i()}else{const o="No manifest was loaded, NFT traits cannot be loaded.";console.error(o),s(new Error(o))}}catch(o){s(o)}})}loadTraitsFromNFTObject(e,t=!0,r=null){return new Promise(async(i,s)=>{if(this.manifestData)try{const o=this.manifestData.getNFTraitOptionsFromObject(e,r);await this._loadTraits(o,t),i()}catch(o){console.error("Error loading traits from NFT object:",o.message),s(new Error("Failed to load traits from NFT object."))}else{const o="No manifest was loaded, NFT traits cannot be loaded.";console.error(o),s(new Error(o))}})}loadInitialTraits(){return new Promise(async(e,t)=>{if(this.manifestData)await this._loadTraits(this.manifestData.getInitialTraits()),e();else{const r="No manifest was loaded, initial traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadAllTraits(){return console.log("load all"),new Promise(async(e,t)=>{if(this.manifestData)await this._loadTraits(this.manifestData.getAllTraits()),e();else{const r="No manifest was loaded, initial traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadTrait(e,t){return new Promise(async(r,i)=>{if(this.manifestData)try{const s=this.manifestData.getTraitOption(e,t);s&&(await this._loadTraits(Yt(s)),r())}catch(s){console.error("Error loading specific trait:",s.message),i(new Error("Failed to load specific trait."))}else{const s="No manifest was loaded, specific trait cannot be loaded.";console.error(s),i(new Error(s))}})}loadCustomTrait(e,t){return new Promise(async(r,i)=>{if(this.manifestData)try{const s=this.manifestData.getCustomTraitOption(e,t);s&&(await this._loadTraits(Yt(s)),r())}catch(s){console.error("Error loading custom trait:",s.message),i(new Error("Failed to load custom trait."))}else{const s="No manifest was loaded, custom trait cannot be loaded.";console.error(s),i(new Error(s))}})}loadCustomTexture(e,t){return new Promise(async(r,i)=>{var o;const s=(o=this.avatar[e])==null?void 0:o.model;if(s)await qde(s,t),r();else{const a="No Group Trait with name "+e+" was found.";console.warn(a),i(new Error(a))}})}setTraitColor(e,t){var i;const r=(i=this.avatar[e])==null?void 0:i.model;if(r)try{const s=new Re(t);r.traverse(o=>{o.isMesh&&(o.material.type==="MeshStandardMaterial"?Array.isArray(o.material)?o.material.forEach(a=>{a.color=s}):o.material.color=s:(o.material[0].uniforms.litFactor.value=s,o.material[0].uniforms.shadeColorFactor.value=new Re(s.r*.8,s.g*.8,s.b*.8)))})}catch(s){throw console.error("Error setting trait color:",s.message),new Error("Failed to set trait color.")}else{const s="No Group Trait with name "+e+" was found.";throw console.warn(s),new Error(s)}}removeTrait(e,t=!1){if(this.isTraitGroupRequired(e)&&!t){console.warn(`No trait with name: ${e} is not removable.`);return}if(this.manifestData.getModelGroup(e)){const i=new mB({traitGroupID:e,traitModel:null});this._addLoadedData(i),d1(this.avatar)}else console.warn(`No trait with name: ${e} was found.`)}updateCullHiddenMeshes(){d1(this.avatar)}loadOptimizerManifest(){this.manifest={colliderTraits:["CUSTOM"],traits:[{name:"Custom",trait:"CUSTOM",collection:[]}]},this.manifestData=new v1(this.manifest)}getCurrentOptimizerCharacterModel(){var e;return(e=this.avatar.CUSTOM)==null?void 0:e.vrm}loadOptimizerCharacter(e){return this.loadCustomTrait("CUSTOM",e)}setManifest(e){return this.removeCurrentCharacter(),new Promise(async(t,r)=>{try{if(this.manifest=e,this.manifest){if(this.manifestData=new v1(this.manifest),this.animationManager)try{await this._animationManagerSetup(this.manifest.animationPath,this.manifest.assetsLocation,this.manifestData.displayScale)}catch(i){console.error("Error loading animations: "+i)}t()}else{const i="Failed to fetch or parse the manifest.";console.error(i),r(new Error(i))}}catch(i){console.error("Error setting manifest:",i.message),r(new Error("Failed to set the manifest."))}})}appendManifest(e,t){return new Promise(async(r,i)=>{try{t?this.manifest={...this.manifest||{},manifest:e}:this.manifest={manifest:e,...this.manifest||{}};const s=new v1(e);this.manifestData.appendManifestData(s),r()}catch(s){console.error("Error setting manifest:",s.message),i(new Error("Failed to set the manifest."))}})}loadManifest(e){return new Promise(async(t,r)=>{try{const i=await this._fetchManifest(e);this.setManifest(i).then(()=>{t()})}catch(i){console.error("Error loading manifest:",i.message),r(new Error("Failed to load the manifest."))}})}loadAppendManifest(e,t){return new Promise(async(r,i)=>{try{const s=await this._fetchManifest(e);this.appendManifest(s,t).then(()=>{r()})}catch(s){console.error("Error loading manifest:",s.message),i(new Error("Failed to load the manifest."))}})}async _loadTraits(e,t=!1){await this.traitLoadManager.loadTraitOptions(Yt(e)).then(r=>{t&&this.getGroupTraits().forEach(s=>{r.some(a=>{var l;return((l=a.traitModel)==null?void 0:l.traitGroup.trait)===s.trait})||this.avatar[s.trait]!=null&&r.push(new mB({traitGroupID:s.trait,traitModel:null}))}),r.forEach(i=>{this._addLoadedData(i)}),d1(this.avatar)})}async _animationManagerSetup(e,t,r){const i=Yt(e);this.animationManager&&(this.animationManager.setScale(r),e.length>0&&(this.animationManager.storeAnimationPaths(i,t||""),await this.animationManager.loadAnimation(i,!1,0,i[0].endsWith(".fbx"),t||"")))}async _fetchManifest(e){return await(await fetch(e)).json()}_getPortaitScreenshotTexture(e,t){this.blinkManager.enableScreenshot(),this.characterModel.traverse(u=>{u.isSkinnedMesh&&u.skeleton.bones.filter(d=>d.name==="head")[0].getWorldPosition(el)});const{screenshotResolution:r,screenshotFaceDistance:i,screenshotFaceOffset:s,screenshotBackground:o,screenshotFOV:a}=t,l=r[0],A=r[1];el.x+=s[0],el.y+=s[1],el.z+=s[2],this.screenshotManager.setBackground(o),this.screenshotManager.setCamera(el,i,a);const c=e?this.screenshotManager.getScreenshotBlob(l,A):this.screenshotManager.getScreenshotTexture(l,A);return this.blinkManager.disableScreenshot(),c}_setupWireframeMaterial(e){e.origMat=e.material;const t=()=>{const o=.1+Math.random()*.9,a=.1+Math.random()*(1-.1),l=.1+Math.random()*(1-.1);return new Re(o,a,l)},r=new Qi({color:t(),wireframe:!0,wireframeLinewidth:.2}),i=e.material;e.setDebugMode=s=>{s?e.material.length?(e.material[0]=r,e.material[1]=r):e.material=r:e.material=i}}_VRMBaseSetup(e,t,r,i,s){var a,l;let o=e.userData.vrm;return e.userData.vrm==null?(console.error("No valid VRM was provided for "+r+" trait, skipping file."),null):(wk(o,{isVRM0:((a=o.meta)==null?void 0:a.metaVersion)==="0"}),this.manifestData.isColliderRequired(r)&&ope(e),lhe(o),this.manifestData.isLipsyncTrait(r)&&(this.lipSync=new Yw(o)),this._modelBaseSetup(o,t,r,i,s),((l=o.meta)==null?void 0:l.metaVersion)==="0"&&o.scene.traverse(A=>{if(A.isSkinnedMesh){Xh.rotateVRM0(o),console.log("Loaded VRM0 file ",o);for(let c=0;c{const f=e.scene.getObjectByName(u);f!=null&&f.isMesh&&o.push(f)}),e.scene.traverse(u=>{!t.meshTargets&&u.isMesh&&o.push(u),u.frustumCulled=!1,u.isMesh&&(this._setupWireframeMaterial(u),a.indexOf(u.name)===-1&&l.push(u))});const A=this.manifest,c=this.manifestData.getModelGroup(r);wk(e,{cullingLayer:t.cullingLayer!=null?t.cullingLayer:c.cullingLayer!=null?c.cullingLayer:A.defaultCullingLayer!=null?A.defaultCullingLayer:-1,cullingDistance:t.cullingDistance!=null?t.cullingDistance:c.cullingDistance!=null?c.cullingDistance:A.defaultCullingDistance!=null?A.defaultCullingDistance:null,maxCullingDistance:t.maxCullingDistance!=null?t.maxCullingDistance:c.maxCullingDistance!=null?c.maxCullingDistance:A.maxCullingDistance!=null?A.maxCullingDistance:1/0,cullingMeshes:l}),o.map((u,f)=>{if(i){const d=i[f]||i[0];d!=null&&(u.material.type==="MeshStandardMaterial"?Array.isArray(u.material)?u.material.forEach(h=>{h.map=d}):u.material.map=d:console.warn("XXX set material texture to shader material",u.material))}if(s){const d=s[f]||s[0];d!=null&&(u.material[0].uniforms.litFactor.value=d,u.material[0].uniforms.shadeColorFactor.value=new Re(d.r*.8,d.g*.8,d.b*.8))}})}_applyManagers(e){this.blinkManager.addVRM(e),this.lookAtManager&&this.lookAtManager.addVRM(e),this.animationManager&&this.animationManager.addVRM(e)}_displayModel(e){if(e){const t=e.scene;this.characterModel.attach(t)}}_positionModel(e){const t=this.manifestData.displayScale;e.scene.scale.set(t,t,t)}_disposeTrait(e){this.blinkManager.removeVRM(e),this.lookAtManager&&this.lookAtManager.removeVRM(e),this.animationManager&&this.animationManager.removeVRM(e),ohe(e)}_addLoadedData(e){const{traitGroupID:t,traitModel:r,textureTrait:i,colorTrait:s,models:o,textures:a,colors:l}=e;if(r==null){this.avatar[t]&&this.avatar[t].vrm&&(this._disposeTrait(this.avatar[t].vrm),this.avatar[t]={});return}let A=null;o.map(c=>{c!=null&&(A=this._VRMBaseSetup(c,r,t,a,l))}),A!=null&&(this.avatar[t]&&this.avatar[t].vrm&&this._disposeTrait(this.avatar[t].vrm),this._positionModel(A),this._displayModel(A),this._applyManagers(A),console.log(this.characterModel),this.avatar[t]={traitInfo:r,textureInfo:i,colorInfo:s,name:r.name,model:A&&A.scene,vrm:A})}}class gpe{constructor(){const e=new BZ;e.onProgress=(i,s,o)=>{this.setLoadPercentage(Math.round(s/o*100))};const t=new x_(e);t.crossOrigin="anonymous",t.register(i=>new Tfe(i,{autoUpdateHumanBones:!0}));const r=new Nu(e);this.loadPercentager=0,this.loadingManager=e,this.gltfLoader=t,this.textureLoader=r,this.isLoading=!1}setLoadPercentage(e){this.loadPercentager=e}loadTraitOptions(e){return new Promise(t=>{this.isLoading=!0;const r=[],i=e.map(async(s,o)=>{var c,u,f;if(s==null){r[o]=null;return}const a=await Promise.all(Yt((c=s==null?void 0:s.traitModel)==null?void 0:c.fullDirectory).map(async d=>{try{return await this.gltfLoader.loadAsync(d)}catch(h){return console.error(`Error loading modelsss ${d}:`,h),null}})),l=await Promise.all(Yt((u=s==null?void 0:s.traitTexture)==null?void 0:u.fullDirectory).map(d=>new Promise(h=>{this.textureLoader.load(d,p=>{p.flipY=!1,p.encoding=ht,h(p)},null,p=>{console.error("error loading texture: ",p),h(null)})}))),A=Yt((f=s==null?void 0:s.traitColor)==null?void 0:f.value).map(d=>new Re(d));r[o]=new mB({traitGroupID:s==null?void 0:s.traitModel.traitGroup.trait,traitModel:s==null?void 0:s.traitModel,textureTrait:s==null?void 0:s.traitTexture,colorTrait:s==null?void 0:s.traitColor,models:a,textures:l,colors:A})});Promise.allSettled(i).then(()=>{this.setLoadPercentage(100),t(r),this.isLoading=!1}).catch(s=>{this.setLoadPercentage(100),console.error("An error occurred:",s),t(r),this.isLoading=!1})})}}class mB{constructor(e){const{traitGroupID:t,traitModel:r,textureTrait:i,colorTrait:s,models:o,textures:a,colors:l}=e;this.traitGroupID=t,this.traitModel=r,this.textureTrait=i,this.colorTrait=s,this.models=o,this.textures=a,this.colors=l}}function mpe(n){const e=new yw,t=new bZ(16777215,.5);e.add(t);const r=new w_(16777215,.5);r.position.set(0,1,1),e.add(r);const i=new kt;e.add(i);const s=new Mr(30,window.innerWidth/window.innerHeight,.1,1e3);s.position.set(0,1.3,2);const o=new ppe({parentModel:e,createAnimationManager:!0,renderCamera:s});o.addLookAtMouse(80,n,s,!0);const a=document.getElementById(n),l=new c0({canvas:a,antialias:!0,alpha:!0,preserveDrawingBuffer:!0}),A=new bie(s,l.domElement);A.minDistance=1,A.maxDistance=4,A.maxPolarAngle=Math.PI/2,A.enablePan=!0,A.target=new z(0,1,0),A.enableDamping=!0,A.dampingFactor=.1;const c=new z(-.5,0,-.5),u=new z(.5,1.5,.5),f=()=>{l.setSize(window.innerWidth,window.innerHeight),s.aspect=window.innerWidth/window.innerHeight,s.updateProjectionMatrix()};window.addEventListener("resize",f),l.setSize(window.innerWidth,window.innerHeight),l.setPixelRatio(window.devicePixelRatio),l.outputEncoding=ht;const d=()=>{requestAnimationFrame(d),A.target.clamp(c,u),A==null||A.update(),o.update(),l.render(e,s)};d();const h=m=>{const g=m.ctrlKey,v=a.getBoundingClientRect(),y=(m.clientX-v.left)/v.width*2-1,w=-((m.clientY-v.top)/v.height)*2+1;o.cameraRaycastCulling(y,w,g)};async function p(){const m="./3d/Platform.glb",v=await new x_().loadAsync(m);i.add(v.scene)}return p(),a.addEventListener("click",h),{scene:e,camera:s,controls:A,characterManager:o,sceneElements:i}}new z;class vpe{constructor(e){this.characterManager=e,this.screenshotManager=e.screenshotManager,this.blinkManager=e.blinkManager,this.animationManager=this.characterManager.animationManager,console.log(this.characterManager),console.log(this.screenshotManager),this.temptime=0}async createLoraData(e,t){const r=await this._fetchManifest(e),{assetsLocation:i="",animationsDirectory:s="",backgroundGrayscale:o=1,topFrameOffsetPixels:a=64,bottomFrameOffsetPixels:l=64,backgroundDescription:A="",width:c=512,height:u=512,dataCollection:f}=r,d=i+s+"/";this.screenshotManager.setBackground([o,o,o]),this.blinkManager.enableScreenshot(),this.screenshotManager._setBonesOffset(.2);const h=g=>new Promise(v=>setTimeout(v,g));let p=0;const m=this;Array.isArray(f)&&await(async()=>{if(Array.isArray(f))for(let v=0;vnew Promise(v=>setTimeout(v,g));this.screenshotManager.setBottomFrameOffset(l),this.screenshotManager.setTopFrameOffset(a),this.screenshotManager.setBackground(s),this.blinkManager.enableScreenshot(),this.screenshotManager._setBonesOffset(.2);let p=0;console.log(t);const m=this;if(Array.isArray(f)){console.log("e");async function g(){var v;if(Array.isArray(f))for(const y of f){const{animationName:w,animationPath:C,framesNumber:b,lookAtCamera:E,expression:x,cameraPosition:S,cameraFrame:M}=y;p++;const Z=w||p.toString().padStart(2,"0");await m.animationManager.loadAnimation(d+C,!0,0);const K=TH(S);m.screenshotManager.setCameraFrameWithName(M,K);const _=(v=m.animationManager.getCurrentClip())==null?void 0:v.duration;if(_){console.log(_);const B=_/b;for(let F=0;F{const[e,t]=me.useState(null),[r,i]=me.useState(null),[s,o]=me.useState(null),[a,l]=me.useState(null),[A,c]=me.useState(null),[u,f]=me.useState(null),[d,h]=me.useState(null),[p,m]=me.useState(null),[g,v]=me.useState(null),[y,w]=me.useState(null),[C,b]=me.useState(!1);let E=!1,[x,S]=me.useState(!1);me.useEffect(()=>{if(E||x)return;S(!0),E=!0;const{scene:_,camera:B,controls:F,characterManager:R,sceneElements:k}=mpe("editor-scene");m(B),h(_),t(R),l(k),c(R.animationManager),f(R.lookAtManager),v(F),i(new vpe(R)),o(new ype(R))},[]);const M=_=>{_==null&&(_=!C),b(_),d.traverse(B=>{B.isMesh&&B.setDebugMode&&B.setDebugMode(_)})},Z=_=>{_?d.add(a):d.remove(a)},K=_=>{g&&(fE.to(g.target,{x:_.targetX??0,y:_.targetY??0,z:_.targetZ??0,duration:1}),fE.fromTo(g,{maxDistance:g.getDistance(),minDistance:g.getDistance(),minPolarAngle:g.getPolarAngle(),maxPolarAngle:g.getPolarAngle(),minAzimuthAngle:g.getAzimuthalAngle(),maxAzimuthAngle:g.getAzimuthalAngle()},{maxDistance:_.distance,minDistance:_.distance,minPolarAngle:Math.PI/2-.11,maxPolarAngle:Math.PI/2-.11,minAzimuthAngle:-.78,maxAzimuthAngle:-.78,duration:1}).then(()=>{g.minPolarAngle=0,g.maxPolarAngle=3.1415,g.minDistance=.5,g.maxDistance=10,g.minAzimuthAngle=1/0,g.maxAzimuthAngle=1/0}))};return P.jsx(ni.Provider,{value:{manifest:y,setManifest:w,scene:d,characterManager:e,loraDataGenerator:r,spriteAtlasGenerator:s,showEnvironmentModels:Z,debugMode:C,toggleDebugMode:M,animationManager:A,lookAtManager:u,camera:p,moveCamera:K,controls:g,sceneElements:a},children:n.children})},wpe={NORMAL:"NORMAL",AR:"AR",AR_FRONT:"AR_FRONT",VR:"VR"},ot={LANDING:"LANDING",CREATE:"CREATE",CLAIM:"CLAIM",LOAD:"LOAD",APPEARANCE:"APPEARANCE",BATCHDOWNLOAD:"BATCHDOWNLOAD",BIO:"BIO",SAVE:"SAVE",MINT:"MINT",CHAT:"CHAT",OPTIMIZER:"OPTIMIZER",BATCHMANIFEST:"BATCHMANIFEST",WALLET:"WALLET"},Bi=Y.createContext(),Cpe=n=>{const[e,t]=Y.useState(wpe.NORMAL),[r,i]=Y.useState(ot.LANDING),[s,o]=Y.useState(!1),[a,l]=Y.useState(!1);return P.jsx(Bi.Provider,{value:{viewMode:r,setViewMode:i,isLoading:s,setIsLoading:o,mouseIsOverUI:a,setMouseIsOverUI:l,currentCameraMode:e,setCurrentCameraMode:t},children:n.children})},bpe="modulepreload",xpe=function(n){return"/CharacterStudio/"+n},Nk={},Ipe=function(e,t,r){if(!t||t.length===0)return e();const i=document.getElementsByTagName("link");return Promise.all(t.map(s=>{if(s=xpe(s),s in Nk)return;Nk[s]=!0;const o=s.endsWith(".css"),a=o?'[rel="stylesheet"]':"";if(!!r)for(let c=i.length-1;c>=0;c--){const u=i[c];if(u.href===s&&(!o||u.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${a}`))return;const A=document.createElement("link");if(A.rel=o?"stylesheet":bpe,o||(A.as="script",A.crossOrigin=""),A.href=s,document.head.appendChild(A),o)return new Promise((c,u)=>{A.addEventListener("load",c),A.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${s}`)))})})).then(()=>e()).catch(s=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s})};function Xw(){return Xw=Object.assign||function(n){for(var e=1;e=0)&&(t[i]=n[i]);return t}function Epe(n){me.useEffect(n,[])}function Upe(n,e){e===void 0&&(e={});var t=e,r=t.volume,i=r===void 0?1:r,s=t.playbackRate,o=s===void 0?1:s,a=t.soundEnabled,l=a===void 0?!0:a,A=t.interrupt,c=A===void 0?!1:A,u=t.onload,f=Fpe(t,["id","volume","playbackRate","soundEnabled","interrupt","onload"]),d=Y.useRef(null),h=Y.useRef(!1),p=Y.useState(null),m=p[0],g=p[1],v=Y.useState(null),y=v[0],w=v[1],C=function(){typeof u=="function"&&u.call(this),h.current&&g(this.duration()*1e3),w(this)};Epe(function(){return Ipe(()=>import("./howler-fa9e008d.js").then(M=>M.h),[]).then(function(M){if(!h.current){var Z;d.current=(Z=M.Howl)!==null&&Z!==void 0?Z:M.default.Howl,h.current=!0,new d.current(Xw({src:Array.isArray(n)?n:[n],volume:i,rate:o,onload:C},f))}}),function(){h.current=!1}}),Y.useEffect(function(){d.current&&y&&w(new d.current(Xw({src:Array.isArray(n)?n:[n],volume:i,onload:C},f)))},[JSON.stringify(n)]),Y.useEffect(function(){y&&(y.volume(i),y.rate(o))},[i,o]);var b=Y.useCallback(function(M){typeof M>"u"&&(M={}),!(!y||!l&&!M.forceSoundEnabled)&&(c&&y.stop(),M.playbackRate&&y.rate(M.playbackRate),y.play(M.id))},[y,l,c]),E=Y.useCallback(function(M){y&&y.stop(M)},[y]),x=Y.useCallback(function(M){y&&y.pause(M)},[y]),S=[b,{sound:y,stop:E,pause:x,duration:m}];return S}const Spe=[{name:"background/cc_bgm.wav",offset:0,duration:123458.58333333334},{name:"background/cc_bgm_balanced.wav",offset:123458.58333333334,duration:123458.60416666666},{name:"effect/character-load.wav",offset:246917.1875,duration:3030},{name:"effect/class-select.wav",offset:249947.1875,duration:2780},{name:"effect/switchingItem.wav",offset:252727.1875,duration:623.75},{name:"ui/back-next-button.wav",offset:253350.9375,duration:155.02083333333334},{name:"ui/class-mouse-over.wav",offset:253505.95833333334,duration:217.52083333333334},{name:"ui/class_click.wav",offset:253723.4791666667,duration:3123.75},{name:"ui/class_pass.wav",offset:256847.2291666667,duration:155},{name:"ui/option_click.wav",offset:257002.2291666667,duration:155.02083333333334},{name:"ui/randomize-button.wav",offset:257157.25000000003,duration:342.5208333333333},{name:"ui/section_click.wav",offset:257499.77083333337,duration:155}],_pe="/CharacterStudio/assets/sounds-3322d50e.mp3",Cs=me.createContext(),Qpe=n=>{const e=i=>Spe.find(s=>i.test(s.name)),[t]=Upe(_pe,{sprite:{switchItem:[e(/switchingItem/).offset,e(/switchingItem/).duration],classSelect:[e(/class-select/).offset,e(/class-select/).duration],characterLoad:[e(/character-load/).offset,e(/character-load/).duration],randomizeButton:[e(/randomize-button/).offset,e(/randomize-button/).duration],classMouseOver:[e(/class-mouse-over/).offset,e(/class-mouse-over/).duration],backNextButton:[e(/back-next-button/).offset,e(/back-next-button/).duration]}}),r=(i,s=0)=>{s===0?t({id:i}):setTimeout(()=>{t({id:i})},s)};return P.jsx(Cs.Provider,{value:{playSound:r},children:n.children})};function $s(n){"@babel/helpers - typeof";return $s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$s(n)}function lo(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Rpe(n,e){if($s(n)!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if($s(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function KH(n){var e=Rpe(n,"string");return $s(e)=="symbol"?e:String(e)}function Dk(n,e){for(var t=0;tn.length)&&(e=n.length);for(var t=0,r=new Array(e);t1&&arguments[1]!==void 0?arguments[1]:{};lo(this,n),this.init(e,t)}return Ao(n,[{key:"init",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=t||Npe,this.options=r,this.debug=r.debug}},{key:"setDebug",value:function(t){this.debug=t}},{key:"log",value:function(){for(var t=arguments.length,r=new Array(t),i=0;i1?r-1:0),s=1;s-1?a.replace(/###/g,"."):a}function i(){return!n||typeof n=="string"}for(var s=typeof e!="string"?[].concat(e):e.split(".");s.length>1;){if(i())return{};var o=r(s.shift());!n[o]&&t&&(n[o]=new t),Object.prototype.hasOwnProperty.call(n,o)?n=n[o]:n={}}return i()?{}:{obj:n,k:r(s.shift())}}function Wk(n,e,t){var r=tQ(n,e,Object),i=r.obj,s=r.k;i[s]=t}function Vpe(n,e,t,r){var i=tQ(n,e,Object),s=i.obj,o=i.k;s[o]=s[o]||[],r&&(s[o]=s[o].concat(t)),r||s[o].push(t)}function Kw(n,e){var t=tQ(n,e),r=t.obj,i=t.k;if(r)return r[i]}function Ok(n,e,t){var r=Kw(n,t);return r!==void 0?r:Kw(e,t)}function e4(n,e,t){for(var r in e)r!=="__proto__"&&r!=="constructor"&&(r in n?typeof n[r]=="string"||n[r]instanceof String||typeof e[r]=="string"||e[r]instanceof String?t&&(n[r]=e[r]):e4(n[r],e[r],t):n[r]=e[r]);return n}function Ff(n){return n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var Lpe={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function Ppe(n){return typeof n=="string"?n.replace(/[&<>"'\/]/g,function(e){return Lpe[e]}):n}var pb=typeof window<"u"&&window.navigator&&typeof window.navigator.userAgentData>"u"&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Wpe=[" ",",","?","!",";"];function Ope(n,e,t){e=e||"",t=t||"";var r=Wpe.filter(function(a){return e.indexOf(a)<0&&t.indexOf(a)<0});if(r.length===0)return!0;var i=new RegExp("(".concat(r.map(function(a){return a==="?"?"\\?":a}).join("|"),")")),s=!i.test(n);if(!s){var o=n.indexOf(t);o>0&&!i.test(n.substring(0,o))&&(s=!0)}return s}function Gk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function my(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function t4(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(n){if(n[e])return n[e];for(var r=e.split(t),i=n,s=0;ss+o;)o++,a=r.slice(s,s+o).join(t),l=i[a];if(l===void 0)return;if(l===null)return null;if(e.endsWith(a)){if(typeof l=="string")return l;if(a&&typeof l[a]=="string")return l[a]}var A=r.slice(s+o).join(t);return A?t4(l,A,t):void 0}i=i[r[s]]}return i}}var Jpe=function(n){hb(t,n);var e=Gpe(t);function t(r){var i,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};return lo(this,t),i=e.call(this),pb&&ic.call(HA(i)),i.data=r||{},i.options=s,i.options.keySeparator===void 0&&(i.options.keySeparator="."),i.options.ignoreJSONStructure===void 0&&(i.options.ignoreJSONStructure=!0),i}return Ao(t,[{key:"addNamespaces",value:function(i){this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}},{key:"removeNamespaces",value:function(i){var s=this.options.ns.indexOf(i);s>-1&&this.options.ns.splice(s,1)}},{key:"getResource",value:function(i,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},l=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,A=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,c=[i,s];o&&typeof o!="string"&&(c=c.concat(o)),o&&typeof o=="string"&&(c=c.concat(l?o.split(l):o)),i.indexOf(".")>-1&&(c=i.split("."));var u=Kw(this.data,c);return u||!A||typeof o!="string"?u:t4(this.data&&this.data[i]&&this.data[i][s],o,l)}},{key:"addResource",value:function(i,s,o,a){var l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},A=this.options.keySeparator;A===void 0&&(A=".");var c=[i,s];o&&(c=c.concat(A?o.split(A):o)),i.indexOf(".")>-1&&(c=i.split("."),a=s,s=c[1]),this.addNamespaces(s),Wk(this.data,c,a),l.silent||this.emit("added",i,s,o,a)}},{key:"addResources",value:function(i,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(var l in o)(typeof o[l]=="string"||Object.prototype.toString.apply(o[l])==="[object Array]")&&this.addResource(i,s,l,o[l],{silent:!0});a.silent||this.emit("added",i,s,o)}},{key:"addResourceBundle",value:function(i,s,o,a,l){var A=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},c=[i,s];i.indexOf(".")>-1&&(c=i.split("."),a=o,o=s,s=c[1]),this.addNamespaces(s);var u=Kw(this.data,c)||{};a?e4(u,o,l):u=my(my({},u),o),Wk(this.data,c,u),A.silent||this.emit("added",i,s,o)}},{key:"removeResourceBundle",value:function(i,s){this.hasResourceBundle(i,s)&&delete this.data[i][s],this.removeNamespaces(s),this.emit("removed",i,s)}},{key:"hasResourceBundle",value:function(i,s){return this.getResource(i,s)!==void 0}},{key:"getResourceBundle",value:function(i,s){return s||(s=this.options.defaultNS),this.options.compatibilityAPI==="v1"?my(my({},{}),this.getResource(i,s)):this.getResource(i,s)}},{key:"getDataByLanguage",value:function(i){return this.data[i]}},{key:"hasLanguageSomeTranslations",value:function(i){var s=this.getDataByLanguage(i),o=s&&Object.keys(s)||[];return!!o.find(function(a){return s[a]&&Object.keys(s[a]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),t}(ic),n4={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,r,i,s){var o=this;return e.forEach(function(a){o.processors[a]&&(t=o.processors[a].process(t,r,i,s))}),t}};function Zk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function si(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Jk={},Hk=function(n){hb(t,n);var e=Hpe(t);function t(r){var i,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return lo(this,t),i=e.call(this),pb&&ic.call(HA(i)),kpe(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r,HA(i)),i.options=s,i.options.keySeparator===void 0&&(i.options.keySeparator="."),i.logger=pa.create("translator"),i}return Ao(t,[{key:"changeLanguage",value:function(i){i&&(this.language=i)}},{key:"exists",value:function(i){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(i==null)return!1;var o=this.resolve(i,s);return o&&o.res!==void 0}},{key:"extractFromKey",value:function(i,s){var o=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");var a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,l=s.ns||this.options.defaultNS||[],A=o&&i.indexOf(o)>-1,c=!this.options.userDefinedKeySeparator&&!s.keySeparator&&!this.options.userDefinedNsSeparator&&!s.nsSeparator&&!Ope(i,o,a);if(A&&!c){var u=i.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:i,namespaces:l};var f=i.split(o);(o!==a||o===a&&this.options.ns.indexOf(f[0])>-1)&&(l=f.shift()),i=f.join(a)}return typeof l=="string"&&(l=[l]),{key:i,namespaces:l}}},{key:"translate",value:function(i,s,o){var a=this;if($s(s)!=="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),s||(s={}),i==null)return"";Array.isArray(i)||(i=[String(i)]);var l=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,A=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,c=this.extractFromKey(i[i.length-1],s),u=c.key,f=c.namespaces,d=f[f.length-1],h=s.lng||this.language,p=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h&&h.toLowerCase()==="cimode"){if(p){var m=s.nsSeparator||this.options.nsSeparator;return l?{res:"".concat(d).concat(m).concat(u),usedKey:u,exactUsedKey:u,usedLng:h,usedNS:d}:"".concat(d).concat(m).concat(u)}return l?{res:u,usedKey:u,exactUsedKey:u,usedLng:h,usedNS:d}:u}var g=this.resolve(i,s),v=g&&g.res,y=g&&g.usedKey||u,w=g&&g.exactUsedKey||u,C=Object.prototype.toString.apply(v),b=["[object Number]","[object Function]","[object RegExp]"],E=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,x=!this.i18nFormat||this.i18nFormat.handleAsObject,S=typeof v!="string"&&typeof v!="boolean"&&typeof v!="number";if(x&&v&&S&&b.indexOf(C)<0&&!(typeof E=="string"&&C==="[object Array]")){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var M=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,v,si(si({},s),{},{ns:f})):"key '".concat(u," (").concat(this.language,")' returned an object instead of string.");return l?(g.res=M,g):M}if(A){var Z=C==="[object Array]",K=Z?[]:{},_=Z?w:y;for(var B in v)if(Object.prototype.hasOwnProperty.call(v,B)){var F="".concat(_).concat(A).concat(B);K[B]=this.translate(F,si(si({},s),{joinArrays:!1,ns:f})),K[B]===F&&(K[B]=v[B])}v=K}}else if(x&&typeof E=="string"&&C==="[object Array]")v=v.join(E),v&&(v=this.extendTranslation(v,i,s,o));else{var R=!1,k=!1,T=s.count!==void 0&&typeof s.count!="string",V=t.hasDefaultValue(s),O=T?this.pluralResolver.getSuffix(h,s.count,s):"",L=s["defaultValue".concat(O)]||s.defaultValue;!this.isValidLookup(v)&&V&&(R=!0,v=L),this.isValidLookup(v)||(k=!0,v=u);var U=s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey,H=U&&k?void 0:v,le=V&&L!==v&&this.options.updateMissing;if(k||R||le){if(this.logger.log(le?"updateKey":"missingKey",h,d,u,le?L:v),A){var N=this.resolve(u,si(si({},s),{},{keySeparator:!1}));N&&N.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var j=[],oe=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&oe&&oe[0])for(var ie=0;ie1&&arguments[1]!==void 0?arguments[1]:{},a,l,A,c,u;return typeof i=="string"&&(i=[i]),i.forEach(function(f){if(!s.isValidLookup(a)){var d=s.extractFromKey(f,o),h=d.key;l=h;var p=d.namespaces;s.options.fallbackNS&&(p=p.concat(s.options.fallbackNS));var m=o.count!==void 0&&typeof o.count!="string",g=m&&!o.ordinal&&o.count===0&&s.pluralResolver.shouldUseIntlApi(),v=o.context!==void 0&&(typeof o.context=="string"||typeof o.context=="number")&&o.context!=="",y=o.lngs?o.lngs:s.languageUtils.toResolveHierarchy(o.lng||s.language,o.fallbackLng);p.forEach(function(w){s.isValidLookup(a)||(u=w,!Jk["".concat(y[0],"-").concat(w)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(u)&&(Jk["".concat(y[0],"-").concat(w)]=!0,s.logger.warn('key "'.concat(l,'" for languages "').concat(y.join(", "),`" won't get resolved as namespace "`).concat(u,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(function(C){if(!s.isValidLookup(a)){c=C;var b=[h];if(s.i18nFormat&&s.i18nFormat.addLookupKeys)s.i18nFormat.addLookupKeys(b,h,C,w,o);else{var E;m&&(E=s.pluralResolver.getSuffix(C,o.count,o));var x="".concat(s.options.pluralSeparator,"zero");if(m&&(b.push(h+E),g&&b.push(h+x)),v){var S="".concat(h).concat(s.options.contextSeparator).concat(o.context);b.push(S),m&&(b.push(S+E),g&&b.push(S+x))}}for(var M;M=b.pop();)s.isValidLookup(a)||(A=M,a=s.getResource(C,w,M,o))}}))})}}),{res:a,usedKey:l,exactUsedKey:A,usedLng:c,usedNS:u}}},{key:"isValidLookup",value:function(i){return i!==void 0&&!(!this.options.returnNull&&i===null)&&!(!this.options.returnEmptyString&&i==="")}},{key:"getResource",value:function(i,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(i,s,o,a):this.resourceStore.getResource(i,s,o,a)}}],[{key:"hasDefaultValue",value:function(i){var s="defaultValue";for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o)&&s===o.substring(0,s.length)&&i[o]!==void 0)return!0;return!1}}]),t}(ic);function w1(n){return n.charAt(0).toUpperCase()+n.slice(1)}var zk=function(){function n(e){lo(this,n),this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=pa.create("languageUtils")}return Ao(n,[{key:"getScriptPartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return null;var r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}},{key:"getLanguagePartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return t;var r=t.split("-");return this.formatLanguageCode(r[0])}},{key:"formatLanguageCode",value:function(t){if(typeof t=="string"&&t.indexOf("-")>-1){var r=["hans","hant","latn","cyrl","cans","mong","arab"],i=t.split("-");return this.options.lowerCaseLng?i=i.map(function(s){return s.toLowerCase()}):i.length===2?(i[0]=i[0].toLowerCase(),i[1]=i[1].toUpperCase(),r.indexOf(i[1].toLowerCase())>-1&&(i[1]=w1(i[1].toLowerCase()))):i.length===3&&(i[0]=i[0].toLowerCase(),i[1].length===2&&(i[1]=i[1].toUpperCase()),i[0]!=="sgn"&&i[2].length===2&&(i[2]=i[2].toUpperCase()),r.indexOf(i[1].toLowerCase())>-1&&(i[1]=w1(i[1].toLowerCase())),r.indexOf(i[2].toLowerCase())>-1&&(i[2]=w1(i[2].toLowerCase()))),i.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}},{key:"isSupportedCode",value:function(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}},{key:"getBestMatchFromCodes",value:function(t){var r=this;if(!t)return null;var i;return t.forEach(function(s){if(!i){var o=r.formatLanguageCode(s);(!r.options.supportedLngs||r.isSupportedCode(o))&&(i=o)}}),!i&&this.options.supportedLngs&&t.forEach(function(s){if(!i){var o=r.getLanguagePartFromCode(s);if(r.isSupportedCode(o))return i=o;i=r.options.supportedLngs.find(function(a){if(a.indexOf(o)===0)return a})}}),i||(i=this.getFallbackCodes(this.options.fallbackLng)[0]),i}},{key:"getFallbackCodes",value:function(t,r){if(!t)return[];if(typeof t=="function"&&(t=t(r)),typeof t=="string"&&(t=[t]),Object.prototype.toString.apply(t)==="[object Array]")return t;if(!r)return t.default||[];var i=t[r];return i||(i=t[this.getScriptPartFromCode(r)]),i||(i=t[this.formatLanguageCode(r)]),i||(i=t[this.getLanguagePartFromCode(r)]),i||(i=t.default),i||[]}},{key:"toResolveHierarchy",value:function(t,r){var i=this,s=this.getFallbackCodes(r||this.options.fallbackLng||[],t),o=[],a=function(A){A&&(i.isSupportedCode(A)?o.push(A):i.logger.warn("rejecting language code not found in supportedLngs: ".concat(A)))};return typeof t=="string"&&t.indexOf("-")>-1?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):typeof t=="string"&&a(this.formatLanguageCode(t)),s.forEach(function(l){o.indexOf(l)<0&&a(i.formatLanguageCode(l))}),o}}]),n}(),Ype=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Xpe={1:function(e){return+(e>1)},2:function(e){return+(e!=1)},3:function(e){return 0},4:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},5:function(e){return e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5},6:function(e){return e==1?0:e>=2&&e<=4?1:2},7:function(e){return e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},8:function(e){return e==1?0:e==2?1:e!=8&&e!=11?2:3},9:function(e){return+(e>=2)},10:function(e){return e==1?0:e==2?1:e<7?2:e<11?3:4},11:function(e){return e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3},12:function(e){return+(e%10!=1||e%100==11)},13:function(e){return+(e!==0)},14:function(e){return e==1?0:e==2?1:e==3?2:3},15:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2},16:function(e){return e%10==1&&e%100!=11?0:e!==0?1:2},17:function(e){return e==1||e%10==1&&e%100!=11?0:1},18:function(e){return e==0?0:e==1?1:2},19:function(e){return e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3},20:function(e){return e==1?0:e==0||e%100>0&&e%100<20?1:2},21:function(e){return e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0},22:function(e){return e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3}},Kpe=["v1","v2","v3"],Yk={zero:0,one:1,two:2,few:3,many:4,other:5};function jpe(){var n={};return Ype.forEach(function(e){e.lngs.forEach(function(t){n[t]={numbers:e.nr,plurals:Xpe[e.fc]}})}),n}var $pe=function(){function n(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};lo(this,n),this.languageUtils=e,this.options=t,this.logger=pa.create("pluralResolver"),(!this.options.compatibilityJSON||this.options.compatibilityJSON==="v4")&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=jpe()}return Ao(n,[{key:"addRule",value:function(t,r){this.rules[t]=r}},{key:"getRule",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(t,{type:r.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}},{key:"needsPlural",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(t,r);return this.shouldUseIntlApi()?i&&i.resolvedOptions().pluralCategories.length>1:i&&i.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(t,r){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,i).map(function(s){return"".concat(r).concat(s)})}},{key:"getSuffixes",value:function(t){var r=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=this.getRule(t,i);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(function(o,a){return Yk[o]-Yk[a]}).map(function(o){return"".concat(r.options.prepend).concat(o)}):s.numbers.map(function(o){return r.getSuffix(t,o,i)}):[]}},{key:"getSuffix",value:function(t,r){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=this.getRule(t,i);return s?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(s.select(r)):this.getSuffixRetroCompatible(s,r):(this.logger.warn("no plural rule found for: ".concat(t)),"")}},{key:"getSuffixRetroCompatible",value:function(t,r){var i=this,s=t.noAbs?t.plurals(r):t.plurals(Math.abs(r)),o=t.numbers[s];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(o===2?o="plural":o===1&&(o=""));var a=function(){return i.options.prepend&&o.toString()?i.options.prepend+o.toString():o.toString()};return this.options.compatibilityJSON==="v1"?o===1?"":typeof o=="number"?"_plural_".concat(o.toString()):a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}},{key:"shouldUseIntlApi",value:function(){return!Kpe.includes(this.options.compatibilityJSON)}}]),n}();function Xk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Bo(n){for(var e=1;e0&&arguments[0]!==void 0?arguments[0]:{};lo(this,n),this.logger=pa.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||function(t){return t},this.init(e)}return Ao(n,[{key:"init",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});var r=t.interpolation;this.escape=r.escape!==void 0?r.escape:Ppe,this.escapeValue=r.escapeValue!==void 0?r.escapeValue:!0,this.useRawValueToEscape=r.useRawValueToEscape!==void 0?r.useRawValueToEscape:!1,this.prefix=r.prefix?Ff(r.prefix):r.prefixEscaped||"{{",this.suffix=r.suffix?Ff(r.suffix):r.suffixEscaped||"}}",this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||",",this.unescapePrefix=r.unescapeSuffix?"":r.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":r.unescapeSuffix||"",this.nestingPrefix=r.nestingPrefix?Ff(r.nestingPrefix):r.nestingPrefixEscaped||Ff("$t("),this.nestingSuffix=r.nestingSuffix?Ff(r.nestingSuffix):r.nestingSuffixEscaped||Ff(")"),this.nestingOptionsSeparator=r.nestingOptionsSeparator?r.nestingOptionsSeparator:r.nestingOptionsSeparator||",",this.maxReplaces=r.maxReplaces?r.maxReplaces:1e3,this.alwaysFormat=r.alwaysFormat!==void 0?r.alwaysFormat:!1,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var t="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(t,"g");var r="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(r,"g");var i="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(i,"g")}},{key:"interpolate",value:function(t,r,i,s){var o=this,a,l,A,c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(m){return m.replace(/\$/g,"$$$$")}var f=function(g){if(g.indexOf(o.formatSeparator)<0){var v=Ok(r,c,g);return o.alwaysFormat?o.format(v,void 0,i,Bo(Bo(Bo({},s),r),{},{interpolationkey:g})):v}var y=g.split(o.formatSeparator),w=y.shift().trim(),C=y.join(o.formatSeparator).trim();return o.format(Ok(r,c,w),C,i,Bo(Bo(Bo({},s),r),{},{interpolationkey:w}))};this.resetRegExp();var d=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,h=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables,p=[{regex:this.regexpUnescape,safeValue:function(g){return u(g)}},{regex:this.regexp,safeValue:function(g){return o.escapeValue?u(o.escape(g)):u(g)}}];return p.forEach(function(m){for(A=0;a=m.regex.exec(t);){var g=a[1].trim();if(l=f(g),l===void 0)if(typeof d=="function"){var v=d(t,a,s);l=typeof v=="string"?v:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))l="";else if(h){l=a[0];continue}else o.logger.warn("missed to pass in variable ".concat(g," for interpolating ").concat(t)),l="";else typeof l!="string"&&!o.useRawValueToEscape&&(l=Pk(l));var y=m.safeValue(l);if(t=t.replace(a[0],y),h?(m.regex.lastIndex+=l.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,A++,A>=o.maxReplaces)break}}),t}},{key:"nest",value:function(t,r){var i=this,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o,a,l;function A(d,h){var p=this.nestingOptionsSeparator;if(d.indexOf(p)<0)return d;var m=d.split(new RegExp("".concat(p,"[ ]*{"))),g="{".concat(m[1]);d=m[0],g=this.interpolate(g,l);var v=g.match(/'/g),y=g.match(/"/g);(v&&v.length%2===0&&!y||y.length%2!==0)&&(g=g.replace(/'/g,'"'));try{l=JSON.parse(g),h&&(l=Bo(Bo({},h),l))}catch(w){return this.logger.warn("failed parsing options string in nesting for key ".concat(d),w),"".concat(d).concat(p).concat(g)}return delete l.defaultValue,d}for(;o=this.nestingRegexp.exec(t);){var c=[];l=Bo({},s),l=l.replace&&typeof l.replace!="string"?l.replace:l,l.applyPostProcessor=!1,delete l.defaultValue;var u=!1;if(o[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(o[1])){var f=o[1].split(this.formatSeparator).map(function(d){return d.trim()});o[1]=f.shift(),c=f,u=!0}if(a=r(A.call(this,o[1].trim(),l),l),a&&o[0]===t&&typeof a!="string")return a;typeof a!="string"&&(a=Pk(a)),a||(this.logger.warn("missed to resolve ".concat(o[1]," for nesting ").concat(t)),a=""),u&&(a=c.reduce(function(d,h){return i.format(d,h,s.lng,Bo(Bo({},s),{},{interpolationkey:o[1].trim()}))},a.trim())),t=t.replace(o[0],a),this.regexp.lastIndex=0}return t}}]),n}();function Kk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function tl(n){for(var e=1;e-1){var r=n.split("(");e=r[0].toLowerCase().trim();var i=r[1].substring(0,r[1].length-1);if(e==="currency"&&i.indexOf(":")<0)t.currency||(t.currency=i.trim());else if(e==="relativetime"&&i.indexOf(":")<0)t.range||(t.range=i.trim());else{var s=i.split(";");s.forEach(function(o){if(o){var a=o.split(":"),l=Tpe(a),A=l[0],c=l.slice(1),u=c.join(":").trim().replace(/^'+|'+$/g,"");t[A.trim()]||(t[A.trim()]=u),u==="false"&&(t[A.trim()]=!1),u==="true"&&(t[A.trim()]=!0),isNaN(u)||(t[A.trim()]=parseInt(u,10))}})}}return{formatName:e,formatOptions:t}}function Ef(n){var e={};return function(r,i,s){var o=i+JSON.stringify(s),a=e[o];return a||(a=n(i,s),e[o]=a),a(r)}}var tge=function(){function n(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};lo(this,n),this.logger=pa.create("formatter"),this.options=e,this.formats={number:Ef(function(t,r){var i=new Intl.NumberFormat(t,tl({},r));return function(s){return i.format(s)}}),currency:Ef(function(t,r){var i=new Intl.NumberFormat(t,tl(tl({},r),{},{style:"currency"}));return function(s){return i.format(s)}}),datetime:Ef(function(t,r){var i=new Intl.DateTimeFormat(t,tl({},r));return function(s){return i.format(s)}}),relativetime:Ef(function(t,r){var i=new Intl.RelativeTimeFormat(t,tl({},r));return function(s){return i.format(s,r.range||"day")}}),list:Ef(function(t,r){var i=new Intl.ListFormat(t,tl({},r));return function(s){return i.format(s)}})},this.init(e)}return Ao(n,[{key:"init",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}},i=r.interpolation;this.formatSeparator=i.formatSeparator?i.formatSeparator:i.formatSeparator||","}},{key:"add",value:function(t,r){this.formats[t.toLowerCase().trim()]=r}},{key:"addCached",value:function(t,r){this.formats[t.toLowerCase().trim()]=Ef(r)}},{key:"format",value:function(t,r,i){var s=this,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=r.split(this.formatSeparator),l=a.reduce(function(A,c){var u=ege(c),f=u.formatName,d=u.formatOptions;if(s.formats[f]){var h=A;try{var p=o&&o.formatParams&&o.formatParams[o.interpolationkey]||{},m=p.locale||p.lng||o.locale||o.lng||i;h=s.formats[f](A,m,tl(tl(tl({},d),o),p))}catch(g){s.logger.warn(g)}return h}else s.logger.warn("there was no format function for ".concat(f));return A},t);return l}}]),n}();function jk(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function $k(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ige(n,e){n.pending[e]!==void 0&&(delete n.pending[e],n.pendingCount--)}var sge=function(n){hb(t,n);var e=nge(t);function t(r,i,s){var o,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return lo(this,t),o=e.call(this),pb&&ic.call(HA(o)),o.backend=r,o.store=i,o.services=s,o.languageUtils=s.languageUtils,o.options=a,o.logger=pa.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=a.maxParallelReads||10,o.readingCalls=0,o.maxRetries=a.maxRetries>=0?a.maxRetries:5,o.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(s,a.backend,a),o}return Ao(t,[{key:"queueLoad",value:function(i,s,o,a){var l=this,A={},c={},u={},f={};return i.forEach(function(d){var h=!0;s.forEach(function(p){var m="".concat(d,"|").concat(p);!o.reload&&l.store.hasResourceBundle(d,p)?l.state[m]=2:l.state[m]<0||(l.state[m]===1?c[m]===void 0&&(c[m]=!0):(l.state[m]=1,h=!1,c[m]===void 0&&(c[m]=!0),A[m]===void 0&&(A[m]=!0),f[p]===void 0&&(f[p]=!0)))}),h||(u[d]=!0)}),(Object.keys(A).length||Object.keys(c).length)&&this.queue.push({pending:c,pendingCount:Object.keys(c).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(A),pending:Object.keys(c),toLoadLanguages:Object.keys(u),toLoadNamespaces:Object.keys(f)}}},{key:"loaded",value:function(i,s,o){var a=i.split("|"),l=a[0],A=a[1];s&&this.emit("failedLoading",l,A,s),o&&this.store.addResourceBundle(l,A,o),this.state[i]=s?-1:2;var c={};this.queue.forEach(function(u){Vpe(u.loaded,[l],A),ige(u,i),s&&u.errors.push(s),u.pendingCount===0&&!u.done&&(Object.keys(u.loaded).forEach(function(f){c[f]||(c[f]={});var d=u.loaded[f];d.length&&d.forEach(function(h){c[f][h]===void 0&&(c[f][h]=!0)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(function(u){return!u.done})}},{key:"read",value:function(i,s,o){var a=this,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,A=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,c=arguments.length>5?arguments[5]:void 0;if(!i.length)return c(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:i,ns:s,fcName:o,tried:l,wait:A,callback:c});return}this.readingCalls++;var u=function(p,m){if(a.readingCalls--,a.waitingReads.length>0){var g=a.waitingReads.shift();a.read(g.lng,g.ns,g.fcName,g.tried,g.wait,g.callback)}if(p&&m&&l2&&arguments[2]!==void 0?arguments[2]:{},l=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),l&&l();typeof i=="string"&&(i=this.languageUtils.toResolveHierarchy(i)),typeof s=="string"&&(s=[s]);var A=this.queueLoad(i,s,a,l);if(!A.toLoad.length)return A.pending.length||l(),null;A.toLoad.forEach(function(c){o.loadOne(c)})}},{key:"load",value:function(i,s,o){this.prepareLoading(i,s,{},o)}},{key:"reload",value:function(i,s,o){this.prepareLoading(i,s,{reload:!0},o)}},{key:"loadOne",value:function(i){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",a=i.split("|"),l=a[0],A=a[1];this.read(l,A,"read",void 0,void 0,function(c,u){c&&s.logger.warn("".concat(o,"loading namespace ").concat(A," for language ").concat(l," failed"),c),!c&&u&&s.logger.log("".concat(o,"loaded namespace ").concat(A," for language ").concat(l),u),s.loaded(i,c,u)})}},{key:"saveMissing",value:function(i,s,o,a,l){var A=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(s)){this.logger.warn('did not save key "'.concat(o,'" as the namespace "').concat(s,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend&&this.backend.create){var u=$k($k({},A),{},{isUpdate:l}),f=this.backend.create.bind(this.backend);if(f.length<6)try{var d;f.length===5?d=f(i,s,o,a,u):d=f(i,s,o,a),d&&typeof d.then=="function"?d.then(function(h){return c(null,h)}).catch(c):c(null,d)}catch(h){c(h)}else f(i,s,o,a,c,u)}!i||!i[0]||this.store.addResource(i[0],s,o,a)}}}]),t}(ic);function qk(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if($s(e[1])==="object"&&(t=e[1]),typeof e[1]=="string"&&(t.defaultValue=e[1]),typeof e[2]=="string"&&(t.tDescription=e[2]),$s(e[2])==="object"||$s(e[3])==="object"){var r=e[3]||e[2];Object.keys(r).forEach(function(i){t[i]=r[i]})}return t},interpolation:{escapeValue:!0,format:function(e,t,r,i){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function eV(n){return typeof n.ns=="string"&&(n.ns=[n.ns]),typeof n.fallbackLng=="string"&&(n.fallbackLng=[n.fallbackLng]),typeof n.fallbackNS=="string"&&(n.fallbackNS=[n.fallbackNS]),n.supportedLngs&&n.supportedLngs.indexOf("cimode")<0&&(n.supportedLngs=n.supportedLngs.concat(["cimode"])),n}function tV(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Ko(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function vy(){}function lge(n){var e=Object.getOwnPropertyNames(Object.getPrototypeOf(n));e.forEach(function(t){typeof n[t]=="function"&&(n[t]=n[t].bind(n))})}var jw=function(n){hb(t,n);var e=oge(t);function t(){var r,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(lo(this,t),r=e.call(this),pb&&ic.call(HA(r)),r.options=eV(i),r.services={},r.logger=pa,r.modules={external:[]},lge(HA(r)),s&&!r.isInitialized&&!i.isClone){if(!r.options.initImmediate)return r.init(i,s),y0(r,HA(r));setTimeout(function(){r.init(i,s)},0)}return r}return Ao(t,[{key:"init",value:function(){var i=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;typeof s=="function"&&(o=s,s={}),!s.defaultNS&&s.defaultNS!==!1&&s.ns&&(typeof s.ns=="string"?s.defaultNS=s.ns:s.ns.indexOf("translation")<0&&(s.defaultNS=s.ns[0]));var a=qk();this.options=Ko(Ko(Ko({},a),this.options),eV(s)),this.options.compatibilityAPI!=="v1"&&(this.options.interpolation=Ko(Ko({},a.interpolation),this.options.interpolation)),s.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=s.keySeparator),s.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=s.nsSeparator);function l(g){return g?typeof g=="function"?new g:g:null}if(!this.options.isClone){this.modules.logger?pa.init(l(this.modules.logger),this.options):pa.init(null,this.options);var A;this.modules.formatter?A=this.modules.formatter:typeof Intl<"u"&&(A=tge);var c=new zk(this.options);this.store=new Jpe(this.options.resources,this.options);var u=this.services;u.logger=pa,u.resourceStore=this.store,u.languageUtils=c,u.pluralResolver=new $pe(c,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),A&&(!this.options.interpolation.format||this.options.interpolation.format===a.interpolation.format)&&(u.formatter=l(A),u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new qpe(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new sge(l(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",function(g){for(var v=arguments.length,y=new Array(v>1?v-1:0),w=1;w1?v-1:0),w=1;w0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined");var d=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];d.forEach(function(g){i[g]=function(){var v;return(v=i.store)[g].apply(v,arguments)}});var h=["addResource","addResources","addResourceBundle","removeResourceBundle"];h.forEach(function(g){i[g]=function(){var v;return(v=i.store)[g].apply(v,arguments),i}});var p=zp(),m=function(){var v=function(w,C){i.isInitialized&&!i.initializedStoreOnce&&i.logger.warn("init: i18next is already initialized. You should call init just once!"),i.isInitialized=!0,i.options.isClone||i.logger.log("initialized",i.options),i.emit("initialized",i.options),p.resolve(C),o(w,C)};if(i.languages&&i.options.compatibilityAPI!=="v1"&&!i.isInitialized)return v(null,i.t.bind(i));i.changeLanguage(i.options.lng,v)};return this.options.resources||!this.options.initImmediate?m():setTimeout(m,0),p}},{key:"loadResources",value:function(i){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vy,a=o,l=typeof i=="string"?i:this.language;if(typeof i=="function"&&(a=i),!this.options.resources||this.options.partialBundledLanguages){if(l&&l.toLowerCase()==="cimode")return a();var A=[],c=function(d){if(d){var h=s.services.languageUtils.toResolveHierarchy(d);h.forEach(function(p){A.indexOf(p)<0&&A.push(p)})}};if(l)c(l);else{var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.forEach(function(f){return c(f)})}this.options.preload&&this.options.preload.forEach(function(f){return c(f)}),this.services.backendConnector.load(A,this.options.ns,function(f){!f&&!s.resolvedLanguage&&s.language&&s.setResolvedLanguage(s.language),a(f)})}else a(null)}},{key:"reloadResources",value:function(i,s,o){var a=zp();return i||(i=this.languages),s||(s=this.options.ns),o||(o=vy),this.services.backendConnector.reload(i,s,function(l){a.resolve(),o(l)}),a}},{key:"use",value:function(i){if(!i)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!i.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return i.type==="backend"&&(this.modules.backend=i),(i.type==="logger"||i.log&&i.warn&&i.error)&&(this.modules.logger=i),i.type==="languageDetector"&&(this.modules.languageDetector=i),i.type==="i18nFormat"&&(this.modules.i18nFormat=i),i.type==="postProcessor"&&n4.addPostProcessor(i),i.type==="formatter"&&(this.modules.formatter=i),i.type==="3rdParty"&&this.modules.external.push(i),this}},{key:"setResolvedLanguage",value:function(i){if(!(!i||!this.languages)&&!(["cimode","dev"].indexOf(i)>-1))for(var s=0;s-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}}},{key:"changeLanguage",value:function(i,s){var o=this;this.isLanguageChangingTo=i;var a=zp();this.emit("languageChanging",i);var l=function(f){o.language=f,o.languages=o.services.languageUtils.toResolveHierarchy(f),o.resolvedLanguage=void 0,o.setResolvedLanguage(f)},A=function(f,d){d?(l(d),o.translator.changeLanguage(d),o.isLanguageChangingTo=void 0,o.emit("languageChanged",d),o.logger.log("languageChanged",d)):o.isLanguageChangingTo=void 0,a.resolve(function(){return o.t.apply(o,arguments)}),s&&s(f,function(){return o.t.apply(o,arguments)})},c=function(f){!i&&!f&&o.services.languageDetector&&(f=[]);var d=typeof f=="string"?f:o.services.languageUtils.getBestMatchFromCodes(f);d&&(o.language||l(d),o.translator.language||o.translator.changeLanguage(d),o.services.languageDetector&&o.services.languageDetector.cacheUserLanguage&&o.services.languageDetector.cacheUserLanguage(d)),o.loadResources(d,function(h){A(h,d)})};return!i&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!i&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(i),a}},{key:"getFixedT",value:function(i,s,o){var a=this,l=function A(c,u){var f;if($s(u)!=="object"){for(var d=arguments.length,h=new Array(d>2?d-2:0),p=2;p1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var a=this.resolvedLanguage||this.languages[0],l=this.options?this.options.fallbackLng:!1,A=this.languages[this.languages.length-1];if(a.toLowerCase()==="cimode")return!0;var c=function(d,h){var p=s.services.backendConnector.state["".concat(d,"|").concat(h)];return p===-1||p===2};if(o.precheck){var u=o.precheck(this,c);if(u!==void 0)return u}return!!(this.hasResourceBundle(a,i)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||c(a,i)&&(!l||c(A,i)))}},{key:"loadNamespaces",value:function(i,s){var o=this,a=zp();return this.options.ns?(typeof i=="string"&&(i=[i]),i.forEach(function(l){o.options.ns.indexOf(l)<0&&o.options.ns.push(l)}),this.loadResources(function(l){a.resolve(),s&&s(l)}),a):(s&&s(),Promise.resolve())}},{key:"loadLanguages",value:function(i,s){var o=zp();typeof i=="string"&&(i=[i]);var a=this.options.preload||[],l=i.filter(function(A){return a.indexOf(A)<0});return l.length?(this.options.preload=a.concat(l),this.loadResources(function(A){o.resolve(),s&&s(A)}),o):(s&&s(),Promise.resolve())}},{key:"dir",value:function(i){if(i||(i=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!i)return"rtl";var s=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services&&this.services.languageUtils||new zk(qk());return s.indexOf(o.getLanguagePartFromCode(i))>-1||i.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var i=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vy,a=Ko(Ko(Ko({},this.options),s),{isClone:!0}),l=new t(a);(s.debug!==void 0||s.prefix!==void 0)&&(l.logger=l.logger.clone(s));var A=["store","services","language"];return A.forEach(function(c){l[c]=i[c]}),l.services=Ko({},this.services),l.services.utils={hasLoadedNamespace:l.hasLoadedNamespace.bind(l)},l.translator=new Hk(l.services,l.options),l.translator.on("*",function(c){for(var u=arguments.length,f=new Array(u>1?u-1:0),d=1;d0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;return new jw(n,e)});var ri=jw.createInstance();ri.createInstance=jw.createInstance;ri.createInstance;ri.dir;ri.init;ri.loadResources;ri.reloadResources;ri.use;ri.changeLanguage;ri.getFixedT;ri.t;ri.exists;ri.setDefaultNamespace;ri.hasLoadedNamespace;ri.loadNamespaces;ri.loadLanguages;function Age(){if(console&&console.warn){for(var n,e=arguments.length,t=new Array(e),r=0;r2&&arguments[2]!==void 0?arguments[2]:{},r=e.languages[0],i=e.options?e.options.fallbackLng:!1,s=e.languages[e.languages.length-1];if(r.toLowerCase()==="cimode")return!0;var o=function(l,A){var c=e.services.backendConnector.state["".concat(l,"|").concat(A)];return c===-1||c===2};return t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&e.services.backendConnector.backend&&e.isLanguageChangingTo&&!o(e.isLanguageChangingTo,n)?!1:!!(e.hasResourceBundle(r,n)||!e.services.backendConnector.backend||e.options.resources&&!e.options.partialBundledLanguages||o(r,n)&&(!i||o(s,n)))}function uge(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!e.languages||!e.languages.length)return hU("i18n.languages were undefined or empty",e.languages),!0;var r=e.options.ignoreJSONStructure!==void 0;return r?e.hasLoadedNamespace(n,{precheck:function(s,o){if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!o(s.isLanguageChangingTo,n))return!1}}):cge(n,e,t)}var fge=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,dge={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},hge=function(e){return dge[e]},pge=function(e){return e.replace(fge,hge)};function iV(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function sV(n){for(var e=1;e0&&arguments[0]!==void 0?arguments[0]:{};pU=sV(sV({},pU),n)}function mge(){return pU}var r4;function vge(n){r4=n}function yge(){return r4}var Bge={type:"3rdParty",init:function(e){gge(e.options.react),vge(e)}},wge=me.createContext(),Cge=function(){function n(){lo(this,n),this.usedNamespaces={}}return Ao(n,[{key:"addUsedNamespaces",value:function(t){var r=this;t.forEach(function(i){r.usedNamespaces[i]||(r.usedNamespaces[i]=!0)})}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}]),n}();function bge(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var r,i,s,o,a=[],l=!0,A=!1;try{if(s=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(r=s.call(t)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(c){A=!0,i=c}finally{try{if(!l&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(A)throw i}}return a}}function xge(n,e){return jH(n)||bge(n,e)||$H(n,e)||qH()}function oV(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function C1(n){for(var e=1;e1&&arguments[1]!==void 0?arguments[1]:{},t=e.i18n,r=me.useContext(wge)||{},i=r.i18n,s=r.defaultNS,o=t||i||yge();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new Cge),!o){hU("You will need to pass in an i18next instance by using initReactI18next");var a=function(S,M){return typeof M=="string"?M:M&&$s(M)==="object"&&typeof M.defaultValue=="string"?M.defaultValue:Array.isArray(S)?S[S.length-1]:S},l=[a,{},!1];return l.t=a,l.i18n={},l.ready=!1,l}o.options.react&&o.options.react.wait!==void 0&&hU("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var A=C1(C1(C1({},mge()),o.options.react),e),c=A.useSuspense,u=A.keyPrefix,f=n||s||o.options&&o.options.defaultNS;f=typeof f=="string"?[f]:f||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(f);var d=(o.isInitialized||o.initializedStoreOnce)&&f.every(function(x){return uge(x,o,A)});function h(){return o.getFixedT(null,A.nsMode==="fallback"?f:f[0],u)}var p=me.useState(h),m=xge(p,2),g=m[0],v=m[1],y=f.join(),w=Ige(y),C=me.useRef(!0);me.useEffect(function(){var x=A.bindI18n,S=A.bindI18nStore;C.current=!0,!d&&!c&&rV(o,f,function(){C.current&&v(h)}),d&&w&&w!==y&&C.current&&v(h);function M(){C.current&&v(h)}return x&&o&&o.on(x,M),S&&o&&o.store.on(S,M),function(){C.current=!1,x&&o&&x.split(" ").forEach(function(Z){return o.off(Z,M)}),S&&o&&S.split(" ").forEach(function(Z){return o.store.off(Z,M)})}},[o,y]);var b=me.useRef(!0);me.useEffect(function(){C.current&&!b.current&&v(h),b.current=!1},[o,u]);var E=[g,o,d];if(E.t=g,E.i18n=o,E.ready=d,d||!d&&!c)return E;throw new Promise(function(x){rV(o,f,function(){x()})})}var s4=[],Fge=s4.forEach,Ege=s4.slice;function Uge(n){return Fge.call(Ege.call(arguments,1),function(e){if(e)for(var t in e)n[t]===void 0&&(n[t]=e[t])}),n}var aV=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Sge=function(e,t,r){var i=r||{};i.path=i.path||"/";var s=encodeURIComponent(t),o="".concat(e,"=").concat(s);if(i.maxAge>0){var a=i.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");o+="; Max-Age=".concat(Math.floor(a))}if(i.domain){if(!aV.test(i.domain))throw new TypeError("option domain is invalid");o+="; Domain=".concat(i.domain)}if(i.path){if(!aV.test(i.path))throw new TypeError("option path is invalid");o+="; Path=".concat(i.path)}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");o+="; Expires=".concat(i.expires.toUTCString())}if(i.httpOnly&&(o+="; HttpOnly"),i.secure&&(o+="; Secure"),i.sameSite){var l=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite;switch(l){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o},lV={create:function(e,t,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(s.expires=new Date,s.expires.setTime(s.expires.getTime()+r*60*1e3)),i&&(s.domain=i),document.cookie=Sge(e,encodeURIComponent(t),s)},read:function(e){for(var t="".concat(e,"="),r=document.cookie.split(";"),i=0;i-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var i=r.substring(1),s=i.split("&"),o=0;o0){var l=s[o].substring(0,a);l===e.lookupQuerystring&&(t=s[o].substring(a+1))}}}return t}},Yp=null,AV=function(){if(Yp!==null)return Yp;try{Yp=window!=="undefined"&&window.localStorage!==null;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch{Yp=!1}return Yp},Rge={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&AV()){var r=window.localStorage.getItem(e.lookupLocalStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&AV()&&window.localStorage.setItem(t.lookupLocalStorage,e)}},Xp=null,cV=function(){if(Xp!==null)return Xp;try{Xp=window!=="undefined"&&window.sessionStorage!==null;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch{Xp=!1}return Xp},Mge={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&cV()){var r=window.sessionStorage.getItem(e.lookupSessionStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&cV()&&window.sessionStorage.setItem(t.lookupSessionStorage,e)}},Tge={name:"navigator",lookup:function(e){var t=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r0?t:void 0}},Nge={name:"htmlTag",lookup:function(e){var t,r=e.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(t=r.getAttribute("lang")),t}},Dge={name:"path",lookup:function(e){var t;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof e.lookupFromPathIndex=="number"){if(typeof r[e.lookupFromPathIndex]!="string")return;t=r[e.lookupFromPathIndex].replace("/","")}else t=r[0].replace("/","")}return t}},kge={name:"subdomain",lookup:function(e){var t=typeof e.lookupFromSubdomainIndex=="number"?e.lookupFromSubdomainIndex+1:1,r=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[t]}};function Vge(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"]}}var o4=function(){function n(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};lo(this,n),this.type="languageDetector",this.detectors={},this.init(e,t)}return Ao(n,[{key:"init",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=t,this.options=Uge(r,this.options||{},Vge()),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(_ge),this.addDetector(Qge),this.addDetector(Rge),this.addDetector(Mge),this.addDetector(Tge),this.addDetector(Nge),this.addDetector(Dge),this.addDetector(kge)}},{key:"addDetector",value:function(t){this.detectors[t.name]=t}},{key:"detect",value:function(t){var r=this;t||(t=this.options.order);var i=[];return t.forEach(function(s){if(r.detectors[s]){var o=r.detectors[s].lookup(r.options);o&&typeof o=="string"&&(o=[o]),o&&(i=i.concat(o))}}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(t,r){var i=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||r.forEach(function(s){i.detectors[s]&&i.detectors[s].cacheUserLanguage(t,i.options)}))}}]),n}();o4.type="languageDetector";const Lge={translation:{pageTitles:{chooseClass:"Choose Character Class",chooseAppearance:"Choose Appearance",createBio:"Create Bio",saveCharacter:"Save Your Character",chat:"Chat With Your Character"},classes:{beastPainter:{name:"Beast Painter",description:"Paints beasts"},engineer:{name:"Engineer",description:"Builds things"},dropHunter:{name:"Drop Hunter",description:"Hunts drops"},theDegen:{name:"The Degen",description:"Degens"},neuralHacker:{name:"Neural Hacker",description:"Hacks neural networks"},liskWitch:{name:"Lisk Witch",description:"Witches lisk"},bruiser:{name:"Bruiser",description:"Bruises things"}},callToAction:{next:"Next",back:"Back",randomize:"Randomize",chat:"Chat",send:"Send"},editor:{title:"Appearance",head:"Head",body:"Body",eyes:"Eyes",outer:"Outer",chest:"Chest",legs:"Legs",feet:"Feet",accessories:"Accessories"},labels:{name:"Name",voice:"Voice",favoriteColor:"Favorite Color",preferredGreeting:"Preferred Greeting",bio:"Bio",question:"Question",yourName:"Your Name",conversation:"Conversation"},text:{unoptimized:"Unoptimized",apiUnderMaintnance:"Voice generation API is temporarily disabled for maintenance!"}}},Pge={translation:{pageTitles:{chooseClass:"Выбрать Класс Персонажа",chooseAppearance:"Выбрать Внешность",createBio:"Создать Биографию",saveCharacter:"Сохранить Персонажа",chat:"Общаться Со Своим Персонажем"},classes:{beastPainter:{name:"Анималист",description:"Рисует зверей"},engineer:{name:"Инженер",description:"Строит вещи"},dropHunter:{name:"Охотник за дропами",description:"Охотится на дропы"},theDegen:{name:"Деген",description:"Дегены"},neuralHacker:{name:"Нейронный Хакер",description:"Взламывает нейр. сети"},liskWitch:{name:"Лиск Ведьма",description:"Лиск Ведьмы"},bruiser:{name:"Громила",description:"Громит вещи"}},callToAction:{next:"Далее",back:"Назад",randomize:"Рандомизировать",chat:"Чат",send:"Отправить"},editor:{title:"Внешность",head:"Голова",body:"Тело",eyes:"Глаза",outer:"Внешний",chest:"Грудь",legs:"Ноги",feet:"Стопы",accessories:"Аксессуары"},labels:{name:"Имя",voice:"Голос",favoriteColor:"Любимый Цвет",preferredGreeting:"Предпочитаемое Приветствие",bio:"Биография",question:"Вопрос",yourName:"Ваше Имя",conversation:"Разговор"},text:{unoptimized:"Неоптимизи­рованный",apiUnderMaintnance:"API генерации голоса временно отключен на техническое обслуживание."}}},Wge={translation:{pageTitles:{chooseClass:"选择角色类型",chooseAppearance:"选择外观",createBio:"创建简介",saveCharacter:"保存角色",chat:"与你的角色聊天"},classes:{beastPainter:{name:"野兽画家",description:"画野兽"},engineer:{name:"工程师",description:"建造物品"},dropHunter:{name:"投放猎手",description:"猎取投放品"},theDegen:{name:"豪赌家",description:"资深赌徒"},neuralHacker:{name:"神经黑客",description:"侵入神经网络"},liskWitch:{name:"Lisk 巫师",description:"施法于 Lisk"},bruiser:{name:"碾压者",description:"碾碎一切"}},callToAction:{next:"下一步",back:"返回",randomize:"随机",chat:"聊天",send:"发送"},editor:{title:"外观",head:"头部",body:"身体",eyes:"眼睛",outer:"外套",chest:"上身",legs:"腿部",feet:"脚部",accessories:"配件"},labels:{name:"名字",voice:"语音",favoriteColor:"颜色偏好",preferredGreeting:"首选问候语",bio:"简介",question:"问题",yourName:"你的名字",conversation:"对话"},text:{unoptimized:"未优化",apiUnderMaintnance:"语音生成API暂时关闭进行维护!"}}},Oge={en:Lge,ru:Pge,zh:Wge};ri.use(o4).use(Bge).init({debug:!0,fallbackLng:"en",interpolation:{escapeValue:!1},resources:Oge});const bs=me.createContext(),Gge=n=>{const{t:e}=i4();return P.jsx(bs.Provider,{value:{t:e},children:n.children})},Zge=` uniform vec3 cameraDir; uniform vec3 eye; @@ -4957,7 +4957,7 @@ class SpeexResampleProcessor extends AudioWorkletProcessor {\r }\r }\r \r -registerProcessor('speex-resample-switch', SpeexResampleProcessor);`;if(typeof cl!="object"){var cl={};window.SepiaFW=cl}(function(n){var e=n.webAudio||{};e.version="0.9.11";var t=window.AudioContext||window.webkitAudioContext,r=void 0,i=void 0;function s(){return r=!!t&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia,!!r||i}e.isStreamRecorderSupported=s(),e.isNativeStreamResamplingSupported=!0,e.tryNativeStreamResampling=!0,e.contentFetchTimeout=8e3,e.defaultProcessorOptions={moduleFolder:"modules",initSuccessCallback:console.log,initErrorCallback:console.error,onerror:console.error};var o={};e.clearPreLoadCache=function(){o={}},e.getSupportedAudioConstraints=function(){var h=navigator.mediaDevices.getSupportedConstraints(),p={},m=e.overwriteSupportedAudioConstraints;return h.deviceId&&(p.deviceId=m.deviceId!=null?m.deviceId:void 0),h.channelCount&&(p.channelCount=m.channelCount!=null?m.channelCount:1),h.noiseSuppression&&(p.noiseSuppression=m.noiseSuppression!=null?m.noiseSuppression:!0),h.autoGainControl&&(p.autoGainControl=m.autoGainControl!=null?m.autoGainControl:!1),h.echoCancellation&&(p.echoCancellation=m.echoCancellation!=null?m.echoCancellation:!1),h.sampleRate&&(p.sampleRate=m.sampleRate!=null?m.sampleRate:48e3),p},e.overwriteSupportedAudioConstraints={},e.defaultMimeTypesForCodecs={ogg:"audio/ogg",ogg_opus:"audio/ogg;codecs=opus",ogg_vorbis:"audio/ogg;codecs=vorbis",ogg_speex:"audio/ogg;codecs=speex",opus:"audio/opus",vorbis:"audio/vorbis",speex:"audio/speex",wav:"audio/wav",raw:"audio/wav",webm_ogg_opus:"audio/webm;codecs=opus",webm_ogg_vorbis:"audio/webm;codecs=vorbis",webm_mkv_pcm:"audio/webm;codecs=pcm",mp3:"audio/mpeg",mp4:"audio/mp4",flac:"audio/flac",mpeg:"audio/mpeg"},e.getSupportedMediaRecorderCodecs=function(){var h={};return window.MediaRecorder&&Object.keys(e.defaultMimeTypesForCodecs).forEach(function(p){var m=e.defaultMimeTypesForCodecs[p];window.MediaRecorder.isTypeSupported(m)&&(h[p]=m)}),h},e.createAudioContext=function(h,p){var m={};!p&&h.targetSampleRate&&(m.sampleRate=h.targetSampleRate);var g=new t(m);return g},e.Processor=function(h,p,m){var g=this;m||(m=e.defaultProcessorOptions.initErrorCallback),p||(p=e.defaultProcessorOptions.initSuccessCallback),h||(h={});var v=h.onerror||e.defaultProcessorOptions.onerror,y=(h.moduleFolder||e.defaultProcessorOptions.moduleFolder).replace(/\/$/,"")+"/",w,C=0,b,E,x,S,M=!1,Z=!1,K=!1,_=h.initializerTimeout||3e3,B,F={},R={},k=[];function T(X){h.debugLog&&h.debugLog("Started init. condition: "+X),F[X]=1}function V(X){F[X]&&(delete F[X],h.debugLog&&h.debugLog("Completed init. condition: "+X),Object.keys(F).length==0&&(Z||(clearTimeout(B),Z=!0,K=!1,p({name:"ProcessorReady",message:"Processor is ready for action",inputSampleRate:w,targetSampleRate:h.targetSampleRate||w,sourceInfo:R,modulesInfo:k}))))}function O(){clearTimeout(B),Z=!1,K=!1,F={},T("sourceSetup"),T("modulesSetup")}function L(X){O(),m(X)}O(),K=!0,B=setTimeout(function(){L({message:"Initialization took too long! If you expect long running init. process use option 'initializerTimeout' (ms).",name:"ProcessorInitTimeout"})},_);async function U(X,ne){if(b&&X&&(b.state!="closed"&&await b.close(),b=null),!b||b.state=="closed")if(b=e.createAudioContext(h,ne),h.startSuspended==null||h.startSuspended){try{await b.resume()}catch{}await b.suspend()}else await b.resume();return b}async function H(){if(h.modules)for(let X=0;X2)throw{name:"PreLoadError",message:"Missing 'path' (url) or unsupported type (use 1=text or 2=arraybuffer)"};ee==1?Ce=await A($):ee==2&&(Ce=await l($)),typeof te=="function"&&(Ce=te(Ce)),G[I]=Ce,o[we]=Ce}catch(Ee){throw{name:"AddModuleError",message:"Failed to pre-load data: "+I+" - name: "+Ge,info:Ee}}}))}catch(I){L(I);return}var se=Xe.options||{};se.preLoadResults=G;var fe;function ve(I){if(!(!I||I.data==null))if(I.data.moduleState==1)fe.isReady=!0,V("module-"+Oe),I.data.moduleInfo&&(fe.moduleInfo=I.data.moduleInfo),pe[Oe]={moduleName:fe.moduleName,moduleInfo:fe.moduleInfo},--Fe==0&&ae(pe);else if(I.data.moduleState==9&&!fe.isTerminated){if(typeof fe.terminate=="function")try{fe.isTerminated=!0,fe.terminate()}catch(D){fe.isTerminated=!0,W({name:"TerminateError",message:"Failed to terminate module",info:D})}}else I.data.moduleState==10?(I.data.error.target=I.target,W(I.data.error)):I.data.moduleResponse||Xe.sendToModules&&(I.data.moduleEvent?Xe.sendToModules.forEach(function(D){X[D]&&!X[D].ignoreSendToModules&&X[D].sendToModule({ctrl:{action:"handle",data:I.data}})}):Xe.sendToModules.forEach(function(D){X[D]&&!X[D].ignoreSendToModules&&X[D].sendToModule({ctrl:{action:"process",data:I.data}})}));Xe.onmessage&&Xe.onmessage(I.data,X)}function W(I){var D;I.message&&I.message.indexOf("Uncaught {")==0?(I.preventDefault(),D=JSON.parse(I.message.replace(/^Uncaught /,"")),I.message=D):D=I,v({name:"AudioModuleProcessorException",message:"Error in module: "+I.target.moduleName+" - "+(D&&D.message?D.message:"Check console for details."),module:I.target.moduleName,info:D}),K&&!Z&&L({message:"Error during setup of module: "+fe.moduleName,name:"ProcessorInitError",info:D}),Xe.onerror&&Xe.onerror(I)}if(Qe==1){if(!ne){L({name:"AddModuleError",message:"Source does not support 'AudioWorkletProcessor' (use only workers instead) - name: "+Ge});return}se.processorOptions||(se.processorOptions=se.setup||{}),se.processorOptions.ctxInfo||(se.processorOptions.ctxInfo={sampleRate:b.sampleRate,targetSampleRate:h.targetSampleRate}),fe=new AudioWorkletNode(b,Ge,se),fe.isReady=!1,fe.moduleName=Ge,fe.port.onmessage=ve,fe.onprocessorerror=W,fe.sendToModule=function(I){fe.isReady?fe.port.postMessage(I):v({name:"AudioModuleProcessorException",message:"'sendToModule' was called before module was actually ready. Consider 'startSuspended' option maybe.'",module:fe.moduleName})}}else if(Qe==2)se.setup||(se.setup={}),se.setup.ctxInfo||(se.setup.ctxInfo={sampleRate:b.sampleRate,targetSampleRate:h.targetSampleRate}),Ge.includes("webrtc-vad")?fe=Eve():Ge.includes("stt-socket")&&(fe=Uve()),fe.isReady=!1,fe.moduleName=Ge,fe.onmessage=ve,fe.onerror=W,fe.sendToModule=function(I){fe.isReady||I&&I.ctrl&&I.ctrl.action=="construct"?fe.postMessage(I):v({name:"AudioModuleProcessorException",message:"'sendToModule' was called before module was actually ready. Consider 'startSuspended' option maybe.",module:fe.moduleName})},fe.sendToModule({ctrl:{action:"construct",options:se}});else if(Qe==3){L({name:"AddModuleError",message:"ScriptProcessor nodes are currently not supported as modules (only source)."});return}else if(Qe==4){L({name:"AddModuleError",message:"AudioNodes are currently not supported as modules (you can use them as custom source)."});return}else{L({name:"AddModuleError",message:"Unknown module type."});return}if(fe.moduleType=Qe,fe.ignoreSendToModules=!1,fe.deactivate=function(){fe.ignoreSendToModules=!0,M&&(fe.sendToModule({ctrl:{action:"stop"}}),fe.sendToModule({ctrl:{action:"reset"}}))},fe.activate=function(){fe.ignoreSendToModules=!1,M&&fe.sendToModule({ctrl:{action:"start"}})},rt.handle=fe,!ne&&Oe==0){var Q=X[0];if(!Q.onmessage){L({name:"AddModuleError",message:"If source is not compatible to 'AudioWorklet' it has to have a 'onmessage' event to get the processed data."});return}Q.onmessage=function(I){!I||I.data==null||(I.data.moduleEvent||I.data.sourceEvent?fe.sendToModule({ctrl:{action:"handle",data:I.data}}):fe.sendToModule({ctrl:{action:"process",data:I.data}}))}}X[Be+Oe]=fe})}else ae([])}function de(X,ne,ae){w=b.sampleRate,ae||(ae={}),h.targetSampleRate&&h.targetSampleRate!=w&&(e.isNativeStreamResamplingSupported=!1,C=w-h.targetSampleRate);var Be=[X],pe=[],Fe=!0;ae.hasWorkletSupport!=null?Fe=ae.hasWorkletSupport:ae.type=="scriptProcessor"&&(Fe=!1),ie(Be,Fe,function(Oe){k=Oe,V("modulesSetup"),g.processNodes=Be;let ke=!1;if(Be.forEach(function(Qe,Ge){Fe&&(!Qe.moduleType||Qe.moduleType==1)&&pe.push(Qe),Qe.moduleInfo&&Qe.moduleInfo.resamplingMode&&(ke=!0)}),C&&!ke){L({message:"Samplerate mismatch and no resampler found!",name:"ProcessorInitError"});return}});var rt=h.destinationNode||b.destination;g.mainAudioContext=b,g.source=X,g.sourceInfo=ae,R=ae,ne||(ne={}),E=function(Oe,ke){Promise.resolve((ne.onBeforeStart||d)()).then(function(){return b.resume()}).then(function(){if(pe.length>1){for(var Qe=1;Qe1)return v({message:"Sorry, but this recorder only supports MONO audio at the moment.",name:"NotSupportedError"});var C=m.mimeType||e.defaultMimeTypesForCodecs[m.codec]||e.defaultMimeTypesForCodecs.webm_ogg_opus,b=m.sampleTime||(m.chunkSize?Math.floor(1e3/y*m.chunkSize):0);if(b&&m.decodeToAudioBuffer&&console.error("WARNING: Partial decoding is not supported at the moment! It is possible but requires adding custom headers for each blob!"),window.MediaRecorder)if(MediaRecorder.isTypeSupported(C)){var E=new MediaRecorder(h,{mimeType:C,bitsPerSecond:y*2*w}),x,S,M=!1;E.onerror=m.onerror||console.error,m.onstart&&(E.onstart=m.onstart),m.onpause&&(E.onpause=m.onpause),m.onresume&&(E.onresume=m.onresume);var Z=m.onstop;E.onstop=function(R){Z&&!m.decodeToAudioBuffer&&Z()};var K=m.ondataavailable||m.onprocess;m.decodeToAudioBuffer?K&&(E.ondataavailable=function(R){if(E.state=="inactive"&&(M=!0),R&&R.data){let k=Date.now();e.offlineAudioContextBlobDecoder(y,w,R.data,function(T){T&&K({data:T.getChannelData(0),decodeTime:Date.now()-k}),!M&&m.recordLimitMs&&Date.now()-x>=m.recordLimitMs?B():M&&Z&&Z()})}}):K&&(E.ondataavailable=function(R){K(R),m.recordLimitMs&&Date.now()-x>=m.recordLimitMs&&B()});var _,B=function(){_&&clearTimeout(_),S=Date.now(),E.state!="inactive"&&E.stop()},F=function(){x=Date.now(),S=void 0,M=!1,b?E.start(b):(E.start(),m.recordLimitMs&&(_=setTimeout(B,m.recordLimitMs)))};return g({getMediaRecorder:function(){return E},mimeType:C,sourceInfo:p,sampleTime:b,start:F,stop:B})}else return v({message:"MIME-Type '"+C+"' is not supported!",name:"NotSupportedError"});else return v({message:"'MediaRecorder' is not available!",name:"NotSupportedError"})}catch(R){return console.error("AudioRecorder",R),v(R)}})()})},e.offlineAudioContextBlobDecoder=function(h,p,m,g){a(m,function(v){if(!v)g();else{var y=new OfflineAudioContext(p,v.byteLength,h);y.decodeAudioData(v,function(w){g(w)},function(w){console.error("offlineAudioContext.decodeAudioData ERROR",w),g()})}})};function a(h,p){if(!h||!h.size)p();else if(typeof h.arrayBuffer=="function")h.arrayBuffer().then(function(g){p(g)}).catch(function(g){console.error("blobToArray '.arrayBuffer' ERROR",g),p()});else{var m=new FileReader;m.onload=function(){p(m.result)},m.onerror=function(g){console.error("blobToArray 'FileReader' ERROR",reader.error,g),p()},m.readAsArrayBuffer(h)}}e.blobToArray=a,e.createLegacyMicrophoneScriptProcessor=function(h){return h||(h={}),e.getMicrophone(h,void 0).then(function(p){var m=p.source,g=m.context,v=g.sampleRate,y=h.bufferSize||2048,w=1,C=g.createScriptProcessor(y,w,w);m.connect(C);var b={node:C,type:"scriptProcessor",typeData:p.info,hasWorkletSupport:!1,start:function(){p.controls.onAfterStart&&p.controls.onAfterStart()},stop:function(){p.controls.onBeforeStop&&p.controls.onBeforeStop()},release:function(){p.controls.onAfterRelease&&p.controls.onAfterRelease()}};if(p.controls&&(p.controls.onBeforeStart&&(b.beforeStart=p.controls.onBeforeStart),p.controls.onAfterStop&&(b.afterStop=p.controls.onAfterStop),p.controls.onBeforeRelease&&(b.beforeRelease=p.controls.onBeforeRelease)),h.onaudioprocess)C.onaudioprocess=h.onaudioprocess;else{let E=function(x){if(x&&x.inputBuffer){var S=[x.inputBuffer.getChannelData(0)];C.onmessage({data:{samples:S,sampleRate:v,channels:w,type:S[0].constructor.name}})}};C.onaudioprocess=function(x){E(x)},C.onmessage=h.onmessage||function(x){}}return b})},e.createWhiteNoiseGeneratorNode=function(h,p,m){p||(p={});var g=e.defaultProcessorOptions.moduleFolder.replace(/\/$/,"")+"/";return new Promise(function(v,y){(async function(){try{var w=e.createAudioContext(p);try{await w.resume()}catch{}await w.suspend();var C=g+"white-noise-generator.js";await w.audioWorklet.addModule(C);var b=new AudioWorkletNode(w,"white-noise-generator",{processorOptions:{gain:h||.1}});m&&(b.port.onmessage=m),v(b)}catch(E){return y(E)}})()})},e.createFileSource=function(h,p,m,g){return p||(p={}),new Promise(function(v,y){try{let w=function(b){y(b)},C=function(b){e.createAudioBufferSource(b,p,m,g).then(function(E){E.typeData={fileUrl:h},v(E)}).catch(w)};e.readFileAsBuffer(h,C,w)}catch(w){y(w)}})},e.createAudioBufferSource=function(h,p,m,g){return p||(p={}),new Promise(function(v,y){(async function(){try{var w=e.createAudioContext(p);try{await w.resume()}catch{}await w.suspend();var C=w.createBufferSource();w.decodeAudioData(h,function(b){return C.buffer=b,C.loop=m??!0,g&&(C.onended=g),v({node:C,type:"fileAudioBuffer",typeData:{},start:function(){C.start()},stop:function(){C.stop()},release:function(){}})},function(b){return y(b)})}catch(b){return y(b)}})()})},e.createSourceAudioPlayer=function(h,p,m,g,v){p||(p={}),p.modules=m||[],p.customSource=h,p.startSuspended==null&&(p.startSuspended=!0);var y=new e.Processor(p,g,v);return y},e.encodeWaveBuffer=function(h,p,m,g,v,y){var w=e.defaultProcessorOptions.moduleFolder.replace(/\/$/,"")+"/",C=new Worker(w+"wave-encoder-worker.js");v||(v=console.log),y||(y=console.error);var b={setup:{inputSampleRate:p,inputSampleSize:h.length,lookbackBufferMs:0}};C.onmessage=function(E){E.data.moduleState==1?C.postMessage({encode:{format:"wave",data:{samples:[h],sampleRate:p,channels:m,isFloat32:g}}}):E.data.encoderResult&&(C.terminate(),E.data.error?y({name:"EncoderError",message:E.data.error}):v(E.data.encoderResult))},C.onerror=function(E){C.terminate(),y(E)},C.postMessage({ctrl:{action:"construct",options:b}})},e.decodeAudioFile=function(h,p,m,g,v){e.readFileAsBuffer(h,function(y){var w=new OfflineAudioContext(m,y.byteLength,p);w.decodeAudioData(y,function(C){g(C)},function(C){v(C)})},function(y){v(y)})},e.decodeAudioFileToInt16Mono=function(h,p,m,g){var v=1;e.decodeAudioFile(h,p,v,function(y){var w=!0;e.encodeWaveBuffer(y.getChannelData(0),p,v,w,function(C){try{var b=new Int16Array(C.wav.buffer);m(b)}catch(E){g(E)}},g)},g)},e.resampleBufferViaSpeex=function(h,p,m,g,v,y,w){y||(y=console.log),w||(w=console.error);try{var C=new OfflineAudioContext(g,h.length,p),b=e.defaultProcessorOptions.moduleFolder.replace(/\/$/,"")+"/",E="speex-resample-switch";C.audioWorklet.addModule(b+E+".js").then(function(){var x={processorOptions:{ctxInfo:{sampleRate:p},targetSampleRate:m,resampleQuality:v,bufferSize:h.length}},S=new AudioWorkletNode(C,E,x);S.port.onmessage=function(M){M.data.moduleState==1?S.port.postMessage({resample:{samples:[h],isInt16:!0}}):M.data.resampleResult&&(C=null,M.data.error?w({name:"ResampleError",message:M.data.error}):y(M.data.resampleResult))},S.onprocessorerror=function(M){C=null,w(M)}})}catch(x){w(x)}},e.readFileAsBuffer=function(h,p,m){cl&&cl.files?cl.files.fetch(h,p,m,"arraybuffer",e.contentFetchTimeout):c("arraybuffer",h,p,m)},e.readFileAsText=function(h,p,m){cl&&cl.files?cl.files.fetch(h,p,m,void 0,e.contentFetchTimeout):c("text",h,p,m)};function l(h){return new Promise(function(p,m){e.readFileAsBuffer(h,function(g){p(g)},function(g){m(g)})})}function A(h){return new Promise(function(p,m){e.readFileAsText(h,function(g){p(g)},function(g){m(g)})})}function c(h,p,m,g){var v=new XMLHttpRequest;v.open("GET",p),v.responseType=h,v.timeout=e.contentFetchTimeout,v.onload=function(y){v.status>=200&&v.status<300?m(v.response):g({status:v.status,message:v.statusText})},v.onerror=function(y){g(y)},v.ontimeout=function(y){g(y)},v.send()}function u(h){try{for(var p=atob(h),m=new Uint8Array(p.length),g=0;g1&&console.error("SepiaVoiceRecorder.decodeAudioFileToInt16Mono - Channels > 1 not supported. Result will only contain data of channel 0."),m||(m=console.log),g||(g=console.error),SepiaFW.webAudio.decodeAudioFileToInt16Mono(d,h,m,g)},n.addAudioElementToPage=function(d,h,p){return SepiaFW.webAudio.addAudioElementToPage(d,h,p)},window.SepiaVoiceRecorder=n})();class _ve{constructor(e,t){nt(this,"volumeThresholds",[.05,10]);nt(this,"gain",1);nt(this,"isLoading",!1);nt(this,"isRecording",!1);nt(this,"isWaitingForFinalResult",!1);nt(this,"waitingForFinalResultTimer");nt(this,"waitingForFinalResultDelay",4e3);nt(this,"asrStreaming",!1);nt(this,"sourceInfo","-?-");if(window.SepiaFW&&(SepiaFW.webAudio.defaultProcessorOptions.moduleFolder="lib"),!window.SepiaVoiceRecorder)SepiaVoiceRecorder={notSupported:!0},console.error("SEPIA Web Audio Library not found or not supported (IE11?)!");else{this.sepiaSpeechRecognition=e,this.sepiaSpeechRecognitionConfig=t;const r=this;SepiaVoiceRecorder.onProcessorReady=function(i){console.log("SepiaVoiceRecorder - onProcessorReady",i),this.sourceInfo="Sample-rate: "+i.targetSampleRate+"Hz (factor: "+i.inputSampleRate/i.targetSampleRate+`) +registerProcessor('speex-resample-switch', SpeexResampleProcessor);`;if(typeof cl!="object"){var cl={};window.SepiaFW=cl}(function(n){var e=n.webAudio||{};e.version="0.9.11";var t=window.AudioContext||window.webkitAudioContext,r=void 0,i=void 0;function s(){return r=!!t&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia,!!r||i}e.isStreamRecorderSupported=s(),e.isNativeStreamResamplingSupported=!0,e.tryNativeStreamResampling=!0,e.contentFetchTimeout=8e3,e.defaultProcessorOptions={moduleFolder:"modules",initSuccessCallback:console.log,initErrorCallback:console.error,onerror:console.error};var o={};e.clearPreLoadCache=function(){o={}},e.getSupportedAudioConstraints=function(){var h=navigator.mediaDevices.getSupportedConstraints(),p={},m=e.overwriteSupportedAudioConstraints;return h.deviceId&&(p.deviceId=m.deviceId!=null?m.deviceId:void 0),h.channelCount&&(p.channelCount=m.channelCount!=null?m.channelCount:1),h.noiseSuppression&&(p.noiseSuppression=m.noiseSuppression!=null?m.noiseSuppression:!0),h.autoGainControl&&(p.autoGainControl=m.autoGainControl!=null?m.autoGainControl:!1),h.echoCancellation&&(p.echoCancellation=m.echoCancellation!=null?m.echoCancellation:!1),h.sampleRate&&(p.sampleRate=m.sampleRate!=null?m.sampleRate:48e3),p},e.overwriteSupportedAudioConstraints={},e.defaultMimeTypesForCodecs={ogg:"audio/ogg",ogg_opus:"audio/ogg;codecs=opus",ogg_vorbis:"audio/ogg;codecs=vorbis",ogg_speex:"audio/ogg;codecs=speex",opus:"audio/opus",vorbis:"audio/vorbis",speex:"audio/speex",wav:"audio/wav",raw:"audio/wav",webm_ogg_opus:"audio/webm;codecs=opus",webm_ogg_vorbis:"audio/webm;codecs=vorbis",webm_mkv_pcm:"audio/webm;codecs=pcm",mp3:"audio/mpeg",mp4:"audio/mp4",flac:"audio/flac",mpeg:"audio/mpeg"},e.getSupportedMediaRecorderCodecs=function(){var h={};return window.MediaRecorder&&Object.keys(e.defaultMimeTypesForCodecs).forEach(function(p){var m=e.defaultMimeTypesForCodecs[p];window.MediaRecorder.isTypeSupported(m)&&(h[p]=m)}),h},e.createAudioContext=function(h,p){var m={};!p&&h.targetSampleRate&&(m.sampleRate=h.targetSampleRate);var g=new t(m);return g},e.Processor=function(h,p,m){var g=this;m||(m=e.defaultProcessorOptions.initErrorCallback),p||(p=e.defaultProcessorOptions.initSuccessCallback),h||(h={});var v=h.onerror||e.defaultProcessorOptions.onerror,y=(h.moduleFolder||e.defaultProcessorOptions.moduleFolder).replace(/\/$/,"")+"/",w,C=0,b,E,x,S,M=!1,Z=!1,K=!1,_=h.initializerTimeout||3e3,B,F={},R={},k=[];function T(X){h.debugLog&&h.debugLog("Started init. condition: "+X),F[X]=1}function V(X){F[X]&&(delete F[X],h.debugLog&&h.debugLog("Completed init. condition: "+X),Object.keys(F).length==0&&(Z||(clearTimeout(B),Z=!0,K=!1,p({name:"ProcessorReady",message:"Processor is ready for action",inputSampleRate:w,targetSampleRate:h.targetSampleRate||w,sourceInfo:R,modulesInfo:k}))))}function O(){clearTimeout(B),Z=!1,K=!1,F={},T("sourceSetup"),T("modulesSetup")}function L(X){O(),m(X)}O(),K=!0,B=setTimeout(function(){L({message:"Initialization took too long! If you expect long running init. process use option 'initializerTimeout' (ms).",name:"ProcessorInitTimeout"})},_);async function U(X,ne){if(b&&X&&(b.state!="closed"&&await b.close(),b=null),!b||b.state=="closed")if(b=e.createAudioContext(h,ne),h.startSuspended==null||h.startSuspended){try{await b.resume()}catch{}await b.suspend()}else await b.resume();return b}async function H(){if(h.modules)for(let X=0;X2)throw{name:"PreLoadError",message:"Missing 'path' (url) or unsupported type (use 1=text or 2=arraybuffer)"};ee==1?Ce=await A($):ee==2&&(Ce=await l($)),typeof te=="function"&&(Ce=te(Ce)),G[I]=Ce,o[we]=Ce}catch(Ee){throw{name:"AddModuleError",message:"Failed to pre-load data: "+I+" - name: "+Ge,info:Ee}}}))}catch(I){L(I);return}var se=Xe.options||{};se.preLoadResults=G;var fe;function ve(I){if(!(!I||I.data==null))if(I.data.moduleState==1)fe.isReady=!0,V("module-"+Oe),I.data.moduleInfo&&(fe.moduleInfo=I.data.moduleInfo),pe[Oe]={moduleName:fe.moduleName,moduleInfo:fe.moduleInfo},--Fe==0&&ae(pe);else if(I.data.moduleState==9&&!fe.isTerminated){if(typeof fe.terminate=="function")try{fe.isTerminated=!0,fe.terminate()}catch(D){fe.isTerminated=!0,W({name:"TerminateError",message:"Failed to terminate module",info:D})}}else I.data.moduleState==10?(I.data.error.target=I.target,W(I.data.error)):I.data.moduleResponse||Xe.sendToModules&&(I.data.moduleEvent?Xe.sendToModules.forEach(function(D){X[D]&&!X[D].ignoreSendToModules&&X[D].sendToModule({ctrl:{action:"handle",data:I.data}})}):Xe.sendToModules.forEach(function(D){X[D]&&!X[D].ignoreSendToModules&&X[D].sendToModule({ctrl:{action:"process",data:I.data}})}));Xe.onmessage&&Xe.onmessage(I.data,X)}function W(I){var D;I.message&&I.message.indexOf("Uncaught {")==0?(I.preventDefault(),D=JSON.parse(I.message.replace(/^Uncaught /,"")),I.message=D):D=I,v({name:"AudioModuleProcessorException",message:"Error in module: "+I.target.moduleName+" - "+(D&&D.message?D.message:"Check console for details."),module:I.target.moduleName,info:D}),K&&!Z&&L({message:"Error during setup of module: "+fe.moduleName,name:"ProcessorInitError",info:D}),Xe.onerror&&Xe.onerror(I)}if(Qe==1){if(!ne){L({name:"AddModuleError",message:"Source does not support 'AudioWorkletProcessor' (use only workers instead) - name: "+Ge});return}se.processorOptions||(se.processorOptions=se.setup||{}),se.processorOptions.ctxInfo||(se.processorOptions.ctxInfo={sampleRate:b.sampleRate,targetSampleRate:h.targetSampleRate}),fe=new AudioWorkletNode(b,Ge,se),fe.isReady=!1,fe.moduleName=Ge,fe.port.onmessage=ve,fe.onprocessorerror=W,fe.sendToModule=function(I){fe.isReady?fe.port.postMessage(I):v({name:"AudioModuleProcessorException",message:"'sendToModule' was called before module was actually ready. Consider 'startSuspended' option maybe.'",module:fe.moduleName})}}else if(Qe==2)se.setup||(se.setup={}),se.setup.ctxInfo||(se.setup.ctxInfo={sampleRate:b.sampleRate,targetSampleRate:h.targetSampleRate}),Ge.includes("webrtc-vad")?fe=Eve():Ge.includes("stt-socket")&&(fe=Uve()),fe.isReady=!1,fe.moduleName=Ge,fe.onmessage=ve,fe.onerror=W,fe.sendToModule=function(I){fe.isReady||I&&I.ctrl&&I.ctrl.action=="construct"?fe.postMessage(I):v({name:"AudioModuleProcessorException",message:"'sendToModule' was called before module was actually ready. Consider 'startSuspended' option maybe.",module:fe.moduleName})},fe.sendToModule({ctrl:{action:"construct",options:se}});else if(Qe==3){L({name:"AddModuleError",message:"ScriptProcessor nodes are currently not supported as modules (only source)."});return}else if(Qe==4){L({name:"AddModuleError",message:"AudioNodes are currently not supported as modules (you can use them as custom source)."});return}else{L({name:"AddModuleError",message:"Unknown module type."});return}if(fe.moduleType=Qe,fe.ignoreSendToModules=!1,fe.deactivate=function(){fe.ignoreSendToModules=!0,M&&(fe.sendToModule({ctrl:{action:"stop"}}),fe.sendToModule({ctrl:{action:"reset"}}))},fe.activate=function(){fe.ignoreSendToModules=!1,M&&fe.sendToModule({ctrl:{action:"start"}})},rt.handle=fe,!ne&&Oe==0){var Q=X[0];if(!Q.onmessage){L({name:"AddModuleError",message:"If source is not compatible to 'AudioWorklet' it has to have a 'onmessage' event to get the processed data."});return}Q.onmessage=function(I){!I||I.data==null||(I.data.moduleEvent||I.data.sourceEvent?fe.sendToModule({ctrl:{action:"handle",data:I.data}}):fe.sendToModule({ctrl:{action:"process",data:I.data}}))}}X[Be+Oe]=fe})}else ae([])}function de(X,ne,ae){w=b.sampleRate,ae||(ae={}),h.targetSampleRate&&h.targetSampleRate!=w&&(e.isNativeStreamResamplingSupported=!1,C=w-h.targetSampleRate);var Be=[X],pe=[],Fe=!0;ae.hasWorkletSupport!=null?Fe=ae.hasWorkletSupport:ae.type=="scriptProcessor"&&(Fe=!1),ie(Be,Fe,function(Oe){k=Oe,V("modulesSetup"),g.processNodes=Be;let ke=!1;if(Be.forEach(function(Qe,Ge){Fe&&(!Qe.moduleType||Qe.moduleType==1)&&pe.push(Qe),Qe.moduleInfo&&Qe.moduleInfo.resamplingMode&&(ke=!0)}),C&&!ke){L({message:"Samplerate mismatch and no resampler found!",name:"ProcessorInitError"});return}});var rt=h.destinationNode||b.destination;g.mainAudioContext=b,g.source=X,g.sourceInfo=ae,R=ae,ne||(ne={}),E=function(Oe,ke){Promise.resolve((ne.onBeforeStart||d)()).then(function(){return b.resume()}).then(function(){if(pe.length>1){for(var Qe=1;Qe1)return v({message:"Sorry, but this recorder only supports MONO audio at the moment.",name:"NotSupportedError"});var C=m.mimeType||e.defaultMimeTypesForCodecs[m.codec]||e.defaultMimeTypesForCodecs.webm_ogg_opus,b=m.sampleTime||(m.chunkSize?Math.floor(1e3/y*m.chunkSize):0);if(b&&m.decodeToAudioBuffer&&console.error("WARNING: Partial decoding is not supported at the moment! It is possible but requires adding custom headers for each blob!"),window.MediaRecorder)if(MediaRecorder.isTypeSupported(C)){var E=new MediaRecorder(h,{mimeType:C,bitsPerSecond:y*2*w}),x,S,M=!1;E.onerror=m.onerror||console.error,m.onstart&&(E.onstart=m.onstart),m.onpause&&(E.onpause=m.onpause),m.onresume&&(E.onresume=m.onresume);var Z=m.onstop;E.onstop=function(R){Z&&!m.decodeToAudioBuffer&&Z()};var K=m.ondataavailable||m.onprocess;m.decodeToAudioBuffer?K&&(E.ondataavailable=function(R){if(E.state=="inactive"&&(M=!0),R&&R.data){let k=Date.now();e.offlineAudioContextBlobDecoder(y,w,R.data,function(T){T&&K({data:T.getChannelData(0),decodeTime:Date.now()-k}),!M&&m.recordLimitMs&&Date.now()-x>=m.recordLimitMs?B():M&&Z&&Z()})}}):K&&(E.ondataavailable=function(R){K(R),m.recordLimitMs&&Date.now()-x>=m.recordLimitMs&&B()});var _,B=function(){_&&clearTimeout(_),S=Date.now(),E.state!="inactive"&&E.stop()},F=function(){x=Date.now(),S=void 0,M=!1,b?E.start(b):(E.start(),m.recordLimitMs&&(_=setTimeout(B,m.recordLimitMs)))};return g({getMediaRecorder:function(){return E},mimeType:C,sourceInfo:p,sampleTime:b,start:F,stop:B})}else return v({message:"MIME-Type '"+C+"' is not supported!",name:"NotSupportedError"});else return v({message:"'MediaRecorder' is not available!",name:"NotSupportedError"})}catch(R){return console.error("AudioRecorder",R),v(R)}})()})},e.offlineAudioContextBlobDecoder=function(h,p,m,g){a(m,function(v){if(!v)g();else{var y=new OfflineAudioContext(p,v.byteLength,h);y.decodeAudioData(v,function(w){g(w)},function(w){console.error("offlineAudioContext.decodeAudioData ERROR",w),g()})}})};function a(h,p){if(!h||!h.size)p();else if(typeof h.arrayBuffer=="function")h.arrayBuffer().then(function(g){p(g)}).catch(function(g){console.error("blobToArray '.arrayBuffer' ERROR",g),p()});else{var m=new FileReader;m.onload=function(){p(m.result)},m.onerror=function(g){console.error("blobToArray 'FileReader' ERROR",reader.error,g),p()},m.readAsArrayBuffer(h)}}e.blobToArray=a,e.createLegacyMicrophoneScriptProcessor=function(h){return h||(h={}),e.getMicrophone(h,void 0).then(function(p){var m=p.source,g=m.context,v=g.sampleRate,y=h.bufferSize||2048,w=1,C=g.createScriptProcessor(y,w,w);m.connect(C);var b={node:C,type:"scriptProcessor",typeData:p.info,hasWorkletSupport:!1,start:function(){p.controls.onAfterStart&&p.controls.onAfterStart()},stop:function(){p.controls.onBeforeStop&&p.controls.onBeforeStop()},release:function(){p.controls.onAfterRelease&&p.controls.onAfterRelease()}};if(p.controls&&(p.controls.onBeforeStart&&(b.beforeStart=p.controls.onBeforeStart),p.controls.onAfterStop&&(b.afterStop=p.controls.onAfterStop),p.controls.onBeforeRelease&&(b.beforeRelease=p.controls.onBeforeRelease)),h.onaudioprocess)C.onaudioprocess=h.onaudioprocess;else{let E=function(x){if(x&&x.inputBuffer){var S=[x.inputBuffer.getChannelData(0)];C.onmessage({data:{samples:S,sampleRate:v,channels:w,type:S[0].constructor.name}})}};C.onaudioprocess=function(x){E(x)},C.onmessage=h.onmessage||function(x){}}return b})},e.createWhiteNoiseGeneratorNode=function(h,p,m){p||(p={});var g=e.defaultProcessorOptions.moduleFolder.replace(/\/$/,"")+"/";return new Promise(function(v,y){(async function(){try{var w=e.createAudioContext(p);try{await w.resume()}catch{}await w.suspend();var C=g+"white-noise-generator.js";await w.audioWorklet.addModule(C);var b=new AudioWorkletNode(w,"white-noise-generator",{processorOptions:{gain:h||.1}});m&&(b.port.onmessage=m),v(b)}catch(E){return y(E)}})()})},e.createFileSource=function(h,p,m,g){return p||(p={}),new Promise(function(v,y){try{let w=function(b){y(b)},C=function(b){e.createAudioBufferSource(b,p,m,g).then(function(E){E.typeData={fileUrl:h},v(E)}).catch(w)};e.readFileAsBuffer(h,C,w)}catch(w){y(w)}})},e.createAudioBufferSource=function(h,p,m,g){return p||(p={}),new Promise(function(v,y){(async function(){try{var w=e.createAudioContext(p);try{await w.resume()}catch{}await w.suspend();var C=w.createBufferSource();w.decodeAudioData(h,function(b){return C.buffer=b,C.loop=m??!0,g&&(C.onended=g),v({node:C,type:"fileAudioBuffer",typeData:{},start:function(){C.start()},stop:function(){C.stop()},release:function(){}})},function(b){return y(b)})}catch(b){return y(b)}})()})},e.createSourceAudioPlayer=function(h,p,m,g,v){p||(p={}),p.modules=m||[],p.customSource=h,p.startSuspended==null&&(p.startSuspended=!0);var y=new e.Processor(p,g,v);return y},e.encodeWaveBuffer=function(h,p,m,g,v,y){var w=e.defaultProcessorOptions.moduleFolder.replace(/\/$/,"")+"/",C=new Worker(w+"wave-encoder-worker.js");v||(v=console.log),y||(y=console.error);var b={setup:{inputSampleRate:p,inputSampleSize:h.length,lookbackBufferMs:0}};C.onmessage=function(E){E.data.moduleState==1?C.postMessage({encode:{format:"wave",data:{samples:[h],sampleRate:p,channels:m,isFloat32:g}}}):E.data.encoderResult&&(C.terminate(),E.data.error?y({name:"EncoderError",message:E.data.error}):v(E.data.encoderResult))},C.onerror=function(E){C.terminate(),y(E)},C.postMessage({ctrl:{action:"construct",options:b}})},e.decodeAudioFile=function(h,p,m,g,v){e.readFileAsBuffer(h,function(y){var w=new OfflineAudioContext(m,y.byteLength,p);w.decodeAudioData(y,function(C){g(C)},function(C){v(C)})},function(y){v(y)})},e.decodeAudioFileToInt16Mono=function(h,p,m,g){var v=1;e.decodeAudioFile(h,p,v,function(y){var w=!0;e.encodeWaveBuffer(y.getChannelData(0),p,v,w,function(C){try{var b=new Int16Array(C.wav.buffer);m(b)}catch(E){g(E)}},g)},g)},e.resampleBufferViaSpeex=function(h,p,m,g,v,y,w){y||(y=console.log),w||(w=console.error);try{var C=new OfflineAudioContext(g,h.length,p),b=e.defaultProcessorOptions.moduleFolder.replace(/\/$/,"")+"/",E="speex-resample-switch";C.audioWorklet.addModule(b+E+".js").then(function(){var x={processorOptions:{ctxInfo:{sampleRate:p},targetSampleRate:m,resampleQuality:v,bufferSize:h.length}},S=new AudioWorkletNode(C,E,x);S.port.onmessage=function(M){M.data.moduleState==1?S.port.postMessage({resample:{samples:[h],isInt16:!0}}):M.data.resampleResult&&(C=null,M.data.error?w({name:"ResampleError",message:M.data.error}):y(M.data.resampleResult))},S.onprocessorerror=function(M){C=null,w(M)}})}catch(x){w(x)}},e.readFileAsBuffer=function(h,p,m){cl&&cl.files?cl.files.fetch(h,p,m,"arraybuffer",e.contentFetchTimeout):c("arraybuffer",h,p,m)},e.readFileAsText=function(h,p,m){cl&&cl.files?cl.files.fetch(h,p,m,void 0,e.contentFetchTimeout):c("text",h,p,m)};function l(h){return new Promise(function(p,m){e.readFileAsBuffer(h,function(g){p(g)},function(g){m(g)})})}function A(h){return new Promise(function(p,m){e.readFileAsText(h,function(g){p(g)},function(g){m(g)})})}function c(h,p,m,g){var v=new XMLHttpRequest;v.open("GET",p),v.responseType=h,v.timeout=e.contentFetchTimeout,v.onload=function(y){v.status>=200&&v.status<300?m(v.response):g({status:v.status,message:v.statusText})},v.onerror=function(y){g(y)},v.ontimeout=function(y){g(y)},v.send()}function u(h){try{for(var p=atob(h),m=new Uint8Array(p.length),g=0;g1&&console.error("SepiaVoiceRecorder.decodeAudioFileToInt16Mono - Channels > 1 not supported. Result will only contain data of channel 0."),m||(m=console.log),g||(g=console.error),SepiaFW.webAudio.decodeAudioFileToInt16Mono(d,h,m,g)},n.addAudioElementToPage=function(d,h,p){return SepiaFW.webAudio.addAudioElementToPage(d,h,p)},window.SepiaVoiceRecorder=n})();class _ve{constructor(e,t){nt(this,"volumeThresholds",[.05,10]);nt(this,"gain",1);nt(this,"isLoading",!1);nt(this,"isRecording",!1);nt(this,"isWaitingForFinalResult",!1);nt(this,"waitingForFinalResultTimer");nt(this,"waitingForFinalResultDelay",4e3);nt(this,"asrStreaming",!1);nt(this,"sourceInfo","-?-");if(window.SepiaFW&&(SepiaFW.webAudio.defaultProcessorOptions.moduleFolder="lib"),!window.SepiaVoiceRecorder)SepiaVoiceRecorder={notSupported:!0},console.error("SEPIA Web Audio Library not found or not supported (IE11?)!");else{this.sepiaSpeechRecognition=e,this.sepiaSpeechRecognitionConfig=t;const r=this;SepiaVoiceRecorder.onProcessorReady=function(i){console.log("SepiaVoiceRecorder - onProcessorReady",i),this.sourceInfo="Sample-rate: "+i.targetSampleRate+"Hz (factor: "+i.inputSampleRate/i.targetSampleRate+`) Device Label: `+(i.sourceInfo?i.sourceInfo.label:""),console.log(this.sourceInfo),r.isLoading=!1,r.isRecording=!1,r.isWaitingForFinalResult=!1,SepiaVoiceRecorder.start()},SepiaVoiceRecorder.onConnected=function(i){i&&i.model&&(console.log("INFO - connected - ASR active model: "+i.model),e._dispatchEvent(new Event("start")))},SepiaVoiceRecorder.onDisconnected=function(){e._dispatchEvent(new Event("end"))},SepiaVoiceRecorder.onProcessorInitError=function(i){r.onMicError();const s=new Ed;switch(s.message=i.message,i.name){case"NotAllowedError":s.error=jp.NOTALLOWED,s._dispatch(e);break;default:console.log(i);break}location.protocol=="http:"&&!location.origin.indexOf("http://localhost")==0&&console.error("Init. ERROR - Likely because of insecure origin (no HTTPS or localhost)")},SepiaVoiceRecorder.onProcessorError=function(i){console.error("SepiaVoiceRecorder - onProcessorError",i),r.onMicError(),console.log("ERROR - onProcessorError: "+i.name)},SepiaVoiceRecorder.onAudioStart=function(i){e._dispatchEvent(new Event("audiostart")),r.isRecording=!0},SepiaVoiceRecorder.onAudioEnd=function(i){e._dispatchEvent(new Event("audioend")),r.isRecording=!1,r.isWaitingForFinalResult&&(clearTimeout(r.waitingForFinalResultTimer),r.waitingForFinalResultTimer=setTimeout(function(){r.isWaitingForFinalResult=!1},r.waitingForFinalResultDelay)),console.log("Microphone is CLOSED")},SepiaVoiceRecorder.onProcessorRelease=function(i){console.log("SepiaVoiceRecorder - onProcessorRelease"),r.isRecording=!1,r.isLoading=!1,r.isWaitingForFinalResult=!1},SepiaVoiceRecorder.onDebugLog=function(i){},SepiaVoiceRecorder.onResamplerData=function(i){},SepiaVoiceRecorder.onSpeechRecognitionStateChange=function(i){i.state=="onStreamStart"?(r.asrStreaming,r.asrStreaming=!0):i.state=="onStreamEnd"&&(r.asrStreaming&&(i.bufferOrTimeLimit===!0&&console.log("Speech Recognition - Stopped streaming due to buffer- or time-limit"),r.isRecording?SepiaVoiceRecorder.stop():r.isWaitingForFinalResult&&(clearTimeout(r.waitingForFinalResultTimer),r.waitingForFinalResultTimer=setTimeout(function(){r.isWaitingForFinalResult=!1},r.waitingForFinalResultDelay))),r.asrStreaming=!1)},SepiaVoiceRecorder.onSpeechRecognitionEvent=function(i){if(i.type=="result"){if(!r.isRecording&&!r.isWaitingForFinalResult)return;const s=new bve;s.transcript=i.transcript,s.confidence=i.confidence;const o=new xve([s]);if(i.isFinal){r.isWaitingForFinalResult&&!r.isRecording&&clearTimeout(r.waitingForFinalResultTimer),o.isFinal=!0;const a=new xU([o]),l=new eC(a);if(i.transcript)l._dispatch(e,"result");else{const A=new Ed;A.error=jp.NOSPEECH,A.message="No speech was detected.",A._dispatch(e)}r.isWaitingForFinalResult=!1}else{o.isFinal=!1;const a=new xU([o]),l=new eC(a);i.transcript?l._dispatch(e,"result"):l._dispatch(e,"nomatch"),r.isWaitingForFinalResult=!0}}else if(i.type=="error"){const s=new Ed;if(s.message=i.message,i.name&&i.message)switch(i.name){case"SocketConnectionError":s.error=jp.NETWORK,s._dispatch(e);break;case"Error":i.message==="ChunkProcessorError failed to load."&&(s.error=jp.SERVICENOTALLOWED,s.message="You are likely unauthorized to access this SEPIA STT server.",s._dispatch(e));break;default:console.log(i);break}else console.error("Speech Recognition Error:",i)}else console.log("Speech Recognition - Event: "+i.type)},SepiaVoiceRecorder.onWaveEncoderAudioData=function(i){},SepiaVoiceRecorder.onVadStateChange=function(i,s){switch(i){case"vaup":e._dispatchEvent(new Event("soundstart"));break;case"vadown":e._dispatchEvent(new Event("soundend"));break;case"speechstart":e._dispatchEvent(new Event("speechstart"));break;case"speechend":e._dispatchEvent(new Event("speechend"));break}}}}toggleMic(){const e=this.sepiaSpeechRecognition.lang.split("-")[0];if(pA.language!=this.sepiaSpeechRecognition.lang&&pA.language!=e){const r=new Ed;r.error=jp.LANGUAGENOTSUPPORTED,r.message="The specified SEPIA STT server does not support the language specified by the user agent.",r._dispatch(this.sepiaSpeechRecognition);return}const t=this;!this.isLoading&&!this.isRecording&&!this.isWaitingForFinalResult?(this.isLoading=!0,SepiaVoiceRecorder.stopAndReleaseIfActive(function(){SepiaFW.webAudio.tryNativeStreamResampling=!1;const r={language:t.sepiaSpeechRecognition.lang,continuous:t.sepiaSpeechRecognition.continuous,messageFormat:"default"};var i=Object.assign(t.sepiaSpeechRecognitionConfig,r);console.log(i),SepiaVoiceRecorder.create({gain:t.gain,asr:i,vad:!0})})):this.isRecording?SepiaVoiceRecorder.stop():(this.isLoading||this.isWaitingForFinalResult)&&SepiaVoiceRecorder.stopAndReleaseIfActive(function(){t.isLoading=!1,t.isRecording=!1,t.isWaitingForFinalResult=!1})}releaseMic(e){SepiaVoiceRecorder.stopAndReleaseIfActive(function(){this.isLoading=!1,this.isRecording=!1,this.isWaitingForFinalResult=!1,e&&e()})}onMicError(){this.isRecording=!1,this.isWaitingForFinalResult=!1,this.isLoading=!1}}class UV{constructor(){nt(this,"src","");nt(this,"weight",1)}}var jc,gC,M4;class Qve{constructor(){Zu(this,gC);Zu(this,jc,[]);nt(this,"length",0);nt(this,"addFromURI",(e,t=1)=>{const r=new UV;fetch(e).then(i=>{i.text().then(s=>{r.src=s,r.weight=t,Is(this,jc).push(r)})}).catch(i=>{console.log("Failed to add SpeechGrammar from URI: ",i)})});nt(this,"addFromString",(e,t=1)=>{const r=new UV;r.src=e,r.weight=t,Is(this,jc).push(r)});return new Proxy(this,{get:(e,t)=>{var r;if(t==="addFromString"||t==="addFromURI")return function(){return e[t].apply(e,arguments)};if(typeof+t=="number")return lR(r=e,gC,M4).call(r,t);if(t==="length")return Is(e,jc).length}})}}jc=new WeakMap,gC=new WeakSet,M4=function(e){return Is(this,jc)[e]};let T4={};const Rve=n=>(T4=n,Mve);var jd;class Mve{constructor(){Zu(this,jd,new _ve(this,T4));nt(this,"grammars",new Qve);nt(this,"lang",document.documentElement.lang||navigator.language);nt(this,"continuous",!1);nt(this,"interimResults",!1);nt(this,"maxAlternatives",1);nt(this,"start",()=>{Is(this,jd).toggleMic()});nt(this,"stop",()=>{Is(this,jd).toggleMic()});nt(this,"abort",()=>{Is(this,jd).toggleMic()});nt(this,"onaudiostart",e=>{});nt(this,"onsoundstart",e=>{});nt(this,"onspeechstart",e=>{});nt(this,"onspeechend",e=>{});nt(this,"onsoundend",e=>{});nt(this,"onaudioend",e=>{});nt(this,"onresult",e=>{});nt(this,"onnomatch",e=>{});nt(this,"onerror",e=>{});nt(this,"onstart",e=>{});nt(this,"onend",e=>{});nt(this,"_eventCallbacks",new Map);nt(this,"_dispatchEvent",e=>{const t=this._eventCallbacks.get(e.type);t&&t.forEach(r=>r(e)),this[`on${e.type}`](e)});nt(this,"addEventListener",(e,t)=>{this._eventCallbacks.has(e)?this._eventCallbacks.get(e).push(t):this._eventCallbacks.set(e,[t])});nt(this,"removeEventListener",(e,t)=>{if(this._eventCallbacks.has(e)){const r=this._eventCallbacks.get(e);r.includes(t)&&r.splice(r.indexOf(t),1)}});Cve()}}jd=new WeakMap;class Tve{constructor(){nt(this,"serverUrl","http://localhost:20741");nt(this,"clientId","any");nt(this,"accessToken","test1234");nt(this,"task","assistant");nt(this,"model","");nt(this,"optimizeFinalResult",!0);nt(this,"engineOptions",{})}}const Nve=2e4;async function Dve(n){let e=0;const t=[];for(let r=n.length-1;r>=0;r--){const i=n[r],s=`${i==null?void 0:i.name}: ${i==null?void 0:i.message}`;if(e+=s.length,e{const{timestamp:e,name:t,message:r,type:i,color:s,err:o}=n;let a=new Date(e);const l=a.getHours()<10?"0"+a.getHours():a.getHours(),A=a.getMinutes()<10?"0"+a.getMinutes():a.getMinutes(),c=`${l}:${A}`;return P.jsxs("div",{className:`${$p.message} ${i&&$p.speaker}`,children:[P.jsxs("div",{className:$p.name,style:i?{}:{color:s},children:[t,", ",P.jsx("span",{children:c})]}),P.jsxs("div",{className:$p["chat-bubble"],style:o?{color:"#7a7a7a"}:{},children:[P.jsx("div",{className:$p.colorBg,style:i?{}:{backgroundColor:s}}),r+(o?" ( Not sent )":"")]})]})},Ove=et.sessionId??Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);et.sessionId=Ove;const Gve=new Tve,Zve="Speaker",Jve=window.webkitSpeechRecognition||Rve(Gve),Hve=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],zve=["January","February","March","April","May","June","July","August","September","October","November","December"];function Yve({templateInfo:n,micEnabled:e,setMicEnabled:t,speechRecognition:r,setSpeechRecognition:i}){const[s,o]=Y.useState(!1),{t:a}=me.useContext(bs),[l]=Y.useState(et[`${n.id}_fulBio`]),[A]=Y.useState(et[`${n.id}_fulBio`].colorKey?E1[et[`${n.id}_fulBio`].colorKey].fontColor:E1[Object.keys(E1)[0]].fontColor),[c,u]=Y.useState(et.speaker||Zve);me.useEffect(()=>{et.speaker=c},[c]);const[f,d]=Y.useState(""),[h,p]=Y.useState([]),m=async b=>{b.preventDefault(),d(b.target.value)};Y.useEffect(()=>{const b=document.querySelector("#msgscroll");b.scrollTo(0,b.scrollHeight)},[h]),me.useEffect(()=>{const b=E=>{E.ctrlKey&&E.key==="c"&&p([])};return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[]);const g=()=>{r.start(),t(!0)},v=()=>{r.stop(),t(!1)};me.useEffect(()=>{s||document.getElementById("messageInput").focus()},[s]);const y=async b=>{if(b.preventDefault&&b.preventDefault(),v(),!s){const x=b.target.elements.message.value;w(x)}},w=async b=>{if(b&&b!==""&&!s){o(!0);const E=l.name;d("");const x={name:c,message:b,timestamp:Date.now(),type:1};p(M=>[...M,x]);const S=await Dve(h);if(S.push(`${c}: ${b}`),b.replaceAll(" ","")===""){const M=the(ehe(Ave)),Z={name:E,message:M,timestamp:Date.now(),type:0};p(K=>[...K,Z]),o(!1)}else try{const M=new Date,Z=`${Hve[M.getDay()]}, ${zve[M.getMonth()]} ${M.getDate()}, ${1900+M.getYear()}`,K=`${M.getHours()}:${M.getMinutes()} `,_="https://upstreet.webaverse.com/api/ai",F={prompt:`The following is part of a conversation between ${c} and ${E}. ${E} is descriptive and helpful, and is honest when it doesn't know an answer. Included is a context which acts a short-term memory, used to guide the conversation and track topics. @@ -5012,4 +5012,4 @@ ${E}:`,max_tokens:250,temperature:.9,top_p:1,frequency_penalty:0,presence_penalt background: -webkit-linear-gradient(to top, #000, rgba(0,0,0,0)); background: linear-gradient(to top, #000, rgba(0,0,0,0)); } - `),Y.createElement("div",{style:c.white,className:"saturation-white"},Y.createElement("div",{style:c.black,className:"saturation-black"}),Y.createElement("div",{style:c.pointer},this.props.pointer?Y.createElement(this.props.pointer,this.props):Y.createElement("div",{style:c.circle}))))}}]),e}(me.PureComponent||me.Component);function lke(n,e){for(var t=-1,r=n==null?0:n.length;++t=0,s=!t&&i&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(r=this.toRgbString()),e==="prgb"&&(r=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(r=this.toHexString()),e==="hex3"&&(r=this.toHexString(!0)),e==="hex4"&&(r=this.toHex8String(!0)),e==="hex8"&&(r=this.toHex8String()),e==="name"&&(r=this.toName()),e==="hsl"&&(r=this.toHslString()),e==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return je(this.toString())},_applyModification:function(e,t){var r=e.apply(null,[this].concat([].slice.call(t)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Ske,arguments)},brighten:function(){return this._applyModification(_ke,arguments)},darken:function(){return this._applyModification(Qke,arguments)},desaturate:function(){return this._applyModification(Fke,arguments)},saturate:function(){return this._applyModification(Eke,arguments)},greyscale:function(){return this._applyModification(Uke,arguments)},spin:function(){return this._applyModification(Rke,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(Nke,arguments)},complement:function(){return this._applyCombination(Mke,arguments)},monochromatic:function(){return this._applyCombination(Dke,arguments)},splitcomplement:function(){return this._applyCombination(Tke,arguments)},triad:function(){return this._applyCombination(jL,[3])},tetrad:function(){return this._applyCombination(jL,[4])}};je.fromRatio=function(n,e){if(hC(n)=="object"){var t={};for(var r in n)n.hasOwnProperty(r)&&(r==="a"?t[r]=n[r]:t[r]=Ig(n[r]));n=t}return je(n,e)};function wke(n){var e={r:0,g:0,b:0},t=1,r=null,i=null,s=null,o=!1,a=!1;return typeof n=="string"&&(n=Wke(n)),hC(n)=="object"&&(nl(n.r)&&nl(n.g)&&nl(n.b)?(e=Cke(n.r,n.g,n.b),o=!0,a=String(n.r).substr(-1)==="%"?"prgb":"rgb"):nl(n.h)&&nl(n.s)&&nl(n.v)?(r=Ig(n.s),i=Ig(n.v),e=xke(n.h,r,i),o=!0,a="hsv"):nl(n.h)&&nl(n.s)&&nl(n.l)&&(r=Ig(n.s),s=Ig(n.l),e=bke(n.h,r,s),o=!0,a="hsl"),n.hasOwnProperty("a")&&(t=n.a)),t=q5(t),{ok:o,format:n.format||a,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function Cke(n,e,t){return{r:wn(n,255)*255,g:wn(e,255)*255,b:wn(t,255)*255}}function zL(n,e,t){n=wn(n,255),e=wn(e,255),t=wn(t,255);var r=Math.max(n,e,t),i=Math.min(n,e,t),s,o,a=(r+i)/2;if(r==i)s=o=0;else{var l=r-i;switch(o=a>.5?l/(2-r-i):l/(r+i),r){case n:s=(e-t)/l+(e1&&(u-=1),u<1/6?A+(c-A)*6*u:u<1/2?c:u<2/3?A+(c-A)*(2/3-u)*6:A}if(e===0)r=i=s=t;else{var a=t<.5?t*(1+e):t+e-t*e,l=2*t-a;r=o(l,a,n+1/3),i=o(l,a,n),s=o(l,a,n-1/3)}return{r:r*255,g:i*255,b:s*255}}function YL(n,e,t){n=wn(n,255),e=wn(e,255),t=wn(t,255);var r=Math.max(n,e,t),i=Math.min(n,e,t),s,o,a=r,l=r-i;if(o=r===0?0:l/r,r==i)s=0;else{switch(r){case n:s=(e-t)/l+(e>1)+720)%360;--e;)r.h=(r.h+i)%360,s.push(je(r));return s}function Dke(n,e){e=e||6;for(var t=je(n).toHsv(),r=t.h,i=t.s,s=t.v,o=[],a=1/e;e--;)o.push(je({h:r,s:i,v:s})),s=(s+a)%1;return o}je.mix=function(n,e,t){t=t===0?0:t||50;var r=je(n).toRgb(),i=je(e).toRgb(),s=t/100,o={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(i.a-r.a)*s+r.a};return je(o)};je.readability=function(n,e){var t=je(n),r=je(e);return(Math.max(t.getLuminance(),r.getLuminance())+.05)/(Math.min(t.getLuminance(),r.getLuminance())+.05)};je.isReadable=function(n,e,t){var r=je.readability(n,e),i,s;switch(s=!1,i=Oke(t),i.level+i.size){case"AAsmall":case"AAAlarge":s=r>=4.5;break;case"AAlarge":s=r>=3;break;case"AAAsmall":s=r>=7;break}return s};je.mostReadable=function(n,e,t){var r=null,i=0,s,o,a,l;t=t||{},o=t.includeFallbackColors,a=t.level,l=t.size;for(var A=0;Ai&&(i=s,r=je(e[A]));return je.isReadable(n,r,{level:a,size:l})||!o?r:(t.includeFallbackColors=!1,je.mostReadable(n,["#fff","#000"],t))};var DU=je.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},kke=je.hexNames=Vke(DU);function Vke(n){var e={};for(var t in n)n.hasOwnProperty(t)&&(e[n[t]]=t);return e}function q5(n){return n=parseFloat(n),(isNaN(n)||n<0||n>1)&&(n=1),n}function wn(n,e){Lke(n)&&(n="100%");var t=Pke(n);return n=Math.min(e,Math.max(0,parseFloat(n))),t&&(n=parseInt(n*e,10)/100),Math.abs(n-e)<1e-6?1:n%e/parseFloat(e)}function Lb(n){return Math.min(1,Math.max(0,n))}function zi(n){return parseInt(n,16)}function Lke(n){return typeof n=="string"&&n.indexOf(".")!=-1&&parseFloat(n)===1}function Pke(n){return typeof n=="string"&&n.indexOf("%")!=-1}function Qo(n){return n.length==1?"0"+n:""+n}function Ig(n){return n<=1&&(n=n*100+"%"),n}function ez(n){return Math.round(parseFloat(n)*255).toString(16)}function $L(n){return zi(n)/255}var bo=function(){var n="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+n+")",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",i="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function nl(n){return!!bo.CSS_UNIT.exec(n)}function Wke(n){n=n.replace(yke,"").replace(Bke,"").toLowerCase();var e=!1;if(DU[n])n=DU[n],e=!0;else if(n=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=bo.rgb.exec(n))?{r:t[1],g:t[2],b:t[3]}:(t=bo.rgba.exec(n))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=bo.hsl.exec(n))?{h:t[1],s:t[2],l:t[3]}:(t=bo.hsla.exec(n))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=bo.hsv.exec(n))?{h:t[1],s:t[2],v:t[3]}:(t=bo.hsva.exec(n))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=bo.hex8.exec(n))?{r:zi(t[1]),g:zi(t[2]),b:zi(t[3]),a:$L(t[4]),format:e?"name":"hex8"}:(t=bo.hex6.exec(n))?{r:zi(t[1]),g:zi(t[2]),b:zi(t[3]),format:e?"name":"hex"}:(t=bo.hex4.exec(n))?{r:zi(t[1]+""+t[1]),g:zi(t[2]+""+t[2]),b:zi(t[3]+""+t[3]),a:$L(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=bo.hex3.exec(n))?{r:zi(t[1]+""+t[1]),g:zi(t[2]+""+t[2]),b:zi(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function Oke(n){var e,t;return n=n||{level:"AA",size:"small"},e=(n.level||"AA").toUpperCase(),t=(n.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}var qL=function(e){var t=["r","g","b","a","h","s","l","v"],r=0,i=0;return vke(t,function(s){if(e[s]&&(r+=1,isNaN(e[s])||(i+=1),s==="s"||s==="l")){var o=/^\d+%$/;o.test(e[s])&&(i+=1)}}),r===i?e:!1},Fg=function(e,t){var r=e.hex?je(e.hex):je(e),i=r.toHsl(),s=r.toHsv(),o=r.toRgb(),a=r.toHex();i.s===0&&(i.h=t||0,s.h=t||0);var l=a==="000000"&&o.a===0;return{hsl:i,hex:l?"transparent":"#"+a,rgb:o,hsv:s,oldHue:e.h||t||i.h,source:e.source}},gc=function(e){if(e==="transparent")return!0;var t=String(e).charAt(0)==="#"?1:0;return e.length!==4+t&&e.length<7+t&&je(e).isValid()},OQ=function(e){if(!e)return"#fff";var t=Fg(e);if(t.hex==="transparent")return"rgba(0,0,0,0.4)";var r=(t.rgb.r*299+t.rgb.g*587+t.rgb.b*114)/1e3;return r>=128?"#000":"#fff"},O1=function(e,t){var r=e.replace("°","");return je(t+" ("+r+")")._ok},tg=Object.assign||function(n){for(var e=1;e1&&arguments[1]!==void 0?arguments[1]:"span";return function(r){Kke(i,r);function i(){var s,o,a,l;Xke(this,i);for(var A=arguments.length,c=Array(A),u=0;ua))return!1;var A=s.get(n),c=s.get(e);if(A&&c)return A==e&&c==n;var u=-1,f=!0,d=t&lVe?new pC:void 0;for(s.set(n,e),s.set(e,n);++u=0||Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t}var Qy=24,_Le=cz.default=function(n){var e=n.fill,t=e===void 0?"currentColor":e,r=n.width,i=r===void 0?Qy:r,s=n.height,o=s===void 0?Qy:s,a=n.style,l=a===void 0?{}:a,A=SLe(n,["fill","width","height","style"]);return v3.default.createElement("svg",m3({viewBox:"0 0 "+Qy+" "+Qy,style:m3({fill:t,width:i,height:o},l)},A),v3.default.createElement("path",{d:"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z"}))},QLe=function(){function n(e,t){for(var r=0;r1&&(i.a=1),r.props.onChange({h:r.props.hsl.h,s:r.props.hsl.s,l:r.props.hsl.l,a:Math.round(i.a*100)/100,source:"rgb"},s)):(i.h||i.s||i.l)&&(typeof i.s=="string"&&i.s.includes("%")&&(i.s=i.s.replace("%","")),typeof i.l=="string"&&i.l.includes("%")&&(i.l=i.l.replace("%","")),i.s==1?i.s=.01:i.l==1&&(i.l=.01),r.props.onChange({h:i.h||r.props.hsl.h,s:Number(g3(i.s)?r.props.hsl.s:i.s),l:Number(g3(i.l)?r.props.hsl.l:i.l),source:"hsl"},s))},r.showHighlight=function(i){i.currentTarget.style.background="#eee"},r.hideHighlight=function(i){i.currentTarget.style.background="transparent"},t.hsl.a!==1&&t.view==="hex"?r.state={view:"rgb"}:r.state={view:t.view},r}return QLe(e,[{key:"render",value:function(){var r=this,i=ut({default:{wrap:{paddingTop:"16px",display:"flex"},fields:{flex:"1",display:"flex",marginLeft:"-6px"},field:{paddingLeft:"6px",width:"100%"},alpha:{paddingLeft:"6px",width:"100%"},toggle:{width:"32px",textAlign:"right",position:"relative"},icon:{marginRight:"-4px",marginTop:"12px",cursor:"pointer",position:"relative"},iconHighlight:{position:"absolute",width:"24px",height:"28px",background:"#eee",borderRadius:"4px",top:"10px",left:"12px",display:"none"},input:{fontSize:"11px",color:"#333",width:"100%",borderRadius:"2px",border:"none",boxShadow:"inset 0 0 0 1px #dadada",height:"21px",textAlign:"center"},label:{textTransform:"uppercase",fontSize:"11px",lineHeight:"11px",color:"#969696",textAlign:"center",display:"block",marginTop:"12px"},svg:{fill:"#333",width:"24px",height:"24px",border:"1px transparent solid",borderRadius:"5px"}},disableAlpha:{alpha:{display:"none"}}},this.props,this.state),s=void 0;return this.state.view==="hex"?s=Y.createElement("div",{style:i.fields,className:"flexbox-fix"},Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"hex",value:this.props.hex,onChange:this.handleChange}))):this.state.view==="rgb"?s=Y.createElement("div",{style:i.fields,className:"flexbox-fix"},Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"r",value:this.props.rgb.r,onChange:this.handleChange})),Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"g",value:this.props.rgb.g,onChange:this.handleChange})),Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"b",value:this.props.rgb.b,onChange:this.handleChange})),Y.createElement("div",{style:i.alpha},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"a",value:this.props.rgb.a,arrowOffset:.01,onChange:this.handleChange}))):this.state.view==="hsl"&&(s=Y.createElement("div",{style:i.fields,className:"flexbox-fix"},Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"h",value:Math.round(this.props.hsl.h),onChange:this.handleChange})),Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"s",value:Math.round(this.props.hsl.s*100)+"%",onChange:this.handleChange})),Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"l",value:Math.round(this.props.hsl.l*100)+"%",onChange:this.handleChange})),Y.createElement("div",{style:i.alpha},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"a",value:this.props.hsl.a,arrowOffset:.01,onChange:this.handleChange})))),Y.createElement("div",{style:i.wrap,className:"flexbox-fix"},s,Y.createElement("div",{style:i.toggle},Y.createElement("div",{style:i.icon,onClick:this.toggleViews,ref:function(a){return r.icon=a}},Y.createElement(_Le,{style:i.svg,onMouseOver:this.showHighlight,onMouseEnter:this.showHighlight,onMouseOut:this.hideHighlight}))))}}],[{key:"getDerivedStateFromProps",value:function(r,i){return r.hsl.a!==1&&i.view==="hex"?{view:"rgb"}:null}}]),e}(Y.Component);uz.defaultProps={view:"hex"};var y3=function(){var e=ut({default:{picker:{width:"12px",height:"12px",borderRadius:"6px",transform:"translate(-6px, -1px)",backgroundColor:"rgb(248, 248, 248)",boxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.37)"}}});return Y.createElement("div",{style:e.picker})},NLe=function(){var e=ut({default:{picker:{width:"12px",height:"12px",borderRadius:"6px",boxShadow:"inset 0 0 0 1px #fff",transform:"translate(-6px, -6px)"}}});return Y.createElement("div",{style:e.picker})},YQ=function(e){var t=e.width,r=e.onChange,i=e.disableAlpha,s=e.rgb,o=e.hsl,a=e.hsv,l=e.hex,A=e.renderers,c=e.styles,u=c===void 0?{}:c,f=e.className,d=f===void 0?"":f,h=e.defaultView,p=ut(Pi({default:{picker:{width:t,background:"#fff",borderRadius:"2px",boxShadow:"0 0 2px rgba(0,0,0,.3), 0 4px 8px rgba(0,0,0,.3)",boxSizing:"initial",fontFamily:"Menlo"},saturation:{width:"100%",paddingBottom:"55%",position:"relative",borderRadius:"2px 2px 0 0",overflow:"hidden"},Saturation:{radius:"2px 2px 0 0"},body:{padding:"16px 16px 12px"},controls:{display:"flex"},color:{width:"32px"},swatch:{marginTop:"6px",width:"16px",height:"16px",borderRadius:"8px",position:"relative",overflow:"hidden"},active:{absolute:"0px 0px 0px 0px",borderRadius:"8px",boxShadow:"inset 0 0 0 1px rgba(0,0,0,.1)",background:"rgba("+s.r+", "+s.g+", "+s.b+", "+s.a+")",zIndex:"2"},toggles:{flex:"1"},hue:{height:"10px",position:"relative",marginBottom:"8px"},Hue:{radius:"2px"},alpha:{height:"10px",position:"relative"},Alpha:{radius:"2px"}},disableAlpha:{color:{width:"22px"},alpha:{display:"none"},hue:{marginBottom:"0px"},swatch:{width:"10px",height:"10px",marginTop:"0px"}}},u),{disableAlpha:i});return Y.createElement("div",{style:p.picker,className:"chrome-picker "+d},Y.createElement("div",{style:p.saturation},Y.createElement(Vb,{style:p.Saturation,hsl:o,hsv:a,pointer:NLe,onChange:r})),Y.createElement("div",{style:p.body},Y.createElement("div",{style:p.controls,className:"flexbox-fix"},Y.createElement("div",{style:p.color},Y.createElement("div",{style:p.swatch},Y.createElement("div",{style:p.active}),Y.createElement(op,{renderers:A}))),Y.createElement("div",{style:p.toggles},Y.createElement("div",{style:p.hue},Y.createElement(ap,{style:p.Hue,hsl:o,pointer:y3,onChange:r})),Y.createElement("div",{style:p.alpha},Y.createElement(TQ,{style:p.Alpha,rgb:s,hsl:o,pointer:y3,renderers:A,onChange:r})))),Y.createElement(uz,{rgb:s,hsl:o,hex:l,view:h,onChange:r,disableAlpha:i})))};YQ.propTypes={width:Te.oneOfType([Te.string,Te.number]),disableAlpha:Te.bool,styles:Te.object,defaultView:Te.oneOf(["hex","rgb","hsl"])};YQ.defaultProps={width:225,disableAlpha:!1,styles:{}};const DLe=Wi(YQ);var kLe=function(e){var t=e.color,r=e.onClick,i=r===void 0?function(){}:r,s=e.onSwatchHover,o=e.active,a=ut({default:{color:{background:t,width:"15px",height:"15px",float:"left",marginRight:"5px",marginBottom:"5px",position:"relative",cursor:"pointer"},dot:{absolute:"5px 5px 5px 5px",background:OQ(t),borderRadius:"50%",opacity:"0"}},active:{dot:{opacity:"1"}},"color-#FFFFFF":{color:{boxShadow:"inset 0 0 0 1px #ddd"},dot:{background:"#000"}},transparent:{dot:{background:"#000"}}},{active:o,"color-#FFFFFF":t==="#FFFFFF",transparent:t==="transparent"});return Y.createElement(Ou,{style:a.color,color:t,onClick:i,onHover:s,focusStyle:{boxShadow:"0 0 4px "+t}},Y.createElement("div",{style:a.dot}))},VLe=function(e){var t=e.hex,r=e.rgb,i=e.onChange,s=ut({default:{fields:{display:"flex",paddingBottom:"6px",paddingRight:"5px",position:"relative"},active:{position:"absolute",top:"6px",left:"5px",height:"9px",width:"9px",background:t},HEXwrap:{flex:"6",position:"relative"},HEXinput:{width:"80%",padding:"0px",paddingLeft:"20%",border:"none",outline:"none",background:"none",fontSize:"12px",color:"#333",height:"16px"},HEXlabel:{display:"none"},RGBwrap:{flex:"3",position:"relative"},RGBinput:{width:"70%",padding:"0px",paddingLeft:"30%",border:"none",outline:"none",background:"none",fontSize:"12px",color:"#333",height:"16px"},RGBlabel:{position:"absolute",top:"3px",left:"0px",lineHeight:"16px",textTransform:"uppercase",fontSize:"12px",color:"#999"}}}),o=function(l,A){l.r||l.g||l.b?i({r:l.r||r.r,g:l.g||r.g,b:l.b||r.b,source:"rgb"},A):i({hex:l.hex,source:"hex"},A)};return Y.createElement("div",{style:s.fields,className:"flexbox-fix"},Y.createElement("div",{style:s.active}),Y.createElement(Mt,{style:{wrap:s.HEXwrap,input:s.HEXinput,label:s.HEXlabel},label:"hex",value:t,onChange:o}),Y.createElement(Mt,{style:{wrap:s.RGBwrap,input:s.RGBinput,label:s.RGBlabel},label:"r",value:r.r,onChange:o}),Y.createElement(Mt,{style:{wrap:s.RGBwrap,input:s.RGBinput,label:s.RGBlabel},label:"g",value:r.g,onChange:o}),Y.createElement(Mt,{style:{wrap:s.RGBwrap,input:s.RGBinput,label:s.RGBlabel},label:"b",value:r.b,onChange:o}))},XQ=function(e){var t=e.onChange,r=e.onSwatchHover,i=e.colors,s=e.hex,o=e.rgb,a=e.styles,l=a===void 0?{}:a,A=e.className,c=A===void 0?"":A,u=ut(Pi({default:{Compact:{background:"#f6f6f6",radius:"4px"},compact:{paddingTop:"5px",paddingLeft:"5px",boxSizing:"initial",width:"240px"},clear:{clear:"both"}}},l)),f=function(h,p){h.hex?gc(h.hex)&&t({hex:h.hex,source:"hex"},p):t(h,p)};return Y.createElement(R0,{style:u.Compact,styles:l},Y.createElement("div",{style:u.compact,className:"compact-picker "+c},Y.createElement("div",null,Gu(i,function(d){return Y.createElement(kLe,{key:d,color:d,active:d.toLowerCase()===s,onClick:f,onSwatchHover:r})}),Y.createElement("div",{style:u.clear})),Y.createElement(VLe,{hex:s,rgb:o,onChange:f})))};XQ.propTypes={colors:Te.arrayOf(Te.string),styles:Te.object};XQ.defaultProps={colors:["#4D4D4D","#999999","#FFFFFF","#F44E3B","#FE9200","#FCDC00","#DBDF00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#FDA1FF","#333333","#808080","#cccccc","#D33115","#E27300","#FCC400","#B0BC00","#68BC00","#16A5A5","#009CE0","#7B64FF","#FA28FF","#000000","#666666","#B3B3B3","#9F0500","#C45100","#FB9E00","#808900","#194D33","#0C797D","#0062B1","#653294","#AB149E"],styles:{}};Wi(XQ);var LLe=function(e){var t=e.hover,r=e.color,i=e.onClick,s=e.onSwatchHover,o={position:"relative",zIndex:"2",outline:"2px solid #fff",boxShadow:"0 0 5px 2px rgba(0,0,0,0.25)"},a=ut({default:{swatch:{width:"25px",height:"25px",fontSize:"0"}},hover:{swatch:o}},{hover:t});return Y.createElement("div",{style:a.swatch},Y.createElement(Ou,{color:r,onClick:i,onHover:s,focusStyle:o}))};const PLe=MQ(LLe);var KQ=function(e){var t=e.width,r=e.colors,i=e.onChange,s=e.onSwatchHover,o=e.triangle,a=e.styles,l=a===void 0?{}:a,A=e.className,c=A===void 0?"":A,u=ut(Pi({default:{card:{width:t,background:"#fff",border:"1px solid rgba(0,0,0,0.2)",boxShadow:"0 3px 12px rgba(0,0,0,0.15)",borderRadius:"4px",position:"relative",padding:"5px",display:"flex",flexWrap:"wrap"},triangle:{position:"absolute",border:"7px solid transparent",borderBottomColor:"#fff"},triangleShadow:{position:"absolute",border:"8px solid transparent",borderBottomColor:"rgba(0,0,0,0.15)"}},"hide-triangle":{triangle:{display:"none"},triangleShadow:{display:"none"}},"top-left-triangle":{triangle:{top:"-14px",left:"10px"},triangleShadow:{top:"-16px",left:"9px"}},"top-right-triangle":{triangle:{top:"-14px",right:"10px"},triangleShadow:{top:"-16px",right:"9px"}},"bottom-left-triangle":{triangle:{top:"35px",left:"10px",transform:"rotate(180deg)"},triangleShadow:{top:"37px",left:"9px",transform:"rotate(180deg)"}},"bottom-right-triangle":{triangle:{top:"35px",right:"10px",transform:"rotate(180deg)"},triangleShadow:{top:"37px",right:"9px",transform:"rotate(180deg)"}}},l),{"hide-triangle":o==="hide","top-left-triangle":o==="top-left","top-right-triangle":o==="top-right","bottom-left-triangle":o==="bottom-left","bottom-right-triangle":o==="bottom-right"}),f=function(h,p){return i({hex:h,source:"hex"},p)};return Y.createElement("div",{style:u.card,className:"github-picker "+c},Y.createElement("div",{style:u.triangleShadow}),Y.createElement("div",{style:u.triangle}),Gu(r,function(d){return Y.createElement(PLe,{color:d,key:d,onClick:f,onSwatchHover:s})}))};KQ.propTypes={width:Te.oneOfType([Te.string,Te.number]),colors:Te.arrayOf(Te.string),triangle:Te.oneOf(["hide","top-left","top-right","bottom-left","bottom-right"]),styles:Te.object};KQ.defaultProps={width:200,colors:["#B80000","#DB3E00","#FCCB00","#008B02","#006B76","#1273DE","#004DCF","#5300EB","#EB9694","#FAD0C3","#FEF3BD","#C1E1C5","#BEDADC","#C4DEF6","#BED3F3","#D4C4FB"],triangle:"top-left",styles:{}};Wi(KQ);var WLe=function(e){var t=e.direction,r=ut({default:{picker:{width:"18px",height:"18px",borderRadius:"50%",transform:"translate(-9px, -1px)",backgroundColor:"rgb(248, 248, 248)",boxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.37)"}},vertical:{picker:{transform:"translate(-3px, -9px)"}}},{vertical:t==="vertical"});return Y.createElement("div",{style:r.picker})},OLe=Object.assign||function(n){for(var e=1;e.5});return Y.createElement("div",{style:r.picker})},HLe=function(){var e=ut({default:{triangle:{width:0,height:0,borderStyle:"solid",borderWidth:"4px 0 4px 6px",borderColor:"transparent transparent transparent #fff",position:"absolute",top:"1px",left:"1px"},triangleBorder:{width:0,height:0,borderStyle:"solid",borderWidth:"5px 0 5px 8px",borderColor:"transparent transparent transparent #555"},left:{Extend:"triangleBorder",transform:"translate(-13px, -4px)"},leftInside:{Extend:"triangle",transform:"translate(-8px, -5px)"},right:{Extend:"triangleBorder",transform:"translate(20px, -14px) rotate(180deg)"},rightInside:{Extend:"triangle",transform:"translate(-8px, -5px)"}}});return Y.createElement("div",{style:e.pointer},Y.createElement("div",{style:e.left},Y.createElement("div",{style:e.leftInside})),Y.createElement("div",{style:e.right},Y.createElement("div",{style:e.rightInside})))},B3=function(e){var t=e.onClick,r=e.label,i=e.children,s=e.active,o=ut({default:{button:{backgroundImage:"linear-gradient(-180deg, #FFFFFF 0%, #E6E6E6 100%)",border:"1px solid #878787",borderRadius:"2px",height:"20px",boxShadow:"0 1px 0 0 #EAEAEA",fontSize:"14px",color:"#000",lineHeight:"20px",textAlign:"center",marginBottom:"10px",cursor:"pointer"}},active:{button:{boxShadow:"0 0 0 1px #878787"}}},{active:s});return Y.createElement("div",{style:o.button,onClick:t},r||i)},zLe=function(e){var t=e.rgb,r=e.currentColor,i=ut({default:{swatches:{border:"1px solid #B3B3B3",borderBottom:"1px solid #F0F0F0",marginBottom:"2px",marginTop:"1px"},new:{height:"34px",background:"rgb("+t.r+","+t.g+", "+t.b+")",boxShadow:"inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 1px 0 #000"},current:{height:"34px",background:r,boxShadow:"inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 -1px 0 #000"},label:{fontSize:"14px",color:"#000",textAlign:"center"}}});return Y.createElement("div",null,Y.createElement("div",{style:i.label},"new"),Y.createElement("div",{style:i.swatches},Y.createElement("div",{style:i.new}),Y.createElement("div",{style:i.current})),Y.createElement("div",{style:i.label},"current"))},YLe=function(){function n(e,t){for(var r=0;r100&&(c.a=100),c.a/=100,t({h:i.h,s:i.s,l:i.l,a:c.a,source:"rgb"},u))};return Y.createElement("div",{style:a.fields,className:"flexbox-fix"},Y.createElement("div",{style:a.double},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"hex",value:s.replace("#",""),onChange:l})),Y.createElement("div",{style:a.single},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"r",value:r.r,onChange:l,dragLabel:"true",dragMax:"255"})),Y.createElement("div",{style:a.single},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"g",value:r.g,onChange:l,dragLabel:"true",dragMax:"255"})),Y.createElement("div",{style:a.single},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"b",value:r.b,onChange:l,dragLabel:"true",dragMax:"255"})),Y.createElement("div",{style:a.alpha},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"a",value:Math.round(r.a*100),onChange:l,dragLabel:"true",dragMax:"100"})))},qLe=Object.assign||function(n){for(var e=1;e=0||Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t}var Ry=24,o3e=dz.default=function(n){var e=n.fill,t=e===void 0?"currentColor":e,r=n.width,i=r===void 0?Ry:r,s=n.height,o=s===void 0?Ry:s,a=n.style,l=a===void 0?{}:a,A=s3e(n,["fill","width","height","style"]);return C3.default.createElement("svg",w3({viewBox:"0 0 "+Ry+" "+Ry,style:w3({fill:t,width:i,height:o},l)},A),C3.default.createElement("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"}))},a3e=function(e){var t=e.color,r=e.onClick,i=r===void 0?function(){}:r,s=e.onSwatchHover,o=e.first,a=e.last,l=e.active,A=ut({default:{color:{width:"40px",height:"24px",cursor:"pointer",background:t,marginBottom:"1px"},check:{color:OQ(t),marginLeft:"8px",display:"none"}},first:{color:{overflow:"hidden",borderRadius:"2px 2px 0 0"}},last:{color:{overflow:"hidden",borderRadius:"0 0 2px 2px"}},active:{check:{display:"block"}},"color-#FFFFFF":{color:{boxShadow:"inset 0 0 0 1px #ddd"},check:{color:"#333"}},transparent:{check:{color:"#333"}}},{first:o,last:a,active:l,"color-#FFFFFF":t==="#FFFFFF",transparent:t==="transparent"});return Y.createElement(Ou,{color:t,style:A.color,onClick:i,onHover:s,focusStyle:{boxShadow:"0 0 4px "+t}},Y.createElement("div",{style:A.check},Y.createElement(o3e,null)))},l3e=function(e){var t=e.onClick,r=e.onSwatchHover,i=e.group,s=e.active,o=ut({default:{group:{paddingBottom:"10px",width:"40px",float:"left",marginRight:"10px"}}});return Y.createElement("div",{style:o.group},Gu(i,function(a,l){return Y.createElement(a3e,{key:a,color:a,active:a.toLowerCase()===s,first:l===0,last:l===i.length-1,onClick:t,onSwatchHover:r})}))},tR=function(e){var t=e.width,r=e.height,i=e.onChange,s=e.onSwatchHover,o=e.colors,a=e.hex,l=e.styles,A=l===void 0?{}:l,c=e.className,u=c===void 0?"":c,f=ut(Pi({default:{picker:{width:t,height:r},overflow:{height:r,overflowY:"scroll"},body:{padding:"16px 0 6px 16px"},clear:{clear:"both"}}},A)),d=function(p,m){return i({hex:p,source:"hex"},m)};return Y.createElement("div",{style:f.picker,className:"swatches-picker "+u},Y.createElement(R0,null,Y.createElement("div",{style:f.overflow},Y.createElement("div",{style:f.body},Gu(o,function(h){return Y.createElement(l3e,{key:h.toString(),group:h,active:a,onClick:d,onSwatchHover:s})}),Y.createElement("div",{style:f.clear})))))};tR.propTypes={width:Te.oneOfType([Te.string,Te.number]),height:Te.oneOfType([Te.string,Te.number]),colors:Te.arrayOf(Te.arrayOf(Te.string)),styles:Te.object};tR.defaultProps={width:320,height:240,colors:[[Vf[900],Vf[700],Vf[500],Vf[300],Vf[100]],[Lf[900],Lf[700],Lf[500],Lf[300],Lf[100]],[Pf[900],Pf[700],Pf[500],Pf[300],Pf[100]],[Wf[900],Wf[700],Wf[500],Wf[300],Wf[100]],[Of[900],Of[700],Of[500],Of[300],Of[100]],[Gf[900],Gf[700],Gf[500],Gf[300],Gf[100]],[Zf[900],Zf[700],Zf[500],Zf[300],Zf[100]],[Jf[900],Jf[700],Jf[500],Jf[300],Jf[100]],[Hf[900],Hf[700],Hf[500],Hf[300],Hf[100]],["#194D33",Eg[700],Eg[500],Eg[300],Eg[100]],[zf[900],zf[700],zf[500],zf[300],zf[100]],[Yf[900],Yf[700],Yf[500],Yf[300],Yf[100]],[Xf[900],Xf[700],Xf[500],Xf[300],Xf[100]],[Kf[900],Kf[700],Kf[500],Kf[300],Kf[100]],[jf[900],jf[700],jf[500],jf[300],jf[100]],[$f[900],$f[700],$f[500],$f[300],$f[100]],[qf[900],qf[700],qf[500],qf[300],qf[100]],[ed[900],ed[700],ed[500],ed[300],ed[100]],["#000000","#525252","#969696","#D9D9D9","#FFFFFF"]],styles:{}};Wi(tR);var nR=function(e){var t=e.onChange,r=e.onSwatchHover,i=e.hex,s=e.colors,o=e.width,a=e.triangle,l=e.styles,A=l===void 0?{}:l,c=e.className,u=c===void 0?"":c,f=ut(Pi({default:{card:{width:o,background:"#fff",border:"0 solid rgba(0,0,0,0.25)",boxShadow:"0 1px 4px rgba(0,0,0,0.25)",borderRadius:"4px",position:"relative"},body:{padding:"15px 9px 9px 15px"},label:{fontSize:"18px",color:"#fff"},triangle:{width:"0px",height:"0px",borderStyle:"solid",borderWidth:"0 9px 10px 9px",borderColor:"transparent transparent #fff transparent",position:"absolute"},triangleShadow:{width:"0px",height:"0px",borderStyle:"solid",borderWidth:"0 9px 10px 9px",borderColor:"transparent transparent rgba(0,0,0,.1) transparent",position:"absolute"},hash:{background:"#F0F0F0",height:"30px",width:"30px",borderRadius:"4px 0 0 4px",float:"left",color:"#98A1A4",display:"flex",alignItems:"center",justifyContent:"center"},input:{width:"100px",fontSize:"14px",color:"#666",border:"0px",outline:"none",height:"28px",boxShadow:"inset 0 0 0 1px #F0F0F0",boxSizing:"content-box",borderRadius:"0 4px 4px 0",float:"left",paddingLeft:"8px"},swatch:{width:"30px",height:"30px",float:"left",borderRadius:"4px",margin:"0 6px 6px 0"},clear:{clear:"both"}},"hide-triangle":{triangle:{display:"none"},triangleShadow:{display:"none"}},"top-left-triangle":{triangle:{top:"-10px",left:"12px"},triangleShadow:{top:"-11px",left:"12px"}},"top-right-triangle":{triangle:{top:"-10px",right:"12px"},triangleShadow:{top:"-11px",right:"12px"}}},A),{"hide-triangle":a==="hide","top-left-triangle":a==="top-left","top-right-triangle":a==="top-right"}),d=function(p,m){gc(p)&&t({hex:p,source:"hex"},m)};return Y.createElement("div",{style:f.card,className:"twitter-picker "+u},Y.createElement("div",{style:f.triangleShadow}),Y.createElement("div",{style:f.triangle}),Y.createElement("div",{style:f.body},Gu(s,function(h,p){return Y.createElement(Ou,{key:p,color:h,hex:h,style:f.swatch,onClick:d,onHover:r,focusStyle:{boxShadow:"0 0 4px "+h}})}),Y.createElement("div",{style:f.hash},"#"),Y.createElement(Mt,{label:null,style:{input:f.input},value:i.replace("#",""),onChange:d}),Y.createElement("div",{style:f.clear})))};nR.propTypes={width:Te.oneOfType([Te.string,Te.number]),triangle:Te.oneOf(["hide","top-left","top-right"]),colors:Te.arrayOf(Te.string),styles:Te.object};nR.defaultProps={width:276,colors:["#FF6900","#FCB900","#7BDCB5","#00D084","#8ED1FC","#0693E3","#ABB8C3","#EB144C","#F78DA7","#9900EF"],triangle:"top-left",styles:{}};Wi(nR);var rR=function(e){var t=ut({default:{picker:{width:"20px",height:"20px",borderRadius:"22px",border:"2px #fff solid",transform:"translate(-12px, -13px)",background:"hsl("+Math.round(e.hsl.h)+", "+Math.round(e.hsl.s*100)+"%, "+Math.round(e.hsl.l*100)+"%)"}}});return Y.createElement("div",{style:t.picker})};rR.propTypes={hsl:Te.shape({h:Te.number,s:Te.number,l:Te.number,a:Te.number})};rR.defaultProps={hsl:{a:1,h:249.94,l:.2,s:.5}};var iR=function(e){var t=ut({default:{picker:{width:"20px",height:"20px",borderRadius:"22px",transform:"translate(-10px, -7px)",background:"hsl("+Math.round(e.hsl.h)+", 100%, 50%)",border:"2px white solid"}}});return Y.createElement("div",{style:t.picker})};iR.propTypes={hsl:Te.shape({h:Te.number,s:Te.number,l:Te.number,a:Te.number})};iR.defaultProps={hsl:{a:1,h:249.94,l:.2,s:.5}};var A3e=function(e){var t=e.onChange,r=e.rgb,i=e.hsl,s=e.hex,o=e.hsv,a=function(d,h){if(d.hex)gc(d.hex)&&t({hex:d.hex,source:"hex"},h);else if(d.rgb){var p=d.rgb.split(",");O1(d.rgb,"rgb")&&t({r:p[0],g:p[1],b:p[2],a:1,source:"rgb"},h)}else if(d.hsv){var m=d.hsv.split(",");O1(d.hsv,"hsv")&&(m[2]=m[2].replace("%",""),m[1]=m[1].replace("%",""),m[0]=m[0].replace("°",""),m[1]==1?m[1]=.01:m[2]==1&&(m[2]=.01),t({h:Number(m[0]),s:Number(m[1]),v:Number(m[2]),source:"hsv"},h))}else if(d.hsl){var g=d.hsl.split(",");O1(d.hsl,"hsl")&&(g[2]=g[2].replace("%",""),g[1]=g[1].replace("%",""),g[0]=g[0].replace("°",""),u[1]==1?u[1]=.01:u[2]==1&&(u[2]=.01),t({h:Number(g[0]),s:Number(g[1]),v:Number(g[2]),source:"hsl"},h))}},l=ut({default:{wrap:{display:"flex",height:"100px",marginTop:"4px"},fields:{width:"100%"},column:{paddingTop:"10px",display:"flex",justifyContent:"space-between"},double:{padding:"0px 4.4px",boxSizing:"border-box"},input:{width:"100%",height:"38px",boxSizing:"border-box",padding:"4px 10% 3px",textAlign:"center",border:"1px solid #dadce0",fontSize:"11px",textTransform:"lowercase",borderRadius:"5px",outline:"none",fontFamily:"Roboto,Arial,sans-serif"},input2:{height:"38px",width:"100%",border:"1px solid #dadce0",boxSizing:"border-box",fontSize:"11px",textTransform:"lowercase",borderRadius:"5px",outline:"none",paddingLeft:"10px",fontFamily:"Roboto,Arial,sans-serif"},label:{textAlign:"center",fontSize:"12px",background:"#fff",position:"absolute",textTransform:"uppercase",color:"#3c4043",width:"35px",top:"-6px",left:"0",right:"0",marginLeft:"auto",marginRight:"auto",fontFamily:"Roboto,Arial,sans-serif"},label2:{left:"10px",textAlign:"center",fontSize:"12px",background:"#fff",position:"absolute",textTransform:"uppercase",color:"#3c4043",width:"32px",top:"-6px",fontFamily:"Roboto,Arial,sans-serif"},single:{flexGrow:"1",margin:"0px 4.4px"}}}),A=r.r+", "+r.g+", "+r.b,c=Math.round(i.h)+"°, "+Math.round(i.s*100)+"%, "+Math.round(i.l*100)+"%",u=Math.round(o.h)+"°, "+Math.round(o.s*100)+"%, "+Math.round(o.v*100)+"%";return Y.createElement("div",{style:l.wrap,className:"flexbox-fix"},Y.createElement("div",{style:l.fields},Y.createElement("div",{style:l.double},Y.createElement(Mt,{style:{input:l.input,label:l.label},label:"hex",value:s,onChange:a})),Y.createElement("div",{style:l.column},Y.createElement("div",{style:l.single},Y.createElement(Mt,{style:{input:l.input2,label:l.label2},label:"rgb",value:A,onChange:a})),Y.createElement("div",{style:l.single},Y.createElement(Mt,{style:{input:l.input2,label:l.label2},label:"hsv",value:u,onChange:a})),Y.createElement("div",{style:l.single},Y.createElement(Mt,{style:{input:l.input2,label:l.label2},label:"hsl",value:c,onChange:a})))))},sR=function(e){var t=e.width,r=e.onChange,i=e.rgb,s=e.hsl,o=e.hsv,a=e.hex,l=e.header,A=e.styles,c=A===void 0?{}:A,u=e.className,f=u===void 0?"":u,d=ut(Pi({default:{picker:{width:t,background:"#fff",border:"1px solid #dfe1e5",boxSizing:"initial",display:"flex",flexWrap:"wrap",borderRadius:"8px 8px 0px 0px"},head:{height:"57px",width:"100%",paddingTop:"16px",paddingBottom:"16px",paddingLeft:"16px",fontSize:"20px",boxSizing:"border-box",fontFamily:"Roboto-Regular,HelveticaNeue,Arial,sans-serif"},saturation:{width:"70%",padding:"0px",position:"relative",overflow:"hidden"},swatch:{width:"30%",height:"228px",padding:"0px",background:"rgba("+i.r+", "+i.g+", "+i.b+", 1)",position:"relative",overflow:"hidden"},body:{margin:"auto",width:"95%"},controls:{display:"flex",boxSizing:"border-box",height:"52px",paddingTop:"22px"},color:{width:"32px"},hue:{height:"8px",position:"relative",margin:"0px 16px 0px 16px",width:"100%"},Hue:{radius:"2px"}}},c));return Y.createElement("div",{style:d.picker,className:"google-picker "+f},Y.createElement("div",{style:d.head},l),Y.createElement("div",{style:d.swatch}),Y.createElement("div",{style:d.saturation},Y.createElement(Vb,{hsl:s,hsv:o,pointer:rR,onChange:r})),Y.createElement("div",{style:d.body},Y.createElement("div",{style:d.controls,className:"flexbox-fix"},Y.createElement("div",{style:d.hue},Y.createElement(ap,{style:d.Hue,hsl:s,radius:"4px",pointer:iR,onChange:r}))),Y.createElement(A3e,{rgb:i,hsl:s,hex:a,hsv:o,onChange:r})))};sR.propTypes={width:Te.oneOfType([Te.string,Te.number]),styles:Te.object,header:Te.string};sR.defaultProps={width:652,styles:{},header:"Color picker"};Wi(sR);function c3e(){const{isLoading:n,setViewMode:e,setIsLoading:t}=Y.useContext(Bi),{toggleDebugMode:r,characterManager:i,animationManager:s,moveCamera:o,loraDataGenerator:a,spriteAtlasGenerator:l,sceneElements:A}=Y.useContext(ni),{playSound:c}=Y.useContext(Cs),{isMute:u}=Y.useContext(Bs),{t:f}=me.useContext(bs),d=()=>{!u&&c("backNextButton"),i.removeCurrentCharacter(),i.removeCurrentManifest(),e(ot.CREATE),r(!1)},[h,p]=Y.useState(null),[m,g]=Y.useState(null),[v,y]=Y.useState(""),[w,C]=Y.useState(null),[b,E]=Y.useState(null),[x,S]=Y.useState(""),[M,Z]=Y.useState(!1),[K,_]=Y.useState({background:"#ffffff"}),B=()=>{!u&&c("backNextButton"),e(ot.SAVE),r(!1)},F=()=>{t(!0),p(null),i.loadRandomTraits().then(()=>{console.log("success"),v!=""&&C(i.getCurrentTraitData(v)),t(!1)}).catch(X=>{t(!1),console.error("Error loading random traits:",X.message)})},R=X=>{_({background:X.hex})},k=X=>{_({background:X.hex}),i.setTraitColor(v,X.hex)},T=async X=>{const ne=rc(X.name),ae=URL.createObjectURL(X);await s.loadAnimation(ae,!1,0,!0,"",ne),S(s.getCurrentAnimationName())},V=async()=>{const X=A.parent;X.remove(A),await a.createLoraData("./lora-assets/manifest.json"),X.add(A)},O=async()=>{const X=A.parent;X.remove(A),await l.createSpriteAtlas("./sprite-atlas-assets/manifest.json"),X.add(A)},L=X=>{if(Z(!1),v!=""){t(!0);const ne=URL.createObjectURL(X);i.loadCustomTexture(v,ne).then(()=>{t(!1)})}else console.warn("Please select a group trait first.")},U=X=>{if(Z(!1),v!=""){t(!0);const ne=URL.createObjectURL(X);i.loadCustomTrait(v,ne).then(()=>{t(!1)})}else console.warn("Please select a group trait first.")},H=X=>{Z(!1),t(!0),i.loadTrait(X.traitGroup.trait,X.id).then(()=>{t(!1),C(X)})},Ae=X=>{Z(!1),i.removeTrait(X),C(null)},N=X=>{Z(!1),t(!0),i.loadRandomTrait(X).then(()=>{t(!1),C(i.getCurrentTraitData(X))})},j=X=>{Z(!1);const ne=Array.from(X),ae=[],Be=pe=>new Promise((Fe,rt)=>{var Oe;if(pe&&pe.name.toLowerCase().endsWith(".json")){const ke=new FileReader,Qe=`${(Oe=i.manifestData)==null?void 0:Oe.getAssetsDirectory()}/anata/_thumbnails/t_${pe.name.split("_")[0]}.jpg`;console.log(Qe),ke.onload=function(Ge){try{const Xe=JSON.parse(Ge.target.result);Xe.thumb=Qe,ae.push(Xe),Fe()}catch(Xe){console.error("Error parsing the JSON file:",Xe),rt(Xe)}},ke.readAsText(pe)}});Promise.all(ne.map(Be)).then(()=>{ae.length>0&&(p(ae),t(!0),i.loadTraitsFromNFTObject(ae[0]).then(()=>{t(!1)}))}).catch(pe=>{console.error("Error processing files:",pe)})},oe=async X=>{const ne=X[0];ne&&ne.name.toLowerCase().endsWith(".fbx")&&T(ne),ne&&(ne.name.toLowerCase().endsWith(".png")||ne.name.toLowerCase().endsWith(".jpg"))&&L(ne),ne&&ne.name.toLowerCase().endsWith(".vrm")&&U(ne),ne&&ne.name.toLowerCase().endsWith(".json")&&j(X)},ie=X=>{!u&&c("optionClick"),Z(!1),v!==X.trait?(g(i.getTraits(X.trait)),y(X.trait),C(i.getCurrentTraitData(X.trait)),E(i.getCurrentTraitVRM(X.trait)),o({targetY:X.cameraTarget.height,distance:X.cameraTarget.distance})):(g(null),y(""),C(null),o({targetY:.8,distance:3.2}))},de=()=>{Z(!1);var X=document.createElement("input");X.type="file",X.accept=".vrm",X.onchange=ne=>{var ae=ne.target.files[0];if(ae.name.endsWith(".vrm")){const Be=URL.createObjectURL(ae);t(!0),i.loadCustomTrait(v,Be).then(()=>{t(!1)})}},X.click()};return P.jsxs("div",{className:Bn.container,children:[P.jsx("div",{className:`loadingIndicator ${n?"active":""}`,children:P.jsx("img",{className:"rotate",src:"ui/loading.svg"})}),P.jsx("div",{className:"sectionTitle",children:f("pageTitles.chooseAppearance")}),P.jsx(C0,{onFilesDrop:oe}),P.jsxs("div",{className:Bn.sideMenu,children:[P.jsx(Eh,{title:"Appearance",left:20}),P.jsx("div",{className:Bn.bottomLine}),P.jsx("div",{className:Bn.scrollContainer,children:P.jsx("div",{className:Bn["editor-container"],children:i.getGroupTraits().map((X,ne)=>P.jsxs("div",{className:Bn.editorButton,onClick:()=>{ie(X)},children:[P.jsx(Uy,{size:56,icon:X.fullIconSvg,rarity:v!==X.trait?"none":"mythic"}),P.jsx("div",{className:Bn.editorText,children:X.name})]},"options_"+ne))})})]}),!!m&&P.jsxs("div",{className:Bn.selectorContainerPos,children:[P.jsx(Eh,{title:v,width:130,left:20}),w&&P.jsx("div",{className:Bn.selectorColorPickerButton,onClick:()=>{Z(!M)},children:P.jsx("img",{className:Bn.selectorColorPickerImg,src:yCe})}),!!M&&P.jsx("div",{draggable:!1,className:Bn.selectorColorPickerUI,children:P.jsx(DLe,{draggable:!1,width:"200px",color:K.background,onChange:R,onChangeComplete:k})}),P.jsx("div",{className:Bn.bottomLine}),P.jsx("div",{className:Bn.scrollContainerOptions,children:P.jsxs("div",{className:Bn["selector-container"],children:[P.jsx("div",{className:`${Bn.selectorButton}`,onClick:()=>{N(v)},children:P.jsx(Uy,{size:56,icon:vCe,rarity:"none"})},"randomize-trait"),i.isTraitGroupRequired(v)?P.jsx(P.Fragment,{}):P.jsx("div",{className:`${Bn.selectorButton}`,icon:WV,onClick:()=>{Ae(v)},children:P.jsx(Uy,{size:56,icon:WV,rarity:w==null?"mythic":"none"})},"no-trait"),m.map(X=>{let ne=X.id===(w==null?void 0:w.id);return P.jsx("div",{className:`${Bn.selectorButton}`,onClick:()=>{H(X)},children:P.jsx(Uy,{size:56,icon:X.fullThumbnail,rarity:ne?"mythic":"none"})},X.id)})]})}),P.jsx("div",{className:Bn.uploadContainer,children:P.jsx("div",{className:Bn.uploadButton,onClick:de,children:P.jsx("div",{children:"Upload "})})})]}),P.jsx(hQ,{jsonSelectionArray:h}),P.jsx(zwe,{selectedTrait:w,selectedVRM:b,animationName:x,setAnimationName:S}),P.jsx(dQ,{loadedAnimationName:x,randomize:F}),P.jsxs("div",{className:Bn.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:f("callToAction.back"),size:14,className:Bn.buttonLeft,onClick:d}),i.canDownload()&&P.jsx(Gt,{theme:"light",text:f("callToAction.next"),size:14,className:Bn.buttonRight,onClick:B}),P.jsx(Gt,{theme:"light",text:"Create Lora Data",size:14,className:Bn.buttonRight,onClick:V}),P.jsx(Gt,{theme:"light",text:"Create Sprite Atlas",size:14,className:Bn.buttonRight,onClick:O})]})]})}const u3e="_InformationContainerPos_rgqwy_1",f3e="_traitInfoTitle_rgqwy_13",d3e="_traitInfoText_rgqwy_21",h3e="_flexSelect_rgqwy_30",p3e="_scrollContainer_rgqwy_65",g3e="_checked_rgqwy_90",m3e="_checkmark_rgqwy_94",v3e="_checkboxHolder_rgqwy_107",y3e="_buttonContainer_rgqwy_114",B3e="_buttonLeft_rgqwy_123",w3e="_buttonRight_rgqwy_127",C3e="_buttonCenter_rgqwy_131",Cr={InformationContainerPos:u3e,traitInfoTitle:f3e,traitInfoText:d3e,flexSelect:h3e,"arrow-button":"_arrow-button_rgqwy_37","left-button":"_left-button_rgqwy_51","right-button":"_right-button_rgqwy_58",scrollContainer:p3e,"custom-checkbox":"_custom-checkbox_rgqwy_76","checkbox-container":"_checkbox-container_rgqwy_81",checked:g3e,checkmark:m3e,checkboxHolder:v3e,buttonContainer:y3e,buttonLeft:B3e,buttonRight:w3e,buttonCenter:C3e},b3e="_InformationContainerPos_1cryw_2",x3e="_scrollContainer_1cryw_16",I3e="_traitInfoTitle_1cryw_28",F3e="_traitInfoText_1cryw_38",E3e="_flexSelect_1cryw_66",U3e="_checked_1cryw_123",S3e="_checkmark_1cryw_127",_3e="_checkboxHolder_1cryw_140",bi={InformationContainerPos:b3e,scrollContainer:x3e,traitInfoTitle:I3e,traitInfoText:F3e,"input-box":"_input-box_1cryw_47",flexSelect:E3e,"arrow-button":"_arrow-button_1cryw_74","left-button":"_left-button_1cryw_90","right-button":"_right-button_1cryw_97","anim-button":"_anim-button_1cryw_104","custom-checkbox":"_custom-checkbox_1cryw_109","checkbox-container":"_checkbox-container_1cryw_114",checked:U3e,checkmark:S3e,checkboxHolder:_3e};function oR({model:n}){const[e,t]=me.useState(0),[r,i]=me.useState(0),[s,o]=me.useState(0),[a,l]=me.useState(0),[A,c]=me.useState(0),[u,f]=me.useState(0),[d,h]=me.useState(0),[p,m]=me.useState(0);return me.useEffect(()=>{if(n!=null){const g=Ih(n,"Mesh"),v=Ih(n,"SkinnedMesh");t(g.length),i(v.length);const y=g.concat(v),{stdMats:w,stdCutoutpMats:C,stdTranspMats:b,mToonMats:E,mToonCutoutMats:x,mToonTranspMats:S}=rhe(y);o(w.length),l(b.length),c(C.length),f(E.length),h(S.length),m(x.length)}},[n]),n!=null?P.jsx("div",{children:P.jsxs("div",{className:bi.InformationContainerPos,children:[P.jsx(Eh,{title:"Model Information",width:180,right:20}),P.jsxs("div",{className:bi.scrollContainer,children:[P.jsx("div",{className:bi.traitInfoTitle,children:"Meshes:"}),P.jsx("div",{className:bi.traitInfoText,children:e}),P.jsx("div",{className:bi.traitInfoTitle,children:"SkinnedMeshes:"}),P.jsx("div",{className:bi.traitInfoText,children:r}),P.jsx("div",{className:bi.traitInfoTitle,children:"Standard Material Count:"}),P.jsxs("div",{className:bi.traitInfoText,children:["opaque: ",s]}),P.jsxs("div",{className:bi.traitInfoText,children:["cutout: ",A]}),P.jsxs("div",{className:bi.traitInfoText,children:["transparent: ",a]}),P.jsx("div",{className:bi.traitInfoTitle,children:"MToon Material Count:"}),P.jsxs("div",{className:bi.traitInfoText,children:["opaque: ",u]}),P.jsxs("div",{className:bi.traitInfoText,children:["cutout: ",p]}),P.jsxs("div",{className:bi.traitInfoText,children:["transparent: ",d]})]})]})}):P.jsx(P.Fragment,{})}function Q3e(){const{isLoading:n,setViewMode:e,setIsLoading:t}=Y.useContext(Bi),{toggleDebugMode:r,characterManager:i,animationManager:s}=Y.useContext(ni),[o,a]=me.useState(null),[l,A]=me.useState(""),[c,u]=Y.useState(""),{playSound:f}=Y.useContext(Cs),{isMute:d}=Y.useContext(Bs),[h,p]=Y.useState(null),m=()=>{!d&&f("backNextButton"),i.removeCurrentCharacter(),i.removeCurrentManifest(),r(!1),e(ot.LANDING)},g=()=>{const S=et.mergeOptions_sel_option||0;return{isVrm0:!0,createTextureAtlas:!0,mToonAtlasSize:Cn(et.mergeOptions_atlas_mtoon_size||6),mToonAtlasSizeTransp:Cn(et.mergeOptions_atlas_mtoon_transp_size||6),stdAtlasSize:Cn(et.mergeOptions_atlas_std_size||6),stdAtlasSizeTransp:Cn(et.mergeOptions_atlas_std_transp_size||6),exportStdAtlas:S===0||S==2,exportMtoonAtlas:S===1||S==2,ktxCompression:et.merge_options_ktx_compression||!1,twoSidedMaterial:et.mergeOptions_two_sided_mat||!1}},v=S=>{i.loadTraitsFromNFTObject(h[S]).then(()=>{i.downloadVRM(h[S].name,g()).then(()=>{S{t(!0),v(0)},{t:w}=me.useContext(bs),C=async S=>{if(i.getCurrentCharacterModel()){const Z=rc(S.name),K=URL.createObjectURL(S);await s.loadAnimation(K,!1,0,!0,"",Z),u(s.getCurrentAnimationName()),URL.revokeObjectURL(K)}else console.warn("Please load a vrm model to test animations.")},b=async S=>{const M=URL.createObjectURL(S);await i.loadOptimizerCharacter(M),URL.revokeObjectURL(M);const Z=rc(S.name);A(Z),a(i.getCurrentCharacterModel())},E=S=>{const M=Array.from(S),Z=[],K=_=>new Promise((B,F)=>{var R;if(_&&_.name.toLowerCase().endsWith(".json")){const k=new FileReader,T=`${(R=i.manifestData)==null?void 0:R.getAssetsDirectory()}/anata/_thumbnails/t_${_.name.split("_")[0]}.jpg`;k.onload=function(V){try{const O=JSON.parse(V.target.result);O.thumb=T,Z.push(O),B()}catch(O){console.error("Error parsing the JSON file:",O),F(O)}},k.readAsText(_)}});Promise.all(M.map(K)).then(()=>{Z.length>0&&(p(Z),t(!0),i.loadTraitsFromNFTObject(Z[0]).then(()=>{t(!1)}))}).catch(_=>{console.error("Error processing files:",_)})},x=async S=>{const M=S[0];console.log("anim"),M&&M.name.toLowerCase().endsWith(".fbx")&&(console.log("anim2"),C(M)),M&&M.name.toLowerCase().endsWith(".vrm")&&b(M),M&&M.name.toLowerCase().endsWith(".json")&&E(S)};return P.jsxs("div",{className:Cr.container,children:[P.jsx("div",{className:`loadingIndicator ${n?"active":""}`,children:P.jsx("img",{className:"rotate",src:"ui/loading.svg"})}),P.jsx("div",{className:"sectionTitle",children:"Batch Download"}),P.jsx(C0,{onFilesDrop:x}),P.jsx(wb,{showDropToDownload:!0,showCreateAtlas:!1,mergeMenuTitle:"Download Options"}),P.jsx(oR,{model:o}),P.jsx(hQ,{jsonSelectionArray:h}),P.jsx(dQ,{loadedAnimationName:c}),P.jsxs("div",{className:Cr.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:w("callToAction.back"),size:14,className:Cr.buttonLeft,onClick:m}),(h==null?void 0:h.length)==1&&P.jsx(Gt,{theme:"light",text:"Download",size:14,className:Cr.buttonRight,onClick:y}),(h==null?void 0:h.length)>1&&P.jsx(Gt,{theme:"light",text:"Download All",size:14,className:Cr.buttonRight,onClick:y})]})]})}function R3e(){const{isLoading:n,setViewMode:e}=Y.useContext(Bi),{characterManager:t,animationManager:r,sceneElements:i,loraDataGenerator:s,spriteAtlasGenerator:o}=Y.useContext(ni),{playSound:a}=Y.useContext(Cs),{isMute:l}=Y.useContext(Bs),[A,c]=me.useState(null),[u,f]=me.useState(""),d=()=>{!l&&a("backNextButton"),t.removeCurrentCharacter(),t.removeCurrentManifest(),e(ot.LANDING)},h=()=>{const b=et.mergeOptions_sel_option||0;return{isVrm0:!0,createTextureAtlas:!0,mToonAtlasSize:Cn(et.mergeOptions_atlas_mtoon_size||6),mToonAtlasSizeTransp:Cn(et.mergeOptions_atlas_mtoon_transp_size||6),stdAtlasSize:Cn(et.mergeOptions_atlas_std_size||6),stdAtlasSizeTransp:Cn(et.mergeOptions_atlas_std_transp_size||6),exportStdAtlas:b===0||b==2,exportMtoonAtlas:b===1||b==2,ktxCompression:et.merge_options_ktx_compression||!1,twoSidedMaterial:et.mergeOptions_two_sided_mat||!1}},p=async()=>{const b=i.parent;b.remove(i),await s.createLoraData("./lora-assets/manifest.json"),b.add(i)},m=async()=>{const b=i.parent;b.remove(i),await o.createSpriteAtlas("./sprite-atlas-assets/manifest.json"),b.add(i)},g=()=>{t.downloadVRM(u+"_merged",h())},{t:v}=me.useContext(bs),y=async b=>{if(t.getCurrentOptimizerCharacterModel()){const x=rc(b.name),S=URL.createObjectURL(b);await r.loadAnimation(S,!1,0,!0,"",x),URL.revokeObjectURL(S)}else console.warn("Please load a vrm model to test animations.")},w=async b=>{const E=URL.createObjectURL(b);await t.loadOptimizerCharacter(E),URL.revokeObjectURL(E);const x=rc(b.name);f(x),c(t.getCurrentCharacterModel())},C=async b=>{const E=b[0];E&&E.name.toLowerCase().endsWith(".fbx")&&y(E),E&&E.name.toLowerCase().endsWith(".vrm")&&w(E)};return P.jsxs("div",{className:Cr.container,children:[P.jsx("div",{className:`loadingIndicator ${n?"active":""}`,children:P.jsx("img",{className:"rotate",src:"ui/loading.svg"})}),P.jsx("div",{className:"sectionTitle",children:"Optimize your character"}),P.jsx(C0,{onFilesDrop:C}),P.jsx(wb,{showDropToDownload:!0,showCreateAtlas:!1,mergeMenuTitle:"Optimizer Options"}),P.jsx(oR,{model:A}),P.jsxs("div",{className:Cr.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:v("callToAction.back"),size:14,className:Cr.buttonLeft,onClick:d}),A!=""&&P.jsx(Gt,{theme:"light",text:"Download",size:14,className:Cr.buttonRight,onClick:g}),A!=""&&P.jsx(Gt,{theme:"light",text:"Create Lora",size:14,className:Cr.buttonRight,onClick:p}),A!=""&&P.jsx(Gt,{theme:"light",text:"Create Sprite Atlas",size:14,className:Cr.buttonRight,onClick:m})]})]})}const M3e="_languageSwitchWrap_83v6a_1",T3e={languageSwitchWrap:M3e},b3={en:{nativeName:"English"},ru:{nativeName:"Русский"},zh:{nativeName:"中文"}};function N3e(){const{t:n,i18n:e}=i4();return P.jsx("div",{className:T3e.languageSwitchWrap,children:P.jsx("select",{onChange:t=>e.changeLanguage(t.target.value),value:e.resolvedLanguage,children:Object.keys(b3).map(t=>P.jsx("option",{value:t,children:b3[t].nativeName},t))})})}function D3e(){const{isLoading:n,setViewMode:e,setIsLoading:t}=Y.useContext(Bi),{characterManager:r,animationManager:i,toggleDebugMode:s}=Y.useContext(ni),[o,a]=me.useState(null),[l,A]=me.useState(""),{playSound:c}=Y.useContext(Cs),{isMute:u}=Y.useContext(Bs);Y.useState(null);const[f,d]=Y.useState(null),[h,p]=Y.useState(""),m=()=>{!u&&c("backNextButton"),r.removeCurrentCharacter(),r.removeCurrentManifest(),s(!1),e(ot.LANDING)},g=()=>{const Z=et.mergeOptions_sel_option||0;return{isVrm0:!0,createTextureAtlas:!0,mToonAtlasSize:Cn(et.mergeOptions_atlas_mtoon_size||6),mToonAtlasSizeTransp:Cn(et.mergeOptions_atlas_mtoon_transp_size||6),stdAtlasSize:Cn(et.mergeOptions_atlas_std_size||6),stdAtlasSizeTransp:Cn(et.mergeOptions_atlas_std_transp_size||6),exportStdAtlas:Z===0||Z==2,exportMtoonAtlas:Z===1||Z==2,ktxCompression:et.merge_options_ktx_compression||!1,twoSidedMaterial:et.mergeOptions_two_sided_mat||!1}},v=(Z,K=!1)=>{const _=f[Z].manifestName;r.savePortraitScreenshot(_,512,1024,1.5,-.1),K?Z{Z{Z==0?v(Z,K):(await r.setManifest(f[Z]),t(!0),r.loadInitialTraits().then(async()=>{await(B=>new Promise(F=>setTimeout(F,B)))(1),v(Z+1,K)}))},w=()=>{t(!0),y(0)},C=()=>{t(!0),y(0,!0)},{t:b}=me.useContext(bs),E=async Z=>{if(r.getCurrentCharacterModel()){const _=rc(Z.name),B=URL.createObjectURL(Z);await i.loadAnimation(B,!1,0,!0,"",_),p(i.getCurrentAnimationName()),URL.revokeObjectURL(B)}else console.warn("Please load a vrm model to test animations.")},x=async Z=>{const K=URL.createObjectURL(Z);await r.loadOptimizerCharacter(K),URL.revokeObjectURL(K);const _=rc(Z.name);A(_),a(r.getCurrentCharacterModel())},S=Z=>{const K=Array.from(Z),_=[],B=F=>new Promise((R,k)=>{if(F&&F.name.toLowerCase().endsWith(".json")){const T=new FileReader,V=F.name.replace(/\.[^/.]+$/,"");T.onload=function(O){try{const L=JSON.parse(O.target.result),U=L.thumbnail;L.manifestName=V,_.push(L),R()}catch(L){console.error("Error parsing the JSON file:",L),k(L)}},T.readAsText(F)}});Promise.all(K.map(B)).then(()=>{_.length>0&&(d(_),r.setManifest(_[0]),t(!0),r.loadInitialTraits().then(()=>{t(!1)}))}).catch(F=>{console.error("Error processing files:",F)})},M=async Z=>{const K=Z[0];K&&K.name.toLowerCase().endsWith(".fbx")&&E(K),K&&K.name.toLowerCase().endsWith(".vrm")&&x(K),K&&K.name.toLowerCase().endsWith(".json")&&S(Z)};return P.jsxs("div",{className:Cr.container,children:[P.jsx("div",{className:`loadingIndicator ${n?"active":""}`,children:P.jsx("img",{className:"rotate",src:"ui/loading.svg"})}),P.jsx("div",{className:"sectionTitle",children:"NFT Characters"}),P.jsx(C0,{onFilesDrop:M}),P.jsx(wb,{showDropToDownload:!0,showCreateAtlas:!1,mergeMenuTitle:"Download Options"}),P.jsx(oR,{model:o}),P.jsx(hQ,{jsonSelectionArray:f,byManifest:!0}),(f==null?void 0:f.length)>0&&P.jsx(dQ,{loadedAnimationName:h}),P.jsxs("div",{className:Cr.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:b("callToAction.back"),size:14,className:Cr.buttonLeft,onClick:m}),(f==null?void 0:f.length)==1&&P.jsx(Gt,{theme:"light",text:"Download",size:14,className:Cr.buttonRight,onClick:w}),(f==null?void 0:f.length)>1&&P.jsx(Gt,{theme:"light",text:"Download All",size:14,className:Cr.buttonRight,onClick:w}),(f==null?void 0:f.length)==1&&P.jsx(Gt,{theme:"light",text:"Get Image",size:14,className:Cr.buttonRight,onClick:C}),(f==null?void 0:f.length)>1&&P.jsx(Gt,{theme:"light",text:"Get All Images",size:14,className:Cr.buttonRight,onClick:C})]})]})}function k3e(){const{t:n}=me.useContext(bs),{setViewMode:e,setIsLoading:t,isLoading:r}=Y.useContext(Bi),{playSound:i}=Y.useContext(Cs),{isMute:s}=Y.useContext(Bs),{manifest:o,characterManager:a}=Y.useContext(ni);me.useState([]);const[l,A]=me.useState([]);me.useEffect(()=>{c()},[]);const c=async()=>{const p=await fQ();EBe(p,"the-anata-nft").then(m=>{A(m.nfts),console.log(m.nfts)})},u=()=>{e(ot.LANDING),!s&&i("backNextButton")},f=async p=>{t(!0),a.loadManifest(o[p].manifest).then(()=>{e(ot.APPEARANCE),a.loadInitialTraits().then(()=>{t(!1)})}),!s&&i("classSelect")},d=()=>{console.log("ttt"),a.loadManifest(o[0].manifest).then(()=>{a.loadAppendManifest(o[1].manifest,!0).then(()=>{console.log(a.manifestData)})})},h=()=>{!s&&i("classMouseOver")};return P.jsxs("div",{className:`${it.container} horizontalScroll`,children:[P.jsx("div",{className:"sectionTitle",children:n("pageTitles.chooseClass")}),P.jsx("div",{className:it.vrmOptimizerButton}),P.jsx("div",{className:it.topLine}),P.jsx("div",{className:it.classContainer,children:l.map((p,m)=>P.jsxs("div",{className:it.class,onClick:()=>f(m),onMouseOver:()=>h(),children:[P.jsx("div",{className:it.classFrame,style:{backgroundImage:`url(${p.image_url})`},children:P.jsx("div",{className:it.frameContainer,children:P.jsx("img",{src:"./assets/backgrounds/class-frame.svg",className:it.frame})})}),P.jsx("div",{className:it.name,children:p.name})]},m))}),P.jsx("div",{className:it.bottomLine}),P.jsxs("div",{className:it.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:n("callToAction.back"),size:14,className:it.buttonLeft,onClick:u}),P.jsx(Gt,{theme:"light",text:"test",size:14,className:it.buttonLeft,onClick:d})]})]})}const V3e="https://beta.anata.dev/character-assets/manifest.json";let Z1;const J1=new z,My=new z;let H1,z1;const L3e=1.4,P3e=new z(0,1.25,0),hz=new z(-.9786403788721187,1.4036900759197288,.9892635490125085),W3e=hz.length(),O3e=.35,x3=6,I3=new z(0,.8,0),pz=new z(-2.2367993753934425,1.1512971720174363,2.2612065299409223),G3e=pz.length(),Z3e=.5,Qf=new z,Zi=new Tt,J3e=new Tt,H3e=new z(1,0,0),z3e=new z(0,1,0);async function Y3e(n){try{const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch manifest. Status: ${e.status}`);return await e.json()}catch(e){return console.error(`Error fetching manifest: ${e.message}`),[]}}async function X3e(){const n=await Y3e(V3e),e=new ume;return{initialManifest:n,effectManager:e}}const K3e=()=>{let n,e;const r=X3e().then(i=>{n="success",e=i},i=>{n="error",e=i});return{read(){if(n==="error")throw e;if(n==="success")return e;throw r}}},j3e=K3e();function $3e(){const{initialManifest:n,effectManager:e}=j3e.read(),[t,r]=me.useState(!1),{camera:i,controls:s,scene:o,moveCamera:a,setManifest:l,lookAtManager:A,showEnvironmentModels:c}=me.useContext(ni),{viewMode:u}=me.useContext(Bi);e.camera=i,e.scene=o;const f=()=>{if(e.camera){if([ot.BIO,ot.CHAT].includes(u)){u===ot.CHAT?(Z1=L3e,J1.copy(P3e),My.copy(hz),H1=W3e,z1=O3e):(Z1=x3,J1.copy(I3),My.copy(pz),H1=G3e,z1=Z3e),Zi.set(0,0,H1,1).applyMatrix4(e.camera.projectionMatrix),Zi.x/=Zi.w,Zi.y/=Zi.w,Zi.z/=Zi.w;const b=J3e.set(z1*Zi.w,Zi.y*Zi.w,Zi.z*Zi.w,Zi.w).applyMatrix4(e.camera.projectionMatrixInverse).x,E=Qf.set(My.x,0,My.z).angleTo(H3e);Qf.set(b,0,0).applyAxisAngle(z3e,E),Qf.add(J1),a({targetX:Qf.x,targetY:Qf.y,targetZ:Qf.z,distance:Z1})}else a({targetX:0,targetY:I3.y,targetZ:0,distance:x3});s&&([ot.APPEARANCE,ot.SAVE,ot.OPTIMIZER,ot.BATCHDOWNLOAD,ot.BATCHMANIFEST].includes(u)?s.enabled=!0:s.enabled=!1)}},[d,h]=me.useState(!1),[p,m]=me.useState(""),[g,v]=me.useState([]),y=(b,E)=>{m(b),h(!0),v([E])},w={[ot.LANDING]:P.jsx(ewe,{}),[ot.APPEARANCE]:P.jsx(c3e,{confirmDialog:y}),[ot.OPTIMIZER]:P.jsx(R3e,{}),[ot.CREATE]:P.jsx(KBe,{}),[ot.WALLET]:P.jsx(k3e,{}),[ot.CLAIM]:P.jsx(jBe,{}),[ot.BATCHMANIFEST]:P.jsx(D3e,{}),[ot.BATCHDOWNLOAD]:P.jsx(Q3e,{}),[ot.LOAD]:P.jsx(lBe,{}),[ot.MINT]:P.jsx(QBe,{}),[ot.SAVE]:P.jsx(vye,{}),[ot.CHAT]:P.jsx(Xve,{})};let C=0;return me.useEffect(()=>{const b=E=>{const x=new Date().getTime(),S=x-C;S<300&&S>10&&E.target.id=="editor-scene"&&r(!t),C=x};return window.addEventListener("touchend",b),window.addEventListener("click",b),()=>{window.removeEventListener("touchend",b),window.removeEventListener("click",b)}},[t]),me.useEffect(()=>{if(A!=null)return f(),[ot.BIO,ot.MINT,ot.CHAT].includes(u)?A.enabled=!1:A.enabled=!0,[ot.LANDING,ot.CREATE,ot.CLAIM,ot.LOAD,ot.CLAIM,ot.CLAIM].includes(u)?c(!1):c(!0),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[u,A]),me.useEffect(()=>{l(n)},[n]),me.useContext(bs),P.jsxs(me.Fragment,{children:[P.jsx("div",{className:"generalTitle",children:"Character Studio"}),P.jsx(N3e,{}),P.jsx(_me,{confirmDialogText:p,confirmDialogCallback:g,confirmDialogWindow:d,setConfirmDialogWindow:h}),P.jsx(kme,{}),w[u]]})}const q3e=n=>{const e=new nS(n);return e.pollingInterval=12e3,e};iF.createRoot(document.getElementById("root")).render(P.jsx(Y.StrictMode,{children:P.jsx(sK,{getLibrary:q3e,children:P.jsx(pj,{children:P.jsx(Gge,{children:P.jsx(dj,{children:P.jsx(Cpe,{children:P.jsx(Bpe,{children:P.jsx(Qpe,{children:P.jsx(me.Suspense,{children:P.jsx($3e,{})})})})})})})})})}));export{td as c,bu as g}; + `),Y.createElement("div",{style:c.white,className:"saturation-white"},Y.createElement("div",{style:c.black,className:"saturation-black"}),Y.createElement("div",{style:c.pointer},this.props.pointer?Y.createElement(this.props.pointer,this.props):Y.createElement("div",{style:c.circle}))))}}]),e}(me.PureComponent||me.Component);function lke(n,e){for(var t=-1,r=n==null?0:n.length;++t=0,s=!t&&i&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(r=this.toRgbString()),e==="prgb"&&(r=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(r=this.toHexString()),e==="hex3"&&(r=this.toHexString(!0)),e==="hex4"&&(r=this.toHex8String(!0)),e==="hex8"&&(r=this.toHex8String()),e==="name"&&(r=this.toName()),e==="hsl"&&(r=this.toHslString()),e==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return je(this.toString())},_applyModification:function(e,t){var r=e.apply(null,[this].concat([].slice.call(t)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Ske,arguments)},brighten:function(){return this._applyModification(_ke,arguments)},darken:function(){return this._applyModification(Qke,arguments)},desaturate:function(){return this._applyModification(Fke,arguments)},saturate:function(){return this._applyModification(Eke,arguments)},greyscale:function(){return this._applyModification(Uke,arguments)},spin:function(){return this._applyModification(Rke,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(Nke,arguments)},complement:function(){return this._applyCombination(Mke,arguments)},monochromatic:function(){return this._applyCombination(Dke,arguments)},splitcomplement:function(){return this._applyCombination(Tke,arguments)},triad:function(){return this._applyCombination(jL,[3])},tetrad:function(){return this._applyCombination(jL,[4])}};je.fromRatio=function(n,e){if(hC(n)=="object"){var t={};for(var r in n)n.hasOwnProperty(r)&&(r==="a"?t[r]=n[r]:t[r]=Ig(n[r]));n=t}return je(n,e)};function wke(n){var e={r:0,g:0,b:0},t=1,r=null,i=null,s=null,o=!1,a=!1;return typeof n=="string"&&(n=Wke(n)),hC(n)=="object"&&(nl(n.r)&&nl(n.g)&&nl(n.b)?(e=Cke(n.r,n.g,n.b),o=!0,a=String(n.r).substr(-1)==="%"?"prgb":"rgb"):nl(n.h)&&nl(n.s)&&nl(n.v)?(r=Ig(n.s),i=Ig(n.v),e=xke(n.h,r,i),o=!0,a="hsv"):nl(n.h)&&nl(n.s)&&nl(n.l)&&(r=Ig(n.s),s=Ig(n.l),e=bke(n.h,r,s),o=!0,a="hsl"),n.hasOwnProperty("a")&&(t=n.a)),t=q5(t),{ok:o,format:n.format||a,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function Cke(n,e,t){return{r:wn(n,255)*255,g:wn(e,255)*255,b:wn(t,255)*255}}function zL(n,e,t){n=wn(n,255),e=wn(e,255),t=wn(t,255);var r=Math.max(n,e,t),i=Math.min(n,e,t),s,o,a=(r+i)/2;if(r==i)s=o=0;else{var l=r-i;switch(o=a>.5?l/(2-r-i):l/(r+i),r){case n:s=(e-t)/l+(e1&&(u-=1),u<1/6?A+(c-A)*6*u:u<1/2?c:u<2/3?A+(c-A)*(2/3-u)*6:A}if(e===0)r=i=s=t;else{var a=t<.5?t*(1+e):t+e-t*e,l=2*t-a;r=o(l,a,n+1/3),i=o(l,a,n),s=o(l,a,n-1/3)}return{r:r*255,g:i*255,b:s*255}}function YL(n,e,t){n=wn(n,255),e=wn(e,255),t=wn(t,255);var r=Math.max(n,e,t),i=Math.min(n,e,t),s,o,a=r,l=r-i;if(o=r===0?0:l/r,r==i)s=0;else{switch(r){case n:s=(e-t)/l+(e>1)+720)%360;--e;)r.h=(r.h+i)%360,s.push(je(r));return s}function Dke(n,e){e=e||6;for(var t=je(n).toHsv(),r=t.h,i=t.s,s=t.v,o=[],a=1/e;e--;)o.push(je({h:r,s:i,v:s})),s=(s+a)%1;return o}je.mix=function(n,e,t){t=t===0?0:t||50;var r=je(n).toRgb(),i=je(e).toRgb(),s=t/100,o={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(i.a-r.a)*s+r.a};return je(o)};je.readability=function(n,e){var t=je(n),r=je(e);return(Math.max(t.getLuminance(),r.getLuminance())+.05)/(Math.min(t.getLuminance(),r.getLuminance())+.05)};je.isReadable=function(n,e,t){var r=je.readability(n,e),i,s;switch(s=!1,i=Oke(t),i.level+i.size){case"AAsmall":case"AAAlarge":s=r>=4.5;break;case"AAlarge":s=r>=3;break;case"AAAsmall":s=r>=7;break}return s};je.mostReadable=function(n,e,t){var r=null,i=0,s,o,a,l;t=t||{},o=t.includeFallbackColors,a=t.level,l=t.size;for(var A=0;Ai&&(i=s,r=je(e[A]));return je.isReadable(n,r,{level:a,size:l})||!o?r:(t.includeFallbackColors=!1,je.mostReadable(n,["#fff","#000"],t))};var DU=je.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},kke=je.hexNames=Vke(DU);function Vke(n){var e={};for(var t in n)n.hasOwnProperty(t)&&(e[n[t]]=t);return e}function q5(n){return n=parseFloat(n),(isNaN(n)||n<0||n>1)&&(n=1),n}function wn(n,e){Lke(n)&&(n="100%");var t=Pke(n);return n=Math.min(e,Math.max(0,parseFloat(n))),t&&(n=parseInt(n*e,10)/100),Math.abs(n-e)<1e-6?1:n%e/parseFloat(e)}function Lb(n){return Math.min(1,Math.max(0,n))}function zi(n){return parseInt(n,16)}function Lke(n){return typeof n=="string"&&n.indexOf(".")!=-1&&parseFloat(n)===1}function Pke(n){return typeof n=="string"&&n.indexOf("%")!=-1}function Qo(n){return n.length==1?"0"+n:""+n}function Ig(n){return n<=1&&(n=n*100+"%"),n}function ez(n){return Math.round(parseFloat(n)*255).toString(16)}function $L(n){return zi(n)/255}var bo=function(){var n="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+n+")",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",i="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function nl(n){return!!bo.CSS_UNIT.exec(n)}function Wke(n){n=n.replace(yke,"").replace(Bke,"").toLowerCase();var e=!1;if(DU[n])n=DU[n],e=!0;else if(n=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=bo.rgb.exec(n))?{r:t[1],g:t[2],b:t[3]}:(t=bo.rgba.exec(n))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=bo.hsl.exec(n))?{h:t[1],s:t[2],l:t[3]}:(t=bo.hsla.exec(n))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=bo.hsv.exec(n))?{h:t[1],s:t[2],v:t[3]}:(t=bo.hsva.exec(n))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=bo.hex8.exec(n))?{r:zi(t[1]),g:zi(t[2]),b:zi(t[3]),a:$L(t[4]),format:e?"name":"hex8"}:(t=bo.hex6.exec(n))?{r:zi(t[1]),g:zi(t[2]),b:zi(t[3]),format:e?"name":"hex"}:(t=bo.hex4.exec(n))?{r:zi(t[1]+""+t[1]),g:zi(t[2]+""+t[2]),b:zi(t[3]+""+t[3]),a:$L(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=bo.hex3.exec(n))?{r:zi(t[1]+""+t[1]),g:zi(t[2]+""+t[2]),b:zi(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function Oke(n){var e,t;return n=n||{level:"AA",size:"small"},e=(n.level||"AA").toUpperCase(),t=(n.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}var qL=function(e){var t=["r","g","b","a","h","s","l","v"],r=0,i=0;return vke(t,function(s){if(e[s]&&(r+=1,isNaN(e[s])||(i+=1),s==="s"||s==="l")){var o=/^\d+%$/;o.test(e[s])&&(i+=1)}}),r===i?e:!1},Fg=function(e,t){var r=e.hex?je(e.hex):je(e),i=r.toHsl(),s=r.toHsv(),o=r.toRgb(),a=r.toHex();i.s===0&&(i.h=t||0,s.h=t||0);var l=a==="000000"&&o.a===0;return{hsl:i,hex:l?"transparent":"#"+a,rgb:o,hsv:s,oldHue:e.h||t||i.h,source:e.source}},gc=function(e){if(e==="transparent")return!0;var t=String(e).charAt(0)==="#"?1:0;return e.length!==4+t&&e.length<7+t&&je(e).isValid()},OQ=function(e){if(!e)return"#fff";var t=Fg(e);if(t.hex==="transparent")return"rgba(0,0,0,0.4)";var r=(t.rgb.r*299+t.rgb.g*587+t.rgb.b*114)/1e3;return r>=128?"#000":"#fff"},O1=function(e,t){var r=e.replace("°","");return je(t+" ("+r+")")._ok},tg=Object.assign||function(n){for(var e=1;e1&&arguments[1]!==void 0?arguments[1]:"span";return function(r){Kke(i,r);function i(){var s,o,a,l;Xke(this,i);for(var A=arguments.length,c=Array(A),u=0;ua))return!1;var A=s.get(n),c=s.get(e);if(A&&c)return A==e&&c==n;var u=-1,f=!0,d=t&lVe?new pC:void 0;for(s.set(n,e),s.set(e,n);++u=0||Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t}var Qy=24,_Le=cz.default=function(n){var e=n.fill,t=e===void 0?"currentColor":e,r=n.width,i=r===void 0?Qy:r,s=n.height,o=s===void 0?Qy:s,a=n.style,l=a===void 0?{}:a,A=SLe(n,["fill","width","height","style"]);return v3.default.createElement("svg",m3({viewBox:"0 0 "+Qy+" "+Qy,style:m3({fill:t,width:i,height:o},l)},A),v3.default.createElement("path",{d:"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z"}))},QLe=function(){function n(e,t){for(var r=0;r1&&(i.a=1),r.props.onChange({h:r.props.hsl.h,s:r.props.hsl.s,l:r.props.hsl.l,a:Math.round(i.a*100)/100,source:"rgb"},s)):(i.h||i.s||i.l)&&(typeof i.s=="string"&&i.s.includes("%")&&(i.s=i.s.replace("%","")),typeof i.l=="string"&&i.l.includes("%")&&(i.l=i.l.replace("%","")),i.s==1?i.s=.01:i.l==1&&(i.l=.01),r.props.onChange({h:i.h||r.props.hsl.h,s:Number(g3(i.s)?r.props.hsl.s:i.s),l:Number(g3(i.l)?r.props.hsl.l:i.l),source:"hsl"},s))},r.showHighlight=function(i){i.currentTarget.style.background="#eee"},r.hideHighlight=function(i){i.currentTarget.style.background="transparent"},t.hsl.a!==1&&t.view==="hex"?r.state={view:"rgb"}:r.state={view:t.view},r}return QLe(e,[{key:"render",value:function(){var r=this,i=ut({default:{wrap:{paddingTop:"16px",display:"flex"},fields:{flex:"1",display:"flex",marginLeft:"-6px"},field:{paddingLeft:"6px",width:"100%"},alpha:{paddingLeft:"6px",width:"100%"},toggle:{width:"32px",textAlign:"right",position:"relative"},icon:{marginRight:"-4px",marginTop:"12px",cursor:"pointer",position:"relative"},iconHighlight:{position:"absolute",width:"24px",height:"28px",background:"#eee",borderRadius:"4px",top:"10px",left:"12px",display:"none"},input:{fontSize:"11px",color:"#333",width:"100%",borderRadius:"2px",border:"none",boxShadow:"inset 0 0 0 1px #dadada",height:"21px",textAlign:"center"},label:{textTransform:"uppercase",fontSize:"11px",lineHeight:"11px",color:"#969696",textAlign:"center",display:"block",marginTop:"12px"},svg:{fill:"#333",width:"24px",height:"24px",border:"1px transparent solid",borderRadius:"5px"}},disableAlpha:{alpha:{display:"none"}}},this.props,this.state),s=void 0;return this.state.view==="hex"?s=Y.createElement("div",{style:i.fields,className:"flexbox-fix"},Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"hex",value:this.props.hex,onChange:this.handleChange}))):this.state.view==="rgb"?s=Y.createElement("div",{style:i.fields,className:"flexbox-fix"},Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"r",value:this.props.rgb.r,onChange:this.handleChange})),Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"g",value:this.props.rgb.g,onChange:this.handleChange})),Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"b",value:this.props.rgb.b,onChange:this.handleChange})),Y.createElement("div",{style:i.alpha},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"a",value:this.props.rgb.a,arrowOffset:.01,onChange:this.handleChange}))):this.state.view==="hsl"&&(s=Y.createElement("div",{style:i.fields,className:"flexbox-fix"},Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"h",value:Math.round(this.props.hsl.h),onChange:this.handleChange})),Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"s",value:Math.round(this.props.hsl.s*100)+"%",onChange:this.handleChange})),Y.createElement("div",{style:i.field},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"l",value:Math.round(this.props.hsl.l*100)+"%",onChange:this.handleChange})),Y.createElement("div",{style:i.alpha},Y.createElement(Mt,{style:{input:i.input,label:i.label},label:"a",value:this.props.hsl.a,arrowOffset:.01,onChange:this.handleChange})))),Y.createElement("div",{style:i.wrap,className:"flexbox-fix"},s,Y.createElement("div",{style:i.toggle},Y.createElement("div",{style:i.icon,onClick:this.toggleViews,ref:function(a){return r.icon=a}},Y.createElement(_Le,{style:i.svg,onMouseOver:this.showHighlight,onMouseEnter:this.showHighlight,onMouseOut:this.hideHighlight}))))}}],[{key:"getDerivedStateFromProps",value:function(r,i){return r.hsl.a!==1&&i.view==="hex"?{view:"rgb"}:null}}]),e}(Y.Component);uz.defaultProps={view:"hex"};var y3=function(){var e=ut({default:{picker:{width:"12px",height:"12px",borderRadius:"6px",transform:"translate(-6px, -1px)",backgroundColor:"rgb(248, 248, 248)",boxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.37)"}}});return Y.createElement("div",{style:e.picker})},NLe=function(){var e=ut({default:{picker:{width:"12px",height:"12px",borderRadius:"6px",boxShadow:"inset 0 0 0 1px #fff",transform:"translate(-6px, -6px)"}}});return Y.createElement("div",{style:e.picker})},YQ=function(e){var t=e.width,r=e.onChange,i=e.disableAlpha,s=e.rgb,o=e.hsl,a=e.hsv,l=e.hex,A=e.renderers,c=e.styles,u=c===void 0?{}:c,f=e.className,d=f===void 0?"":f,h=e.defaultView,p=ut(Pi({default:{picker:{width:t,background:"#fff",borderRadius:"2px",boxShadow:"0 0 2px rgba(0,0,0,.3), 0 4px 8px rgba(0,0,0,.3)",boxSizing:"initial",fontFamily:"Menlo"},saturation:{width:"100%",paddingBottom:"55%",position:"relative",borderRadius:"2px 2px 0 0",overflow:"hidden"},Saturation:{radius:"2px 2px 0 0"},body:{padding:"16px 16px 12px"},controls:{display:"flex"},color:{width:"32px"},swatch:{marginTop:"6px",width:"16px",height:"16px",borderRadius:"8px",position:"relative",overflow:"hidden"},active:{absolute:"0px 0px 0px 0px",borderRadius:"8px",boxShadow:"inset 0 0 0 1px rgba(0,0,0,.1)",background:"rgba("+s.r+", "+s.g+", "+s.b+", "+s.a+")",zIndex:"2"},toggles:{flex:"1"},hue:{height:"10px",position:"relative",marginBottom:"8px"},Hue:{radius:"2px"},alpha:{height:"10px",position:"relative"},Alpha:{radius:"2px"}},disableAlpha:{color:{width:"22px"},alpha:{display:"none"},hue:{marginBottom:"0px"},swatch:{width:"10px",height:"10px",marginTop:"0px"}}},u),{disableAlpha:i});return Y.createElement("div",{style:p.picker,className:"chrome-picker "+d},Y.createElement("div",{style:p.saturation},Y.createElement(Vb,{style:p.Saturation,hsl:o,hsv:a,pointer:NLe,onChange:r})),Y.createElement("div",{style:p.body},Y.createElement("div",{style:p.controls,className:"flexbox-fix"},Y.createElement("div",{style:p.color},Y.createElement("div",{style:p.swatch},Y.createElement("div",{style:p.active}),Y.createElement(op,{renderers:A}))),Y.createElement("div",{style:p.toggles},Y.createElement("div",{style:p.hue},Y.createElement(ap,{style:p.Hue,hsl:o,pointer:y3,onChange:r})),Y.createElement("div",{style:p.alpha},Y.createElement(TQ,{style:p.Alpha,rgb:s,hsl:o,pointer:y3,renderers:A,onChange:r})))),Y.createElement(uz,{rgb:s,hsl:o,hex:l,view:h,onChange:r,disableAlpha:i})))};YQ.propTypes={width:Te.oneOfType([Te.string,Te.number]),disableAlpha:Te.bool,styles:Te.object,defaultView:Te.oneOf(["hex","rgb","hsl"])};YQ.defaultProps={width:225,disableAlpha:!1,styles:{}};const DLe=Wi(YQ);var kLe=function(e){var t=e.color,r=e.onClick,i=r===void 0?function(){}:r,s=e.onSwatchHover,o=e.active,a=ut({default:{color:{background:t,width:"15px",height:"15px",float:"left",marginRight:"5px",marginBottom:"5px",position:"relative",cursor:"pointer"},dot:{absolute:"5px 5px 5px 5px",background:OQ(t),borderRadius:"50%",opacity:"0"}},active:{dot:{opacity:"1"}},"color-#FFFFFF":{color:{boxShadow:"inset 0 0 0 1px #ddd"},dot:{background:"#000"}},transparent:{dot:{background:"#000"}}},{active:o,"color-#FFFFFF":t==="#FFFFFF",transparent:t==="transparent"});return Y.createElement(Ou,{style:a.color,color:t,onClick:i,onHover:s,focusStyle:{boxShadow:"0 0 4px "+t}},Y.createElement("div",{style:a.dot}))},VLe=function(e){var t=e.hex,r=e.rgb,i=e.onChange,s=ut({default:{fields:{display:"flex",paddingBottom:"6px",paddingRight:"5px",position:"relative"},active:{position:"absolute",top:"6px",left:"5px",height:"9px",width:"9px",background:t},HEXwrap:{flex:"6",position:"relative"},HEXinput:{width:"80%",padding:"0px",paddingLeft:"20%",border:"none",outline:"none",background:"none",fontSize:"12px",color:"#333",height:"16px"},HEXlabel:{display:"none"},RGBwrap:{flex:"3",position:"relative"},RGBinput:{width:"70%",padding:"0px",paddingLeft:"30%",border:"none",outline:"none",background:"none",fontSize:"12px",color:"#333",height:"16px"},RGBlabel:{position:"absolute",top:"3px",left:"0px",lineHeight:"16px",textTransform:"uppercase",fontSize:"12px",color:"#999"}}}),o=function(l,A){l.r||l.g||l.b?i({r:l.r||r.r,g:l.g||r.g,b:l.b||r.b,source:"rgb"},A):i({hex:l.hex,source:"hex"},A)};return Y.createElement("div",{style:s.fields,className:"flexbox-fix"},Y.createElement("div",{style:s.active}),Y.createElement(Mt,{style:{wrap:s.HEXwrap,input:s.HEXinput,label:s.HEXlabel},label:"hex",value:t,onChange:o}),Y.createElement(Mt,{style:{wrap:s.RGBwrap,input:s.RGBinput,label:s.RGBlabel},label:"r",value:r.r,onChange:o}),Y.createElement(Mt,{style:{wrap:s.RGBwrap,input:s.RGBinput,label:s.RGBlabel},label:"g",value:r.g,onChange:o}),Y.createElement(Mt,{style:{wrap:s.RGBwrap,input:s.RGBinput,label:s.RGBlabel},label:"b",value:r.b,onChange:o}))},XQ=function(e){var t=e.onChange,r=e.onSwatchHover,i=e.colors,s=e.hex,o=e.rgb,a=e.styles,l=a===void 0?{}:a,A=e.className,c=A===void 0?"":A,u=ut(Pi({default:{Compact:{background:"#f6f6f6",radius:"4px"},compact:{paddingTop:"5px",paddingLeft:"5px",boxSizing:"initial",width:"240px"},clear:{clear:"both"}}},l)),f=function(h,p){h.hex?gc(h.hex)&&t({hex:h.hex,source:"hex"},p):t(h,p)};return Y.createElement(R0,{style:u.Compact,styles:l},Y.createElement("div",{style:u.compact,className:"compact-picker "+c},Y.createElement("div",null,Gu(i,function(d){return Y.createElement(kLe,{key:d,color:d,active:d.toLowerCase()===s,onClick:f,onSwatchHover:r})}),Y.createElement("div",{style:u.clear})),Y.createElement(VLe,{hex:s,rgb:o,onChange:f})))};XQ.propTypes={colors:Te.arrayOf(Te.string),styles:Te.object};XQ.defaultProps={colors:["#4D4D4D","#999999","#FFFFFF","#F44E3B","#FE9200","#FCDC00","#DBDF00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#FDA1FF","#333333","#808080","#cccccc","#D33115","#E27300","#FCC400","#B0BC00","#68BC00","#16A5A5","#009CE0","#7B64FF","#FA28FF","#000000","#666666","#B3B3B3","#9F0500","#C45100","#FB9E00","#808900","#194D33","#0C797D","#0062B1","#653294","#AB149E"],styles:{}};Wi(XQ);var LLe=function(e){var t=e.hover,r=e.color,i=e.onClick,s=e.onSwatchHover,o={position:"relative",zIndex:"2",outline:"2px solid #fff",boxShadow:"0 0 5px 2px rgba(0,0,0,0.25)"},a=ut({default:{swatch:{width:"25px",height:"25px",fontSize:"0"}},hover:{swatch:o}},{hover:t});return Y.createElement("div",{style:a.swatch},Y.createElement(Ou,{color:r,onClick:i,onHover:s,focusStyle:o}))};const PLe=MQ(LLe);var KQ=function(e){var t=e.width,r=e.colors,i=e.onChange,s=e.onSwatchHover,o=e.triangle,a=e.styles,l=a===void 0?{}:a,A=e.className,c=A===void 0?"":A,u=ut(Pi({default:{card:{width:t,background:"#fff",border:"1px solid rgba(0,0,0,0.2)",boxShadow:"0 3px 12px rgba(0,0,0,0.15)",borderRadius:"4px",position:"relative",padding:"5px",display:"flex",flexWrap:"wrap"},triangle:{position:"absolute",border:"7px solid transparent",borderBottomColor:"#fff"},triangleShadow:{position:"absolute",border:"8px solid transparent",borderBottomColor:"rgba(0,0,0,0.15)"}},"hide-triangle":{triangle:{display:"none"},triangleShadow:{display:"none"}},"top-left-triangle":{triangle:{top:"-14px",left:"10px"},triangleShadow:{top:"-16px",left:"9px"}},"top-right-triangle":{triangle:{top:"-14px",right:"10px"},triangleShadow:{top:"-16px",right:"9px"}},"bottom-left-triangle":{triangle:{top:"35px",left:"10px",transform:"rotate(180deg)"},triangleShadow:{top:"37px",left:"9px",transform:"rotate(180deg)"}},"bottom-right-triangle":{triangle:{top:"35px",right:"10px",transform:"rotate(180deg)"},triangleShadow:{top:"37px",right:"9px",transform:"rotate(180deg)"}}},l),{"hide-triangle":o==="hide","top-left-triangle":o==="top-left","top-right-triangle":o==="top-right","bottom-left-triangle":o==="bottom-left","bottom-right-triangle":o==="bottom-right"}),f=function(h,p){return i({hex:h,source:"hex"},p)};return Y.createElement("div",{style:u.card,className:"github-picker "+c},Y.createElement("div",{style:u.triangleShadow}),Y.createElement("div",{style:u.triangle}),Gu(r,function(d){return Y.createElement(PLe,{color:d,key:d,onClick:f,onSwatchHover:s})}))};KQ.propTypes={width:Te.oneOfType([Te.string,Te.number]),colors:Te.arrayOf(Te.string),triangle:Te.oneOf(["hide","top-left","top-right","bottom-left","bottom-right"]),styles:Te.object};KQ.defaultProps={width:200,colors:["#B80000","#DB3E00","#FCCB00","#008B02","#006B76","#1273DE","#004DCF","#5300EB","#EB9694","#FAD0C3","#FEF3BD","#C1E1C5","#BEDADC","#C4DEF6","#BED3F3","#D4C4FB"],triangle:"top-left",styles:{}};Wi(KQ);var WLe=function(e){var t=e.direction,r=ut({default:{picker:{width:"18px",height:"18px",borderRadius:"50%",transform:"translate(-9px, -1px)",backgroundColor:"rgb(248, 248, 248)",boxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.37)"}},vertical:{picker:{transform:"translate(-3px, -9px)"}}},{vertical:t==="vertical"});return Y.createElement("div",{style:r.picker})},OLe=Object.assign||function(n){for(var e=1;e.5});return Y.createElement("div",{style:r.picker})},HLe=function(){var e=ut({default:{triangle:{width:0,height:0,borderStyle:"solid",borderWidth:"4px 0 4px 6px",borderColor:"transparent transparent transparent #fff",position:"absolute",top:"1px",left:"1px"},triangleBorder:{width:0,height:0,borderStyle:"solid",borderWidth:"5px 0 5px 8px",borderColor:"transparent transparent transparent #555"},left:{Extend:"triangleBorder",transform:"translate(-13px, -4px)"},leftInside:{Extend:"triangle",transform:"translate(-8px, -5px)"},right:{Extend:"triangleBorder",transform:"translate(20px, -14px) rotate(180deg)"},rightInside:{Extend:"triangle",transform:"translate(-8px, -5px)"}}});return Y.createElement("div",{style:e.pointer},Y.createElement("div",{style:e.left},Y.createElement("div",{style:e.leftInside})),Y.createElement("div",{style:e.right},Y.createElement("div",{style:e.rightInside})))},B3=function(e){var t=e.onClick,r=e.label,i=e.children,s=e.active,o=ut({default:{button:{backgroundImage:"linear-gradient(-180deg, #FFFFFF 0%, #E6E6E6 100%)",border:"1px solid #878787",borderRadius:"2px",height:"20px",boxShadow:"0 1px 0 0 #EAEAEA",fontSize:"14px",color:"#000",lineHeight:"20px",textAlign:"center",marginBottom:"10px",cursor:"pointer"}},active:{button:{boxShadow:"0 0 0 1px #878787"}}},{active:s});return Y.createElement("div",{style:o.button,onClick:t},r||i)},zLe=function(e){var t=e.rgb,r=e.currentColor,i=ut({default:{swatches:{border:"1px solid #B3B3B3",borderBottom:"1px solid #F0F0F0",marginBottom:"2px",marginTop:"1px"},new:{height:"34px",background:"rgb("+t.r+","+t.g+", "+t.b+")",boxShadow:"inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 1px 0 #000"},current:{height:"34px",background:r,boxShadow:"inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 -1px 0 #000"},label:{fontSize:"14px",color:"#000",textAlign:"center"}}});return Y.createElement("div",null,Y.createElement("div",{style:i.label},"new"),Y.createElement("div",{style:i.swatches},Y.createElement("div",{style:i.new}),Y.createElement("div",{style:i.current})),Y.createElement("div",{style:i.label},"current"))},YLe=function(){function n(e,t){for(var r=0;r100&&(c.a=100),c.a/=100,t({h:i.h,s:i.s,l:i.l,a:c.a,source:"rgb"},u))};return Y.createElement("div",{style:a.fields,className:"flexbox-fix"},Y.createElement("div",{style:a.double},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"hex",value:s.replace("#",""),onChange:l})),Y.createElement("div",{style:a.single},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"r",value:r.r,onChange:l,dragLabel:"true",dragMax:"255"})),Y.createElement("div",{style:a.single},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"g",value:r.g,onChange:l,dragLabel:"true",dragMax:"255"})),Y.createElement("div",{style:a.single},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"b",value:r.b,onChange:l,dragLabel:"true",dragMax:"255"})),Y.createElement("div",{style:a.alpha},Y.createElement(Mt,{style:{input:a.input,label:a.label},label:"a",value:Math.round(r.a*100),onChange:l,dragLabel:"true",dragMax:"100"})))},qLe=Object.assign||function(n){for(var e=1;e=0||Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t}var Ry=24,o3e=dz.default=function(n){var e=n.fill,t=e===void 0?"currentColor":e,r=n.width,i=r===void 0?Ry:r,s=n.height,o=s===void 0?Ry:s,a=n.style,l=a===void 0?{}:a,A=s3e(n,["fill","width","height","style"]);return C3.default.createElement("svg",w3({viewBox:"0 0 "+Ry+" "+Ry,style:w3({fill:t,width:i,height:o},l)},A),C3.default.createElement("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"}))},a3e=function(e){var t=e.color,r=e.onClick,i=r===void 0?function(){}:r,s=e.onSwatchHover,o=e.first,a=e.last,l=e.active,A=ut({default:{color:{width:"40px",height:"24px",cursor:"pointer",background:t,marginBottom:"1px"},check:{color:OQ(t),marginLeft:"8px",display:"none"}},first:{color:{overflow:"hidden",borderRadius:"2px 2px 0 0"}},last:{color:{overflow:"hidden",borderRadius:"0 0 2px 2px"}},active:{check:{display:"block"}},"color-#FFFFFF":{color:{boxShadow:"inset 0 0 0 1px #ddd"},check:{color:"#333"}},transparent:{check:{color:"#333"}}},{first:o,last:a,active:l,"color-#FFFFFF":t==="#FFFFFF",transparent:t==="transparent"});return Y.createElement(Ou,{color:t,style:A.color,onClick:i,onHover:s,focusStyle:{boxShadow:"0 0 4px "+t}},Y.createElement("div",{style:A.check},Y.createElement(o3e,null)))},l3e=function(e){var t=e.onClick,r=e.onSwatchHover,i=e.group,s=e.active,o=ut({default:{group:{paddingBottom:"10px",width:"40px",float:"left",marginRight:"10px"}}});return Y.createElement("div",{style:o.group},Gu(i,function(a,l){return Y.createElement(a3e,{key:a,color:a,active:a.toLowerCase()===s,first:l===0,last:l===i.length-1,onClick:t,onSwatchHover:r})}))},tR=function(e){var t=e.width,r=e.height,i=e.onChange,s=e.onSwatchHover,o=e.colors,a=e.hex,l=e.styles,A=l===void 0?{}:l,c=e.className,u=c===void 0?"":c,f=ut(Pi({default:{picker:{width:t,height:r},overflow:{height:r,overflowY:"scroll"},body:{padding:"16px 0 6px 16px"},clear:{clear:"both"}}},A)),d=function(p,m){return i({hex:p,source:"hex"},m)};return Y.createElement("div",{style:f.picker,className:"swatches-picker "+u},Y.createElement(R0,null,Y.createElement("div",{style:f.overflow},Y.createElement("div",{style:f.body},Gu(o,function(h){return Y.createElement(l3e,{key:h.toString(),group:h,active:a,onClick:d,onSwatchHover:s})}),Y.createElement("div",{style:f.clear})))))};tR.propTypes={width:Te.oneOfType([Te.string,Te.number]),height:Te.oneOfType([Te.string,Te.number]),colors:Te.arrayOf(Te.arrayOf(Te.string)),styles:Te.object};tR.defaultProps={width:320,height:240,colors:[[Vf[900],Vf[700],Vf[500],Vf[300],Vf[100]],[Lf[900],Lf[700],Lf[500],Lf[300],Lf[100]],[Pf[900],Pf[700],Pf[500],Pf[300],Pf[100]],[Wf[900],Wf[700],Wf[500],Wf[300],Wf[100]],[Of[900],Of[700],Of[500],Of[300],Of[100]],[Gf[900],Gf[700],Gf[500],Gf[300],Gf[100]],[Zf[900],Zf[700],Zf[500],Zf[300],Zf[100]],[Jf[900],Jf[700],Jf[500],Jf[300],Jf[100]],[Hf[900],Hf[700],Hf[500],Hf[300],Hf[100]],["#194D33",Eg[700],Eg[500],Eg[300],Eg[100]],[zf[900],zf[700],zf[500],zf[300],zf[100]],[Yf[900],Yf[700],Yf[500],Yf[300],Yf[100]],[Xf[900],Xf[700],Xf[500],Xf[300],Xf[100]],[Kf[900],Kf[700],Kf[500],Kf[300],Kf[100]],[jf[900],jf[700],jf[500],jf[300],jf[100]],[$f[900],$f[700],$f[500],$f[300],$f[100]],[qf[900],qf[700],qf[500],qf[300],qf[100]],[ed[900],ed[700],ed[500],ed[300],ed[100]],["#000000","#525252","#969696","#D9D9D9","#FFFFFF"]],styles:{}};Wi(tR);var nR=function(e){var t=e.onChange,r=e.onSwatchHover,i=e.hex,s=e.colors,o=e.width,a=e.triangle,l=e.styles,A=l===void 0?{}:l,c=e.className,u=c===void 0?"":c,f=ut(Pi({default:{card:{width:o,background:"#fff",border:"0 solid rgba(0,0,0,0.25)",boxShadow:"0 1px 4px rgba(0,0,0,0.25)",borderRadius:"4px",position:"relative"},body:{padding:"15px 9px 9px 15px"},label:{fontSize:"18px",color:"#fff"},triangle:{width:"0px",height:"0px",borderStyle:"solid",borderWidth:"0 9px 10px 9px",borderColor:"transparent transparent #fff transparent",position:"absolute"},triangleShadow:{width:"0px",height:"0px",borderStyle:"solid",borderWidth:"0 9px 10px 9px",borderColor:"transparent transparent rgba(0,0,0,.1) transparent",position:"absolute"},hash:{background:"#F0F0F0",height:"30px",width:"30px",borderRadius:"4px 0 0 4px",float:"left",color:"#98A1A4",display:"flex",alignItems:"center",justifyContent:"center"},input:{width:"100px",fontSize:"14px",color:"#666",border:"0px",outline:"none",height:"28px",boxShadow:"inset 0 0 0 1px #F0F0F0",boxSizing:"content-box",borderRadius:"0 4px 4px 0",float:"left",paddingLeft:"8px"},swatch:{width:"30px",height:"30px",float:"left",borderRadius:"4px",margin:"0 6px 6px 0"},clear:{clear:"both"}},"hide-triangle":{triangle:{display:"none"},triangleShadow:{display:"none"}},"top-left-triangle":{triangle:{top:"-10px",left:"12px"},triangleShadow:{top:"-11px",left:"12px"}},"top-right-triangle":{triangle:{top:"-10px",right:"12px"},triangleShadow:{top:"-11px",right:"12px"}}},A),{"hide-triangle":a==="hide","top-left-triangle":a==="top-left","top-right-triangle":a==="top-right"}),d=function(p,m){gc(p)&&t({hex:p,source:"hex"},m)};return Y.createElement("div",{style:f.card,className:"twitter-picker "+u},Y.createElement("div",{style:f.triangleShadow}),Y.createElement("div",{style:f.triangle}),Y.createElement("div",{style:f.body},Gu(s,function(h,p){return Y.createElement(Ou,{key:p,color:h,hex:h,style:f.swatch,onClick:d,onHover:r,focusStyle:{boxShadow:"0 0 4px "+h}})}),Y.createElement("div",{style:f.hash},"#"),Y.createElement(Mt,{label:null,style:{input:f.input},value:i.replace("#",""),onChange:d}),Y.createElement("div",{style:f.clear})))};nR.propTypes={width:Te.oneOfType([Te.string,Te.number]),triangle:Te.oneOf(["hide","top-left","top-right"]),colors:Te.arrayOf(Te.string),styles:Te.object};nR.defaultProps={width:276,colors:["#FF6900","#FCB900","#7BDCB5","#00D084","#8ED1FC","#0693E3","#ABB8C3","#EB144C","#F78DA7","#9900EF"],triangle:"top-left",styles:{}};Wi(nR);var rR=function(e){var t=ut({default:{picker:{width:"20px",height:"20px",borderRadius:"22px",border:"2px #fff solid",transform:"translate(-12px, -13px)",background:"hsl("+Math.round(e.hsl.h)+", "+Math.round(e.hsl.s*100)+"%, "+Math.round(e.hsl.l*100)+"%)"}}});return Y.createElement("div",{style:t.picker})};rR.propTypes={hsl:Te.shape({h:Te.number,s:Te.number,l:Te.number,a:Te.number})};rR.defaultProps={hsl:{a:1,h:249.94,l:.2,s:.5}};var iR=function(e){var t=ut({default:{picker:{width:"20px",height:"20px",borderRadius:"22px",transform:"translate(-10px, -7px)",background:"hsl("+Math.round(e.hsl.h)+", 100%, 50%)",border:"2px white solid"}}});return Y.createElement("div",{style:t.picker})};iR.propTypes={hsl:Te.shape({h:Te.number,s:Te.number,l:Te.number,a:Te.number})};iR.defaultProps={hsl:{a:1,h:249.94,l:.2,s:.5}};var A3e=function(e){var t=e.onChange,r=e.rgb,i=e.hsl,s=e.hex,o=e.hsv,a=function(d,h){if(d.hex)gc(d.hex)&&t({hex:d.hex,source:"hex"},h);else if(d.rgb){var p=d.rgb.split(",");O1(d.rgb,"rgb")&&t({r:p[0],g:p[1],b:p[2],a:1,source:"rgb"},h)}else if(d.hsv){var m=d.hsv.split(",");O1(d.hsv,"hsv")&&(m[2]=m[2].replace("%",""),m[1]=m[1].replace("%",""),m[0]=m[0].replace("°",""),m[1]==1?m[1]=.01:m[2]==1&&(m[2]=.01),t({h:Number(m[0]),s:Number(m[1]),v:Number(m[2]),source:"hsv"},h))}else if(d.hsl){var g=d.hsl.split(",");O1(d.hsl,"hsl")&&(g[2]=g[2].replace("%",""),g[1]=g[1].replace("%",""),g[0]=g[0].replace("°",""),u[1]==1?u[1]=.01:u[2]==1&&(u[2]=.01),t({h:Number(g[0]),s:Number(g[1]),v:Number(g[2]),source:"hsl"},h))}},l=ut({default:{wrap:{display:"flex",height:"100px",marginTop:"4px"},fields:{width:"100%"},column:{paddingTop:"10px",display:"flex",justifyContent:"space-between"},double:{padding:"0px 4.4px",boxSizing:"border-box"},input:{width:"100%",height:"38px",boxSizing:"border-box",padding:"4px 10% 3px",textAlign:"center",border:"1px solid #dadce0",fontSize:"11px",textTransform:"lowercase",borderRadius:"5px",outline:"none",fontFamily:"Roboto,Arial,sans-serif"},input2:{height:"38px",width:"100%",border:"1px solid #dadce0",boxSizing:"border-box",fontSize:"11px",textTransform:"lowercase",borderRadius:"5px",outline:"none",paddingLeft:"10px",fontFamily:"Roboto,Arial,sans-serif"},label:{textAlign:"center",fontSize:"12px",background:"#fff",position:"absolute",textTransform:"uppercase",color:"#3c4043",width:"35px",top:"-6px",left:"0",right:"0",marginLeft:"auto",marginRight:"auto",fontFamily:"Roboto,Arial,sans-serif"},label2:{left:"10px",textAlign:"center",fontSize:"12px",background:"#fff",position:"absolute",textTransform:"uppercase",color:"#3c4043",width:"32px",top:"-6px",fontFamily:"Roboto,Arial,sans-serif"},single:{flexGrow:"1",margin:"0px 4.4px"}}}),A=r.r+", "+r.g+", "+r.b,c=Math.round(i.h)+"°, "+Math.round(i.s*100)+"%, "+Math.round(i.l*100)+"%",u=Math.round(o.h)+"°, "+Math.round(o.s*100)+"%, "+Math.round(o.v*100)+"%";return Y.createElement("div",{style:l.wrap,className:"flexbox-fix"},Y.createElement("div",{style:l.fields},Y.createElement("div",{style:l.double},Y.createElement(Mt,{style:{input:l.input,label:l.label},label:"hex",value:s,onChange:a})),Y.createElement("div",{style:l.column},Y.createElement("div",{style:l.single},Y.createElement(Mt,{style:{input:l.input2,label:l.label2},label:"rgb",value:A,onChange:a})),Y.createElement("div",{style:l.single},Y.createElement(Mt,{style:{input:l.input2,label:l.label2},label:"hsv",value:u,onChange:a})),Y.createElement("div",{style:l.single},Y.createElement(Mt,{style:{input:l.input2,label:l.label2},label:"hsl",value:c,onChange:a})))))},sR=function(e){var t=e.width,r=e.onChange,i=e.rgb,s=e.hsl,o=e.hsv,a=e.hex,l=e.header,A=e.styles,c=A===void 0?{}:A,u=e.className,f=u===void 0?"":u,d=ut(Pi({default:{picker:{width:t,background:"#fff",border:"1px solid #dfe1e5",boxSizing:"initial",display:"flex",flexWrap:"wrap",borderRadius:"8px 8px 0px 0px"},head:{height:"57px",width:"100%",paddingTop:"16px",paddingBottom:"16px",paddingLeft:"16px",fontSize:"20px",boxSizing:"border-box",fontFamily:"Roboto-Regular,HelveticaNeue,Arial,sans-serif"},saturation:{width:"70%",padding:"0px",position:"relative",overflow:"hidden"},swatch:{width:"30%",height:"228px",padding:"0px",background:"rgba("+i.r+", "+i.g+", "+i.b+", 1)",position:"relative",overflow:"hidden"},body:{margin:"auto",width:"95%"},controls:{display:"flex",boxSizing:"border-box",height:"52px",paddingTop:"22px"},color:{width:"32px"},hue:{height:"8px",position:"relative",margin:"0px 16px 0px 16px",width:"100%"},Hue:{radius:"2px"}}},c));return Y.createElement("div",{style:d.picker,className:"google-picker "+f},Y.createElement("div",{style:d.head},l),Y.createElement("div",{style:d.swatch}),Y.createElement("div",{style:d.saturation},Y.createElement(Vb,{hsl:s,hsv:o,pointer:rR,onChange:r})),Y.createElement("div",{style:d.body},Y.createElement("div",{style:d.controls,className:"flexbox-fix"},Y.createElement("div",{style:d.hue},Y.createElement(ap,{style:d.Hue,hsl:s,radius:"4px",pointer:iR,onChange:r}))),Y.createElement(A3e,{rgb:i,hsl:s,hex:a,hsv:o,onChange:r})))};sR.propTypes={width:Te.oneOfType([Te.string,Te.number]),styles:Te.object,header:Te.string};sR.defaultProps={width:652,styles:{},header:"Color picker"};Wi(sR);function c3e(){const{isLoading:n,setViewMode:e,setIsLoading:t}=Y.useContext(Bi),{toggleDebugMode:r,characterManager:i,animationManager:s,moveCamera:o,loraDataGenerator:a,spriteAtlasGenerator:l,sceneElements:A}=Y.useContext(ni),{playSound:c}=Y.useContext(Cs),{isMute:u}=Y.useContext(Bs),{t:f}=me.useContext(bs),d=()=>{!u&&c("backNextButton"),i.removeCurrentCharacter(),i.removeCurrentManifest(),e(ot.CREATE),r(!1)},[h,p]=Y.useState(null),[m,g]=Y.useState(null),[v,y]=Y.useState(""),[w,C]=Y.useState(null),[b,E]=Y.useState(null),[x,S]=Y.useState(""),[M,Z]=Y.useState(!1),[K,_]=Y.useState({background:"#ffffff"}),B=()=>{!u&&c("backNextButton"),e(ot.SAVE),r(!1)},F=()=>{t(!0),p(null),i.loadRandomTraits().then(()=>{console.log("success"),v!=""&&C(i.getCurrentTraitData(v)),t(!1)}).catch(X=>{t(!1),console.error("Error loading random traits:",X.message)})},R=X=>{_({background:X.hex})},k=X=>{_({background:X.hex}),i.setTraitColor(v,X.hex)},T=async X=>{const ne=rc(X.name),ae=URL.createObjectURL(X);await s.loadAnimation(ae,!1,0,!0,"",ne),S(s.getCurrentAnimationName())},V=async()=>{const X=A.parent;X.remove(A),await a.createLoraData("./lora-assets/manifest.json"),X.add(A)},O=async()=>{const X=A.parent;X.remove(A),await l.createSpriteAtlas("./sprite-atlas-assets/manifest.json"),X.add(A)},L=X=>{if(Z(!1),v!=""){t(!0);const ne=URL.createObjectURL(X);i.loadCustomTexture(v,ne).then(()=>{t(!1)})}else console.warn("Please select a group trait first.")},U=X=>{if(Z(!1),v!=""){t(!0);const ne=URL.createObjectURL(X);i.loadCustomTrait(v,ne).then(()=>{t(!1)})}else console.warn("Please select a group trait first.")},H=X=>{Z(!1),t(!0),i.loadTrait(X.traitGroup.trait,X.id).then(()=>{t(!1),C(X)})},le=X=>{Z(!1),i.removeTrait(X),C(null)},N=X=>{Z(!1),t(!0),i.loadRandomTrait(X).then(()=>{t(!1),C(i.getCurrentTraitData(X))})},j=X=>{Z(!1);const ne=Array.from(X),ae=[],Be=pe=>new Promise((Fe,rt)=>{var Oe;if(pe&&pe.name.toLowerCase().endsWith(".json")){const ke=new FileReader,Qe=`${(Oe=i.manifestData)==null?void 0:Oe.getAssetsDirectory()}/anata/_thumbnails/t_${pe.name.split("_")[0]}.jpg`;console.log(Qe),ke.onload=function(Ge){try{const Xe=JSON.parse(Ge.target.result);Xe.thumb=Qe,ae.push(Xe),Fe()}catch(Xe){console.error("Error parsing the JSON file:",Xe),rt(Xe)}},ke.readAsText(pe)}});Promise.all(ne.map(Be)).then(()=>{ae.length>0&&(p(ae),t(!0),i.loadTraitsFromNFTObject(ae[0]).then(()=>{t(!1)}))}).catch(pe=>{console.error("Error processing files:",pe)})},oe=async X=>{const ne=X[0];ne&&ne.name.toLowerCase().endsWith(".fbx")&&T(ne),ne&&(ne.name.toLowerCase().endsWith(".png")||ne.name.toLowerCase().endsWith(".jpg"))&&L(ne),ne&&ne.name.toLowerCase().endsWith(".vrm")&&U(ne),ne&&ne.name.toLowerCase().endsWith(".json")&&j(X)},ie=X=>{!u&&c("optionClick"),Z(!1),v!==X.trait?(g(i.getTraits(X.trait)),y(X.trait),C(i.getCurrentTraitData(X.trait)),E(i.getCurrentTraitVRM(X.trait)),o({targetY:X.cameraTarget.height,distance:X.cameraTarget.distance})):(g(null),y(""),C(null),o({targetY:.8,distance:3.2}))},de=()=>{Z(!1);var X=document.createElement("input");X.type="file",X.accept=".vrm",X.onchange=ne=>{var ae=ne.target.files[0];if(ae.name.endsWith(".vrm")){const Be=URL.createObjectURL(ae);t(!0),i.loadCustomTrait(v,Be).then(()=>{t(!1)})}},X.click()};return P.jsxs("div",{className:Bn.container,children:[P.jsx("div",{className:`loadingIndicator ${n?"active":""}`,children:P.jsx("img",{className:"rotate",src:"ui/loading.svg"})}),P.jsx("div",{className:"sectionTitle",children:f("pageTitles.chooseAppearance")}),P.jsx(C0,{onFilesDrop:oe}),P.jsxs("div",{className:Bn.sideMenu,children:[P.jsx(Eh,{title:"Appearance",left:20}),P.jsx("div",{className:Bn.bottomLine}),P.jsx("div",{className:Bn.scrollContainer,children:P.jsx("div",{className:Bn["editor-container"],children:i.getGroupTraits().map((X,ne)=>P.jsxs("div",{className:Bn.editorButton,onClick:()=>{ie(X)},children:[P.jsx(Uy,{size:56,icon:X.fullIconSvg,rarity:v!==X.trait?"none":"mythic"}),P.jsx("div",{className:Bn.editorText,children:X.name})]},"options_"+ne))})})]}),!!m&&P.jsxs("div",{className:Bn.selectorContainerPos,children:[P.jsx(Eh,{title:v,width:130,left:20}),w&&P.jsx("div",{className:Bn.selectorColorPickerButton,onClick:()=>{Z(!M)},children:P.jsx("img",{className:Bn.selectorColorPickerImg,src:yCe})}),!!M&&P.jsx("div",{draggable:!1,className:Bn.selectorColorPickerUI,children:P.jsx(DLe,{draggable:!1,width:"200px",color:K.background,onChange:R,onChangeComplete:k})}),P.jsx("div",{className:Bn.bottomLine}),P.jsx("div",{className:Bn.scrollContainerOptions,children:P.jsxs("div",{className:Bn["selector-container"],children:[P.jsx("div",{className:`${Bn.selectorButton}`,onClick:()=>{N(v)},children:P.jsx(Uy,{size:56,icon:vCe,rarity:"none"})},"randomize-trait"),i.isTraitGroupRequired(v)?P.jsx(P.Fragment,{}):P.jsx("div",{className:`${Bn.selectorButton}`,icon:WV,onClick:()=>{le(v)},children:P.jsx(Uy,{size:56,icon:WV,rarity:w==null?"mythic":"none"})},"no-trait"),m.map(X=>{let ne=X.id===(w==null?void 0:w.id);return P.jsx("div",{className:`${Bn.selectorButton}`,onClick:()=>{H(X)},children:P.jsx(Uy,{size:56,icon:X.fullThumbnail,rarity:ne?"mythic":"none"})},X.id)})]})}),P.jsx("div",{className:Bn.uploadContainer,children:P.jsx("div",{className:Bn.uploadButton,onClick:de,children:P.jsx("div",{children:"Upload "})})})]}),P.jsx(hQ,{jsonSelectionArray:h}),P.jsx(zwe,{selectedTrait:w,selectedVRM:b,animationName:x,setAnimationName:S}),P.jsx(dQ,{loadedAnimationName:x,randomize:F}),P.jsxs("div",{className:Bn.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:f("callToAction.back"),size:14,className:Bn.buttonLeft,onClick:d}),i.canDownload()&&P.jsx(Gt,{theme:"light",text:f("callToAction.next"),size:14,className:Bn.buttonRight,onClick:B}),P.jsx(Gt,{theme:"light",text:"Create Lora Data",size:14,className:Bn.buttonRight,onClick:V}),P.jsx(Gt,{theme:"light",text:"Create Sprite Atlas",size:14,className:Bn.buttonRight,onClick:O})]})]})}const u3e="_InformationContainerPos_rgqwy_1",f3e="_traitInfoTitle_rgqwy_13",d3e="_traitInfoText_rgqwy_21",h3e="_flexSelect_rgqwy_30",p3e="_scrollContainer_rgqwy_65",g3e="_checked_rgqwy_90",m3e="_checkmark_rgqwy_94",v3e="_checkboxHolder_rgqwy_107",y3e="_buttonContainer_rgqwy_114",B3e="_buttonLeft_rgqwy_123",w3e="_buttonRight_rgqwy_127",C3e="_buttonCenter_rgqwy_131",Cr={InformationContainerPos:u3e,traitInfoTitle:f3e,traitInfoText:d3e,flexSelect:h3e,"arrow-button":"_arrow-button_rgqwy_37","left-button":"_left-button_rgqwy_51","right-button":"_right-button_rgqwy_58",scrollContainer:p3e,"custom-checkbox":"_custom-checkbox_rgqwy_76","checkbox-container":"_checkbox-container_rgqwy_81",checked:g3e,checkmark:m3e,checkboxHolder:v3e,buttonContainer:y3e,buttonLeft:B3e,buttonRight:w3e,buttonCenter:C3e},b3e="_InformationContainerPos_1cryw_2",x3e="_scrollContainer_1cryw_16",I3e="_traitInfoTitle_1cryw_28",F3e="_traitInfoText_1cryw_38",E3e="_flexSelect_1cryw_66",U3e="_checked_1cryw_123",S3e="_checkmark_1cryw_127",_3e="_checkboxHolder_1cryw_140",bi={InformationContainerPos:b3e,scrollContainer:x3e,traitInfoTitle:I3e,traitInfoText:F3e,"input-box":"_input-box_1cryw_47",flexSelect:E3e,"arrow-button":"_arrow-button_1cryw_74","left-button":"_left-button_1cryw_90","right-button":"_right-button_1cryw_97","anim-button":"_anim-button_1cryw_104","custom-checkbox":"_custom-checkbox_1cryw_109","checkbox-container":"_checkbox-container_1cryw_114",checked:U3e,checkmark:S3e,checkboxHolder:_3e};function oR({model:n}){const[e,t]=me.useState(0),[r,i]=me.useState(0),[s,o]=me.useState(0),[a,l]=me.useState(0),[A,c]=me.useState(0),[u,f]=me.useState(0),[d,h]=me.useState(0),[p,m]=me.useState(0);return me.useEffect(()=>{if(n!=null){const g=Ih(n,"Mesh"),v=Ih(n,"SkinnedMesh");t(g.length),i(v.length);const y=g.concat(v),{stdMats:w,stdCutoutpMats:C,stdTranspMats:b,mToonMats:E,mToonCutoutMats:x,mToonTranspMats:S}=rhe(y);o(w.length),l(b.length),c(C.length),f(E.length),h(S.length),m(x.length)}},[n]),n!=null?P.jsx("div",{children:P.jsxs("div",{className:bi.InformationContainerPos,children:[P.jsx(Eh,{title:"Model Information",width:180,right:20}),P.jsxs("div",{className:bi.scrollContainer,children:[P.jsx("div",{className:bi.traitInfoTitle,children:"Meshes:"}),P.jsx("div",{className:bi.traitInfoText,children:e}),P.jsx("div",{className:bi.traitInfoTitle,children:"SkinnedMeshes:"}),P.jsx("div",{className:bi.traitInfoText,children:r}),P.jsx("div",{className:bi.traitInfoTitle,children:"Standard Material Count:"}),P.jsxs("div",{className:bi.traitInfoText,children:["opaque: ",s]}),P.jsxs("div",{className:bi.traitInfoText,children:["cutout: ",A]}),P.jsxs("div",{className:bi.traitInfoText,children:["transparent: ",a]}),P.jsx("div",{className:bi.traitInfoTitle,children:"MToon Material Count:"}),P.jsxs("div",{className:bi.traitInfoText,children:["opaque: ",u]}),P.jsxs("div",{className:bi.traitInfoText,children:["cutout: ",p]}),P.jsxs("div",{className:bi.traitInfoText,children:["transparent: ",d]})]})]})}):P.jsx(P.Fragment,{})}function Q3e(){const{isLoading:n,setViewMode:e,setIsLoading:t}=Y.useContext(Bi),{toggleDebugMode:r,characterManager:i,animationManager:s}=Y.useContext(ni),[o,a]=me.useState(null),[l,A]=me.useState(""),[c,u]=Y.useState(""),{playSound:f}=Y.useContext(Cs),{isMute:d}=Y.useContext(Bs),[h,p]=Y.useState(null),m=()=>{!d&&f("backNextButton"),i.removeCurrentCharacter(),i.removeCurrentManifest(),r(!1),e(ot.LANDING)},g=()=>{const S=et.mergeOptions_sel_option||0;return{isVrm0:!0,createTextureAtlas:!0,mToonAtlasSize:Cn(et.mergeOptions_atlas_mtoon_size||6),mToonAtlasSizeTransp:Cn(et.mergeOptions_atlas_mtoon_transp_size||6),stdAtlasSize:Cn(et.mergeOptions_atlas_std_size||6),stdAtlasSizeTransp:Cn(et.mergeOptions_atlas_std_transp_size||6),exportStdAtlas:S===0||S==2,exportMtoonAtlas:S===1||S==2,ktxCompression:et.merge_options_ktx_compression||!1,twoSidedMaterial:et.mergeOptions_two_sided_mat||!1}},v=S=>{i.loadTraitsFromNFTObject(h[S]).then(()=>{i.downloadVRM(h[S].name,g()).then(()=>{S{t(!0),v(0)},{t:w}=me.useContext(bs),C=async S=>{if(i.getCurrentCharacterModel()){const Z=rc(S.name),K=URL.createObjectURL(S);await s.loadAnimation(K,!1,0,!0,"",Z),u(s.getCurrentAnimationName()),URL.revokeObjectURL(K)}else console.warn("Please load a vrm model to test animations.")},b=async S=>{const M=URL.createObjectURL(S);await i.loadOptimizerCharacter(M),URL.revokeObjectURL(M);const Z=rc(S.name);A(Z),a(i.getCurrentCharacterModel())},E=S=>{const M=Array.from(S),Z=[],K=_=>new Promise((B,F)=>{var R;if(_&&_.name.toLowerCase().endsWith(".json")){const k=new FileReader,T=`${(R=i.manifestData)==null?void 0:R.getAssetsDirectory()}/anata/_thumbnails/t_${_.name.split("_")[0]}.jpg`;k.onload=function(V){try{const O=JSON.parse(V.target.result);O.thumb=T,Z.push(O),B()}catch(O){console.error("Error parsing the JSON file:",O),F(O)}},k.readAsText(_)}});Promise.all(M.map(K)).then(()=>{Z.length>0&&(p(Z),t(!0),i.loadTraitsFromNFTObject(Z[0]).then(()=>{t(!1)}))}).catch(_=>{console.error("Error processing files:",_)})},x=async S=>{const M=S[0];console.log("anim"),M&&M.name.toLowerCase().endsWith(".fbx")&&(console.log("anim2"),C(M)),M&&M.name.toLowerCase().endsWith(".vrm")&&b(M),M&&M.name.toLowerCase().endsWith(".json")&&E(S)};return P.jsxs("div",{className:Cr.container,children:[P.jsx("div",{className:`loadingIndicator ${n?"active":""}`,children:P.jsx("img",{className:"rotate",src:"ui/loading.svg"})}),P.jsx("div",{className:"sectionTitle",children:"Batch Download"}),P.jsx(C0,{onFilesDrop:x}),P.jsx(wb,{showDropToDownload:!0,showCreateAtlas:!1,mergeMenuTitle:"Download Options"}),P.jsx(oR,{model:o}),P.jsx(hQ,{jsonSelectionArray:h}),P.jsx(dQ,{loadedAnimationName:c}),P.jsxs("div",{className:Cr.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:w("callToAction.back"),size:14,className:Cr.buttonLeft,onClick:m}),(h==null?void 0:h.length)==1&&P.jsx(Gt,{theme:"light",text:"Download",size:14,className:Cr.buttonRight,onClick:y}),(h==null?void 0:h.length)>1&&P.jsx(Gt,{theme:"light",text:"Download All",size:14,className:Cr.buttonRight,onClick:y})]})]})}function R3e(){const{isLoading:n,setViewMode:e}=Y.useContext(Bi),{characterManager:t,animationManager:r,sceneElements:i,loraDataGenerator:s,spriteAtlasGenerator:o}=Y.useContext(ni),{playSound:a}=Y.useContext(Cs),{isMute:l}=Y.useContext(Bs),[A,c]=me.useState(null),[u,f]=me.useState(""),d=()=>{!l&&a("backNextButton"),t.removeCurrentCharacter(),t.removeCurrentManifest(),e(ot.LANDING)},h=()=>{const b=et.mergeOptions_sel_option||0;return{isVrm0:!0,createTextureAtlas:!0,mToonAtlasSize:Cn(et.mergeOptions_atlas_mtoon_size||6),mToonAtlasSizeTransp:Cn(et.mergeOptions_atlas_mtoon_transp_size||6),stdAtlasSize:Cn(et.mergeOptions_atlas_std_size||6),stdAtlasSizeTransp:Cn(et.mergeOptions_atlas_std_transp_size||6),exportStdAtlas:b===0||b==2,exportMtoonAtlas:b===1||b==2,ktxCompression:et.merge_options_ktx_compression||!1,twoSidedMaterial:et.mergeOptions_two_sided_mat||!1}},p=async()=>{const b=i.parent;b.remove(i),await s.createLoraData("./lora-assets/manifest.json"),b.add(i)},m=async()=>{const b=i.parent;b.remove(i),await o.createSpriteAtlas("./sprite-atlas-assets/manifest.json"),b.add(i)},g=()=>{t.downloadVRM(u+"_merged",h())},{t:v}=me.useContext(bs),y=async b=>{if(t.getCurrentOptimizerCharacterModel()){const x=rc(b.name),S=URL.createObjectURL(b);await r.loadAnimation(S,!1,0,!0,"",x),URL.revokeObjectURL(S)}else console.warn("Please load a vrm model to test animations.")},w=async b=>{const E=URL.createObjectURL(b);await t.loadOptimizerCharacter(E),URL.revokeObjectURL(E);const x=rc(b.name);f(x),c({...t.getCurrentCharacterModel()})},C=async b=>{const E=b[0];E&&E.name.toLowerCase().endsWith(".fbx")&&y(E),E&&E.name.toLowerCase().endsWith(".vrm")&&w(E)};return P.jsxs("div",{className:Cr.container,children:[P.jsx("div",{className:`loadingIndicator ${n?"active":""}`,children:P.jsx("img",{className:"rotate",src:"ui/loading.svg"})}),P.jsx("div",{className:"sectionTitle",children:"Optimize your character"}),P.jsx(C0,{onFilesDrop:C}),P.jsx(wb,{showDropToDownload:!0,showCreateAtlas:!1,mergeMenuTitle:"Optimizer Options"}),P.jsx(oR,{model:A}),P.jsxs("div",{className:Cr.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:v("callToAction.back"),size:14,className:Cr.buttonLeft,onClick:d}),A!=""&&P.jsx(Gt,{theme:"light",text:"Download",size:14,className:Cr.buttonRight,onClick:g}),A!=""&&P.jsx(Gt,{theme:"light",text:"Create Lora",size:14,className:Cr.buttonRight,onClick:p}),A!=""&&P.jsx(Gt,{theme:"light",text:"Create Sprite Atlas",size:14,className:Cr.buttonRight,onClick:m})]})]})}const M3e="_languageSwitchWrap_83v6a_1",T3e={languageSwitchWrap:M3e},b3={en:{nativeName:"English"},ru:{nativeName:"Русский"},zh:{nativeName:"中文"}};function N3e(){const{t:n,i18n:e}=i4();return P.jsx("div",{className:T3e.languageSwitchWrap,children:P.jsx("select",{onChange:t=>e.changeLanguage(t.target.value),value:e.resolvedLanguage,children:Object.keys(b3).map(t=>P.jsx("option",{value:t,children:b3[t].nativeName},t))})})}function D3e(){const{isLoading:n,setViewMode:e,setIsLoading:t}=Y.useContext(Bi),{characterManager:r,animationManager:i,toggleDebugMode:s}=Y.useContext(ni),[o,a]=me.useState(null),[l,A]=me.useState(""),{playSound:c}=Y.useContext(Cs),{isMute:u}=Y.useContext(Bs);Y.useState(null);const[f,d]=Y.useState(null),[h,p]=Y.useState(""),m=()=>{!u&&c("backNextButton"),r.removeCurrentCharacter(),r.removeCurrentManifest(),s(!1),e(ot.LANDING)},g=()=>{const Z=et.mergeOptions_sel_option||0;return{isVrm0:!0,createTextureAtlas:!0,mToonAtlasSize:Cn(et.mergeOptions_atlas_mtoon_size||6),mToonAtlasSizeTransp:Cn(et.mergeOptions_atlas_mtoon_transp_size||6),stdAtlasSize:Cn(et.mergeOptions_atlas_std_size||6),stdAtlasSizeTransp:Cn(et.mergeOptions_atlas_std_transp_size||6),exportStdAtlas:Z===0||Z==2,exportMtoonAtlas:Z===1||Z==2,ktxCompression:et.merge_options_ktx_compression||!1,twoSidedMaterial:et.mergeOptions_two_sided_mat||!1}},v=(Z,K=!1)=>{const _=f[Z].manifestName;r.savePortraitScreenshot(_,512,1024,1.5,-.1),K?Z{Z{Z==0?v(Z,K):(await r.setManifest(f[Z]),t(!0),r.loadInitialTraits().then(async()=>{await(B=>new Promise(F=>setTimeout(F,B)))(1),v(Z+1,K)}))},w=()=>{t(!0),y(0)},C=()=>{t(!0),y(0,!0)},{t:b}=me.useContext(bs),E=async Z=>{if(r.getCurrentCharacterModel()){const _=rc(Z.name),B=URL.createObjectURL(Z);await i.loadAnimation(B,!1,0,!0,"",_),p(i.getCurrentAnimationName()),URL.revokeObjectURL(B)}else console.warn("Please load a vrm model to test animations.")},x=async Z=>{const K=URL.createObjectURL(Z);await r.loadOptimizerCharacter(K),URL.revokeObjectURL(K);const _=rc(Z.name);A(_),a(r.getCurrentCharacterModel())},S=Z=>{const K=Array.from(Z),_=[],B=F=>new Promise((R,k)=>{if(F&&F.name.toLowerCase().endsWith(".json")){const T=new FileReader,V=F.name.replace(/\.[^/.]+$/,"");T.onload=function(O){try{const L=JSON.parse(O.target.result),U=L.thumbnail;L.manifestName=V,_.push(L),R()}catch(L){console.error("Error parsing the JSON file:",L),k(L)}},T.readAsText(F)}});Promise.all(K.map(B)).then(()=>{_.length>0&&(d(_),r.setManifest(_[0]),t(!0),r.loadInitialTraits().then(()=>{t(!1)}))}).catch(F=>{console.error("Error processing files:",F)})},M=async Z=>{const K=Z[0];K&&K.name.toLowerCase().endsWith(".fbx")&&E(K),K&&K.name.toLowerCase().endsWith(".vrm")&&x(K),K&&K.name.toLowerCase().endsWith(".json")&&S(Z)};return P.jsxs("div",{className:Cr.container,children:[P.jsx("div",{className:`loadingIndicator ${n?"active":""}`,children:P.jsx("img",{className:"rotate",src:"ui/loading.svg"})}),P.jsx("div",{className:"sectionTitle",children:"NFT Characters"}),P.jsx(C0,{onFilesDrop:M}),P.jsx(wb,{showDropToDownload:!0,showCreateAtlas:!1,mergeMenuTitle:"Download Options"}),P.jsx(oR,{model:o}),P.jsx(hQ,{jsonSelectionArray:f,byManifest:!0}),(f==null?void 0:f.length)>0&&P.jsx(dQ,{loadedAnimationName:h}),P.jsxs("div",{className:Cr.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:b("callToAction.back"),size:14,className:Cr.buttonLeft,onClick:m}),(f==null?void 0:f.length)==1&&P.jsx(Gt,{theme:"light",text:"Download",size:14,className:Cr.buttonRight,onClick:w}),(f==null?void 0:f.length)>1&&P.jsx(Gt,{theme:"light",text:"Download All",size:14,className:Cr.buttonRight,onClick:w}),(f==null?void 0:f.length)==1&&P.jsx(Gt,{theme:"light",text:"Get Image",size:14,className:Cr.buttonRight,onClick:C}),(f==null?void 0:f.length)>1&&P.jsx(Gt,{theme:"light",text:"Get All Images",size:14,className:Cr.buttonRight,onClick:C})]})]})}function k3e(){const{t:n}=me.useContext(bs),{setViewMode:e,setIsLoading:t,isLoading:r}=Y.useContext(Bi),{playSound:i}=Y.useContext(Cs),{isMute:s}=Y.useContext(Bs),{manifest:o,characterManager:a}=Y.useContext(ni);me.useState([]);const[l,A]=me.useState([]);me.useEffect(()=>{c()},[]);const c=async()=>{const p=await fQ();EBe(p,"the-anata-nft").then(m=>{A(m.nfts),console.log(m.nfts)})},u=()=>{e(ot.LANDING),!s&&i("backNextButton")},f=async p=>{t(!0),a.loadManifest(o[p].manifest).then(()=>{e(ot.APPEARANCE),a.loadInitialTraits().then(()=>{t(!1)})}),!s&&i("classSelect")},d=()=>{console.log("ttt"),a.loadManifest(o[0].manifest).then(()=>{a.loadAppendManifest(o[1].manifest,!0).then(()=>{console.log(a.manifestData)})})},h=()=>{!s&&i("classMouseOver")};return P.jsxs("div",{className:`${it.container} horizontalScroll`,children:[P.jsx("div",{className:"sectionTitle",children:n("pageTitles.chooseClass")}),P.jsx("div",{className:it.vrmOptimizerButton}),P.jsx("div",{className:it.topLine}),P.jsx("div",{className:it.classContainer,children:l.map((p,m)=>P.jsxs("div",{className:it.class,onClick:()=>f(m),onMouseOver:()=>h(),children:[P.jsx("div",{className:it.classFrame,style:{backgroundImage:`url(${p.image_url})`},children:P.jsx("div",{className:it.frameContainer,children:P.jsx("img",{src:"./assets/backgrounds/class-frame.svg",className:it.frame})})}),P.jsx("div",{className:it.name,children:p.name})]},m))}),P.jsx("div",{className:it.bottomLine}),P.jsxs("div",{className:it.buttonContainer,children:[P.jsx(Gt,{theme:"light",text:n("callToAction.back"),size:14,className:it.buttonLeft,onClick:u}),P.jsx(Gt,{theme:"light",text:"test",size:14,className:it.buttonLeft,onClick:d})]})]})}const V3e="https://beta.anata.dev/character-assets/manifest.json";let Z1;const J1=new z,My=new z;let H1,z1;const L3e=1.4,P3e=new z(0,1.25,0),hz=new z(-.9786403788721187,1.4036900759197288,.9892635490125085),W3e=hz.length(),O3e=.35,x3=6,I3=new z(0,.8,0),pz=new z(-2.2367993753934425,1.1512971720174363,2.2612065299409223),G3e=pz.length(),Z3e=.5,Qf=new z,Zi=new Tt,J3e=new Tt,H3e=new z(1,0,0),z3e=new z(0,1,0);async function Y3e(n){try{const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch manifest. Status: ${e.status}`);return await e.json()}catch(e){return console.error(`Error fetching manifest: ${e.message}`),[]}}async function X3e(){const n=await Y3e(V3e),e=new ume;return{initialManifest:n,effectManager:e}}const K3e=()=>{let n,e;const r=X3e().then(i=>{n="success",e=i},i=>{n="error",e=i});return{read(){if(n==="error")throw e;if(n==="success")return e;throw r}}},j3e=K3e();function $3e(){const{initialManifest:n,effectManager:e}=j3e.read(),[t,r]=me.useState(!1),{camera:i,controls:s,scene:o,moveCamera:a,setManifest:l,lookAtManager:A,showEnvironmentModels:c}=me.useContext(ni),{viewMode:u}=me.useContext(Bi);e.camera=i,e.scene=o;const f=()=>{if(e.camera){if([ot.BIO,ot.CHAT].includes(u)){u===ot.CHAT?(Z1=L3e,J1.copy(P3e),My.copy(hz),H1=W3e,z1=O3e):(Z1=x3,J1.copy(I3),My.copy(pz),H1=G3e,z1=Z3e),Zi.set(0,0,H1,1).applyMatrix4(e.camera.projectionMatrix),Zi.x/=Zi.w,Zi.y/=Zi.w,Zi.z/=Zi.w;const b=J3e.set(z1*Zi.w,Zi.y*Zi.w,Zi.z*Zi.w,Zi.w).applyMatrix4(e.camera.projectionMatrixInverse).x,E=Qf.set(My.x,0,My.z).angleTo(H3e);Qf.set(b,0,0).applyAxisAngle(z3e,E),Qf.add(J1),a({targetX:Qf.x,targetY:Qf.y,targetZ:Qf.z,distance:Z1})}else a({targetX:0,targetY:I3.y,targetZ:0,distance:x3});s&&([ot.APPEARANCE,ot.SAVE,ot.OPTIMIZER,ot.BATCHDOWNLOAD,ot.BATCHMANIFEST].includes(u)?s.enabled=!0:s.enabled=!1)}},[d,h]=me.useState(!1),[p,m]=me.useState(""),[g,v]=me.useState([]),y=(b,E)=>{m(b),h(!0),v([E])},w={[ot.LANDING]:P.jsx(ewe,{}),[ot.APPEARANCE]:P.jsx(c3e,{confirmDialog:y}),[ot.OPTIMIZER]:P.jsx(R3e,{}),[ot.CREATE]:P.jsx(KBe,{}),[ot.WALLET]:P.jsx(k3e,{}),[ot.CLAIM]:P.jsx(jBe,{}),[ot.BATCHMANIFEST]:P.jsx(D3e,{}),[ot.BATCHDOWNLOAD]:P.jsx(Q3e,{}),[ot.LOAD]:P.jsx(lBe,{}),[ot.MINT]:P.jsx(QBe,{}),[ot.SAVE]:P.jsx(vye,{}),[ot.CHAT]:P.jsx(Xve,{})};let C=0;return me.useEffect(()=>{const b=E=>{const x=new Date().getTime(),S=x-C;S<300&&S>10&&E.target.id=="editor-scene"&&r(!t),C=x};return window.addEventListener("touchend",b),window.addEventListener("click",b),()=>{window.removeEventListener("touchend",b),window.removeEventListener("click",b)}},[t]),me.useEffect(()=>{if(A!=null)return f(),[ot.BIO,ot.MINT,ot.CHAT].includes(u)?A.enabled=!1:A.enabled=!0,[ot.LANDING,ot.CREATE,ot.CLAIM,ot.LOAD,ot.CLAIM,ot.CLAIM].includes(u)?c(!1):c(!0),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[u,A]),me.useEffect(()=>{l(n)},[n]),me.useContext(bs),P.jsxs(me.Fragment,{children:[P.jsx("div",{className:"generalTitle",children:"Character Studio"}),P.jsx(N3e,{}),P.jsx(_me,{confirmDialogText:p,confirmDialogCallback:g,confirmDialogWindow:d,setConfirmDialogWindow:h}),P.jsx(kme,{}),w[u]]})}const q3e=n=>{const e=new nS(n);return e.pollingInterval=12e3,e};iF.createRoot(document.getElementById("root")).render(P.jsx(Y.StrictMode,{children:P.jsx(sK,{getLibrary:q3e,children:P.jsx(pj,{children:P.jsx(Gge,{children:P.jsx(dj,{children:P.jsx(Cpe,{children:P.jsx(Bpe,{children:P.jsx(Qpe,{children:P.jsx(me.Suspense,{children:P.jsx($3e,{})})})})})})})})})}));export{td as c,bu as g}; diff --git a/index.html b/index.html index 4834514b..f9c1b32e 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ Character Studio - +