>>26-c}B&&(this.words[M]=B,this.length++)}if(p!==0){for(M=this.length-1;M>=0;M--)this.words[M+p]=this.words[M];for(M=0;M=0);var v;c?v=(c-c%26)/26:v=0;var M=a%26,B=Math.min((a-M)/26,this.length),C=67108863^67108863>>>M<B)for(this.length-=B,o=0;o=0&&(g!==0||o>=v);o--){var H=this.words[o]|0;this.words[o]=g<<26-M|H>>>M,g=H&C}return x&&g!==0&&(x.words[x.length++]=g),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(a,c,p){return i(this.negative===0),this.iushrn(a,c,p)},n.prototype.shln=function(a){return this.clone().ishln(a)},n.prototype.ushln=function(a){return this.clone().iushln(a)},n.prototype.shrn=function(a){return this.clone().ishrn(a)},n.prototype.ushrn=function(a){return this.clone().iushrn(a)},n.prototype.testn=function(a){i(typeof a=="number"&&a>=0);var c=a%26,p=(a-c)/26,v=1<=0);var c=a%26,p=(a-c)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(c!==0&&p++,this.length=Math.min(p,this.length),c!==0){var v=67108863^67108863>>>c<=67108864;c++)this.words[c]-=67108864,c===this.length-1?this.words[c+1]=1:this.words[c+1]++;return this.length=Math.max(this.length,c+1),this},n.prototype.isubn=function(a){if(i(typeof a=="number"),i(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var c=0;c>26)-(x/67108864|0),this.words[M+p]=B&67108863}for(;M>26,this.words[M+p]=B&67108863;if(C===0)return this.strip();for(i(C===-1),C=0,M=0;M>26,this.words[M]=B&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(a,c){var p=this.length-a.length,v=this.clone(),M=a,B=M.words[M.length-1]|0,C=this._countBits(B);p=26-C,p!==0&&(M=M.ushln(p),v.iushln(p),B=M.words[M.length-1]|0);var x=v.length-M.length,o;if(c!=="mod"){o=new n(null),o.length=x+1,o.words=new Array(o.length);for(var g=0;g=0;Z--){var J=(v.words[M.length+Z]|0)*67108864+(v.words[M.length+Z-1]|0);for(J=Math.min(J/B|0,67108863),v._ishlnsubmul(M,J,Z);v.negative!==0;)J--,v.negative=0,v._ishlnsubmul(M,1,Z),v.isZero()||(v.negative^=1);o&&(o.words[Z]=J)}return o&&o.strip(),v.strip(),c!=="div"&&p!==0&&v.iushrn(p),{div:o||null,mod:v}},n.prototype.divmod=function(a,c,p){if(i(!a.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var v,M,B;return this.negative!==0&&a.negative===0?(B=this.neg().divmod(a,c),c!=="mod"&&(v=B.div.neg()),c!=="div"&&(M=B.mod.neg(),p&&M.negative!==0&&M.iadd(a)),{div:v,mod:M}):this.negative===0&&a.negative!==0?(B=this.divmod(a.neg(),c),c!=="mod"&&(v=B.div.neg()),{div:v,mod:B.mod}):this.negative&a.negative?(B=this.neg().divmod(a.neg(),c),c!=="div"&&(M=B.mod.neg(),p&&M.negative!==0&&M.isub(a)),{div:B.div,mod:M}):a.length>this.length||this.cmp(a)<0?{div:new n(0),mod:this}:a.length===1?c==="div"?{div:this.divn(a.words[0]),mod:null}:c==="mod"?{div:null,mod:new n(this.modn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new n(this.modn(a.words[0]))}:this._wordDiv(a,c)},n.prototype.div=function(a){return this.divmod(a,"div",!1).div},n.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},n.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},n.prototype.divRound=function(a){var c=this.divmod(a);if(c.mod.isZero())return c.div;var p=c.div.negative!==0?c.mod.isub(a):c.mod,v=a.ushrn(1),M=a.andln(1),B=p.cmp(v);return B<0||M===1&&B===0?c.div:c.div.negative!==0?c.div.isubn(1):c.div.iaddn(1)},n.prototype.modn=function(a){i(a<=67108863);for(var c=(1<<26)%a,p=0,v=this.length-1;v>=0;v--)p=(c*p+(this.words[v]|0))%a;return p},n.prototype.idivn=function(a){i(a<=67108863);for(var c=0,p=this.length-1;p>=0;p--){var v=(this.words[p]|0)+c*67108864;this.words[p]=v/a|0,c=v%a}return this.strip()},n.prototype.divn=function(a){return this.clone().idivn(a)},n.prototype.egcd=function(a){i(a.negative===0),i(!a.isZero());var c=this,p=a.clone();c.negative!==0?c=c.umod(a):c=c.clone();for(var v=new n(1),M=new n(0),B=new n(0),C=new n(1),x=0;c.isEven()&&p.isEven();)c.iushrn(1),p.iushrn(1),++x;for(var o=p.clone(),g=c.clone();!c.isZero();){for(var H=0,Z=1;!(c.words[0]&Z)&&H<26;++H,Z<<=1);if(H>0)for(c.iushrn(H);H-- >0;)(v.isOdd()||M.isOdd())&&(v.iadd(o),M.isub(g)),v.iushrn(1),M.iushrn(1);for(var J=0,ie=1;!(p.words[0]&ie)&&J<26;++J,ie<<=1);if(J>0)for(p.iushrn(J);J-- >0;)(B.isOdd()||C.isOdd())&&(B.iadd(o),C.isub(g)),B.iushrn(1),C.iushrn(1);c.cmp(p)>=0?(c.isub(p),v.isub(B),M.isub(C)):(p.isub(c),B.isub(v),C.isub(M))}return{a:B,b:C,gcd:p.iushln(x)}},n.prototype._invmp=function(a){i(a.negative===0),i(!a.isZero());var c=this,p=a.clone();c.negative!==0?c=c.umod(a):c=c.clone();for(var v=new n(1),M=new n(0),B=p.clone();c.cmpn(1)>0&&p.cmpn(1)>0;){for(var C=0,x=1;!(c.words[0]&x)&&C<26;++C,x<<=1);if(C>0)for(c.iushrn(C);C-- >0;)v.isOdd()&&v.iadd(B),v.iushrn(1);for(var o=0,g=1;!(p.words[0]&g)&&o<26;++o,g<<=1);if(o>0)for(p.iushrn(o);o-- >0;)M.isOdd()&&M.iadd(B),M.iushrn(1);c.cmp(p)>=0?(c.isub(p),v.isub(M)):(p.isub(c),M.isub(v))}var H;return c.cmpn(1)===0?H=v:H=M,H.cmpn(0)<0&&H.iadd(a),H},n.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var c=this.clone(),p=a.clone();c.negative=0,p.negative=0;for(var v=0;c.isEven()&&p.isEven();v++)c.iushrn(1),p.iushrn(1);do{for(;c.isEven();)c.iushrn(1);for(;p.isEven();)p.iushrn(1);var M=c.cmp(p);if(M<0){var B=c;c=p,p=B}else if(M===0||p.cmpn(1)===0)break;c.isub(p)}while(!0);return p.iushln(v)},n.prototype.invm=function(a){return this.egcd(a).a.umod(a)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(a){return this.words[0]&a},n.prototype.bincn=function(a){i(typeof a=="number");var c=a%26,p=(a-c)/26,v=1<>>26,C&=67108863,this.words[B]=C}return M!==0&&(this.words[B]=M,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(a){var c=a<0;if(this.negative!==0&&!c)return-1;if(this.negative===0&&c)return 1;this.strip();var p;if(this.length>1)p=1;else{c&&(a=-a),i(a<=67108863,"Number is too big");var v=this.words[0]|0;p=v===a?0:va.length)return 1;if(this.length=0;p--){var v=this.words[p]|0,M=a.words[p]|0;if(v!==M){vM&&(c=1);break}}return c},n.prototype.gtn=function(a){return this.cmpn(a)===1},n.prototype.gt=function(a){return this.cmp(a)===1},n.prototype.gten=function(a){return this.cmpn(a)>=0},n.prototype.gte=function(a){return this.cmp(a)>=0},n.prototype.ltn=function(a){return this.cmpn(a)===-1},n.prototype.lt=function(a){return this.cmp(a)===-1},n.prototype.lten=function(a){return this.cmpn(a)<=0},n.prototype.lte=function(a){return this.cmp(a)<=0},n.prototype.eqn=function(a){return this.cmpn(a)===0},n.prototype.eq=function(a){return this.cmp(a)===0},n.red=function(a){return new V(a)},n.prototype.toRed=function(a){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},n.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(a){return this.red=a,this},n.prototype.forceRed=function(a){return i(!this.red,"Already a number in reduction context"),this._forceRed(a)},n.prototype.redAdd=function(a){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},n.prototype.redIAdd=function(a){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},n.prototype.redSub=function(a){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},n.prototype.redISub=function(a){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},n.prototype.redShl=function(a){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},n.prototype.redMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},n.prototype.redIMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},n.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(a){return i(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var j={k256:null,p224:null,p192:null,p25519:null};function K(A,a){this.name=A,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}K.prototype._tmp=function(){var a=new n(null);return a.words=new Array(Math.ceil(this.n/13)),a},K.prototype.ireduce=function(a){var c=a,p;do this.split(c,this.tmp),c=this.imulK(c),c=c.iadd(this.tmp),p=c.bitLength();while(p>this.n);var v=p0?c.isub(this.p):c.strip!==void 0?c.strip():c._strip(),c},K.prototype.split=function(a,c){a.iushrn(this.n,0,c)},K.prototype.imulK=function(a){return a.imul(this.k)};function Y(){K.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}f(Y,K),Y.prototype.split=function(a,c){for(var p=4194303,v=Math.min(a.length,9),M=0;M>>22,B=C}B>>>=22,a.words[M-10]=B,B===0&&a.length>10?a.length-=10:a.length-=9},Y.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var c=0,p=0;p>>=26,a.words[p]=M,c=v}return c!==0&&(a.words[a.length++]=c),a},n._prime=function(a){if(j[a])return j[a];var c;if(a==="k256")c=new Y;else if(a==="p224")c=new Q;else if(a==="p192")c=new se;else if(a==="p25519")c=new re;else throw new Error("Unknown prime "+a);return j[a]=c,c};function V(A){if(typeof A=="string"){var a=n._prime(A);this.m=a.p,this.prime=a}else i(A.gtn(1),"modulus must be greater than 1"),this.m=A,this.prime=null}V.prototype._verify1=function(a){i(a.negative===0,"red works only with positives"),i(a.red,"red works only with red numbers")},V.prototype._verify2=function(a,c){i((a.negative|c.negative)===0,"red works only with positives"),i(a.red&&a.red===c.red,"red works only with red numbers")},V.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):a.umod(this.m)._forceRed(this)},V.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},V.prototype.add=function(a,c){this._verify2(a,c);var p=a.add(c);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},V.prototype.iadd=function(a,c){this._verify2(a,c);var p=a.iadd(c);return p.cmp(this.m)>=0&&p.isub(this.m),p},V.prototype.sub=function(a,c){this._verify2(a,c);var p=a.sub(c);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},V.prototype.isub=function(a,c){this._verify2(a,c);var p=a.isub(c);return p.cmpn(0)<0&&p.iadd(this.m),p},V.prototype.shl=function(a,c){return this._verify1(a),this.imod(a.ushln(c))},V.prototype.imul=function(a,c){return this._verify2(a,c),this.imod(a.imul(c))},V.prototype.mul=function(a,c){return this._verify2(a,c),this.imod(a.mul(c))},V.prototype.isqr=function(a){return this.imul(a,a.clone())},V.prototype.sqr=function(a){return this.mul(a,a)},V.prototype.sqrt=function(a){if(a.isZero())return a.clone();var c=this.m.andln(3);if(i(c%2===1),c===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(a,p)}for(var v=this.m.subn(1),M=0;!v.isZero()&&v.andln(1)===0;)M++,v.iushrn(1);i(!v.isZero());var B=new n(1).toRed(this),C=B.redNeg(),x=this.m.subn(1).iushrn(1),o=this.m.bitLength();for(o=new n(2*o*o).toRed(this);this.pow(o,x).cmp(C)!==0;)o.redIAdd(C);for(var g=this.pow(o,v),H=this.pow(a,v.addn(1).iushrn(1)),Z=this.pow(a,v),J=M;Z.cmp(B)!==0;){for(var ie=Z,R=0;ie.cmp(B)!==0;R++)ie=ie.redSqr();i(R=0;M--){for(var g=c.words[M],H=o-1;H>=0;H--){var Z=g>>H&1;if(B!==v[0]&&(B=this.sqr(B)),Z===0&&C===0){x=0;continue}C<<=1,C|=Z,x++,!(x!==p&&(M!==0||H!==0))&&(B=this.mul(B,v[C]),x=0,C=0)}o=26}return B},V.prototype.convertTo=function(a){var c=a.umod(this.m);return c===a?c.clone():c},V.prototype.convertFrom=function(a){var c=a.clone();return c.red=null,c},n.mont=function(a){return new Me(a)};function Me(A){V.call(this,A),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(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)}f(Me,V),Me.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},Me.prototype.convertFrom=function(a){var c=this.imod(a.mul(this.rinv));return c.red=null,c},Me.prototype.imul=function(a,c){if(a.isZero()||c.isZero())return a.words[0]=0,a.length=1,a;var p=a.imul(c),v=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),M=p.isub(v).iushrn(this.shift),B=M;return M.cmp(this.m)>=0?B=M.isub(this.m):M.cmpn(0)<0&&(B=M.iadd(this.m)),B._forceRed(this)},Me.prototype.mul=function(a,c){if(a.isZero()||c.isZero())return new n(0)._forceRed(this);var p=a.mul(c),v=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),M=p.isub(v).iushrn(this.shift),B=M;return M.cmp(this.m)>=0?B=M.isub(this.m):M.cmpn(0)<0&&(B=M.iadd(this.m)),B._forceRed(this)},Me.prototype.invm=function(a){var c=this.imod(a._invmp(this.m).mul(this.r2));return c._forceRed(this)}})(t,ht)}(si);var Bt=si.exports,zt=pn;function pn(t,e){if(!t)throw new Error(e||"Assertion failed")}pn.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var oi={};(function(t){var e=t;function r(n,u){if(Array.isArray(n))return n.slice();if(!n)return[];var h=[];if(typeof n!="string"){for(var b=0;b>8,E=_&255;w?h.push(w,E):h.push(E)}return h}e.toArray=r;function i(n){return n.length===1?"0"+n:n}e.zero2=i;function f(n){for(var u="",h=0;h(N>>1)-1?k=(N>>1)-z:k=z,O.isubn(k)):k=0,F[D]=k,O.iushrn(1)}return F}e.getNAF=n;function u(w,E){var P=[[],[]];w=w.clone(),E=E.clone();for(var F=0,N=0,O;w.cmpn(-F)>0||E.cmpn(-N)>0;){var D=w.andln(3)+F&3,k=E.andln(3)+N&3;D===3&&(D=-1),k===3&&(k=-1);var z;D&1?(O=w.andln(7)+F&7,(O===3||O===5)&&k===2?z=-D:z=D):z=0,P[0].push(z);var j;k&1?(O=E.andln(7)+N&7,(O===3||O===5)&&D===2?j=-k:j=k):j=0,P[1].push(j),2*F===z+1&&(F=1-F),2*N===j+1&&(N=1-N),w.iushrn(1),E.iushrn(1)}return P}e.getJSF=u;function h(w,E,P){var F="_"+E;w.prototype[E]=function(){return this[F]!==void 0?this[F]:this[F]=P.call(this)}}e.cachedProperty=h;function b(w){return typeof w=="string"?e.toArray(w,"hex"):w}e.parseBytes=b;function _(w){return new r(w,"hex","le")}e.intFromLE=_}(rt);var di={exports:{}},hi;di.exports=function(e){return hi||(hi=new Nt(null)),hi.generate(e)};function Nt(t){this.rand=t}if(di.exports.Rand=Nt,Nt.prototype.generate=function(e){return this._rand(e)},Nt.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),i=0;i0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Lr=Ft;Ft.prototype.point=function(){throw new Error("Not implemented")},Ft.prototype.validate=function(){throw new Error("Not implemented")},Ft.prototype._fixedNafMul=function(e,r){Fr(e.precomputed);var i=e._getDoubles(),f=Nr(r,1,this._bitLength),n=(1<=h;_--)b=(b<<1)+f[_];u.push(b)}for(var w=this.jpoint(null,null,null),E=this.jpoint(null,null,null),P=n;P>0;P--){for(h=0;h=0;b--){for(var _=0;b>=0&&u[b]===0;b--)_++;if(b>=0&&_++,h=h.dblp(_),b<0)break;var w=u[b];Fr(w!==0),e.type==="affine"?w>0?h=h.mixedAdd(n[w-1>>1]):h=h.mixedAdd(n[-w-1>>1].neg()):w>0?h=h.add(n[w-1>>1]):h=h.add(n[-w-1>>1].neg())}return e.type==="affine"?h.toP():h},Ft.prototype._wnafMulAdd=function(e,r,i,f,n){var u=this._wnafT1,h=this._wnafT2,b=this._wnafT3,_=0,w,E,P;for(w=0;w=1;w-=2){var N=w-1,O=w;if(u[N]!==1||u[O]!==1){b[N]=Nr(i[N],u[N],this._bitLength),b[O]=Nr(i[O],u[O],this._bitLength),_=Math.max(b[N].length,_),_=Math.max(b[O].length,_);continue}var D=[r[N],null,null,r[O]];r[N].y.cmp(r[O].y)===0?(D[1]=r[N].add(r[O]),D[2]=r[N].toJ().mixedAdd(r[O].neg())):r[N].y.cmp(r[O].y.redNeg())===0?(D[1]=r[N].toJ().mixedAdd(r[O]),D[2]=r[N].add(r[O].neg())):(D[1]=r[N].toJ().mixedAdd(r[O]),D[2]=r[N].toJ().mixedAdd(r[O].neg()));var k=[-3,-1,-5,-7,0,7,5,1,3],z=ha(i[N],i[O]);for(_=Math.max(z[0].length,_),b[N]=new Array(_),b[O]=new Array(_),E=0;E<_;E++){var j=z[0][E]|0,K=z[1][E]|0;b[N][E]=k[(j+1)*3+(K+1)],b[O][E]=0,h[N]=D}}var Y=this.jpoint(null,null,null),Q=this._wnafT4;for(w=_;w>=0;w--){for(var se=0;w>=0;){var re=!0;for(E=0;E=0&&se++,Y=Y.dblp(se),w<0)break;for(E=0;E0?P=h[E][V-1>>1]:V<0&&(P=h[E][-V-1>>1].neg()),P.type==="affine"?Y=Y.mixedAdd(P):Y=Y.add(P))}}for(w=0;w=Math.ceil((e.bitLength()+1)/r.step):!1},nt.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],f=this,n=0;n=0&&(F=_,N=w),E.negative&&(E=E.neg(),P=P.neg()),F.negative&&(F=F.neg(),N=N.neg()),[{a:E,b:P},{a:F,b:N}]},ft.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],f=r[1],n=f.b.mul(e).divRound(this.n),u=i.b.neg().mul(e).divRound(this.n),h=n.mul(i.a),b=u.mul(f.a),_=n.mul(i.b),w=u.mul(f.b),E=e.sub(h).sub(b),P=_.add(w).neg();return{k1:E,k2:P}},ft.prototype.pointFromX=function(e,r){e=new Ee(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),f=i.redSqrt();if(f.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var n=f.fromRed().isOdd();return(r&&!n||!r&&n)&&(f=f.redNeg()),this.point(e,f)},ft.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,f=this.a.redMul(r),n=r.redSqr().redMul(r).redIAdd(f).redIAdd(this.b);return i.redSqr().redISub(n).cmpn(0)===0},ft.prototype._endoWnafMulAdd=function(e,r,i){for(var f=this._endoWnafT1,n=this._endoWnafT2,u=0;u":""},Ke.prototype.isInfinity=function(){return this.inf},Ke.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 r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),f=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,f)},Ke.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 r=this.curve.a,i=this.x.redSqr(),f=e.redInvm(),n=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(f),u=n.redSqr().redISub(this.x.redAdd(this.x)),h=n.redMul(this.x.redSub(u)).redISub(this.y);return this.curve.point(u,h)},Ke.prototype.getX=function(){return this.x.fromRed()},Ke.prototype.getY=function(){return this.y.fromRed()},Ke.prototype.mul=function(e){return e=new Ee(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)},Ke.prototype.mulAdd=function(e,r,i){var f=[this,r],n=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(f,n):this.curve._wnafMulAdd(1,f,n,2)},Ke.prototype.jmulAdd=function(e,r,i){var f=[this,r],n=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(f,n,!0):this.curve._wnafMulAdd(1,f,n,2,!0)},Ke.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)},Ke.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,f=function(n){return n.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(f)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(f)}}}return r},Ke.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 Ve(t,e,r,i){er.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ee(0)):(this.x=new Ee(e,16),this.y=new Ee(r,16),this.z=new Ee(i,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}li(Ve,er.BasePoint),ft.prototype.jpoint=function(e,r,i){return new Ve(this,e,r,i)},Ve.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),f=this.y.redMul(r).redMul(e);return this.curve.point(i,f)},Ve.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ve.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),f=this.x.redMul(r),n=e.x.redMul(i),u=this.y.redMul(r.redMul(e.z)),h=e.y.redMul(i.redMul(this.z)),b=f.redSub(n),_=u.redSub(h);if(b.cmpn(0)===0)return _.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var w=b.redSqr(),E=w.redMul(b),P=f.redMul(w),F=_.redSqr().redIAdd(E).redISub(P).redISub(P),N=_.redMul(P.redISub(F)).redISub(u.redMul(E)),O=this.z.redMul(e.z).redMul(b);return this.curve.jpoint(F,N,O)},Ve.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,f=e.x.redMul(r),n=this.y,u=e.y.redMul(r).redMul(this.z),h=i.redSub(f),b=n.redSub(u);if(h.cmpn(0)===0)return b.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var _=h.redSqr(),w=_.redMul(h),E=i.redMul(_),P=b.redSqr().redIAdd(w).redISub(E).redISub(E),F=b.redMul(E.redISub(P)).redISub(n.redMul(w)),N=this.z.redMul(h);return this.curve.jpoint(P,F,N)},Ve.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r=0)return!1;if(i.redIAdd(n),this.x.cmp(i)===0)return!0}},Ve.prototype.inspect=function(){return this.isInfinity()?"":""},Ve.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var tr=Bt,gn=Ae,Or=Lr,ba=rt;function rr(t){Or.call(this,"mont",t),this.a=new tr(t.a,16).toRed(this.red),this.b=new tr(t.b,16).toRed(this.red),this.i4=new tr(4).toRed(this.red).redInvm(),this.two=new tr(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}gn(rr,Or);var pa=rr;rr.prototype.validate=function(e){var r=e.normalize().x,i=r.redSqr(),f=i.redMul(r).redAdd(i.redMul(this.a)).redAdd(r),n=f.redSqrt();return n.redSqr().cmp(f)===0};function He(t,e,r){Or.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new tr(e,16),this.z=new tr(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}gn(He,Or.BasePoint),rr.prototype.decodePoint=function(e,r){return this.point(ba.toArray(e,r),1)},rr.prototype.point=function(e,r){return new He(this,e,r)},rr.prototype.pointFromJSON=function(e){return He.fromJSON(this,e)},He.prototype.precompute=function(){},He.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},He.fromJSON=function(e,r){return new He(e,r[0],r[1]||e.one)},He.prototype.inspect=function(){return this.isInfinity()?"":""},He.prototype.isInfinity=function(){return this.z.cmpn(0)===0},He.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),i=this.x.redSub(this.z),f=i.redSqr(),n=r.redSub(f),u=r.redMul(f),h=n.redMul(f.redAdd(this.curve.a24.redMul(n)));return this.curve.point(u,h)},He.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},He.prototype.diffAdd=function(e,r){var i=this.x.redAdd(this.z),f=this.x.redSub(this.z),n=e.x.redAdd(e.z),u=e.x.redSub(e.z),h=u.redMul(i),b=n.redMul(f),_=r.z.redMul(h.redAdd(b).redSqr()),w=r.x.redMul(h.redISub(b).redSqr());return this.curve.point(_,w)},He.prototype.mul=function(e){for(var r=e.clone(),i=this,f=this.curve.point(null,null),n=this,u=[];r.cmpn(0)!==0;r.iushrn(1))u.push(r.andln(1));for(var h=u.length-1;h>=0;h--)u[h]===0?(i=i.diffAdd(f,n),f=f.dbl()):(f=i.diffAdd(f,n),i=i.dbl());return f},He.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},He.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},He.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},He.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},He.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var va=rt,Rt=Bt,xn=Ae,$r=Lr,ya=va.assert;function vt(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,$r.call(this,"edwards",t),this.a=new Rt(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Rt(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Rt(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),ya(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}xn(vt,$r);var ga=vt;vt.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},vt.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},vt.prototype.jpoint=function(e,r,i,f){return this.point(e,r,i,f)},vt.prototype.pointFromX=function(e,r){e=new Rt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),f=this.c2.redSub(this.a.redMul(i)),n=this.one.redSub(this.c2.redMul(this.d).redMul(i)),u=f.redMul(n.redInvm()),h=u.redSqrt();if(h.redSqr().redSub(u).cmp(this.zero)!==0)throw new Error("invalid point");var b=h.fromRed().isOdd();return(r&&!b||!r&&b)&&(h=h.redNeg()),this.point(e,h)},vt.prototype.pointFromY=function(e,r){e=new Rt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),f=i.redSub(this.c2),n=i.redMul(this.d).redMul(this.c2).redSub(this.a),u=f.redMul(n.redInvm());if(u.cmp(this.zero)===0){if(r)throw new Error("invalid point");return this.point(this.zero,e)}var h=u.redSqrt();if(h.redSqr().redSub(u).cmp(this.zero)!==0)throw new Error("invalid point");return h.fromRed().isOdd()!==r&&(h=h.redNeg()),this.point(h,e)},vt.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),i=e.y.redSqr(),f=r.redMul(this.a).redAdd(i),n=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(i)));return f.cmp(n)===0};function me(t,e,r,i,f){$r.BasePoint.call(this,t,"projective"),e===null&&r===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Rt(e,16),this.y=new Rt(r,16),this.z=i?new Rt(i,16):this.curve.one,this.t=f&&new Rt(f,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.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}xn(me,$r.BasePoint),vt.prototype.pointFromJSON=function(e){return me.fromJSON(this,e)},vt.prototype.point=function(e,r,i,f){return new me(this,e,r,i,f)},me.fromJSON=function(e,r){return new me(e,r[0],r[1],r[2])},me.prototype.inspect=function(){return this.isInfinity()?"":""},me.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},me.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var f=this.curve._mulA(e),n=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),u=f.redAdd(r),h=u.redSub(i),b=f.redSub(r),_=n.redMul(h),w=u.redMul(b),E=n.redMul(b),P=h.redMul(u);return this.curve.point(_,w,P,E)},me.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),i=this.y.redSqr(),f,n,u,h,b,_;if(this.curve.twisted){h=this.curve._mulA(r);var w=h.redAdd(i);this.zOne?(f=e.redSub(r).redSub(i).redMul(w.redSub(this.curve.two)),n=w.redMul(h.redSub(i)),u=w.redSqr().redSub(w).redSub(w)):(b=this.z.redSqr(),_=w.redSub(b).redISub(b),f=e.redSub(r).redISub(i).redMul(_),n=w.redMul(h.redSub(i)),u=w.redMul(_))}else h=r.redAdd(i),b=this.curve._mulC(this.z).redSqr(),_=h.redSub(b).redSub(b),f=this.curve._mulC(e.redISub(h)).redMul(_),n=this.curve._mulC(h).redMul(r.redISub(i)),u=h.redMul(_);return this.curve.point(f,n,u)},me.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},me.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),f=this.t.redMul(this.curve.dd).redMul(e.t),n=this.z.redMul(e.z.redAdd(e.z)),u=i.redSub(r),h=n.redSub(f),b=n.redAdd(f),_=i.redAdd(r),w=u.redMul(h),E=b.redMul(_),P=u.redMul(_),F=h.redMul(b);return this.curve.point(w,E,F,P)},me.prototype._projAdd=function(e){var r=this.z.redMul(e.z),i=r.redSqr(),f=this.x.redMul(e.x),n=this.y.redMul(e.y),u=this.curve.d.redMul(f).redMul(n),h=i.redSub(u),b=i.redAdd(u),_=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(f).redISub(n),w=r.redMul(h).redMul(_),E,P;return this.curve.twisted?(E=r.redMul(b).redMul(n.redSub(this.curve._mulA(f))),P=h.redMul(b)):(E=r.redMul(b).redMul(n.redSub(f)),P=this.curve._mulC(h).redMul(b)),this.curve.point(w,E,P)},me.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},me.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},me.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},me.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},me.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},me.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},me.prototype.getX=function(){return this.normalize(),this.x.fromRed()},me.prototype.getY=function(){return this.normalize(),this.y.fromRed()},me.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},me.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var i=e.clone(),f=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(f),this.x.cmp(r)===0)return!0}},me.prototype.toP=me.prototype.normalize,me.prototype.mixedAdd=me.prototype.add,function(t){var e=t;e.base=Lr,e.short=la,e.mont=pa,e.edwards=ga}(ci);var kr={},Ur={},oe={},xa=zt,ma=Ae;oe.inherits=ma;function wa(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function _a(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),f=0;f>6|192,r[i++]=n&63|128):wa(t,f)?(n=65536+((n&1023)<<10)+(t.charCodeAt(++f)&1023),r[i++]=n>>18|240,r[i++]=n>>12&63|128,r[i++]=n>>6&63|128,r[i++]=n&63|128):(r[i++]=n>>12|224,r[i++]=n>>6&63|128,r[i++]=n&63|128)}else for(f=0;f>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}oe.htonl=mn;function Sa(t,e){for(var r="",i=0;i>>0}return n}oe.join32=Ea;function Aa(t,e){for(var r=new Array(t.length*4),i=0,f=0;i>>24,r[f+1]=n>>>16&255,r[f+2]=n>>>8&255,r[f+3]=n&255):(r[f+3]=n>>>24,r[f+2]=n>>>16&255,r[f+1]=n>>>8&255,r[f]=n&255)}return r}oe.split32=Aa;function Ia(t,e){return t>>>e|t<<32-e}oe.rotr32=Ia;function Ba(t,e){return t<>>32-e}oe.rotl32=Ba;function Ra(t,e){return t+e>>>0}oe.sum32=Ra;function Pa(t,e,r){return t+e+r>>>0}oe.sum32_3=Pa;function Ta(t,e,r,i){return t+e+r+i>>>0}oe.sum32_4=Ta;function Ca(t,e,r,i,f){return t+e+r+i+f>>>0}oe.sum32_5=Ca;function Na(t,e,r,i){var f=t[e],n=t[e+1],u=i+n>>>0,h=(u>>0,t[e+1]=u}oe.sum64=Na;function Fa(t,e,r,i){var f=e+i>>>0,n=(f>>0}oe.sum64_hi=Fa;function La(t,e,r,i){var f=e+i;return f>>>0}oe.sum64_lo=La;function Oa(t,e,r,i,f,n,u,h){var b=0,_=e;_=_+i>>>0,b+=_>>0,b+=_>>0,b+=_>>0}oe.sum64_4_hi=Oa;function $a(t,e,r,i,f,n,u,h){var b=e+i+n+h;return b>>>0}oe.sum64_4_lo=$a;function ka(t,e,r,i,f,n,u,h,b,_){var w=0,E=e;E=E+i>>>0,w+=E>>0,w+=E>>0,w+=E>>0,w+=E<_?1:0;var P=t+r+f+u+b+w;return P>>>0}oe.sum64_5_hi=ka;function Ua(t,e,r,i,f,n,u,h,b,_){var w=e+i+n+h+_;return w>>>0}oe.sum64_5_lo=Ua;function Da(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}oe.rotr64_hi=Da;function qa(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}oe.rotr64_lo=qa;function za(t,e,r){return t>>>r}oe.shr64_hi=za;function Ka(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}oe.shr64_lo=Ka;var ir={},Mn=oe,Ha=zt;function Dr(){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}ir.BlockHash=Dr,Dr.prototype.update=function(e,r){if(e=Mn.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=Mn.join32(e,0,e.length-i,this.endian);for(var f=0;f>>24&255,f[n++]=e>>>16&255,f[n++]=e>>>8&255,f[n++]=e&255}else for(f[n++]=e&255,f[n++]=e>>>8&255,f[n++]=e>>>16&255,f[n++]=e>>>24&255,f[n++]=0,f[n++]=0,f[n++]=0,f[n++]=0,u=8;u>>3}yt.g0_256=Ga;function Za(t){return gt(t,17)^gt(t,19)^t>>>10}yt.g1_256=Za;var fr=oe,Ja=ir,Xa=yt,bi=fr.rotl32,yr=fr.sum32,Qa=fr.sum32_5,e0=Xa.ft_1,In=Ja.BlockHash,t0=[1518500249,1859775393,2400959708,3395469782];function xt(){if(!(this instanceof xt))return new xt;In.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}fr.inherits(xt,In);var r0=xt;xt.blockSize=512,xt.outSize=160,xt.hmacStrength=80,xt.padLength=64,xt.prototype._update=function(e,r){for(var i=this.W,f=0;f<16;f++)i[f]=e[r+f];for(;fthis.blockSize&&(e=new this.Hash().update(e).digest()),K0(e.length<=this.blockSize);for(var r=e.length;r=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var V0=Ot;Ot.prototype._init=function(e,r,i){var f=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Ot.prototype.generate=function(e,r,i,f){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(f=i,i=r,r=null),i&&(i=Wt.toArray(i,f||"hex"),this._update(i));for(var n=[];n.length"};var zr=Bt,wi=rt,J0=wi.assert;function Kr(t,e){if(t instanceof Kr)return t;this._importDER(t,e)||(J0(t.r&&t.s,"Signature without r or s"),this.r=new zr(t.r,16),this.s=new zr(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var X0=Kr;function Q0(){this.place=0}function _i(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4)return!1;for(var f=0,n=0,u=e.place;n>>=0;return f<=127?!1:(e.place=u,f)}function Kn(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Kr.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=Kn(r),i=Kn(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var f=[2];Mi(f,r.length),f=f.concat(r),f.push(2),Mi(f,i.length);var n=f.concat(i),u=[48];return Mi(u,n.length),u=u.concat(n),wi.encode(u,e)};var jt=Bt,Hn=V0,es=rt,Si=kr,ts=yn,Wn=es.assert,Ei=Z0,Hr=X0;function at(t){if(!(this instanceof at))return new at(t);typeof t=="string"&&(Wn(Object.prototype.hasOwnProperty.call(Si,t),"Unknown curve "+t),t=Si[t]),t instanceof Si.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var rs=at;at.prototype.keyPair=function(e){return new Ei(this,e)},at.prototype.keyFromPrivate=function(e,r){return Ei.fromPrivate(this,e,r)},at.prototype.keyFromPublic=function(e,r){return Ei.fromPublic(this,e,r)},at.prototype.genKeyPair=function(e){e||(e={});for(var r=new Hn({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||ts(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),f=this.n.sub(new jt(2));;){var n=new jt(r.generate(i));if(!(n.cmp(f)>0))return n.iaddn(1),this.keyFromPrivate(n)}},at.prototype._truncateToN=function(e,r){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},at.prototype.sign=function(e,r,i,f){typeof i=="object"&&(f=i,i=null),f||(f={}),r=this.keyFromPrivate(r,i),e=this._truncateToN(new jt(e,16));for(var n=this.n.byteLength(),u=r.getPrivate().toArray("be",n),h=e.toArray("be",n),b=new Hn({hash:this.hash,entropy:u,nonce:h,pers:f.pers,persEnc:f.persEnc||"utf8"}),_=this.n.sub(new jt(1)),w=0;;w++){var E=f.k?f.k(w):new jt(b.generate(this.n.byteLength()));if(E=this._truncateToN(E,!0),!(E.cmpn(1)<=0||E.cmp(_)>=0)){var P=this.g.mul(E);if(!P.isInfinity()){var F=P.getX(),N=F.umod(this.n);if(N.cmpn(0)!==0){var O=E.invm(this.n).mul(N.mul(r.getPrivate()).iadd(e));if(O=O.umod(this.n),O.cmpn(0)!==0){var D=(P.getY().isOdd()?1:0)|(F.cmp(N)!==0?2:0);return f.canonical&&O.cmp(this.nh)>0&&(O=this.n.sub(O),D^=1),new Hr({r:N,s:O,recoveryParam:D})}}}}}},at.prototype.verify=function(e,r,i,f){e=this._truncateToN(new jt(e,16)),i=this.keyFromPublic(i,f),r=new Hr(r,"hex");var n=r.r,u=r.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0||u.cmpn(1)<0||u.cmp(this.n)>=0)return!1;var h=u.invm(this.n),b=h.mul(e).umod(this.n),_=h.mul(n).umod(this.n),w;return this.curve._maxwellTrick?(w=this.g.jmulAdd(b,i.getPublic(),_),w.isInfinity()?!1:w.eqXToP(n)):(w=this.g.mulAdd(b,i.getPublic(),_),w.isInfinity()?!1:w.getX().umod(this.n).cmp(n)===0)},at.prototype.recoverPubKey=function(t,e,r,i){Wn((3&r)===r,"The recovery param is more than two bits"),e=new Hr(e,i);var f=this.n,n=new jt(t),u=e.r,h=e.s,b=r&1,_=r>>1;if(u.cmp(this.curve.p.umod(this.curve.n))>=0&&_)throw new Error("Unable to find sencond key candinate");_?u=this.curve.pointFromX(u.add(this.curve.n),b):u=this.curve.pointFromX(u,b);var w=e.r.invm(f),E=f.sub(n).mul(w).umod(f),P=h.mul(w).umod(f);return this.g.mulAdd(E,u,P)},at.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Hr(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var f=0;f<4;f++){var n;try{n=this.recoverPubKey(t,e,f)}catch{continue}if(n.eq(r))return f}throw new Error("Unable to find valid recovery factor")};var xr=rt,jn=xr.assert,Vn=xr.parseBytes,dr=xr.cachedProperty;function We(t,e){this.eddsa=t,this._secret=Vn(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Vn(e.pub)}We.fromPublic=function(e,r){return r instanceof We?r:new We(e,{pub:r})},We.fromSecret=function(e,r){return r instanceof We?r:new We(e,{secret:r})},We.prototype.secret=function(){return this._secret},dr(We,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),dr(We,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),dr(We,"privBytes",function(){var e=this.eddsa,r=this.hash(),i=e.encodingLength-1,f=r.slice(0,e.encodingLength);return f[0]&=248,f[i]&=127,f[i]|=64,f}),dr(We,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),dr(We,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),dr(We,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),We.prototype.sign=function(e){return jn(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},We.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},We.prototype.getSecret=function(e){return jn(this._secret,"KeyPair is public only"),xr.encode(this.secret(),e)},We.prototype.getPublic=function(e){return xr.encode(this.pubBytes(),e)};var is=We,ns=Bt,Wr=rt,fs=Wr.assert,jr=Wr.cachedProperty,as=Wr.parseBytes;function Vt(t,e){this.eddsa=t,typeof e!="object"&&(e=as(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),fs(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof ns&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}jr(Vt,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),jr(Vt,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),jr(Vt,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),jr(Vt,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Vt.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Vt.prototype.toHex=function(){return Wr.encode(this.toBytes(),"hex").toUpperCase()};var ss=Vt,os=Ur,ds=kr,hr=rt,hs=hr.assert,Yn=hr.parseBytes,Gn=is,Zn=ss;function et(t){if(hs(t==="ed25519","only tested with ed25519 so far"),!(this instanceof et))return new et(t);t=ds[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=os.sha512}var cs=et;et.prototype.sign=function(e,r){e=Yn(e);var i=this.keyFromSecret(r),f=this.hashInt(i.messagePrefix(),e),n=this.g.mul(f),u=this.encodePoint(n),h=this.hashInt(u,i.pubBytes(),e).mul(i.priv()),b=f.add(h).umod(this.curve.n);return this.makeSignature({R:n,S:b,Rencoded:u})},et.prototype.verify=function(e,r,i){e=Yn(e),r=this.makeSignature(r);var f=this.keyFromPublic(i),n=this.hashInt(r.Rencoded(),f.pubBytes(),e),u=this.g.mul(r.S()),h=r.R().add(f.pub().mul(n));return h.eq(u)},et.prototype.hashInt=function(){for(var e=this.hash(),r=0;r=0)return null;r=r.toRed(de.red);let i=r.redSqr().redIMul(r).redIAdd(de.b).redSqrt();return t===3!==i.isOdd()&&(i=i.redNeg()),St.keyPair({pub:{x:r,y:i}})}function bs(t,e,r){let i=new ye(e),f=new ye(r);if(i.cmp(de.p)>=0||f.cmp(de.p)>=0||(i=i.toRed(de.red),f=f.toRed(de.red),(t===6||t===7)&&f.isOdd()!==(t===7)))return null;const n=i.redSqr().redIMul(i);return f.redSqr().redISub(n.redIAdd(de.b)).isZero()?St.keyPair({pub:{x:i,y:f}}):null}function $t(t){const e=t[0];switch(e){case 2:case 3:return t.length!==33?null:ls(e,t.subarray(1,33));case 4:case 6:case 7:return t.length!==65?null:bs(e,t.subarray(1,33),t.subarray(33,65));default:return null}}function Yt(t,e){const r=e.encode(null,t.length===33);for(let i=0;i=0||(r.iadd(new ye(t)),r.cmp(de.n)>=0&&r.isub(de.n),r.isZero()))return 1;const i=r.toArrayLike(Uint8Array,"be",32);return t.set(i),0},privateKeyTweakMul(t,e){let r=new ye(e);if(r.cmp(de.n)>=0||r.isZero())return 1;r.imul(new ye(t)),r.cmp(de.n)>=0&&(r=r.umod(de.n));const i=r.toArrayLike(Uint8Array,"be",32);return t.set(i),0},publicKeyVerify(t){return $t(t)===null?1:0},publicKeyCreate(t,e){const r=new ye(e);if(r.cmp(de.n)>=0||r.isZero())return 1;const i=St.keyFromPrivate(e).getPublic();return Yt(t,i),0},publicKeyConvert(t,e){const r=$t(e);if(r===null)return 1;const i=r.getPublic();return Yt(t,i),0},publicKeyNegate(t,e){const r=$t(e);if(r===null)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),Yt(t,i),0},publicKeyCombine(t,e){const r=new Array(e.length);for(let f=0;f=0)return 2;const f=i.getPublic().add(de.g.mul(r));return f.isInfinity()?2:(Yt(t,f),0)},publicKeyTweakMul(t,e,r){const i=$t(e);if(i===null)return 1;if(r=new ye(r),r.cmp(de.n)>=0||r.isZero())return 2;const f=i.getPublic().mul(r);return Yt(t,f),0},signatureNormalize(t){const e=new ye(t.subarray(0,32)),r=new ye(t.subarray(32,64));return e.cmp(de.n)>=0||r.cmp(de.n)>=0?1:(r.cmp(St.nh)===1&&t.set(de.n.sub(r).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(t,e){const r=e.subarray(0,32),i=e.subarray(32,64);if(new ye(r).cmp(de.n)>=0||new ye(i).cmp(de.n)>=0)return 1;const{output:f}=t;let n=f.subarray(4,4+33);n[0]=0,n.set(r,1);let u=33,h=0;for(;u>1&&n[h]===0&&!(n[h+1]&128);--u,++h);if(n=n.subarray(h),n[0]&128||u>1&&n[0]===0&&!(n[1]&128))return 1;let b=f.subarray(6+33,6+33+33);b[0]=0,b.set(i,1);let _=33,w=0;for(;_>1&&b[w]===0&&!(b[w+1]&128);--_,++w);return b=b.subarray(w),b[0]&128||_>1&&b[0]===0&&!(b[1]&128)?1:(t.outputlen=6+u+_,f[0]=48,f[1]=t.outputlen-2,f[2]=2,f[3]=n.length,f.set(n,4),f[4+u]=2,f[5+u]=b.length,f.set(b,6+u),0)},signatureImport(t,e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return 1;const r=e[3];if(r===0||5+r>=e.length||e[4+r]!==2)return 1;const i=e[5+r];if(i===0||6+r+i!==e.length||e[4]&128||r>1&&e[4]===0&&!(e[5]&128)||e[r+6]&128||i>1&&e[r+6]===0&&!(e[r+7]&128))return 1;let f=e.subarray(4,4+r);if(f.length===33&&f[0]===0&&(f=f.subarray(1)),f.length>32)return 1;let n=e.subarray(6+r);if(n.length===33&&n[0]===0&&(n=n.slice(1)),n.length>32)throw new Error("S length is too long");let u=new ye(f);u.cmp(de.n)>=0&&(u=new ye(0));let h=new ye(e.subarray(6+r));return h.cmp(de.n)>=0&&(h=new ye(0)),t.set(u.toArrayLike(Uint8Array,"be",32),0),t.set(h.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(t,e,r,i,f){if(f){const h=f;f=b=>{const _=h(e,r,null,i,b);if(!(_ instanceof Uint8Array&&_.length===32))throw new Error("This is the way");return new ye(_)}}const n=new ye(r);if(n.cmp(de.n)>=0||n.isZero())return 1;let u;try{u=St.sign(e,r,{canonical:!0,k:f,pers:i})}catch{return 1}return t.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),t.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),t.recid=u.recoveryParam,0},ecdsaVerify(t,e,r){const i={r:t.subarray(0,32),s:t.subarray(32,64)},f=new ye(i.r),n=new ye(i.s);if(f.cmp(de.n)>=0||n.cmp(de.n)>=0)return 1;if(n.cmp(St.nh)===1||f.isZero()||n.isZero())return 3;const u=$t(r);if(u===null)return 2;const h=u.getPublic();return St.verify(e,i,h)?0:3},ecdsaRecover(t,e,r,i){const f={r:e.slice(0,32),s:e.slice(32,64)},n=new ye(f.r),u=new ye(f.s);if(n.cmp(de.n)>=0||u.cmp(de.n)>=0)return 1;if(n.isZero()||u.isZero())return 2;let h;try{h=St.recoverPubKey(i,f,r)}catch{return 2}return Yt(t,h),0},ecdh(t,e,r,i,f,n,u){const h=$t(e);if(h===null)return 1;const b=new ye(r);if(b.cmp(de.n)>=0||b.isZero())return 2;const _=h.getPublic().mul(b);if(f===void 0){const w=_.encode(null,!0),E=St.hash().update(w).digest();for(let P=0;P<32;++P)t[P]=E[P]}else{n||(n=new Uint8Array(32));const w=_.getX().toArray("be",32);for(let N=0;N<32;++N)n[N]=w[N];u||(u=new Uint8Array(32));const E=_.getY().toArray("be",32);for(let N=0;N<32;++N)u[N]=E[N];const P=f(n,u,i);if(!(P instanceof Uint8Array&&P.length===t.length))return 2;t.set(P)}return 0}},vs=oa(ps);const tt=hn(vs);var Se={},Vr={};Vr.byteLength=xs,Vr.toByteArray=ws,Vr.fromByteArray=Ss;for(var Et=[],st=[],ys=typeof Uint8Array<"u"?Uint8Array:Array,Ai="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",cr=0,gs=Ai.length;cr0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var i=r===e?0:4-r%4;return[r,i]}function xs(t){var e=Jn(t),r=e[0],i=e[1];return(r+i)*3/4-i}function ms(t,e,r){return(e+r)*3/4-r}function ws(t){var e,r=Jn(t),i=r[0],f=r[1],n=new ys(ms(t,i,f)),u=0,h=f>0?i-4:i,b;for(b=0;b>16&255,n[u++]=e>>8&255,n[u++]=e&255;return f===2&&(e=st[t.charCodeAt(b)]<<2|st[t.charCodeAt(b+1)]>>4,n[u++]=e&255),f===1&&(e=st[t.charCodeAt(b)]<<10|st[t.charCodeAt(b+1)]<<4|st[t.charCodeAt(b+2)]>>2,n[u++]=e>>8&255,n[u++]=e&255),n}function _s(t){return Et[t>>18&63]+Et[t>>12&63]+Et[t>>6&63]+Et[t&63]}function Ms(t,e,r){for(var i,f=[],n=e;nh?h:u+n));return i===1?(e=t[r-1],f.push(Et[e>>2]+Et[e<<4&63]+"==")):i===2&&(e=(t[r-2]<<8)+t[r-1],f.push(Et[e>>10]+Et[e>>4&63]+Et[e<<2&63]+"=")),f.join("")}var Ii={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */Ii.read=function(t,e,r,i,f){var n,u,h=f*8-i-1,b=(1<>1,w=-7,E=r?f-1:0,P=r?-1:1,F=t[e+E];for(E+=P,n=F&(1<<-w)-1,F>>=-w,w+=h;w>0;n=n*256+t[e+E],E+=P,w-=8);for(u=n&(1<<-w)-1,n>>=-w,w+=i;w>0;u=u*256+t[e+E],E+=P,w-=8);if(n===0)n=1-_;else{if(n===b)return u?NaN:(F?-1:1)*(1/0);u=u+Math.pow(2,i),n=n-_}return(F?-1:1)*u*Math.pow(2,n-i)},Ii.write=function(t,e,r,i,f,n){var u,h,b,_=n*8-f-1,w=(1<<_)-1,E=w>>1,P=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,F=i?0:n-1,N=i?1:-1,O=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(h=isNaN(e)?1:0,u=w):(u=Math.floor(Math.log(e)/Math.LN2),e*(b=Math.pow(2,-u))<1&&(u--,b*=2),u+E>=1?e+=P/b:e+=P*Math.pow(2,1-E),e*b>=2&&(u++,b/=2),u+E>=w?(h=0,u=w):u+E>=1?(h=(e*b-1)*Math.pow(2,f),u=u+E):(h=e*Math.pow(2,E-1)*Math.pow(2,f),u=0));f>=8;t[r+F]=h&255,F+=N,h/=256,f-=8);for(u=u<0;t[r+F]=u&255,F+=N,u/=256,_-=8);t[r+F-N]|=O*128};/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */(function(t){const e=Vr,r=Ii,i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=h,t.SlowBuffer=z,t.INSPECT_MAX_BYTES=50;const f=2147483647;t.kMaxLength=f,h.TYPED_ARRAY_SUPPORT=n(),!h.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 n(){try{const l=new Uint8Array(1),s={foo:function(){return 42}};return Object.setPrototypeOf(s,Uint8Array.prototype),Object.setPrototypeOf(l,s),l.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function u(l){if(l>f)throw new RangeError('The value "'+l+'" is invalid for option "size"');const s=new Uint8Array(l);return Object.setPrototypeOf(s,h.prototype),s}function h(l,s,d){if(typeof l=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(l)}return b(l,s,d)}h.poolSize=8192;function b(l,s,d){if(typeof l=="string")return P(l,s);if(ArrayBuffer.isView(l))return N(l);if(l==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l);if(ce(l,ArrayBuffer)||l&&ce(l.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ce(l,SharedArrayBuffer)||l&&ce(l.buffer,SharedArrayBuffer)))return O(l,s,d);if(typeof l=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const y=l.valueOf&&l.valueOf();if(y!=null&&y!==l)return h.from(y,s,d);const I=D(l);if(I)return I;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof l[Symbol.toPrimitive]=="function")return h.from(l[Symbol.toPrimitive]("string"),s,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l)}h.from=function(l,s,d){return b(l,s,d)},Object.setPrototypeOf(h.prototype,Uint8Array.prototype),Object.setPrototypeOf(h,Uint8Array);function _(l){if(typeof l!="number")throw new TypeError('"size" argument must be of type number');if(l<0)throw new RangeError('The value "'+l+'" is invalid for option "size"')}function w(l,s,d){return _(l),l<=0?u(l):s!==void 0?typeof d=="string"?u(l).fill(s,d):u(l).fill(s):u(l)}h.alloc=function(l,s,d){return w(l,s,d)};function E(l){return _(l),u(l<0?0:k(l)|0)}h.allocUnsafe=function(l){return E(l)},h.allocUnsafeSlow=function(l){return E(l)};function P(l,s){if((typeof s!="string"||s==="")&&(s="utf8"),!h.isEncoding(s))throw new TypeError("Unknown encoding: "+s);const d=j(l,s)|0;let y=u(d);const I=y.write(l,s);return I!==d&&(y=y.slice(0,I)),y}function F(l){const s=l.length<0?0:k(l.length)|0,d=u(s);for(let y=0;y=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return l|0}function z(l){return+l!=l&&(l=0),h.alloc(+l)}h.isBuffer=function(s){return s!=null&&s._isBuffer===!0&&s!==h.prototype},h.compare=function(s,d){if(ce(s,Uint8Array)&&(s=h.from(s,s.offset,s.byteLength)),ce(d,Uint8Array)&&(d=h.from(d,d.offset,d.byteLength)),!h.isBuffer(s)||!h.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(s===d)return 0;let y=s.length,I=d.length;for(let L=0,$=Math.min(y,I);L<$;++L)if(s[L]!==d[L]){y=s[L],I=d[L];break}return yI.length?(h.isBuffer($)||($=h.from($)),$.copy(I,L)):Uint8Array.prototype.set.call(I,$,L);else if(h.isBuffer($))$.copy(I,L);else throw new TypeError('"list" argument must be an Array of Buffers');L+=$.length}return I};function j(l,s){if(h.isBuffer(l))return l.length;if(ArrayBuffer.isView(l)||ce(l,ArrayBuffer))return l.byteLength;if(typeof l!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof l);const d=l.length,y=arguments.length>2&&arguments[2]===!0;if(!y&&d===0)return 0;let I=!1;for(;;)switch(s){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return ue(l).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return Ut(l).length;default:if(I)return y?-1:ue(l).length;s=(""+s).toLowerCase(),I=!0}}h.byteLength=j;function K(l,s,d){let y=!1;if((s===void 0||s<0)&&(s=0),s>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,s>>>=0,d<=s))return"";for(l||(l="utf8");;)switch(l){case"hex":return x(this,s,d);case"utf8":case"utf-8":return p(this,s,d);case"ascii":return B(this,s,d);case"latin1":case"binary":return C(this,s,d);case"base64":return c(this,s,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o(this,s,d);default:if(y)throw new TypeError("Unknown encoding: "+l);l=(l+"").toLowerCase(),y=!0}}h.prototype._isBuffer=!0;function Y(l,s,d){const y=l[s];l[s]=l[d],l[d]=y}h.prototype.swap16=function(){const s=this.length;if(s%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;dd&&(s+=" ... "),""},i&&(h.prototype[i]=h.prototype.inspect),h.prototype.compare=function(s,d,y,I,L){if(ce(s,Uint8Array)&&(s=h.from(s,s.offset,s.byteLength)),!h.isBuffer(s))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof s);if(d===void 0&&(d=0),y===void 0&&(y=s?s.length:0),I===void 0&&(I=0),L===void 0&&(L=this.length),d<0||y>s.length||I<0||L>this.length)throw new RangeError("out of range index");if(I>=L&&d>=y)return 0;if(I>=L)return-1;if(d>=y)return 1;if(d>>>=0,y>>>=0,I>>>=0,L>>>=0,this===s)return 0;let $=L-I,te=y-d;const _e=Math.min($,te),fe=this.slice(I,L),ae=s.slice(d,y);for(let pe=0;pe<_e;++pe)if(fe[pe]!==ae[pe]){$=fe[pe],te=ae[pe];break}return $2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,At(d)&&(d=I?0:l.length-1),d<0&&(d=l.length+d),d>=l.length){if(I)return-1;d=l.length-1}else if(d<0)if(I)d=0;else return-1;if(typeof s=="string"&&(s=h.from(s,y)),h.isBuffer(s))return s.length===0?-1:se(l,s,d,y,I);if(typeof s=="number")return s=s&255,typeof Uint8Array.prototype.indexOf=="function"?I?Uint8Array.prototype.indexOf.call(l,s,d):Uint8Array.prototype.lastIndexOf.call(l,s,d):se(l,[s],d,y,I);throw new TypeError("val must be string, number or Buffer")}function se(l,s,d,y,I){let L=1,$=l.length,te=s.length;if(y!==void 0&&(y=String(y).toLowerCase(),y==="ucs2"||y==="ucs-2"||y==="utf16le"||y==="utf-16le")){if(l.length<2||s.length<2)return-1;L=2,$/=2,te/=2,d/=2}function _e(ae,pe){return L===1?ae[pe]:ae.readUInt16BE(pe*L)}let fe;if(I){let ae=-1;for(fe=d;fe<$;fe++)if(_e(l,fe)===_e(s,ae===-1?0:fe-ae)){if(ae===-1&&(ae=fe),fe-ae+1===te)return ae*L}else ae!==-1&&(fe-=fe-ae),ae=-1}else for(d+te>$&&(d=$-te),fe=d;fe>=0;fe--){let ae=!0;for(let pe=0;peI&&(y=I)):y=I;const L=s.length;y>L/2&&(y=L/2);let $;for($=0;$>>0,isFinite(y)?(y=y>>>0,I===void 0&&(I="utf8")):(I=y,y=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const L=this.length-d;if((y===void 0||y>L)&&(y=L),s.length>0&&(y<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");I||(I="utf8");let $=!1;for(;;)switch(I){case"hex":return re(this,s,d,y);case"utf8":case"utf-8":return V(this,s,d,y);case"ascii":case"latin1":case"binary":return Me(this,s,d,y);case"base64":return A(this,s,d,y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a(this,s,d,y);default:if($)throw new TypeError("Unknown encoding: "+I);I=(""+I).toLowerCase(),$=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function c(l,s,d){return s===0&&d===l.length?e.fromByteArray(l):e.fromByteArray(l.slice(s,d))}function p(l,s,d){d=Math.min(l.length,d);const y=[];let I=s;for(;I239?4:L>223?3:L>191?2:1;if(I+te<=d){let _e,fe,ae,pe;switch(te){case 1:L<128&&($=L);break;case 2:_e=l[I+1],(_e&192)===128&&(pe=(L&31)<<6|_e&63,pe>127&&($=pe));break;case 3:_e=l[I+1],fe=l[I+2],(_e&192)===128&&(fe&192)===128&&(pe=(L&15)<<12|(_e&63)<<6|fe&63,pe>2047&&(pe<55296||pe>57343)&&($=pe));break;case 4:_e=l[I+1],fe=l[I+2],ae=l[I+3],(_e&192)===128&&(fe&192)===128&&(ae&192)===128&&(pe=(L&15)<<18|(_e&63)<<12|(fe&63)<<6|ae&63,pe>65535&&pe<1114112&&($=pe))}}$===null?($=65533,te=1):$>65535&&($-=65536,y.push($>>>10&1023|55296),$=56320|$&1023),y.push($),I+=te}return M(y)}const v=4096;function M(l){const s=l.length;if(s<=v)return String.fromCharCode.apply(String,l);let d="",y=0;for(;yy)&&(d=y);let I="";for(let L=s;Ly&&(s=y),d<0?(d+=y,d<0&&(d=0)):d>y&&(d=y),dd)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(s,d,y){s=s>>>0,d=d>>>0,y||g(s,d,this.length);let I=this[s],L=1,$=0;for(;++$>>0,d=d>>>0,y||g(s,d,this.length);let I=this[s+--d],L=1;for(;d>0&&(L*=256);)I+=this[s+--d]*L;return I},h.prototype.readUint8=h.prototype.readUInt8=function(s,d){return s=s>>>0,d||g(s,1,this.length),this[s]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(s,d){return s=s>>>0,d||g(s,2,this.length),this[s]|this[s+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(s,d){return s=s>>>0,d||g(s,2,this.length),this[s]<<8|this[s+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(s,d){return s=s>>>0,d||g(s,4,this.length),(this[s]|this[s+1]<<8|this[s+2]<<16)+this[s+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(s,d){return s=s>>>0,d||g(s,4,this.length),this[s]*16777216+(this[s+1]<<16|this[s+2]<<8|this[s+3])},h.prototype.readBigUInt64LE=le(function(s){s=s>>>0,U(s,"offset");const d=this[s],y=this[s+7];(d===void 0||y===void 0)&&G(s,this.length-8);const I=d+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24,L=this[++s]+this[++s]*2**8+this[++s]*2**16+y*2**24;return BigInt(I)+(BigInt(L)<>>0,U(s,"offset");const d=this[s],y=this[s+7];(d===void 0||y===void 0)&&G(s,this.length-8);const I=d*2**24+this[++s]*2**16+this[++s]*2**8+this[++s],L=this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+y;return(BigInt(I)<>>0,d=d>>>0,y||g(s,d,this.length);let I=this[s],L=1,$=0;for(;++$=L&&(I-=Math.pow(2,8*d)),I},h.prototype.readIntBE=function(s,d,y){s=s>>>0,d=d>>>0,y||g(s,d,this.length);let I=d,L=1,$=this[s+--I];for(;I>0&&(L*=256);)$+=this[s+--I]*L;return L*=128,$>=L&&($-=Math.pow(2,8*d)),$},h.prototype.readInt8=function(s,d){return s=s>>>0,d||g(s,1,this.length),this[s]&128?(255-this[s]+1)*-1:this[s]},h.prototype.readInt16LE=function(s,d){s=s>>>0,d||g(s,2,this.length);const y=this[s]|this[s+1]<<8;return y&32768?y|4294901760:y},h.prototype.readInt16BE=function(s,d){s=s>>>0,d||g(s,2,this.length);const y=this[s+1]|this[s]<<8;return y&32768?y|4294901760:y},h.prototype.readInt32LE=function(s,d){return s=s>>>0,d||g(s,4,this.length),this[s]|this[s+1]<<8|this[s+2]<<16|this[s+3]<<24},h.prototype.readInt32BE=function(s,d){return s=s>>>0,d||g(s,4,this.length),this[s]<<24|this[s+1]<<16|this[s+2]<<8|this[s+3]},h.prototype.readBigInt64LE=le(function(s){s=s>>>0,U(s,"offset");const d=this[s],y=this[s+7];(d===void 0||y===void 0)&&G(s,this.length-8);const I=this[s+4]+this[s+5]*2**8+this[s+6]*2**16+(y<<24);return(BigInt(I)<>>0,U(s,"offset");const d=this[s],y=this[s+7];(d===void 0||y===void 0)&&G(s,this.length-8);const I=(d<<24)+this[++s]*2**16+this[++s]*2**8+this[++s];return(BigInt(I)<>>0,d||g(s,4,this.length),r.read(this,s,!0,23,4)},h.prototype.readFloatBE=function(s,d){return s=s>>>0,d||g(s,4,this.length),r.read(this,s,!1,23,4)},h.prototype.readDoubleLE=function(s,d){return s=s>>>0,d||g(s,8,this.length),r.read(this,s,!0,52,8)},h.prototype.readDoubleBE=function(s,d){return s=s>>>0,d||g(s,8,this.length),r.read(this,s,!1,52,8)};function H(l,s,d,y,I,L){if(!h.isBuffer(l))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>I||sl.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(s,d,y,I){if(s=+s,d=d>>>0,y=y>>>0,!I){const te=Math.pow(2,8*y)-1;H(this,s,d,y,te,0)}let L=1,$=0;for(this[d]=s&255;++$>>0,y=y>>>0,!I){const te=Math.pow(2,8*y)-1;H(this,s,d,y,te,0)}let L=y-1,$=1;for(this[d+L]=s&255;--L>=0&&($*=256);)this[d+L]=s/$&255;return d+y},h.prototype.writeUint8=h.prototype.writeUInt8=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,1,255,0),this[d]=s&255,d+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,2,65535,0),this[d]=s&255,this[d+1]=s>>>8,d+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,2,65535,0),this[d]=s>>>8,this[d+1]=s&255,d+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,4,4294967295,0),this[d+3]=s>>>24,this[d+2]=s>>>16,this[d+1]=s>>>8,this[d]=s&255,d+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,4,4294967295,0),this[d]=s>>>24,this[d+1]=s>>>16,this[d+2]=s>>>8,this[d+3]=s&255,d+4};function Z(l,s,d,y,I){m(s,y,I,l,d,7);let L=Number(s&BigInt(4294967295));l[d++]=L,L=L>>8,l[d++]=L,L=L>>8,l[d++]=L,L=L>>8,l[d++]=L;let $=Number(s>>BigInt(32)&BigInt(4294967295));return l[d++]=$,$=$>>8,l[d++]=$,$=$>>8,l[d++]=$,$=$>>8,l[d++]=$,d}function J(l,s,d,y,I){m(s,y,I,l,d,7);let L=Number(s&BigInt(4294967295));l[d+7]=L,L=L>>8,l[d+6]=L,L=L>>8,l[d+5]=L,L=L>>8,l[d+4]=L;let $=Number(s>>BigInt(32)&BigInt(4294967295));return l[d+3]=$,$=$>>8,l[d+2]=$,$=$>>8,l[d+1]=$,$=$>>8,l[d]=$,d+8}h.prototype.writeBigUInt64LE=le(function(s,d=0){return Z(this,s,d,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=le(function(s,d=0){return J(this,s,d,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(s,d,y,I){if(s=+s,d=d>>>0,!I){const _e=Math.pow(2,8*y-1);H(this,s,d,y,_e-1,-_e)}let L=0,$=1,te=0;for(this[d]=s&255;++L>0)-te&255;return d+y},h.prototype.writeIntBE=function(s,d,y,I){if(s=+s,d=d>>>0,!I){const _e=Math.pow(2,8*y-1);H(this,s,d,y,_e-1,-_e)}let L=y-1,$=1,te=0;for(this[d+L]=s&255;--L>=0&&($*=256);)s<0&&te===0&&this[d+L+1]!==0&&(te=1),this[d+L]=(s/$>>0)-te&255;return d+y},h.prototype.writeInt8=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,1,127,-128),s<0&&(s=255+s+1),this[d]=s&255,d+1},h.prototype.writeInt16LE=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,2,32767,-32768),this[d]=s&255,this[d+1]=s>>>8,d+2},h.prototype.writeInt16BE=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,2,32767,-32768),this[d]=s>>>8,this[d+1]=s&255,d+2},h.prototype.writeInt32LE=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,4,2147483647,-2147483648),this[d]=s&255,this[d+1]=s>>>8,this[d+2]=s>>>16,this[d+3]=s>>>24,d+4},h.prototype.writeInt32BE=function(s,d,y){return s=+s,d=d>>>0,y||H(this,s,d,4,2147483647,-2147483648),s<0&&(s=4294967295+s+1),this[d]=s>>>24,this[d+1]=s>>>16,this[d+2]=s>>>8,this[d+3]=s&255,d+4},h.prototype.writeBigInt64LE=le(function(s,d=0){return Z(this,s,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=le(function(s,d=0){return J(this,s,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ie(l,s,d,y,I,L){if(d+y>l.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function R(l,s,d,y,I){return s=+s,d=d>>>0,I||ie(l,s,d,4),r.write(l,s,d,y,23,4),d+4}h.prototype.writeFloatLE=function(s,d,y){return R(this,s,d,!0,y)},h.prototype.writeFloatBE=function(s,d,y){return R(this,s,d,!1,y)};function T(l,s,d,y,I){return s=+s,d=d>>>0,I||ie(l,s,d,8),r.write(l,s,d,y,52,8),d+8}h.prototype.writeDoubleLE=function(s,d,y){return T(this,s,d,!0,y)},h.prototype.writeDoubleBE=function(s,d,y){return T(this,s,d,!1,y)},h.prototype.copy=function(s,d,y,I){if(!h.isBuffer(s))throw new TypeError("argument should be a Buffer");if(y||(y=0),!I&&I!==0&&(I=this.length),d>=s.length&&(d=s.length),d||(d=0),I>0&&I=this.length)throw new RangeError("Index out of range");if(I<0)throw new RangeError("sourceEnd out of bounds");I>this.length&&(I=this.length),s.length-d>>0,y=y===void 0?this.length:y>>>0,s||(s=0);let L;if(typeof s=="number")for(L=d;L2**32?I=X(String(d)):typeof d=="bigint"&&(I=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(I=X(I)),I+="n"),y+=` It must be ${s}. Received ${I}`,y},RangeError);function X(l){let s="",d=l.length;const y=l[0]==="-"?1:0;for(;d>=y+4;d-=3)s=`_${l.slice(d-3,d)}${s}`;return`${l.slice(0,d)}${s}`}function S(l,s,d){U(s,"offset"),(l[s]===void 0||l[s+d]===void 0)&&G(s,l.length-(d+1))}function m(l,s,d,y,I,L){if(l>d||l3?s===0||s===BigInt(0)?te=`>= 0${$} and < 2${$} ** ${(L+1)*8}${$}`:te=`>= -(2${$} ** ${(L+1)*8-1}${$}) and < 2 ** ${(L+1)*8-1}${$}`:te=`>= ${s}${$} and <= ${d}${$}`,new q.ERR_OUT_OF_RANGE("value",te,l)}S(y,I,L)}function U(l,s){if(typeof l!="number")throw new q.ERR_INVALID_ARG_TYPE(s,"number",l)}function G(l,s,d){throw Math.floor(l)!==l?(U(l,d),new q.ERR_OUT_OF_RANGE(d||"offset","an integer",l)):s<0?new q.ERR_BUFFER_OUT_OF_BOUNDS:new q.ERR_OUT_OF_RANGE(d||"offset",`>= ${d?1:0} and <= ${s}`,l)}const ne=/[^+/0-9A-Za-z-_]/g;function ee(l){if(l=l.split("=")[0],l=l.trim().replace(ne,""),l.length<2)return"";for(;l.length%4!==0;)l=l+"=";return l}function ue(l,s){s=s||1/0;let d;const y=l.length;let I=null;const L=[];for(let $=0;$55295&&d<57344){if(!I){if(d>56319){(s-=3)>-1&&L.push(239,191,189);continue}else if($+1===y){(s-=3)>-1&&L.push(239,191,189);continue}I=d;continue}if(d<56320){(s-=3)>-1&&L.push(239,191,189),I=d;continue}d=(I-55296<<10|d-56320)+65536}else I&&(s-=3)>-1&&L.push(239,191,189);if(I=null,d<128){if((s-=1)<0)break;L.push(d)}else if(d<2048){if((s-=2)<0)break;L.push(d>>6|192,d&63|128)}else if(d<65536){if((s-=3)<0)break;L.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((s-=4)<0)break;L.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return L}function ve(l){const s=[];for(let d=0;d>8,I=d%256,L.push(I),L.push(y);return L}function Ut(l){return e.toByteArray(ee(l))}function xe(l,s,d,y){let I;for(I=0;I=s.length||I>=l.length);++I)s[I+d]=l[I];return I}function ce(l,s){return l instanceof s||l!=null&&l.constructor!=null&&l.constructor.name!=null&&l.constructor.name===s.name}function At(l){return l!==l}const we=function(){const l="0123456789abcdef",s=new Array(256);for(let d=0;d<16;++d){const y=d*16;for(let I=0;I<16;++I)s[y+I]=l[d]+l[I]}return s}();function le(l){return typeof BigInt>"u"?It:l}function It(){throw new Error("BigInt not supported")}})(Se);const Es=(t,e,r="tsp",i=0)=>{const f=pr.toWords(Se.Buffer.concat([t,e]));return f.unshift(i),pr.encode(r,f,116)},Xn=(t,e="tsp")=>{const{prefix:r,words:i}=pr.decode(t,1023);if(r!=e)throw new Error("Invalid prefix!");if(i.shift()!=0)throw new Error("Invalid version!");const n=Se.Buffer.from(pr.fromWords(i));return{scanKey:n.slice(0,33),spendKey:n.slice(33)}};var Bi={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh */(function(t,e){var r=Se,i=r.Buffer;function f(u,h){for(var b in u)h[b]=u[b]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(f(r,e),e.Buffer=n);function n(u,h,b){return i(u,h,b)}n.prototype=Object.create(i.prototype),f(i,n),n.from=function(u,h,b){if(typeof u=="number")throw new TypeError("Argument must not be a number");return i(u,h,b)},n.alloc=function(u,h,b){if(typeof u!="number")throw new TypeError("Argument must be a number");var _=i(u);return h!==void 0?typeof b=="string"?_.fill(h,b):_.fill(h):_.fill(0),_},n.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return i(u)},n.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(u)}})(Bi,Bi.exports);var bt=Bi.exports,Ri={exports:{}},Qn=qt.EventEmitter,Pi,ef;function As(){if(ef)return Pi;ef=1;function t(N,O){var D=Object.keys(N);if(Object.getOwnPropertySymbols){var k=Object.getOwnPropertySymbols(N);O&&(k=k.filter(function(z){return Object.getOwnPropertyDescriptor(N,z).enumerable})),D.push.apply(D,k)}return D}function e(N){for(var O=1;O0?this.tail.next=k:this.head=k,this.tail=k,++this.length}},{key:"unshift",value:function(D){var k={data:D,next:this.head};this.length===0&&(this.tail=k),this.head=k,++this.length}},{key:"shift",value:function(){if(this.length!==0){var D=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,D}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(D){if(this.length===0)return"";for(var k=this.head,z=""+k.data;k=k.next;)z+=D+k.data;return z}},{key:"concat",value:function(D){if(this.length===0)return _.alloc(0);for(var k=_.allocUnsafe(D>>>0),z=this.head,j=0;z;)F(z.data,k,j),j+=z.data.length,z=z.next;return k}},{key:"consume",value:function(D,k){var z;return DK.length?K.length:D;if(Y===K.length?j+=K:j+=K.slice(0,D),D-=Y,D===0){Y===K.length?(++z,k.next?this.head=k.next:this.head=this.tail=null):(this.head=k,k.data=K.slice(Y));break}++z}return this.length-=z,j}},{key:"_getBuffer",value:function(D){var k=_.allocUnsafe(D),z=this.head,j=1;for(z.data.copy(k),D-=z.data.length;z=z.next;){var K=z.data,Y=D>K.length?K.length:D;if(K.copy(k,k.length-D,0,Y),D-=Y,D===0){Y===K.length?(++j,z.next?this.head=z.next:this.head=this.tail=null):(this.head=z,z.data=K.slice(Y));break}++j}return this.length-=j,k}},{key:P,value:function(D,k){return E(this,e(e({},k),{},{depth:0,customInspect:!1}))}}]),N}(),Pi}function Is(t,e){var r=this,i=this._readableState&&this._readableState.destroyed,f=this._writableState&&this._writableState.destroyed;return i||f?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(Ti,this,t)):process.nextTick(Ti,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(n){!e&&n?r._writableState?r._writableState.errorEmitted?process.nextTick(Yr,r):(r._writableState.errorEmitted=!0,process.nextTick(tf,r,n)):process.nextTick(tf,r,n):e?(process.nextTick(Yr,r),e(n)):process.nextTick(Yr,r)}),this)}function tf(t,e){Ti(t,e),Yr(t)}function Yr(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function Bs(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Ti(t,e){t.emit("error",e)}function Rs(t,e){var r=t._readableState,i=t._writableState;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}var rf={destroy:Is,undestroy:Bs,errorOrDestroy:Rs},Gt={};function Ps(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var nf={};function ot(t,e,r){r||(r=Error);function i(n,u,h){return typeof e=="string"?e:e(n,u,h)}var f=function(n){Ps(u,n);function u(h,b,_){return n.call(this,i(h,b,_))||this}return u}(r);f.prototype.name=r.name,f.prototype.code=t,nf[t]=f}function ff(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(i){return String(i)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:r===2?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}else return"of ".concat(e," ").concat(String(t))}function Ts(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function Cs(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function Ns(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}ot("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),ot("ERR_INVALID_ARG_TYPE",function(t,e,r){var i;typeof e=="string"&&Ts(e,"not ")?(i="must not be",e=e.replace(/^not /,"")):i="must be";var f;if(Cs(t," argument"))f="The ".concat(t," ").concat(i," ").concat(ff(e,"type"));else{var n=Ns(t,".")?"property":"argument";f='The "'.concat(t,'" ').concat(n," ").concat(i," ").concat(ff(e,"type"))}return f+=". Received type ".concat(typeof r),f},TypeError),ot("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),ot("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),ot("ERR_STREAM_PREMATURE_CLOSE","Premature close"),ot("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),ot("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),ot("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),ot("ERR_STREAM_WRITE_AFTER_END","write after end"),ot("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),ot("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),ot("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Gt.codes=nf;var Fs=Gt.codes.ERR_INVALID_OPT_VALUE;function Ls(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Os(t,e,r,i){var f=Ls(e,i,r);if(f!=null){if(!(isFinite(f)&&Math.floor(f)===f)||f<0){var n=i?r:"highWaterMark";throw new Fs(n,f)}return Math.floor(f)}return t.objectMode?16:16*1024}var af={getHighWaterMark:Os},$s=ks;function ks(t,e){if(Ci("noDeprecation"))return t;var r=!1;function i(){if(!r){if(Ci("throwDeprecation"))throw new Error(e);Ci("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}return i}function Ci(t){try{if(!ht.localStorage)return!1}catch{return!1}var e=ht.localStorage[t];return e==null?!1:String(e).toLowerCase()==="true"}var Ni,sf;function of(){if(sf)return Ni;sf=1,Ni=re;function t(R){var T=this;this.next=null,this.entry=null,this.finish=function(){ie(T,R)}}var e;re.WritableState=Q;var r={deprecate:$s},i=Qn,f=Se.Buffer,n=(typeof ht<"u"?ht:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function u(R){return f.from(R)}function h(R){return f.isBuffer(R)||R instanceof n}var b=rf,_=af,w=_.getHighWaterMark,E=Gt.codes,P=E.ERR_INVALID_ARG_TYPE,F=E.ERR_METHOD_NOT_IMPLEMENTED,N=E.ERR_MULTIPLE_CALLBACK,O=E.ERR_STREAM_CANNOT_PIPE,D=E.ERR_STREAM_DESTROYED,k=E.ERR_STREAM_NULL_VALUES,z=E.ERR_STREAM_WRITE_AFTER_END,j=E.ERR_UNKNOWN_ENCODING,K=b.errorOrDestroy;Ae(re,i);function Y(){}function Q(R,T,q){e=e||ur(),R=R||{},typeof q!="boolean"&&(q=T instanceof e),this.objectMode=!!R.objectMode,q&&(this.objectMode=this.objectMode||!!R.writableObjectMode),this.highWaterMark=w(this,R,"writableHighWaterMark",q),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var W=R.decodeStrings===!1;this.decodeStrings=!W,this.defaultEncoding=R.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(X){M(T,X)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=R.emitClose!==!1,this.autoDestroy=!!R.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}Q.prototype.getBuffer=function(){for(var T=this.bufferedRequest,q=[];T;)q.push(T),T=T.next;return q},function(){try{Object.defineProperty(Q.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var se;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(se=Function.prototype[Symbol.hasInstance],Object.defineProperty(re,Symbol.hasInstance,{value:function(T){return se.call(this,T)?!0:this!==re?!1:T&&T._writableState instanceof Q}})):se=function(T){return T instanceof this};function re(R){e=e||ur();var T=this instanceof e;if(!T&&!se.call(re,this))return new re(R);this._writableState=new Q(R,this,T),this.writable=!0,R&&(typeof R.write=="function"&&(this._write=R.write),typeof R.writev=="function"&&(this._writev=R.writev),typeof R.destroy=="function"&&(this._destroy=R.destroy),typeof R.final=="function"&&(this._final=R.final)),i.call(this)}re.prototype.pipe=function(){K(this,new O)};function V(R,T){var q=new z;K(R,q),process.nextTick(T,q)}function Me(R,T,q,W){var X;return q===null?X=new k:typeof q!="string"&&!T.objectMode&&(X=new P("chunk",["string","Buffer"],q)),X?(K(R,X),process.nextTick(W,X),!1):!0}re.prototype.write=function(R,T,q){var W=this._writableState,X=!1,S=!W.objectMode&&h(R);return S&&!f.isBuffer(R)&&(R=u(R)),typeof T=="function"&&(q=T,T=null),S?T="buffer":T||(T=W.defaultEncoding),typeof q!="function"&&(q=Y),W.ending?V(this,q):(S||Me(this,W,R,q))&&(W.pendingcb++,X=a(this,W,S,R,T,q)),X},re.prototype.cork=function(){this._writableState.corked++},re.prototype.uncork=function(){var R=this._writableState;R.corked&&(R.corked--,!R.writing&&!R.corked&&!R.bufferProcessing&&R.bufferedRequest&&x(this,R))},re.prototype.setDefaultEncoding=function(T){if(typeof T=="string"&&(T=T.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((T+"").toLowerCase())>-1))throw new j(T);return this._writableState.defaultEncoding=T,this},Object.defineProperty(re.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function A(R,T,q){return!R.objectMode&&R.decodeStrings!==!1&&typeof T=="string"&&(T=f.from(T,q)),T}Object.defineProperty(re.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function a(R,T,q,W,X,S){if(!q){var m=A(T,W,X);W!==m&&(q=!0,X="buffer",W=m)}var U=T.objectMode?1:W.length;T.length+=U;var G=T.length>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function qs(t,e,r){var i=e.length-1;if(i=0?(f>0&&(t.lastNeed=f-1),f):--i=0?(f>0&&(t.lastNeed=f-2),f):--i=0?(f>0&&(f===2?f=0:t.lastNeed=f-3),f):0))}function zs(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"�"}}function Ks(t){var e=this.lastTotal-this.lastNeed,r=zs(this,t);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function Hs(t,e){var r=qs(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)}function Ws(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e}function js(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function Vs(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function Ys(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function Gs(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function Zs(t){return t.toString(this.encoding)}function Js(t){return t&&t.length?this.write(t):""}var cf=Gt.codes.ERR_STREAM_PREMATURE_CLOSE;function Xs(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,i=new Array(r),f=0;f0)if(typeof m!="string"&&!ee.objectMode&&Object.getPrototypeOf(m)!==i.prototype&&(m=n(m)),G)ee.endEmitted?Y(S,new k):A(S,ee,m,!0);else if(ee.ended)Y(S,new O);else{if(ee.destroyed)return!1;ee.reading=!1,ee.decoder&&!U?(m=ee.decoder.write(m),ee.objectMode||m.length!==0?A(S,ee,m,!1):x(S,ee)):A(S,ee,m,!1)}else G||(ee.reading=!1,x(S,ee))}return!ee.ended&&(ee.length=c?S=c:(S--,S|=S>>>1,S|=S>>>2,S|=S>>>4,S|=S>>>8,S|=S>>>16,S++),S}function v(S,m){return S<=0||m.length===0&&m.ended?0:m.objectMode?1:S!==S?m.flowing&&m.length?m.buffer.head.data.length:m.length:(S>m.highWaterMark&&(m.highWaterMark=p(S)),S<=m.length?S:m.ended?m.length:(m.needReadable=!0,0))}V.prototype.read=function(S){b("read",S),S=parseInt(S,10);var m=this._readableState,U=S;if(S!==0&&(m.emittedReadable=!1),S===0&&m.needReadable&&((m.highWaterMark!==0?m.length>=m.highWaterMark:m.length>0)||m.ended))return b("read: emitReadable",m.length,m.ended),m.length===0&&m.ended?q(this):B(this),null;if(S=v(S,m),S===0&&m.ended)return m.length===0&&q(this),null;var G=m.needReadable;b("need readable",G),(m.length===0||m.length-S0?ne=T(S,m):ne=null,ne===null?(m.needReadable=m.length<=m.highWaterMark,S=0):(m.length-=S,m.awaitDrain=0),m.length===0&&(m.ended||(m.needReadable=!0),U!==S&&m.ended&&q(this)),ne!==null&&this.emit("data",ne),ne};function M(S,m){if(b("onEofChunk"),!m.ended){if(m.decoder){var U=m.decoder.end();U&&U.length&&(m.buffer.push(U),m.length+=m.objectMode?1:U.length)}m.ended=!0,m.sync?B(S):(m.needReadable=!1,m.emittedReadable||(m.emittedReadable=!0,C(S)))}}function B(S){var m=S._readableState;b("emitReadable",m.needReadable,m.emittedReadable),m.needReadable=!1,m.emittedReadable||(b("emitReadable",m.flowing),m.emittedReadable=!0,process.nextTick(C,S))}function C(S){var m=S._readableState;b("emitReadable_",m.destroyed,m.length,m.ended),!m.destroyed&&(m.length||m.ended)&&(S.emit("readable"),m.emittedReadable=!1),m.needReadable=!m.flowing&&!m.ended&&m.length<=m.highWaterMark,R(S)}function x(S,m){m.readingMore||(m.readingMore=!0,process.nextTick(o,S,m))}function o(S,m){for(;!m.reading&&!m.ended&&(m.length1&&X(G.pipes,S)!==-1)&&!Ut&&(b("false write response, pause",G.awaitDrain),G.awaitDrain++),U.pause())}function At(l){b("onerror",l),It(),S.removeListener("error",At),e(S,"error")===0&&Y(S,l)}se(S,"error",At);function we(){S.removeListener("finish",le),It()}S.once("close",we);function le(){b("onfinish"),S.removeListener("close",we),It()}S.once("finish",le);function It(){b("unpipe"),U.unpipe(S)}return S.emit("pipe",U),G.flowing||(b("pipe resume"),U.resume()),S};function g(S){return function(){var U=S._readableState;b("pipeOnDrain",U.awaitDrain),U.awaitDrain&&U.awaitDrain--,U.awaitDrain===0&&e(S,"data")&&(U.flowing=!0,R(S))}}V.prototype.unpipe=function(S){var m=this._readableState,U={hasUnpiped:!1};if(m.pipesCount===0)return this;if(m.pipesCount===1)return S&&S!==m.pipes?this:(S||(S=m.pipes),m.pipes=null,m.pipesCount=0,m.flowing=!1,S&&S.emit("unpipe",this,U),this);if(!S){var G=m.pipes,ne=m.pipesCount;m.pipes=null,m.pipesCount=0,m.flowing=!1;for(var ee=0;ee0,G.flowing!==!1&&this.resume()):S==="readable"&&!G.endEmitted&&!G.readableListening&&(G.readableListening=G.needReadable=!0,G.flowing=!1,G.emittedReadable=!1,b("on readable",G.length,G.reading),G.length?B(this):G.reading||process.nextTick(Z,this)),U},V.prototype.addListener=V.prototype.on,V.prototype.removeListener=function(S,m){var U=r.prototype.removeListener.call(this,S,m);return S==="readable"&&process.nextTick(H,this),U},V.prototype.removeAllListeners=function(S){var m=r.prototype.removeAllListeners.apply(this,arguments);return(S==="readable"||S===void 0)&&process.nextTick(H,this),m};function H(S){var m=S._readableState;m.readableListening=S.listenerCount("readable")>0,m.resumeScheduled&&!m.paused?m.flowing=!0:S.listenerCount("data")>0&&S.resume()}function Z(S){b("readable nexttick read 0"),S.read(0)}V.prototype.resume=function(){var S=this._readableState;return S.flowing||(b("resume"),S.flowing=!S.readableListening,J(this,S)),S.paused=!1,this};function J(S,m){m.resumeScheduled||(m.resumeScheduled=!0,process.nextTick(ie,S,m))}function ie(S,m){b("resume",m.reading),m.reading||S.read(0),m.resumeScheduled=!1,S.emit("resume"),R(S),m.flowing&&!m.reading&&S.read(0)}V.prototype.pause=function(){return b("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(b("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function R(S){var m=S._readableState;for(b("flow",m.flowing);m.flowing&&S.read()!==null;);}V.prototype.wrap=function(S){var m=this,U=this._readableState,G=!1;S.on("end",function(){if(b("wrapped end"),U.decoder&&!U.ended){var ue=U.decoder.end();ue&&ue.length&&m.push(ue)}m.push(null)}),S.on("data",function(ue){if(b("wrapped data"),U.decoder&&(ue=U.decoder.write(ue)),!(U.objectMode&&ue==null)&&!(!U.objectMode&&(!ue||!ue.length))){var ve=m.push(ue);ve||(G=!0,S.pause())}});for(var ne in S)this[ne]===void 0&&typeof S[ne]=="function"&&(this[ne]=function(ve){return function(){return S[ve].apply(S,arguments)}}(ne));for(var ee=0;ee=m.length?(m.decoder?U=m.buffer.join(""):m.buffer.length===1?U=m.buffer.first():U=m.buffer.concat(m.length),m.buffer.clear()):U=m.buffer.consume(S,m.decoder),U}function q(S){var m=S._readableState;b("endReadable",m.endEmitted),m.endEmitted||(m.ended=!0,process.nextTick(W,m,S))}function W(S,m){if(b("endReadableNT",S.endEmitted,S.length),!S.endEmitted&&S.length===0&&(S.endEmitted=!0,m.readable=!1,m.emit("end"),S.autoDestroy)){var U=m._writableState;(!U||U.autoDestroy&&U.finished)&&m.destroy()}}typeof Symbol=="function"&&(V.from=function(S,m){return K===void 0&&(K=ro()),K(V,S,m)});function X(S,m){for(var U=0,G=S.length;U0;return po(u,b,_,function(w){f||(f=w),w&&n.forEach(_f),!b&&(n.forEach(_f),i(f))})});return e.reduce(vo)}var xo=go;(function(t,e){e=t.exports=vf(),e.Stream=e,e.Readable=e,e.Writable=of(),e.Duplex=ur(),e.Transform=yf,e.PassThrough=ho,e.finished=$i,e.pipeline=xo})(Ri,Ri.exports);var mo=Ri.exports,Xr=bt.Buffer,Mf=mo.Transform,wo=Ae;function _o(t,e){if(!Xr.isBuffer(t)&&typeof t!="string")throw new TypeError(e+" must be a string or a buffer")}function kt(t){Mf.call(this),this._block=Xr.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}wo(kt,Mf),kt.prototype._transform=function(t,e,r){var i=null;try{this.update(t,e)}catch(f){i=f}r(i)},kt.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(r){e=r}t(e)},kt.prototype.update=function(t,e){if(_o(t,"Data"),this._finalized)throw new Error("Digest already called");Xr.isBuffer(t)||(t=Xr.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var f=this._blockOffset;f0;++n)this._length[n]+=u,u=this._length[n]/4294967296|0,u>0&&(this._length[n]-=4294967296*u);return this},kt.prototype._update=function(){throw new Error("_update is not implemented")},kt.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();t!==void 0&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},kt.prototype._digest=function(){throw new Error("_digest is not implemented")};var Sf=kt,Mo=Ae,Ef=Sf,So=bt.Buffer,Eo=new Array(16);function Qr(){Ef.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}Mo(Qr,Ef),Qr.prototype._update=function(){for(var t=Eo,e=0;e<16;++e)t[e]=this._block.readInt32LE(e*4);var r=this._a,i=this._b,f=this._c,n=this._d;r=Ge(r,i,f,n,t[0],3614090360,7),n=Ge(n,r,i,f,t[1],3905402710,12),f=Ge(f,n,r,i,t[2],606105819,17),i=Ge(i,f,n,r,t[3],3250441966,22),r=Ge(r,i,f,n,t[4],4118548399,7),n=Ge(n,r,i,f,t[5],1200080426,12),f=Ge(f,n,r,i,t[6],2821735955,17),i=Ge(i,f,n,r,t[7],4249261313,22),r=Ge(r,i,f,n,t[8],1770035416,7),n=Ge(n,r,i,f,t[9],2336552879,12),f=Ge(f,n,r,i,t[10],4294925233,17),i=Ge(i,f,n,r,t[11],2304563134,22),r=Ge(r,i,f,n,t[12],1804603682,7),n=Ge(n,r,i,f,t[13],4254626195,12),f=Ge(f,n,r,i,t[14],2792965006,17),i=Ge(i,f,n,r,t[15],1236535329,22),r=Ze(r,i,f,n,t[1],4129170786,5),n=Ze(n,r,i,f,t[6],3225465664,9),f=Ze(f,n,r,i,t[11],643717713,14),i=Ze(i,f,n,r,t[0],3921069994,20),r=Ze(r,i,f,n,t[5],3593408605,5),n=Ze(n,r,i,f,t[10],38016083,9),f=Ze(f,n,r,i,t[15],3634488961,14),i=Ze(i,f,n,r,t[4],3889429448,20),r=Ze(r,i,f,n,t[9],568446438,5),n=Ze(n,r,i,f,t[14],3275163606,9),f=Ze(f,n,r,i,t[3],4107603335,14),i=Ze(i,f,n,r,t[8],1163531501,20),r=Ze(r,i,f,n,t[13],2850285829,5),n=Ze(n,r,i,f,t[2],4243563512,9),f=Ze(f,n,r,i,t[7],1735328473,14),i=Ze(i,f,n,r,t[12],2368359562,20),r=Je(r,i,f,n,t[5],4294588738,4),n=Je(n,r,i,f,t[8],2272392833,11),f=Je(f,n,r,i,t[11],1839030562,16),i=Je(i,f,n,r,t[14],4259657740,23),r=Je(r,i,f,n,t[1],2763975236,4),n=Je(n,r,i,f,t[4],1272893353,11),f=Je(f,n,r,i,t[7],4139469664,16),i=Je(i,f,n,r,t[10],3200236656,23),r=Je(r,i,f,n,t[13],681279174,4),n=Je(n,r,i,f,t[0],3936430074,11),f=Je(f,n,r,i,t[3],3572445317,16),i=Je(i,f,n,r,t[6],76029189,23),r=Je(r,i,f,n,t[9],3654602809,4),n=Je(n,r,i,f,t[12],3873151461,11),f=Je(f,n,r,i,t[15],530742520,16),i=Je(i,f,n,r,t[2],3299628645,23),r=Xe(r,i,f,n,t[0],4096336452,6),n=Xe(n,r,i,f,t[7],1126891415,10),f=Xe(f,n,r,i,t[14],2878612391,15),i=Xe(i,f,n,r,t[5],4237533241,21),r=Xe(r,i,f,n,t[12],1700485571,6),n=Xe(n,r,i,f,t[3],2399980690,10),f=Xe(f,n,r,i,t[10],4293915773,15),i=Xe(i,f,n,r,t[1],2240044497,21),r=Xe(r,i,f,n,t[8],1873313359,6),n=Xe(n,r,i,f,t[15],4264355552,10),f=Xe(f,n,r,i,t[6],2734768916,15),i=Xe(i,f,n,r,t[13],1309151649,21),r=Xe(r,i,f,n,t[4],4149444226,6),n=Xe(n,r,i,f,t[11],3174756917,10),f=Xe(f,n,r,i,t[2],718787259,15),i=Xe(i,f,n,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+f|0,this._d=this._d+n|0},Qr.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=So.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t};function ei(t,e){return t<>>32-e}function Ge(t,e,r,i,f,n,u){return ei(t+(e&r|~e&i)+f+n|0,u)+e|0}function Ze(t,e,r,i,f,n,u){return ei(t+(e&i|r&~i)+f+n|0,u)+e|0}function Je(t,e,r,i,f,n,u){return ei(t+(e^r^i)+f+n|0,u)+e|0}function Xe(t,e,r,i,f,n,u){return ei(t+(r^(e|~i))+f+n|0,u)+e|0}var Ao=Qr,zi=Se.Buffer,Io=Ae,Af=Sf,Bo=new Array(16),_r=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Mr=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Sr=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Er=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],Ar=[0,1518500249,1859775393,2400959708,2840853838],Ir=[1352829926,1548603684,1836072691,2053994217,0];function ti(){Af.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}Io(ti,Af),ti.prototype._update=function(){for(var t=Bo,e=0;e<16;++e)t[e]=this._block.readInt32LE(e*4);for(var r=this._a|0,i=this._b|0,f=this._c|0,n=this._d|0,u=this._e|0,h=this._a|0,b=this._b|0,_=this._c|0,w=this._d|0,E=this._e|0,P=0;P<80;P+=1){var F,N;P<16?(F=If(r,i,f,n,u,t[_r[P]],Ar[0],Sr[P]),N=Tf(h,b,_,w,E,t[Mr[P]],Ir[0],Er[P])):P<32?(F=Bf(r,i,f,n,u,t[_r[P]],Ar[1],Sr[P]),N=Pf(h,b,_,w,E,t[Mr[P]],Ir[1],Er[P])):P<48?(F=Rf(r,i,f,n,u,t[_r[P]],Ar[2],Sr[P]),N=Rf(h,b,_,w,E,t[Mr[P]],Ir[2],Er[P])):P<64?(F=Pf(r,i,f,n,u,t[_r[P]],Ar[3],Sr[P]),N=Bf(h,b,_,w,E,t[Mr[P]],Ir[3],Er[P])):(F=Tf(r,i,f,n,u,t[_r[P]],Ar[4],Sr[P]),N=If(h,b,_,w,E,t[Mr[P]],Ir[4],Er[P])),r=u,u=n,n=Zt(f,10),f=i,i=F,h=E,E=w,w=Zt(_,10),_=b,b=N}var O=this._b+f+w|0;this._b=this._c+n+E|0,this._c=this._d+u+h|0,this._d=this._e+r+b|0,this._e=this._a+i+_|0,this._a=O},ti.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=zi.alloc?zi.alloc(20):new zi(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t};function Zt(t,e){return t<>>32-e}function If(t,e,r,i,f,n,u,h){return Zt(t+(e^r^i)+n+u|0,h)+f|0}function Bf(t,e,r,i,f,n,u,h){return Zt(t+(e&r|~e&i)+n+u|0,h)+f|0}function Rf(t,e,r,i,f,n,u,h){return Zt(t+((e|~r)^i)+n+u|0,h)+f|0}function Pf(t,e,r,i,f,n,u,h){return Zt(t+(e&i|r&~i)+n+u|0,h)+f|0}function Tf(t,e,r,i,f,n,u,h){return Zt(t+(e^(r|~i))+n+u|0,h)+f|0}var Ro=ti,Cf={exports:{}},Nf=bt.Buffer;function ri(t,e){this._block=Nf.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}ri.prototype.update=function(t,e){typeof t=="string"&&(e=e||"utf8",t=Nf.from(t,e));for(var r=this._block,i=this._blockSize,f=t.length,n=this._len,u=0;u=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(r&4294967295)>>>0,f=(r-i)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var n=this._hash();return t?n.toString(t):n},ri.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var lr=ri,Po=Ae,Ff=lr,To=bt.Buffer,Co=[1518500249,1859775393,-1894007588,-899497514],No=new Array(80);function Br(){this.init(),this._w=No,Ff.call(this,64,56)}Po(Br,Ff),Br.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Fo(t){return t<<5|t>>>27}function Lo(t){return t<<30|t>>>2}function Oo(t,e,r,i){return t===0?e&r|~e&i:t===2?e&r|e&i|r&i:e^r^i}Br.prototype._update=function(t){for(var e=this._w,r=this._a|0,i=this._b|0,f=this._c|0,n=this._d|0,u=this._e|0,h=0;h<16;++h)e[h]=t.readInt32BE(h*4);for(;h<80;++h)e[h]=e[h-3]^e[h-8]^e[h-14]^e[h-16];for(var b=0;b<80;++b){var _=~~(b/20),w=Fo(r)+Oo(_,i,f,n)+u+e[b]+Co[_]|0;u=n,n=f,f=Lo(i),i=r,r=w}this._a=r+this._a|0,this._b=i+this._b|0,this._c=f+this._c|0,this._d=n+this._d|0,this._e=u+this._e|0},Br.prototype._hash=function(){var t=To.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};var $o=Br,ko=Ae,Lf=lr,Uo=bt.Buffer,Do=[1518500249,1859775393,-1894007588,-899497514],qo=new Array(80);function Rr(){this.init(),this._w=qo,Lf.call(this,64,56)}ko(Rr,Lf),Rr.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function zo(t){return t<<1|t>>>31}function Ko(t){return t<<5|t>>>27}function Ho(t){return t<<30|t>>>2}function Wo(t,e,r,i){return t===0?e&r|~e&i:t===2?e&r|e&i|r&i:e^r^i}Rr.prototype._update=function(t){for(var e=this._w,r=this._a|0,i=this._b|0,f=this._c|0,n=this._d|0,u=this._e|0,h=0;h<16;++h)e[h]=t.readInt32BE(h*4);for(;h<80;++h)e[h]=zo(e[h-3]^e[h-8]^e[h-14]^e[h-16]);for(var b=0;b<80;++b){var _=~~(b/20),w=Ko(r)+Wo(_,i,f,n)+u+e[b]+Do[_]|0;u=n,n=f,f=Ho(i),i=r,r=w}this._a=r+this._a|0,this._b=i+this._b|0,this._c=f+this._c|0,this._d=n+this._d|0,this._e=u+this._e|0},Rr.prototype._hash=function(){var t=Uo.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};var jo=Rr,Vo=Ae,Of=lr,Yo=bt.Buffer,Go=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Zo=new Array(64);function Pr(){this.init(),this._w=Zo,Of.call(this,64,56)}Vo(Pr,Of),Pr.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Jo(t,e,r){return r^t&(e^r)}function Xo(t,e,r){return t&e|r&(t|e)}function Qo(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function ed(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function td(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function rd(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}Pr.prototype._update=function(t){for(var e=this._w,r=this._a|0,i=this._b|0,f=this._c|0,n=this._d|0,u=this._e|0,h=this._f|0,b=this._g|0,_=this._h|0,w=0;w<16;++w)e[w]=t.readInt32BE(w*4);for(;w<64;++w)e[w]=rd(e[w-2])+e[w-7]+td(e[w-15])+e[w-16]|0;for(var E=0;E<64;++E){var P=_+ed(u)+Jo(u,h,b)+Go[E]+e[E]|0,F=Qo(r)+Xo(r,i,f)|0;_=b,b=h,h=u,u=n+P|0,n=f,f=i,i=r,r=P+F|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=f+this._c|0,this._d=n+this._d|0,this._e=u+this._e|0,this._f=h+this._f|0,this._g=b+this._g|0,this._h=_+this._h|0},Pr.prototype._hash=function(){var t=Yo.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t};var $f=Pr,id=Ae,nd=$f,fd=lr,ad=bt.Buffer,sd=new Array(64);function ii(){this.init(),this._w=sd,fd.call(this,64,56)}id(ii,nd),ii.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},ii.prototype._hash=function(){var t=ad.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t};var od=ii,dd=Ae,kf=lr,hd=bt.Buffer,Uf=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],cd=new Array(160);function Tr(){this.init(),this._w=cd,kf.call(this,128,112)}dd(Tr,kf),Tr.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Df(t,e,r){return r^t&(e^r)}function qf(t,e,r){return t&e|r&(t|e)}function zf(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function Kf(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function ud(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function ld(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function bd(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function pd(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function je(t,e){return t>>>0>>0?1:0}Tr.prototype._update=function(t){for(var e=this._w,r=this._ah|0,i=this._bh|0,f=this._ch|0,n=this._dh|0,u=this._eh|0,h=this._fh|0,b=this._gh|0,_=this._hh|0,w=this._al|0,E=this._bl|0,P=this._cl|0,F=this._dl|0,N=this._el|0,O=this._fl|0,D=this._gl|0,k=this._hl|0,z=0;z<32;z+=2)e[z]=t.readInt32BE(z*4),e[z+1]=t.readInt32BE(z*4+4);for(;z<160;z+=2){var j=e[z-30],K=e[z-15*2+1],Y=ud(j,K),Q=ld(K,j);j=e[z-2*2],K=e[z-2*2+1];var se=bd(j,K),re=pd(K,j),V=e[z-7*2],Me=e[z-7*2+1],A=e[z-16*2],a=e[z-16*2+1],c=Q+Me|0,p=Y+V+je(c,Q)|0;c=c+re|0,p=p+se+je(c,re)|0,c=c+a|0,p=p+A+je(c,a)|0,e[z]=p,e[z+1]=c}for(var v=0;v<160;v+=2){p=e[v],c=e[v+1];var M=qf(r,i,f),B=qf(w,E,P),C=zf(r,w),x=zf(w,r),o=Kf(u,N),g=Kf(N,u),H=Uf[v],Z=Uf[v+1],J=Df(u,h,b),ie=Df(N,O,D),R=k+g|0,T=_+o+je(R,k)|0;R=R+ie|0,T=T+J+je(R,ie)|0,R=R+Z|0,T=T+H+je(R,Z)|0,R=R+c|0,T=T+p+je(R,c)|0;var q=x+B|0,W=C+M+je(q,x)|0;_=b,k=D,b=h,D=O,h=u,O=N,N=F+R|0,u=n+T+je(N,F)|0,n=f,F=P,f=i,P=E,i=r,E=w,w=R+q|0,r=T+W+je(w,R)|0}this._al=this._al+w|0,this._bl=this._bl+E|0,this._cl=this._cl+P|0,this._dl=this._dl+F|0,this._el=this._el+N|0,this._fl=this._fl+O|0,this._gl=this._gl+D|0,this._hl=this._hl+k|0,this._ah=this._ah+r+je(this._al,w)|0,this._bh=this._bh+i+je(this._bl,E)|0,this._ch=this._ch+f+je(this._cl,P)|0,this._dh=this._dh+n+je(this._dl,F)|0,this._eh=this._eh+u+je(this._el,N)|0,this._fh=this._fh+h+je(this._fl,O)|0,this._gh=this._gh+b+je(this._gl,D)|0,this._hh=this._hh+_+je(this._hl,k)|0},Tr.prototype._hash=function(){var t=hd.allocUnsafe(64);function e(r,i,f){t.writeInt32BE(r,f),t.writeInt32BE(i,f+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t};var Hf=Tr,vd=Ae,yd=Hf,gd=lr,xd=bt.Buffer,md=new Array(160);function ni(){this.init(),this._w=md,gd.call(this,128,112)}vd(ni,yd),ni.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},ni.prototype._hash=function(){var t=xd.allocUnsafe(48);function e(r,i,f){t.writeInt32BE(r,f),t.writeInt32BE(i,f+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t};var wd=ni,Jt=Cf.exports=function(e){e=e.toLowerCase();var r=Jt[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r};Jt.sha=$o,Jt.sha1=jo,Jt.sha224=od,Jt.sha256=$f,Jt.sha384=wd,Jt.sha512=Hf;var _d=Cf.exports,Wf=bt.Buffer,jf=qt.Transform,Md=Gr.StringDecoder,Sd=Ae;function pt(t){jf.call(this),this.hashMode=typeof t=="string",this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}Sd(pt,jf),pt.prototype.update=function(t,e,r){typeof t=="string"&&(t=Wf.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},pt.prototype.setAutoPadding=function(){},pt.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},pt.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},pt.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},pt.prototype._transform=function(t,e,r){var i;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(f){i=f}finally{r(i)}},pt.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(r){e=r}t(e)},pt.prototype._finalOrDigest=function(t){var e=this.__final()||Wf.alloc(0);return t&&(e=this._toString(e,t,!0)),e},pt.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new Md(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var i=this._decoder.write(t);return r&&(i+=this._decoder.end()),i};var Ed=pt,Ad=Ae,Id=Ao,Bd=Ro,Rd=_d,Vf=Ed;function fi(t){Vf.call(this,"digest"),this._hash=t}Ad(fi,Vf),fi.prototype._update=function(t){this._hash.update(t)},fi.prototype._final=function(){return this._hash.digest()};var Pd=function(e){return e=e.toLowerCase(),e==="md5"?new Id:e==="rmd160"||e==="ripemd160"?new Bd:new fi(Rd(e))};const Ki=hn(Pd),Yf=t=>{const e=Se.Buffer.concat(t.map(r=>Se.Buffer.concat([Se.Buffer.from(r.txid,"hex").reverse(),Td(r.vout)])).sort((r,i)=>r.compare(i)));return Ki("sha256").update(e).digest()},Gf=t=>{const e=t.map(r=>{const i=Se.Buffer.from(r.key,"hex");return r.isXOnly&&tt.publicKeyCreate(i,!0)[0]===3?tt.privateKeyNegate(i):i});return Se.Buffer.from(e.slice(1).reduce((r,i)=>tt.privateKeyTweakAdd(r,i),e[0]))},Zf=t=>{const e=Se.Buffer.alloc(4);return e.writeUInt32BE(t),e},Td=t=>{const e=Se.Buffer.alloc(4);return e.writeUInt32LE(t),e},Cd=(t,e,r,i="tsp")=>{var b;const f=Gf(t),n=Yf(e),u=new Map;for(const{address:_,amount:w}of r){const{scanKey:E,spendKey:P}=Xn(_,i);u.has(E.toString("hex"))?(b=u.get(E.toString("hex")))==null||b.push({spendKey:P,amount:w}):u.set(E.toString("hex"),[{spendKey:P,amount:w}])}const h=[];for(const[_,w]of u.entries()){const E=Se.Buffer.from(_,"hex"),P=tt.publicKeyTweakMul(tt.publicKeyTweakMul(E,n,!0),f);let F=0;for(const{spendKey:N,amount:O}of w){const D=Ki("sha256").update(Se.Buffer.concat([P,Zf(F)])).digest(),k=tt.publicKeyTweakAdd(N,D,!0);h.push({pubkey:Se.Buffer.from(k),value:O}),F++}}return h},Nd=(t,e,r,i)=>{const f=tt.publicKeyNegate(e,!0);let n=tt.publicKeyCombine([t,f],!0),u=i[Se.Buffer.from(n).toString("hex")];return u||(n=tt.publicKeyCombine([tt.publicKeyNegate(t,!0),f],!0),u=i[Se.Buffer.from(n).toString("hex")]),u?tt.privateKeyTweakAdd(r,Se.Buffer.from(u,"hex")):null},Fd=(t,e,r,i,f)=>{const n=tt.publicKeyTweakAdd(t,e,!0);for(let u=0;u{const u=tt.publicKeyTweakMul(r,tt.privateKeyTweakMul(t,i),!0),h=new Map;let b=0,_=0;do{const w=Ki("sha256").update(Se.Buffer.concat([u,Zf(b)])).digest();_=Fd(e,w,f,h,n),b+=_}while(_>0&&f.length>0);return h};dt.calculateSumOfPrivateKeys=Gf,dt.createOutputs=Cd,dt.decodeSilentPaymentAddress=Xn,dt.encodeSilentPaymentAddress=Es,dt.hashOutpoints=Yf,dt.scanOutputs=Ld,Object.defineProperty(dt,Symbol.toStringTag,{value:"Module"})});
diff --git a/dist/utility.d.ts b/dist/utility.d.ts
new file mode 100644
index 0000000..29b08c8
--- /dev/null
+++ b/dist/utility.d.ts
@@ -0,0 +1,5 @@
+import { Outpoint, PrivateKey } from './interface';
+import { Buffer } from 'buffer';
+export declare const hashOutpoints: (outpoints: Outpoint[]) => Buffer;
+export declare const calculateSumOfPrivateKeys: (keys: PrivateKey[]) => Buffer;
+export declare const serialiseUint32: (n: number) => Buffer;
diff --git a/package.json b/package.json
index cdaf1f7..d9bf6a5 100644
--- a/package.json
+++ b/package.json
@@ -31,9 +31,9 @@
],
"scripts": {
"build": "tsc && vite build",
- "format": "prettier --ignore-path .gitignore --loglevel=silent --write \"**/*.+(js|ts|json)\"",
- "format:check": "prettier --check \"**/*.+(js|ts|json)\"",
- "lint": "eslint --ext .js,.ts .",
+ "format": "prettier --ignore-path .gitignore --loglevel=silent --write \"**/*.+(js|ts|json)\" \"!dist/*\"",
+ "format:check": "prettier --check \"**/*.+(js|ts|json)\" \"!dist/*\"",
+ "lint": "eslint --ext .js,.ts . --ignore-pattern \"dist/*\"",
"test": "jest",
"test:cov": "jest --coverage",
"test:watch": "jest --watchAll",