@smartledger/bsv 7.10.0 → 7.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +1 -1
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +1 -1
- package/bsv.min.js +1 -1
- package/build/esbuild.js +4 -3
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/lib/covenant-interface.js +16 -6
- package/package.json +1 -1
- package/test/build/bundle_externals.js +116 -0
- package/version.js +1 -1
package/bsv.min.js
CHANGED
|
@@ -14,7 +14,7 @@ Use Chrome, Firefox or Internet Explorer 11`)}var jU=nt().Buffer,id=globalThis.c
|
|
|
14
14
|
`)}});var vI=k(gI=>{v();var pI=gI;pI.der=_m();pI.pem=dI()});var Pc=k(mI=>{v();var Rc=mI;Rc.bignum=Ln();Rc.define=jE().define;Rc.base=kc();Rc.constants=dm();Rc.decoders=sI();Rc.encoders=vI()});var wI=k((Pde,_I)=>{"use strict";v();var Un=Pc(),yI=Un.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),wY=Un.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),xm=Un.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),SY=Un.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(xm),this.key("subjectPublicKey").bitstr())}),xY=Un.define("RelativeDistinguishedName",function(){this.setof(wY)}),EY=Un.define("RDNSequence",function(){this.seqof(xY)}),bI=Un.define("Name",function(){this.choice({rdnSequence:this.use(EY)})}),IY=Un.define("Validity",function(){this.seq().obj(this.key("notBefore").use(yI),this.key("notAfter").use(yI))}),OY=Un.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),AY=Un.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(xm),this.key("issuer").use(bI),this.key("validity").use(IY),this.key("subject").use(bI),this.key("subjectPublicKeyInfo").use(SY),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(OY).optional())}),PY=Un.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(AY),this.key("signatureAlgorithm").use(xm),this.key("signatureValue").bitstr())});_I.exports=PY});var xI=k(Hn=>{"use strict";v();var Fn=Pc();Hn.certificate=wI();var TY=Fn.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});Hn.RSAPrivateKey=TY;var kY=Fn.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});Hn.RSAPublicKey=kY;var SI=Fn.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),RY=Fn.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(SI),this.key("subjectPublicKey").bitstr())});Hn.PublicKey=RY;var BY=Fn.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(SI),this.key("subjectPrivateKey").octstr())});Hn.PrivateKey=BY;var MY=Fn.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});Hn.EncryptedPrivateKey=MY;var CY=Fn.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});Hn.DSAPrivateKey=CY;Hn.DSAparam=Fn.define("DSAparam",function(){this.int()});var NY=Fn.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),DY=Fn.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(NY),this.key("publicKey").optional().explicit(1).bitstr())});Hn.ECPrivateKey=DY;Hn.signature=Fn.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})});var EI=k((Bde,LY)=>{LY.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}});var OI=k((Mde,II)=>{"use strict";v();var qY=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,UY=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,FY=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,HY=Xh(),jY=D2(),z2=nt().Buffer;II.exports=function(e,t){var r=e.toString(),i=r.match(qY),n;if(i){var a="aes"+i[1],s=z2.from(i[2],"hex"),u=z2.from(i[3].replace(/[\r\n]/g,""),"base64"),c=HY(t,s.slice(0,8),parseInt(i[1],10)).key,l=[],m=jY.createDecipheriv(a,c,s);l.push(m.update(u)),l.push(m.final()),n=z2.concat(l)}else{var o=r.match(FY);n=z2.from(o[2].replace(/[\r\n]/g,""),"base64")}var w=r.match(UY)[1];return{tag:w,data:n}}});var Im=k((Nde,PI)=>{"use strict";v();var Ti=xI(),zY=EI(),KY=OI(),VY=D2(),GY=Cv().pbkdf2Sync,Em=nt().Buffer;function ZY(e,t){var r=e.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),n=zY[e.algorithm.decrypt.cipher.algo.join(".")],o=e.algorithm.decrypt.cipher.iv,a=e.subjectPrivateKey,s=parseInt(n.split("-")[1],10)/8,u=GY(t,r,i,s,"sha1"),c=VY.createDecipheriv(n,u,o),l=[];return l.push(c.update(a)),l.push(c.final()),Em.concat(l)}function AI(e){var t;typeof e=="object"&&!Em.isBuffer(e)&&(t=e.passphrase,e=e.key),typeof e=="string"&&(e=Em.from(e));var r=KY(e,t),i=r.tag,n=r.data,o,a;switch(i){case"CERTIFICATE":a=Ti.certificate.decode(n,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(a||(a=Ti.PublicKey.decode(n,"der")),o=a.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return Ti.RSAPublicKey.decode(a.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return a.subjectPrivateKey=a.subjectPublicKey,{type:"ec",data:a};case"1.2.840.10040.4.1":return a.algorithm.params.pub_key=Ti.DSAparam.decode(a.subjectPublicKey.data,"der"),{type:"dsa",data:a.algorithm.params};default:throw new Error("unknown key id "+o)}case"ENCRYPTED PRIVATE KEY":n=Ti.EncryptedPrivateKey.decode(n,"der"),n=ZY(n,t);case"PRIVATE KEY":switch(a=Ti.PrivateKey.decode(n,"der"),o=a.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return Ti.RSAPrivateKey.decode(a.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:a.algorithm.curve,privateKey:Ti.ECPrivateKey.decode(a.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return a.algorithm.params.priv_key=Ti.DSAparam.decode(a.subjectPrivateKey,"der"),{type:"dsa",params:a.algorithm.params};default:throw new Error("unknown key id "+o)}case"RSA PUBLIC KEY":return Ti.RSAPublicKey.decode(n,"der");case"RSA PRIVATE KEY":return Ti.RSAPrivateKey.decode(n,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:Ti.DSAPrivateKey.decode(n,"der")};case"EC PRIVATE KEY":return n=Ti.ECPrivateKey.decode(n,"der"),{curve:n.parameters.value,privateKey:n.privateKey};default:throw new Error("unknown key type "+i)}}AI.signature=Ti.signature;PI.exports=AI});var Am=k((Lde,TI)=>{v();var WY=zh(),Om=nt().Buffer;TI.exports=function(e,t){for(var r=Om.alloc(0),i=0,n;r.length<t;)n=YY(i++),r=Om.concat([r,WY("sha1").update(e).update(n).digest()]);return r.slice(0,t)};function YY(e){var t=Om.allocUnsafe(4);return t.writeUInt32BE(e,0),t}});var Pm=k((Ude,kI)=>{v();kI.exports=function(t,r){for(var i=t.length,n=-1;++n<i;)t[n]^=r[n];return t}});var Tm=k((Hde,BI)=>{v();var RI=Ln(),$Y=nt().Buffer;function XY(e,t){return $Y.from(e.toRed(RI.mont(t.modulus)).redPow(new RI(t.publicExponent)).fromRed().toArray())}BI.exports=XY});var CI=k((MI,km)=>{v();(function(e,t){"use strict";function r(y,f){if(!y)throw new Error(f||"Assertion failed")}function i(y,f){y.super_=f;var d=function(){};d.prototype=f.prototype,y.prototype=new d,y.prototype.constructor=y}function n(y,f,d){if(n.isBN(y))return y;this.negative=0,this.words=null,this.length=0,this.red=null,y!==null&&((f==="le"||f==="be")&&(d=f,f=10),this._init(y||0,f||10,d||"be"))}typeof e=="object"?e.exports=n:t.BN=n,n.BN=n,n.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Zt().Buffer}catch{}n.isBN=function(f){return f instanceof n?!0:f!==null&&typeof f=="object"&&f.constructor.wordSize===n.wordSize&&Array.isArray(f.words)},n.max=function(f,d){return f.cmp(d)>0?f:d},n.min=function(f,d){return f.cmp(d)<0?f:d},n.prototype._init=function(f,d,_){if(typeof f=="number")return this._initNumber(f,d,_);if(typeof f=="object")return this._initArray(f,d,_);d==="hex"&&(d=16),r(d===(d|0)&&d>=2&&d<=36),f=f.toString().replace(/\s+/g,"");var x=0;f[0]==="-"&&(x++,this.negative=1),x<f.length&&(d===16?this._parseHex(f,x,_):(this._parseBase(f,d,x),_==="le"&&this._initArray(this.toArray(),d,_)))},n.prototype._initNumber=function(f,d,_){f<0&&(this.negative=1,f=-f),f<67108864?(this.words=[f&67108863],this.length=1):f<4503599627370496?(this.words=[f&67108863,f/67108864&67108863],this.length=2):(r(f<9007199254740992),this.words=[f&67108863,f/67108864&67108863,1],this.length=3),_==="le"&&this._initArray(this.toArray(),d,_)},n.prototype._initArray=function(f,d,_){if(r(typeof f.length=="number"),f.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(f.length/3),this.words=new Array(this.length);for(var x=0;x<this.length;x++)this.words[x]=0;var b,p,O=0;if(_==="be")for(x=f.length-1,b=0;x>=0;x-=3)p=f[x]|f[x-1]<<8|f[x-2]<<16,this.words[b]|=p<<O&67108863,this.words[b+1]=p>>>26-O&67108863,O+=24,O>=26&&(O-=26,b++);else if(_==="le")for(x=0,b=0;x<f.length;x+=3)p=f[x]|f[x+1]<<8|f[x+2]<<16,this.words[b]|=p<<O&67108863,this.words[b+1]=p>>>26-O&67108863,O+=24,O>=26&&(O-=26,b++);return this._strip()};function a(y,f){var d=y.charCodeAt(f);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;r(!1,"Invalid character in "+y)}function s(y,f,d){var _=a(y,d);return d-1>=f&&(_|=a(y,d-1)<<4),_}n.prototype._parseHex=function(f,d,_){this.length=Math.ceil((f.length-d)/6),this.words=new Array(this.length);for(var x=0;x<this.length;x++)this.words[x]=0;var b=0,p=0,O;if(_==="be")for(x=f.length-1;x>=d;x-=2)O=s(f,d,x)<<b,this.words[p]|=O&67108863,b>=18?(b-=18,p+=1,this.words[p]|=O>>>26):b+=8;else{var T=f.length-d;for(x=T%2===0?d+1:d;x<f.length;x+=2)O=s(f,d,x)<<b,this.words[p]|=O&67108863,b>=18?(b-=18,p+=1,this.words[p]|=O>>>26):b+=8}this._strip()};function u(y,f,d,_){for(var x=0,b=0,p=Math.min(y.length,d),O=f;O<p;O++){var T=y.charCodeAt(O)-48;x*=_,T>=49?b=T-49+10:T>=17?b=T-17+10:b=T,r(T>=0&&b<_,"Invalid character"),x+=b}return x}n.prototype._parseBase=function(f,d,_){this.words=[0],this.length=1;for(var x=0,b=1;b<=67108863;b*=d)x++;x--,b=b/d|0;for(var p=f.length-_,O=p%x,T=Math.min(p,p-O)+_,S=0,B=_;B<T;B+=x)S=u(f,B,B+x,d),this.imuln(b),this.words[0]+S<67108864?this.words[0]+=S:this._iaddn(S);if(O!==0){var Y=1;for(S=u(f,B,f.length,d),B=0;B<O;B++)Y*=d;this.imuln(Y),this.words[0]+S<67108864?this.words[0]+=S:this._iaddn(S)}this._strip()},n.prototype.copy=function(f){f.words=new Array(this.length);for(var d=0;d<this.length;d++)f.words[d]=this.words[d];f.length=this.length,f.negative=this.negative,f.red=this.red};function c(y,f){y.words=f.words,y.length=f.length,y.negative=f.negative,y.red=f.red}if(n.prototype._move=function(f){c(f,this)},n.prototype.clone=function(){var f=new n(null);return this.copy(f),f},n.prototype._expand=function(f){for(;this.length<f;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch{n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var m=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],w=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],E=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(f,d){f=f||10,d=d|0||1;var _;if(f===16||f==="hex"){_="";for(var x=0,b=0,p=0;p<this.length;p++){var O=this.words[p],T=((O<<x|b)&16777215).toString(16);b=O>>>24-x&16777215,x+=2,x>=26&&(x-=26,p--),b!==0||p!==this.length-1?_=m[6-T.length]+T+_:_=T+_}for(b!==0&&(_=b.toString(16)+_);_.length%d!==0;)_="0"+_;return this.negative!==0&&(_="-"+_),_}if(f===(f|0)&&f>=2&&f<=36){var S=w[f],B=E[f];_="";var Y=this.clone();for(Y.negative=0;!Y.isZero();){var $=Y.modrn(B).toString(f);Y=Y.idivn(B),Y.isZero()?_=$+_:_=m[S-$.length]+$+_}for(this.isZero()&&(_="0"+_);_.length%d!==0;)_="0"+_;return this.negative!==0&&(_="-"+_),_}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var f=this.words[0];return this.length===2?f+=this.words[1]*67108864:this.length===3&&this.words[2]===1?f+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-f:f},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(f,d){return this.toArrayLike(o,f,d)}),n.prototype.toArray=function(f,d){return this.toArrayLike(Array,f,d)};var P=function(f,d){return f.allocUnsafe?f.allocUnsafe(d):new f(d)};n.prototype.toArrayLike=function(f,d,_){this._strip();var x=this.byteLength(),b=_||Math.max(1,x);r(x<=b,"byte array longer than desired length"),r(b>0,"Requested array length <= 0");var p=P(f,b),O=d==="le"?"LE":"BE";return this["_toArrayLike"+O](p,x),p},n.prototype._toArrayLikeLE=function(f,d){for(var _=0,x=0,b=0,p=0;b<this.length;b++){var O=this.words[b]<<p|x;f[_++]=O&255,_<f.length&&(f[_++]=O>>8&255),_<f.length&&(f[_++]=O>>16&255),p===6?(_<f.length&&(f[_++]=O>>24&255),x=0,p=0):(x=O>>>24,p+=2)}if(_<f.length)for(f[_++]=x;_<f.length;)f[_++]=0},n.prototype._toArrayLikeBE=function(f,d){for(var _=f.length-1,x=0,b=0,p=0;b<this.length;b++){var O=this.words[b]<<p|x;f[_--]=O&255,_>=0&&(f[_--]=O>>8&255),_>=0&&(f[_--]=O>>16&255),p===6?(_>=0&&(f[_--]=O>>24&255),x=0,p=0):(x=O>>>24,p+=2)}if(_>=0)for(f[_--]=x;_>=0;)f[_--]=0},Math.clz32?n.prototype._countBits=function(f){return 32-Math.clz32(f)}:n.prototype._countBits=function(f){var d=f,_=0;return d>=4096&&(_+=13,d>>>=13),d>=64&&(_+=7,d>>>=7),d>=8&&(_+=4,d>>>=4),d>=2&&(_+=2,d>>>=2),_+d},n.prototype._zeroBits=function(f){if(f===0)return 26;var d=f,_=0;return(d&8191)===0&&(_+=13,d>>>=13),(d&127)===0&&(_+=7,d>>>=7),(d&15)===0&&(_+=4,d>>>=4),(d&3)===0&&(_+=2,d>>>=2),(d&1)===0&&_++,_},n.prototype.bitLength=function(){var f=this.words[this.length-1],d=this._countBits(f);return(this.length-1)*26+d};function M(y){for(var f=new Array(y.bitLength()),d=0;d<f.length;d++){var _=d/26|0,x=d%26;f[d]=y.words[_]>>>x&1}return f}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var f=0,d=0;d<this.length;d++){var _=this._zeroBits(this.words[d]);if(f+=_,_!==26)break}return f},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(f){return this.negative!==0?this.abs().inotn(f).iaddn(1):this.clone()},n.prototype.fromTwos=function(f){return this.testn(f-1)?this.notn(f).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return this.negative!==0},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(f){for(;this.length<f.length;)this.words[this.length++]=0;for(var d=0;d<f.length;d++)this.words[d]=this.words[d]|f.words[d];return this._strip()},n.prototype.ior=function(f){return r((this.negative|f.negative)===0),this.iuor(f)},n.prototype.or=function(f){return this.length>f.length?this.clone().ior(f):f.clone().ior(this)},n.prototype.uor=function(f){return this.length>f.length?this.clone().iuor(f):f.clone().iuor(this)},n.prototype.iuand=function(f){var d;this.length>f.length?d=f:d=this;for(var _=0;_<d.length;_++)this.words[_]=this.words[_]&f.words[_];return this.length=d.length,this._strip()},n.prototype.iand=function(f){return r((this.negative|f.negative)===0),this.iuand(f)},n.prototype.and=function(f){return this.length>f.length?this.clone().iand(f):f.clone().iand(this)},n.prototype.uand=function(f){return this.length>f.length?this.clone().iuand(f):f.clone().iuand(this)},n.prototype.iuxor=function(f){var d,_;this.length>f.length?(d=this,_=f):(d=f,_=this);for(var x=0;x<_.length;x++)this.words[x]=d.words[x]^_.words[x];if(this!==d)for(;x<d.length;x++)this.words[x]=d.words[x];return this.length=d.length,this._strip()},n.prototype.ixor=function(f){return r((this.negative|f.negative)===0),this.iuxor(f)},n.prototype.xor=function(f){return this.length>f.length?this.clone().ixor(f):f.clone().ixor(this)},n.prototype.uxor=function(f){return this.length>f.length?this.clone().iuxor(f):f.clone().iuxor(this)},n.prototype.inotn=function(f){r(typeof f=="number"&&f>=0);var d=Math.ceil(f/26)|0,_=f%26;this._expand(d),_>0&&d--;for(var x=0;x<d;x++)this.words[x]=~this.words[x]&67108863;return _>0&&(this.words[x]=~this.words[x]&67108863>>26-_),this._strip()},n.prototype.notn=function(f){return this.clone().inotn(f)},n.prototype.setn=function(f,d){r(typeof f=="number"&&f>=0);var _=f/26|0,x=f%26;return this._expand(_+1),d?this.words[_]=this.words[_]|1<<x:this.words[_]=this.words[_]&~(1<<x),this._strip()},n.prototype.iadd=function(f){var d;if(this.negative!==0&&f.negative===0)return this.negative=0,d=this.isub(f),this.negative^=1,this._normSign();if(this.negative===0&&f.negative!==0)return f.negative=0,d=this.isub(f),f.negative=1,d._normSign();var _,x;this.length>f.length?(_=this,x=f):(_=f,x=this);for(var b=0,p=0;p<x.length;p++)d=(_.words[p]|0)+(x.words[p]|0)+b,this.words[p]=d&67108863,b=d>>>26;for(;b!==0&&p<_.length;p++)d=(_.words[p]|0)+b,this.words[p]=d&67108863,b=d>>>26;if(this.length=_.length,b!==0)this.words[this.length]=b,this.length++;else if(_!==this)for(;p<_.length;p++)this.words[p]=_.words[p];return this},n.prototype.add=function(f){var d;return f.negative!==0&&this.negative===0?(f.negative=0,d=this.sub(f),f.negative^=1,d):f.negative===0&&this.negative!==0?(this.negative=0,d=f.sub(this),this.negative=1,d):this.length>f.length?this.clone().iadd(f):f.clone().iadd(this)},n.prototype.isub=function(f){if(f.negative!==0){f.negative=0;var d=this.iadd(f);return f.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(f),this.negative=1,this._normSign();var _=this.cmp(f);if(_===0)return this.negative=0,this.length=1,this.words[0]=0,this;var x,b;_>0?(x=this,b=f):(x=f,b=this);for(var p=0,O=0;O<b.length;O++)d=(x.words[O]|0)-(b.words[O]|0)+p,p=d>>26,this.words[O]=d&67108863;for(;p!==0&&O<x.length;O++)d=(x.words[O]|0)+p,p=d>>26,this.words[O]=d&67108863;if(p===0&&O<x.length&&x!==this)for(;O<x.length;O++)this.words[O]=x.words[O];return this.length=Math.max(this.length,O),x!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(f){return this.clone().isub(f)};function D(y,f,d){d.negative=f.negative^y.negative;var _=y.length+f.length|0;d.length=_,_=_-1|0;var x=y.words[0]|0,b=f.words[0]|0,p=x*b,O=p&67108863,T=p/67108864|0;d.words[0]=O;for(var S=1;S<_;S++){for(var B=T>>>26,Y=T&67108863,$=Math.min(S,f.length-1),ne=Math.max(0,S-y.length+1);ne<=$;ne++){var he=S-ne|0;x=y.words[he]|0,b=f.words[ne]|0,p=x*b+Y,B+=p/67108864|0,Y=p&67108863}d.words[S]=Y|0,T=B|0}return T!==0?d.words[S]=T|0:d.length--,d._strip()}var L=function(f,d,_){var x=f.words,b=d.words,p=_.words,O=0,T,S,B,Y=x[0]|0,$=Y&8191,ne=Y>>>13,he=x[1]|0,pe=he&8191,q=he>>>13,W=x[2]|0,X=W&8191,te=W>>>13,me=x[3]|0,se=me&8191,fe=me>>>13,xe=x[4]|0,le=xe&8191,ve=xe>>>13,Ht=x[5]|0,Se=Ht&8191,ce=Ht>>>13,Te=x[6]|0,be=Te&8191,_e=Te>>>13,en=x[7]|0,Ce=en&8191,Re=en>>>13,eu=x[8]|0,Ne=eu&8191,Le=eu>>>13,$l=x[9]|0,qe=$l&8191,Ue=$l>>>13,Xl=b[0]|0,Fe=Xl&8191,He=Xl>>>13,Jl=b[1]|0,je=Jl&8191,ze=Jl>>>13,Ql=b[2]|0,Ke=Ql&8191,Ve=Ql>>>13,eh=b[3]|0,Ge=eh&8191,Ze=eh>>>13,th=b[4]|0,We=th&8191,Ye=th>>>13,rh=b[5]|0,$e=rh&8191,Xe=rh>>>13,ih=b[6]|0,Je=ih&8191,Qe=ih>>>13,nh=b[7]|0,et=nh&8191,tt=nh>>>13,oh=b[8]|0,rt=oh&8191,it=oh>>>13,Zf=b[9]|0,Qt=Zf&8191,er=Zf>>>13;_.negative=f.negative^d.negative,_.length=19,T=Math.imul($,Fe),S=Math.imul($,He),S=S+Math.imul(ne,Fe)|0,B=Math.imul(ne,He);var tu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(tu>>>26)|0,tu&=67108863,T=Math.imul(pe,Fe),S=Math.imul(pe,He),S=S+Math.imul(q,Fe)|0,B=Math.imul(q,He),T=T+Math.imul($,je)|0,S=S+Math.imul($,ze)|0,S=S+Math.imul(ne,je)|0,B=B+Math.imul(ne,ze)|0;var ru=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(ru>>>26)|0,ru&=67108863,T=Math.imul(X,Fe),S=Math.imul(X,He),S=S+Math.imul(te,Fe)|0,B=Math.imul(te,He),T=T+Math.imul(pe,je)|0,S=S+Math.imul(pe,ze)|0,S=S+Math.imul(q,je)|0,B=B+Math.imul(q,ze)|0,T=T+Math.imul($,Ke)|0,S=S+Math.imul($,Ve)|0,S=S+Math.imul(ne,Ke)|0,B=B+Math.imul(ne,Ve)|0;var iu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(iu>>>26)|0,iu&=67108863,T=Math.imul(se,Fe),S=Math.imul(se,He),S=S+Math.imul(fe,Fe)|0,B=Math.imul(fe,He),T=T+Math.imul(X,je)|0,S=S+Math.imul(X,ze)|0,S=S+Math.imul(te,je)|0,B=B+Math.imul(te,ze)|0,T=T+Math.imul(pe,Ke)|0,S=S+Math.imul(pe,Ve)|0,S=S+Math.imul(q,Ke)|0,B=B+Math.imul(q,Ve)|0,T=T+Math.imul($,Ge)|0,S=S+Math.imul($,Ze)|0,S=S+Math.imul(ne,Ge)|0,B=B+Math.imul(ne,Ze)|0;var nu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(nu>>>26)|0,nu&=67108863,T=Math.imul(le,Fe),S=Math.imul(le,He),S=S+Math.imul(ve,Fe)|0,B=Math.imul(ve,He),T=T+Math.imul(se,je)|0,S=S+Math.imul(se,ze)|0,S=S+Math.imul(fe,je)|0,B=B+Math.imul(fe,ze)|0,T=T+Math.imul(X,Ke)|0,S=S+Math.imul(X,Ve)|0,S=S+Math.imul(te,Ke)|0,B=B+Math.imul(te,Ve)|0,T=T+Math.imul(pe,Ge)|0,S=S+Math.imul(pe,Ze)|0,S=S+Math.imul(q,Ge)|0,B=B+Math.imul(q,Ze)|0,T=T+Math.imul($,We)|0,S=S+Math.imul($,Ye)|0,S=S+Math.imul(ne,We)|0,B=B+Math.imul(ne,Ye)|0;var ou=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(ou>>>26)|0,ou&=67108863,T=Math.imul(Se,Fe),S=Math.imul(Se,He),S=S+Math.imul(ce,Fe)|0,B=Math.imul(ce,He),T=T+Math.imul(le,je)|0,S=S+Math.imul(le,ze)|0,S=S+Math.imul(ve,je)|0,B=B+Math.imul(ve,ze)|0,T=T+Math.imul(se,Ke)|0,S=S+Math.imul(se,Ve)|0,S=S+Math.imul(fe,Ke)|0,B=B+Math.imul(fe,Ve)|0,T=T+Math.imul(X,Ge)|0,S=S+Math.imul(X,Ze)|0,S=S+Math.imul(te,Ge)|0,B=B+Math.imul(te,Ze)|0,T=T+Math.imul(pe,We)|0,S=S+Math.imul(pe,Ye)|0,S=S+Math.imul(q,We)|0,B=B+Math.imul(q,Ye)|0,T=T+Math.imul($,$e)|0,S=S+Math.imul($,Xe)|0,S=S+Math.imul(ne,$e)|0,B=B+Math.imul(ne,Xe)|0;var au=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(au>>>26)|0,au&=67108863,T=Math.imul(be,Fe),S=Math.imul(be,He),S=S+Math.imul(_e,Fe)|0,B=Math.imul(_e,He),T=T+Math.imul(Se,je)|0,S=S+Math.imul(Se,ze)|0,S=S+Math.imul(ce,je)|0,B=B+Math.imul(ce,ze)|0,T=T+Math.imul(le,Ke)|0,S=S+Math.imul(le,Ve)|0,S=S+Math.imul(ve,Ke)|0,B=B+Math.imul(ve,Ve)|0,T=T+Math.imul(se,Ge)|0,S=S+Math.imul(se,Ze)|0,S=S+Math.imul(fe,Ge)|0,B=B+Math.imul(fe,Ze)|0,T=T+Math.imul(X,We)|0,S=S+Math.imul(X,Ye)|0,S=S+Math.imul(te,We)|0,B=B+Math.imul(te,Ye)|0,T=T+Math.imul(pe,$e)|0,S=S+Math.imul(pe,Xe)|0,S=S+Math.imul(q,$e)|0,B=B+Math.imul(q,Xe)|0,T=T+Math.imul($,Je)|0,S=S+Math.imul($,Qe)|0,S=S+Math.imul(ne,Je)|0,B=B+Math.imul(ne,Qe)|0;var su=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(su>>>26)|0,su&=67108863,T=Math.imul(Ce,Fe),S=Math.imul(Ce,He),S=S+Math.imul(Re,Fe)|0,B=Math.imul(Re,He),T=T+Math.imul(be,je)|0,S=S+Math.imul(be,ze)|0,S=S+Math.imul(_e,je)|0,B=B+Math.imul(_e,ze)|0,T=T+Math.imul(Se,Ke)|0,S=S+Math.imul(Se,Ve)|0,S=S+Math.imul(ce,Ke)|0,B=B+Math.imul(ce,Ve)|0,T=T+Math.imul(le,Ge)|0,S=S+Math.imul(le,Ze)|0,S=S+Math.imul(ve,Ge)|0,B=B+Math.imul(ve,Ze)|0,T=T+Math.imul(se,We)|0,S=S+Math.imul(se,Ye)|0,S=S+Math.imul(fe,We)|0,B=B+Math.imul(fe,Ye)|0,T=T+Math.imul(X,$e)|0,S=S+Math.imul(X,Xe)|0,S=S+Math.imul(te,$e)|0,B=B+Math.imul(te,Xe)|0,T=T+Math.imul(pe,Je)|0,S=S+Math.imul(pe,Qe)|0,S=S+Math.imul(q,Je)|0,B=B+Math.imul(q,Qe)|0,T=T+Math.imul($,et)|0,S=S+Math.imul($,tt)|0,S=S+Math.imul(ne,et)|0,B=B+Math.imul(ne,tt)|0;var uu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(uu>>>26)|0,uu&=67108863,T=Math.imul(Ne,Fe),S=Math.imul(Ne,He),S=S+Math.imul(Le,Fe)|0,B=Math.imul(Le,He),T=T+Math.imul(Ce,je)|0,S=S+Math.imul(Ce,ze)|0,S=S+Math.imul(Re,je)|0,B=B+Math.imul(Re,ze)|0,T=T+Math.imul(be,Ke)|0,S=S+Math.imul(be,Ve)|0,S=S+Math.imul(_e,Ke)|0,B=B+Math.imul(_e,Ve)|0,T=T+Math.imul(Se,Ge)|0,S=S+Math.imul(Se,Ze)|0,S=S+Math.imul(ce,Ge)|0,B=B+Math.imul(ce,Ze)|0,T=T+Math.imul(le,We)|0,S=S+Math.imul(le,Ye)|0,S=S+Math.imul(ve,We)|0,B=B+Math.imul(ve,Ye)|0,T=T+Math.imul(se,$e)|0,S=S+Math.imul(se,Xe)|0,S=S+Math.imul(fe,$e)|0,B=B+Math.imul(fe,Xe)|0,T=T+Math.imul(X,Je)|0,S=S+Math.imul(X,Qe)|0,S=S+Math.imul(te,Je)|0,B=B+Math.imul(te,Qe)|0,T=T+Math.imul(pe,et)|0,S=S+Math.imul(pe,tt)|0,S=S+Math.imul(q,et)|0,B=B+Math.imul(q,tt)|0,T=T+Math.imul($,rt)|0,S=S+Math.imul($,it)|0,S=S+Math.imul(ne,rt)|0,B=B+Math.imul(ne,it)|0;var fu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(fu>>>26)|0,fu&=67108863,T=Math.imul(qe,Fe),S=Math.imul(qe,He),S=S+Math.imul(Ue,Fe)|0,B=Math.imul(Ue,He),T=T+Math.imul(Ne,je)|0,S=S+Math.imul(Ne,ze)|0,S=S+Math.imul(Le,je)|0,B=B+Math.imul(Le,ze)|0,T=T+Math.imul(Ce,Ke)|0,S=S+Math.imul(Ce,Ve)|0,S=S+Math.imul(Re,Ke)|0,B=B+Math.imul(Re,Ve)|0,T=T+Math.imul(be,Ge)|0,S=S+Math.imul(be,Ze)|0,S=S+Math.imul(_e,Ge)|0,B=B+Math.imul(_e,Ze)|0,T=T+Math.imul(Se,We)|0,S=S+Math.imul(Se,Ye)|0,S=S+Math.imul(ce,We)|0,B=B+Math.imul(ce,Ye)|0,T=T+Math.imul(le,$e)|0,S=S+Math.imul(le,Xe)|0,S=S+Math.imul(ve,$e)|0,B=B+Math.imul(ve,Xe)|0,T=T+Math.imul(se,Je)|0,S=S+Math.imul(se,Qe)|0,S=S+Math.imul(fe,Je)|0,B=B+Math.imul(fe,Qe)|0,T=T+Math.imul(X,et)|0,S=S+Math.imul(X,tt)|0,S=S+Math.imul(te,et)|0,B=B+Math.imul(te,tt)|0,T=T+Math.imul(pe,rt)|0,S=S+Math.imul(pe,it)|0,S=S+Math.imul(q,rt)|0,B=B+Math.imul(q,it)|0,T=T+Math.imul($,Qt)|0,S=S+Math.imul($,er)|0,S=S+Math.imul(ne,Qt)|0,B=B+Math.imul(ne,er)|0;var cu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(cu>>>26)|0,cu&=67108863,T=Math.imul(qe,je),S=Math.imul(qe,ze),S=S+Math.imul(Ue,je)|0,B=Math.imul(Ue,ze),T=T+Math.imul(Ne,Ke)|0,S=S+Math.imul(Ne,Ve)|0,S=S+Math.imul(Le,Ke)|0,B=B+Math.imul(Le,Ve)|0,T=T+Math.imul(Ce,Ge)|0,S=S+Math.imul(Ce,Ze)|0,S=S+Math.imul(Re,Ge)|0,B=B+Math.imul(Re,Ze)|0,T=T+Math.imul(be,We)|0,S=S+Math.imul(be,Ye)|0,S=S+Math.imul(_e,We)|0,B=B+Math.imul(_e,Ye)|0,T=T+Math.imul(Se,$e)|0,S=S+Math.imul(Se,Xe)|0,S=S+Math.imul(ce,$e)|0,B=B+Math.imul(ce,Xe)|0,T=T+Math.imul(le,Je)|0,S=S+Math.imul(le,Qe)|0,S=S+Math.imul(ve,Je)|0,B=B+Math.imul(ve,Qe)|0,T=T+Math.imul(se,et)|0,S=S+Math.imul(se,tt)|0,S=S+Math.imul(fe,et)|0,B=B+Math.imul(fe,tt)|0,T=T+Math.imul(X,rt)|0,S=S+Math.imul(X,it)|0,S=S+Math.imul(te,rt)|0,B=B+Math.imul(te,it)|0,T=T+Math.imul(pe,Qt)|0,S=S+Math.imul(pe,er)|0,S=S+Math.imul(q,Qt)|0,B=B+Math.imul(q,er)|0;var lu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(lu>>>26)|0,lu&=67108863,T=Math.imul(qe,Ke),S=Math.imul(qe,Ve),S=S+Math.imul(Ue,Ke)|0,B=Math.imul(Ue,Ve),T=T+Math.imul(Ne,Ge)|0,S=S+Math.imul(Ne,Ze)|0,S=S+Math.imul(Le,Ge)|0,B=B+Math.imul(Le,Ze)|0,T=T+Math.imul(Ce,We)|0,S=S+Math.imul(Ce,Ye)|0,S=S+Math.imul(Re,We)|0,B=B+Math.imul(Re,Ye)|0,T=T+Math.imul(be,$e)|0,S=S+Math.imul(be,Xe)|0,S=S+Math.imul(_e,$e)|0,B=B+Math.imul(_e,Xe)|0,T=T+Math.imul(Se,Je)|0,S=S+Math.imul(Se,Qe)|0,S=S+Math.imul(ce,Je)|0,B=B+Math.imul(ce,Qe)|0,T=T+Math.imul(le,et)|0,S=S+Math.imul(le,tt)|0,S=S+Math.imul(ve,et)|0,B=B+Math.imul(ve,tt)|0,T=T+Math.imul(se,rt)|0,S=S+Math.imul(se,it)|0,S=S+Math.imul(fe,rt)|0,B=B+Math.imul(fe,it)|0,T=T+Math.imul(X,Qt)|0,S=S+Math.imul(X,er)|0,S=S+Math.imul(te,Qt)|0,B=B+Math.imul(te,er)|0;var hu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(hu>>>26)|0,hu&=67108863,T=Math.imul(qe,Ge),S=Math.imul(qe,Ze),S=S+Math.imul(Ue,Ge)|0,B=Math.imul(Ue,Ze),T=T+Math.imul(Ne,We)|0,S=S+Math.imul(Ne,Ye)|0,S=S+Math.imul(Le,We)|0,B=B+Math.imul(Le,Ye)|0,T=T+Math.imul(Ce,$e)|0,S=S+Math.imul(Ce,Xe)|0,S=S+Math.imul(Re,$e)|0,B=B+Math.imul(Re,Xe)|0,T=T+Math.imul(be,Je)|0,S=S+Math.imul(be,Qe)|0,S=S+Math.imul(_e,Je)|0,B=B+Math.imul(_e,Qe)|0,T=T+Math.imul(Se,et)|0,S=S+Math.imul(Se,tt)|0,S=S+Math.imul(ce,et)|0,B=B+Math.imul(ce,tt)|0,T=T+Math.imul(le,rt)|0,S=S+Math.imul(le,it)|0,S=S+Math.imul(ve,rt)|0,B=B+Math.imul(ve,it)|0,T=T+Math.imul(se,Qt)|0,S=S+Math.imul(se,er)|0,S=S+Math.imul(fe,Qt)|0,B=B+Math.imul(fe,er)|0;var du=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(du>>>26)|0,du&=67108863,T=Math.imul(qe,We),S=Math.imul(qe,Ye),S=S+Math.imul(Ue,We)|0,B=Math.imul(Ue,Ye),T=T+Math.imul(Ne,$e)|0,S=S+Math.imul(Ne,Xe)|0,S=S+Math.imul(Le,$e)|0,B=B+Math.imul(Le,Xe)|0,T=T+Math.imul(Ce,Je)|0,S=S+Math.imul(Ce,Qe)|0,S=S+Math.imul(Re,Je)|0,B=B+Math.imul(Re,Qe)|0,T=T+Math.imul(be,et)|0,S=S+Math.imul(be,tt)|0,S=S+Math.imul(_e,et)|0,B=B+Math.imul(_e,tt)|0,T=T+Math.imul(Se,rt)|0,S=S+Math.imul(Se,it)|0,S=S+Math.imul(ce,rt)|0,B=B+Math.imul(ce,it)|0,T=T+Math.imul(le,Qt)|0,S=S+Math.imul(le,er)|0,S=S+Math.imul(ve,Qt)|0,B=B+Math.imul(ve,er)|0;var pu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(pu>>>26)|0,pu&=67108863,T=Math.imul(qe,$e),S=Math.imul(qe,Xe),S=S+Math.imul(Ue,$e)|0,B=Math.imul(Ue,Xe),T=T+Math.imul(Ne,Je)|0,S=S+Math.imul(Ne,Qe)|0,S=S+Math.imul(Le,Je)|0,B=B+Math.imul(Le,Qe)|0,T=T+Math.imul(Ce,et)|0,S=S+Math.imul(Ce,tt)|0,S=S+Math.imul(Re,et)|0,B=B+Math.imul(Re,tt)|0,T=T+Math.imul(be,rt)|0,S=S+Math.imul(be,it)|0,S=S+Math.imul(_e,rt)|0,B=B+Math.imul(_e,it)|0,T=T+Math.imul(Se,Qt)|0,S=S+Math.imul(Se,er)|0,S=S+Math.imul(ce,Qt)|0,B=B+Math.imul(ce,er)|0;var gu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(gu>>>26)|0,gu&=67108863,T=Math.imul(qe,Je),S=Math.imul(qe,Qe),S=S+Math.imul(Ue,Je)|0,B=Math.imul(Ue,Qe),T=T+Math.imul(Ne,et)|0,S=S+Math.imul(Ne,tt)|0,S=S+Math.imul(Le,et)|0,B=B+Math.imul(Le,tt)|0,T=T+Math.imul(Ce,rt)|0,S=S+Math.imul(Ce,it)|0,S=S+Math.imul(Re,rt)|0,B=B+Math.imul(Re,it)|0,T=T+Math.imul(be,Qt)|0,S=S+Math.imul(be,er)|0,S=S+Math.imul(_e,Qt)|0,B=B+Math.imul(_e,er)|0;var vu=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(vu>>>26)|0,vu&=67108863,T=Math.imul(qe,et),S=Math.imul(qe,tt),S=S+Math.imul(Ue,et)|0,B=Math.imul(Ue,tt),T=T+Math.imul(Ne,rt)|0,S=S+Math.imul(Ne,it)|0,S=S+Math.imul(Le,rt)|0,B=B+Math.imul(Le,it)|0,T=T+Math.imul(Ce,Qt)|0,S=S+Math.imul(Ce,er)|0,S=S+Math.imul(Re,Qt)|0,B=B+Math.imul(Re,er)|0;var R5=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(R5>>>26)|0,R5&=67108863,T=Math.imul(qe,rt),S=Math.imul(qe,it),S=S+Math.imul(Ue,rt)|0,B=Math.imul(Ue,it),T=T+Math.imul(Ne,Qt)|0,S=S+Math.imul(Ne,er)|0,S=S+Math.imul(Le,Qt)|0,B=B+Math.imul(Le,er)|0;var B5=(O+T|0)+((S&8191)<<13)|0;O=(B+(S>>>13)|0)+(B5>>>26)|0,B5&=67108863,T=Math.imul(qe,Qt),S=Math.imul(qe,er),S=S+Math.imul(Ue,Qt)|0,B=Math.imul(Ue,er);var M5=(O+T|0)+((S&8191)<<13)|0;return O=(B+(S>>>13)|0)+(M5>>>26)|0,M5&=67108863,p[0]=tu,p[1]=ru,p[2]=iu,p[3]=nu,p[4]=ou,p[5]=au,p[6]=su,p[7]=uu,p[8]=fu,p[9]=cu,p[10]=lu,p[11]=hu,p[12]=du,p[13]=pu,p[14]=gu,p[15]=vu,p[16]=R5,p[17]=B5,p[18]=M5,O!==0&&(p[19]=O,_.length++),_};Math.imul||(L=D);function U(y,f,d){d.negative=f.negative^y.negative,d.length=y.length+f.length;for(var _=0,x=0,b=0;b<d.length-1;b++){var p=x;x=0;for(var O=_&67108863,T=Math.min(b,f.length-1),S=Math.max(0,b-y.length+1);S<=T;S++){var B=b-S,Y=y.words[B]|0,$=f.words[S]|0,ne=Y*$,he=ne&67108863;p=p+(ne/67108864|0)|0,he=he+O|0,O=he&67108863,p=p+(he>>>26)|0,x+=p>>>26,p&=67108863}d.words[b]=O,_=p,p=x}return _!==0?d.words[b]=_:d.length--,d._strip()}function K(y,f,d){return U(y,f,d)}n.prototype.mulTo=function(f,d){var _,x=this.length+f.length;return this.length===10&&f.length===10?_=L(this,f,d):x<63?_=D(this,f,d):x<1024?_=U(this,f,d):_=K(this,f,d),_};function C(y,f){this.x=y,this.y=f}C.prototype.makeRBT=function(f){for(var d=new Array(f),_=n.prototype._countBits(f)-1,x=0;x<f;x++)d[x]=this.revBin(x,_,f);return d},C.prototype.revBin=function(f,d,_){if(f===0||f===_-1)return f;for(var x=0,b=0;b<d;b++)x|=(f&1)<<d-b-1,f>>=1;return x},C.prototype.permute=function(f,d,_,x,b,p){for(var O=0;O<p;O++)x[O]=d[f[O]],b[O]=_[f[O]]},C.prototype.transform=function(f,d,_,x,b,p){this.permute(p,f,d,_,x,b);for(var O=1;O<b;O<<=1)for(var T=O<<1,S=Math.cos(2*Math.PI/T),B=Math.sin(2*Math.PI/T),Y=0;Y<b;Y+=T)for(var $=S,ne=B,he=0;he<O;he++){var pe=_[Y+he],q=x[Y+he],W=_[Y+he+O],X=x[Y+he+O],te=$*W-ne*X;X=$*X+ne*W,W=te,_[Y+he]=pe+W,x[Y+he]=q+X,_[Y+he+O]=pe-W,x[Y+he+O]=q-X,he!==T&&(te=S*$-B*ne,ne=S*ne+B*$,$=te)}},C.prototype.guessLen13b=function(f,d){var _=Math.max(d,f)|1,x=_&1,b=0;for(_=_/2|0;_;_=_>>>1)b++;return 1<<b+1+x},C.prototype.conjugate=function(f,d,_){if(!(_<=1))for(var x=0;x<_/2;x++){var b=f[x];f[x]=f[_-x-1],f[_-x-1]=b,b=d[x],d[x]=-d[_-x-1],d[_-x-1]=-b}},C.prototype.normalize13b=function(f,d){for(var _=0,x=0;x<d/2;x++){var b=Math.round(f[2*x+1]/d)*8192+Math.round(f[2*x]/d)+_;f[x]=b&67108863,b<67108864?_=0:_=b/67108864|0}return f},C.prototype.convert13b=function(f,d,_,x){for(var b=0,p=0;p<d;p++)b=b+(f[p]|0),_[2*p]=b&8191,b=b>>>13,_[2*p+1]=b&8191,b=b>>>13;for(p=2*d;p<x;++p)_[p]=0;r(b===0),r((b&-8192)===0)},C.prototype.stub=function(f){for(var d=new Array(f),_=0;_<f;_++)d[_]=0;return d},C.prototype.mulp=function(f,d,_){var x=2*this.guessLen13b(f.length,d.length),b=this.makeRBT(x),p=this.stub(x),O=new Array(x),T=new Array(x),S=new Array(x),B=new Array(x),Y=new Array(x),$=new Array(x),ne=_.words;ne.length=x,this.convert13b(f.words,f.length,O,x),this.convert13b(d.words,d.length,B,x),this.transform(O,p,T,S,x,b),this.transform(B,p,Y,$,x,b);for(var he=0;he<x;he++){var pe=T[he]*Y[he]-S[he]*$[he];S[he]=T[he]*$[he]+S[he]*Y[he],T[he]=pe}return this.conjugate(T,S,x),this.transform(T,S,ne,p,x,b),this.conjugate(ne,p,x),this.normalize13b(ne,x),_.negative=f.negative^d.negative,_.length=f.length+d.length,_._strip()},n.prototype.mul=function(f){var d=new n(null);return d.words=new Array(this.length+f.length),this.mulTo(f,d)},n.prototype.mulf=function(f){var d=new n(null);return d.words=new Array(this.length+f.length),K(this,f,d)},n.prototype.imul=function(f){return this.clone().mulTo(f,this)},n.prototype.imuln=function(f){var d=f<0;d&&(f=-f),r(typeof f=="number"),r(f<67108864);for(var _=0,x=0;x<this.length;x++){var b=(this.words[x]|0)*f,p=(b&67108863)+(_&67108863);_>>=26,_+=b/67108864|0,_+=p>>>26,this.words[x]=p&67108863}return _!==0&&(this.words[x]=_,this.length++),this.length=f===0?1:this.length,d?this.ineg():this},n.prototype.muln=function(f){return this.clone().imuln(f)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(f){var d=M(f);if(d.length===0)return new n(1);for(var _=this,x=0;x<d.length&&d[x]===0;x++,_=_.sqr());if(++x<d.length)for(var b=_.sqr();x<d.length;x++,b=b.sqr())d[x]!==0&&(_=_.mul(b));return _},n.prototype.iushln=function(f){r(typeof f=="number"&&f>=0);var d=f%26,_=(f-d)/26,x=67108863>>>26-d<<26-d,b;if(d!==0){var p=0;for(b=0;b<this.length;b++){var O=this.words[b]&x,T=(this.words[b]|0)-O<<d;this.words[b]=T|p,p=O>>>26-d}p&&(this.words[b]=p,this.length++)}if(_!==0){for(b=this.length-1;b>=0;b--)this.words[b+_]=this.words[b];for(b=0;b<_;b++)this.words[b]=0;this.length+=_}return this._strip()},n.prototype.ishln=function(f){return r(this.negative===0),this.iushln(f)},n.prototype.iushrn=function(f,d,_){r(typeof f=="number"&&f>=0);var x;d?x=(d-d%26)/26:x=0;var b=f%26,p=Math.min((f-b)/26,this.length),O=67108863^67108863>>>b<<b,T=_;if(x-=p,x=Math.max(0,x),T){for(var S=0;S<p;S++)T.words[S]=this.words[S];T.length=p}if(p!==0)if(this.length>p)for(this.length-=p,S=0;S<this.length;S++)this.words[S]=this.words[S+p];else this.words[0]=0,this.length=1;var B=0;for(S=this.length-1;S>=0&&(B!==0||S>=x);S--){var Y=this.words[S]|0;this.words[S]=B<<26-b|Y>>>b,B=Y&O}return T&&B!==0&&(T.words[T.length++]=B),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(f,d,_){return r(this.negative===0),this.iushrn(f,d,_)},n.prototype.shln=function(f){return this.clone().ishln(f)},n.prototype.ushln=function(f){return this.clone().iushln(f)},n.prototype.shrn=function(f){return this.clone().ishrn(f)},n.prototype.ushrn=function(f){return this.clone().iushrn(f)},n.prototype.testn=function(f){r(typeof f=="number"&&f>=0);var d=f%26,_=(f-d)/26,x=1<<d;if(this.length<=_)return!1;var b=this.words[_];return!!(b&x)},n.prototype.imaskn=function(f){r(typeof f=="number"&&f>=0);var d=f%26,_=(f-d)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=_)return this;if(d!==0&&_++,this.length=Math.min(_,this.length),d!==0){var x=67108863^67108863>>>d<<d;this.words[this.length-1]&=x}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.maskn=function(f){return this.clone().imaskn(f)},n.prototype.iaddn=function(f){return r(typeof f=="number"),r(f<67108864),f<0?this.isubn(-f):this.negative!==0?this.length===1&&(this.words[0]|0)<=f?(this.words[0]=f-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(f),this.negative=1,this):this._iaddn(f)},n.prototype._iaddn=function(f){this.words[0]+=f;for(var d=0;d<this.length&&this.words[d]>=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(f){if(r(typeof f=="number"),r(f<67108864),f<0)return this.iaddn(-f);if(this.negative!==0)return this.negative=0,this.iaddn(f),this.negative=1,this;if(this.words[0]-=f,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d<this.length&&this.words[d]<0;d++)this.words[d]+=67108864,this.words[d+1]-=1;return this._strip()},n.prototype.addn=function(f){return this.clone().iaddn(f)},n.prototype.subn=function(f){return this.clone().isubn(f)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(f,d,_){var x=f.length+_,b;this._expand(x);var p,O=0;for(b=0;b<f.length;b++){p=(this.words[b+_]|0)+O;var T=(f.words[b]|0)*d;p-=T&67108863,O=(p>>26)-(T/67108864|0),this.words[b+_]=p&67108863}for(;b<this.length-_;b++)p=(this.words[b+_]|0)+O,O=p>>26,this.words[b+_]=p&67108863;if(O===0)return this._strip();for(r(O===-1),O=0,b=0;b<this.length;b++)p=-(this.words[b]|0)+O,O=p>>26,this.words[b]=p&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(f,d){var _=this.length-f.length,x=this.clone(),b=f,p=b.words[b.length-1]|0,O=this._countBits(p);_=26-O,_!==0&&(b=b.ushln(_),x.iushln(_),p=b.words[b.length-1]|0);var T=x.length-b.length,S;if(d!=="mod"){S=new n(null),S.length=T+1,S.words=new Array(S.length);for(var B=0;B<S.length;B++)S.words[B]=0}var Y=x.clone()._ishlnsubmul(b,1,T);Y.negative===0&&(x=Y,S&&(S.words[T]=1));for(var $=T-1;$>=0;$--){var ne=(x.words[b.length+$]|0)*67108864+(x.words[b.length+$-1]|0);for(ne=Math.min(ne/p|0,67108863),x._ishlnsubmul(b,ne,$);x.negative!==0;)ne--,x.negative=0,x._ishlnsubmul(b,1,$),x.isZero()||(x.negative^=1);S&&(S.words[$]=ne)}return S&&S._strip(),x._strip(),d!=="div"&&_!==0&&x.iushrn(_),{div:S||null,mod:x}},n.prototype.divmod=function(f,d,_){if(r(!f.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var x,b,p;return this.negative!==0&&f.negative===0?(p=this.neg().divmod(f,d),d!=="mod"&&(x=p.div.neg()),d!=="div"&&(b=p.mod.neg(),_&&b.negative!==0&&b.iadd(f)),{div:x,mod:b}):this.negative===0&&f.negative!==0?(p=this.divmod(f.neg(),d),d!=="mod"&&(x=p.div.neg()),{div:x,mod:p.mod}):(this.negative&f.negative)!==0?(p=this.neg().divmod(f.neg(),d),d!=="div"&&(b=p.mod.neg(),_&&b.negative!==0&&b.isub(f)),{div:p.div,mod:b}):f.length>this.length||this.cmp(f)<0?{div:new n(0),mod:this}:f.length===1?d==="div"?{div:this.divn(f.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(f.words[0]))}:{div:this.divn(f.words[0]),mod:new n(this.modrn(f.words[0]))}:this._wordDiv(f,d)},n.prototype.div=function(f){return this.divmod(f,"div",!1).div},n.prototype.mod=function(f){return this.divmod(f,"mod",!1).mod},n.prototype.umod=function(f){return this.divmod(f,"mod",!0).mod},n.prototype.divRound=function(f){var d=this.divmod(f);if(d.mod.isZero())return d.div;var _=d.div.negative!==0?d.mod.isub(f):d.mod,x=f.ushrn(1),b=f.andln(1),p=_.cmp(x);return p<0||b===1&&p===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(f){var d=f<0;d&&(f=-f),r(f<=67108863);for(var _=(1<<26)%f,x=0,b=this.length-1;b>=0;b--)x=(_*x+(this.words[b]|0))%f;return d?-x:x},n.prototype.modn=function(f){return this.modrn(f)},n.prototype.idivn=function(f){var d=f<0;d&&(f=-f),r(f<=67108863);for(var _=0,x=this.length-1;x>=0;x--){var b=(this.words[x]|0)+_*67108864;this.words[x]=b/f|0,_=b%f}return this._strip(),d?this.ineg():this},n.prototype.divn=function(f){return this.clone().idivn(f)},n.prototype.egcd=function(f){r(f.negative===0),r(!f.isZero());var d=this,_=f.clone();d.negative!==0?d=d.umod(f):d=d.clone();for(var x=new n(1),b=new n(0),p=new n(0),O=new n(1),T=0;d.isEven()&&_.isEven();)d.iushrn(1),_.iushrn(1),++T;for(var S=_.clone(),B=d.clone();!d.isZero();){for(var Y=0,$=1;(d.words[0]&$)===0&&Y<26;++Y,$<<=1);if(Y>0)for(d.iushrn(Y);Y-- >0;)(x.isOdd()||b.isOdd())&&(x.iadd(S),b.isub(B)),x.iushrn(1),b.iushrn(1);for(var ne=0,he=1;(_.words[0]&he)===0&&ne<26;++ne,he<<=1);if(ne>0)for(_.iushrn(ne);ne-- >0;)(p.isOdd()||O.isOdd())&&(p.iadd(S),O.isub(B)),p.iushrn(1),O.iushrn(1);d.cmp(_)>=0?(d.isub(_),x.isub(p),b.isub(O)):(_.isub(d),p.isub(x),O.isub(b))}return{a:p,b:O,gcd:_.iushln(T)}},n.prototype._invmp=function(f){r(f.negative===0),r(!f.isZero());var d=this,_=f.clone();d.negative!==0?d=d.umod(f):d=d.clone();for(var x=new n(1),b=new n(0),p=_.clone();d.cmpn(1)>0&&_.cmpn(1)>0;){for(var O=0,T=1;(d.words[0]&T)===0&&O<26;++O,T<<=1);if(O>0)for(d.iushrn(O);O-- >0;)x.isOdd()&&x.iadd(p),x.iushrn(1);for(var S=0,B=1;(_.words[0]&B)===0&&S<26;++S,B<<=1);if(S>0)for(_.iushrn(S);S-- >0;)b.isOdd()&&b.iadd(p),b.iushrn(1);d.cmp(_)>=0?(d.isub(_),x.isub(b)):(_.isub(d),b.isub(x))}var Y;return d.cmpn(1)===0?Y=x:Y=b,Y.cmpn(0)<0&&Y.iadd(f),Y},n.prototype.gcd=function(f){if(this.isZero())return f.abs();if(f.isZero())return this.abs();var d=this.clone(),_=f.clone();d.negative=0,_.negative=0;for(var x=0;d.isEven()&&_.isEven();x++)d.iushrn(1),_.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;_.isEven();)_.iushrn(1);var b=d.cmp(_);if(b<0){var p=d;d=_,_=p}else if(b===0||_.cmpn(1)===0)break;d.isub(_)}while(!0);return _.iushln(x)},n.prototype.invm=function(f){return this.egcd(f).a.umod(f)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(f){return this.words[0]&f},n.prototype.bincn=function(f){r(typeof f=="number");var d=f%26,_=(f-d)/26,x=1<<d;if(this.length<=_)return this._expand(_+1),this.words[_]|=x,this;for(var b=x,p=_;b!==0&&p<this.length;p++){var O=this.words[p]|0;O+=b,b=O>>>26,O&=67108863,this.words[p]=O}return b!==0&&(this.words[p]=b,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(f){var d=f<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var _;if(this.length>1)_=1;else{d&&(f=-f),r(f<=67108863,"Number is too big");var x=this.words[0]|0;_=x===f?0:x<f?-1:1}return this.negative!==0?-_|0:_},n.prototype.cmp=function(f){if(this.negative!==0&&f.negative===0)return-1;if(this.negative===0&&f.negative!==0)return 1;var d=this.ucmp(f);return this.negative!==0?-d|0:d},n.prototype.ucmp=function(f){if(this.length>f.length)return 1;if(this.length<f.length)return-1;for(var d=0,_=this.length-1;_>=0;_--){var x=this.words[_]|0,b=f.words[_]|0;if(x!==b){x<b?d=-1:x>b&&(d=1);break}}return d},n.prototype.gtn=function(f){return this.cmpn(f)===1},n.prototype.gt=function(f){return this.cmp(f)===1},n.prototype.gten=function(f){return this.cmpn(f)>=0},n.prototype.gte=function(f){return this.cmp(f)>=0},n.prototype.ltn=function(f){return this.cmpn(f)===-1},n.prototype.lt=function(f){return this.cmp(f)===-1},n.prototype.lten=function(f){return this.cmpn(f)<=0},n.prototype.lte=function(f){return this.cmp(f)<=0},n.prototype.eqn=function(f){return this.cmpn(f)===0},n.prototype.eq=function(f){return this.cmp(f)===0},n.red=function(f){return new g(f)},n.prototype.toRed=function(f){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),f.convertTo(this)._forceRed(f)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(f){return this.red=f,this},n.prototype.forceRed=function(f){return r(!this.red,"Already a number in reduction context"),this._forceRed(f)},n.prototype.redAdd=function(f){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,f)},n.prototype.redIAdd=function(f){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,f)},n.prototype.redSub=function(f){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,f)},n.prototype.redISub=function(f){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,f)},n.prototype.redShl=function(f){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,f)},n.prototype.redMul=function(f){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.mul(this,f)},n.prototype.redIMul=function(f){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.imul(this,f)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(f){return r(this.red&&!f.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,f)};var N={k256:null,p224:null,p192:null,p25519:null};function F(y,f){this.name=y,this.p=new n(f,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}F.prototype._tmp=function(){var f=new n(null);return f.words=new Array(Math.ceil(this.n/13)),f},F.prototype.ireduce=function(f){var d=f,_;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),_=d.bitLength();while(_>this.n);var x=_<this.n?-1:d.ucmp(this.p);return x===0?(d.words[0]=0,d.length=1):x>0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},F.prototype.split=function(f,d){f.iushrn(this.n,0,d)},F.prototype.imulK=function(f){return f.imul(this.k)};function H(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(H,F),H.prototype.split=function(f,d){for(var _=4194303,x=Math.min(f.length,9),b=0;b<x;b++)d.words[b]=f.words[b];if(d.length=x,f.length<=9){f.words[0]=0,f.length=1;return}var p=f.words[9];for(d.words[d.length++]=p&_,b=10;b<f.length;b++){var O=f.words[b]|0;f.words[b-10]=(O&_)<<4|p>>>22,p=O}p>>>=22,f.words[b-10]=p,p===0&&f.length>10?f.length-=10:f.length-=9},H.prototype.imulK=function(f){f.words[f.length]=0,f.words[f.length+1]=0,f.length+=2;for(var d=0,_=0;_<f.length;_++){var x=f.words[_]|0;d+=x*977,f.words[_]=d&67108863,d=x*64+(d/67108864|0)}return f.words[f.length-1]===0&&(f.length--,f.words[f.length-1]===0&&f.length--),f};function z(){F.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(z,F);function G(){F.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(G,F);function R(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(R,F),R.prototype.imulK=function(f){for(var d=0,_=0;_<f.length;_++){var x=(f.words[_]|0)*19+d,b=x&67108863;x>>>=26,f.words[_]=b,d=x}return d!==0&&(f.words[f.length++]=d),f},n._prime=function(f){if(N[f])return N[f];var d;if(f==="k256")d=new H;else if(f==="p224")d=new z;else if(f==="p192")d=new G;else if(f==="p25519")d=new R;else throw new Error("Unknown prime "+f);return N[f]=d,d};function g(y){if(typeof y=="string"){var f=n._prime(y);this.m=f.p,this.prime=f}else r(y.gtn(1),"modulus must be greater than 1"),this.m=y,this.prime=null}g.prototype._verify1=function(f){r(f.negative===0,"red works only with positives"),r(f.red,"red works only with red numbers")},g.prototype._verify2=function(f,d){r((f.negative|d.negative)===0,"red works only with positives"),r(f.red&&f.red===d.red,"red works only with red numbers")},g.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(c(f,f.umod(this.m)._forceRed(this)),f)},g.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},g.prototype.add=function(f,d){this._verify2(f,d);var _=f.add(d);return _.cmp(this.m)>=0&&_.isub(this.m),_._forceRed(this)},g.prototype.iadd=function(f,d){this._verify2(f,d);var _=f.iadd(d);return _.cmp(this.m)>=0&&_.isub(this.m),_},g.prototype.sub=function(f,d){this._verify2(f,d);var _=f.sub(d);return _.cmpn(0)<0&&_.iadd(this.m),_._forceRed(this)},g.prototype.isub=function(f,d){this._verify2(f,d);var _=f.isub(d);return _.cmpn(0)<0&&_.iadd(this.m),_},g.prototype.shl=function(f,d){return this._verify1(f),this.imod(f.ushln(d))},g.prototype.imul=function(f,d){return this._verify2(f,d),this.imod(f.imul(d))},g.prototype.mul=function(f,d){return this._verify2(f,d),this.imod(f.mul(d))},g.prototype.isqr=function(f){return this.imul(f,f.clone())},g.prototype.sqr=function(f){return this.mul(f,f)},g.prototype.sqrt=function(f){if(f.isZero())return f.clone();var d=this.m.andln(3);if(r(d%2===1),d===3){var _=this.m.add(new n(1)).iushrn(2);return this.pow(f,_)}for(var x=this.m.subn(1),b=0;!x.isZero()&&x.andln(1)===0;)b++,x.iushrn(1);r(!x.isZero());var p=new n(1).toRed(this),O=p.redNeg(),T=this.m.subn(1).iushrn(1),S=this.m.bitLength();for(S=new n(2*S*S).toRed(this);this.pow(S,T).cmp(O)!==0;)S.redIAdd(O);for(var B=this.pow(S,x),Y=this.pow(f,x.addn(1).iushrn(1)),$=this.pow(f,x),ne=b;$.cmp(p)!==0;){for(var he=$,pe=0;he.cmp(p)!==0;pe++)he=he.redSqr();r(pe<ne);var q=this.pow(B,new n(1).iushln(ne-pe-1));Y=Y.redMul(q),B=q.redSqr(),$=$.redMul(B),ne=pe}return Y},g.prototype.invm=function(f){var d=f._invmp(this.m);return d.negative!==0?(d.negative=0,this.imod(d).redNeg()):this.imod(d)},g.prototype.pow=function(f,d){if(d.isZero())return new n(1).toRed(this);if(d.cmpn(1)===0)return f.clone();var _=4,x=new Array(1<<_);x[0]=new n(1).toRed(this),x[1]=f;for(var b=2;b<x.length;b++)x[b]=this.mul(x[b-1],f);var p=x[0],O=0,T=0,S=d.bitLength()%26;for(S===0&&(S=26),b=d.length-1;b>=0;b--){for(var B=d.words[b],Y=S-1;Y>=0;Y--){var $=B>>Y&1;if(p!==x[0]&&(p=this.sqr(p)),$===0&&O===0){T=0;continue}O<<=1,O|=$,T++,!(T!==_&&(b!==0||Y!==0))&&(p=this.mul(p,x[O]),T=0,O=0)}S=26}return p},g.prototype.convertTo=function(f){var d=f.umod(this.m);return d===f?d.clone():d},g.prototype.convertFrom=function(f){var d=f.clone();return d.red=null,d},n.mont=function(f){return new I(f)};function I(y){g.call(this,y),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)}i(I,g),I.prototype.convertTo=function(f){return this.imod(f.ushln(this.shift))},I.prototype.convertFrom=function(f){var d=this.imod(f.mul(this.rinv));return d.red=null,d},I.prototype.imul=function(f,d){if(f.isZero()||d.isZero())return f.words[0]=0,f.length=1,f;var _=f.imul(d),x=_.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=_.isub(x).iushrn(this.shift),p=b;return b.cmp(this.m)>=0?p=b.isub(this.m):b.cmpn(0)<0&&(p=b.iadd(this.m)),p._forceRed(this)},I.prototype.mul=function(f,d){if(f.isZero()||d.isZero())return new n(0)._forceRed(this);var _=f.mul(d),x=_.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=_.isub(x).iushrn(this.shift),p=b;return b.cmp(this.m)>=0?p=b.isub(this.m):b.cmpn(0)<0&&(p=b.iadd(this.m)),p._forceRed(this)},I.prototype.invm=function(f){var d=this.imod(f._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof km>"u"||km,MI)});var Rm=k((Kde,LI)=>{"use strict";v();var Bc=CI(),JY=wu(),QY=nt().Buffer;function NI(e){var t=e.modulus.byteLength(),r;do r=new Bc(JY(t));while(r.cmp(e.modulus)>=0||!r.umod(e.prime1)||!r.umod(e.prime2));return r}function e$(e){var t=NI(e),r=t.toRed(Bc.mont(e.modulus)).redPow(new Bc(e.publicExponent)).fromRed();return{blinder:r,unblinder:t.invm(e.modulus)}}function DI(e,t){var r=e$(t),i=t.modulus.byteLength(),n=new Bc(e).mul(r.blinder).umod(t.modulus),o=n.toRed(Bc.mont(t.prime1)),a=n.toRed(Bc.mont(t.prime2)),s=t.coefficient,u=t.prime1,c=t.prime2,l=o.redPow(t.exponent1).fromRed(),m=a.redPow(t.exponent2).fromRed(),w=l.isub(m).imul(s).umod(u).imul(c);return m.iadd(w).imul(r.unblinder).umod(t.modulus).toArrayLike(QY,"be",i)}DI.getr=NI;LI.exports=DI});var HI=k((Gde,FI)=>{v();var t$=Im(),Bm=wu(),r$=zh(),qI=Am(),UI=Pm(),Mm=Ln(),i$=Tm(),n$=Rm(),jn=nt().Buffer;FI.exports=function(t,r,i){var n;t.padding?n=t.padding:i?n=1:n=4;var o=t$(t),a;if(n===4)a=o$(o,r);else if(n===1)a=a$(o,r,i);else if(n===3){if(a=new Mm(r),a.cmp(o.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return i?n$(a,o):i$(a,o)};function o$(e,t){var r=e.modulus.byteLength(),i=t.length,n=r$("sha1").update(jn.alloc(0)).digest(),o=n.length,a=2*o;if(i>r-a-2)throw new Error("message too long");var s=jn.alloc(r-i-a-2),u=r-o-1,c=Bm(o),l=UI(jn.concat([n,s,jn.alloc(1,1),t],u),qI(c,u)),m=UI(c,qI(l,o));return new Mm(jn.concat([jn.alloc(1),m,l],r))}function a$(e,t,r){var i=t.length,n=e.modulus.byteLength();if(i>n-11)throw new Error("message too long");var o;return r?o=jn.alloc(n-i-3,255):o=s$(n-i-3),new Mm(jn.concat([jn.from([0,r?1:2]),o,jn.alloc(1),t],n))}function s$(e){for(var t=jn.allocUnsafe(e),r=0,i=Bm(e*2),n=0,o;r<e;)n===i.length&&(i=Bm(e*2),n=0),o=i[n++],o&&(t[r++]=o);return t}});var GI=k((Wde,VI)=>{v();var u$=Im(),jI=Am(),zI=Pm(),KI=Ln(),f$=Rm(),c$=zh(),l$=Tm(),t0=nt().Buffer;VI.exports=function(t,r,i){var n;t.padding?n=t.padding:i?n=1:n=4;var o=u$(t),a=o.modulus.byteLength();if(r.length>a||new KI(r).cmp(o.modulus)>=0)throw new Error("decryption error");var s;i?s=l$(new KI(r),o):s=f$(r,o);var u=t0.alloc(a-s.length);if(s=t0.concat([u,s],a),n===4)return h$(o,s);if(n===1)return d$(o,s,i);if(n===3)return s;throw new Error("unknown padding")};function h$(e,t){var r=e.modulus.byteLength(),i=c$("sha1").update(t0.alloc(0)).digest(),n=i.length;if(t[0]!==0)throw new Error("decryption error");var o=t.slice(1,n+1),a=t.slice(n+1),s=zI(o,jI(a,n)),u=zI(a,jI(s,r-n-1));if(p$(i,u.slice(0,n)))throw new Error("decryption error");for(var c=n;u[c]===0;)c++;if(u[c++]!==1)throw new Error("decryption error");return u.slice(c)}function d$(e,t,r){for(var i=t.slice(0,2),n=2,o=0;t[n++]!==0;)if(n>=t.length){o++;break}var a=t.slice(2,n-1);if((i.toString("hex")!=="0002"&&!r||i.toString("hex")!=="0001"&&r)&&o++,a.length<8&&o++,o)throw new Error("decryption error");return t.slice(n)}function p$(e,t){e=t0.from(e),t=t0.from(t);var r=0,i=e.length;e.length!==t.length&&(r++,i=Math.min(e.length,t.length));for(var n=-1;++n<i;)r+=e[n]^t[n];return r}});var ZI=k(Gu=>{v();Gu.publicEncrypt=HI();Gu.privateDecrypt=GI();Gu.privateEncrypt=function(t,r){return Gu.publicEncrypt(t,r,!0)};Gu.publicDecrypt=function(t,r){return Gu.privateDecrypt(t,r,!0)}});var iO=k(r0=>{"use strict";v();function WI(){throw new Error(`secure random number generation not supported by this browser
|
|
15
15
|
use chrome, FireFox or Internet Explorer 11`)}var $I=nt(),YI=wu(),XI=$I.Buffer,JI=$I.kMaxLength,Cm=globalThis.crypto||globalThis.msCrypto,QI=Math.pow(2,32)-1;function eO(e,t){if(typeof e!="number"||e!==e)throw new TypeError("offset must be a number");if(e>QI||e<0)throw new TypeError("offset must be a uint32");if(e>JI||e>t)throw new RangeError("offset out of range")}function tO(e,t,r){if(typeof e!="number"||e!==e)throw new TypeError("size must be a number");if(e>QI||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>JI)throw new RangeError("buffer too small")}Cm&&Cm.getRandomValues||!A.default.browser?(r0.randomFill=g$,r0.randomFillSync=v$):(r0.randomFill=WI,r0.randomFillSync=WI);function g$(e,t,r,i){if(!XI.isBuffer(e)&&!(e instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof t=="function")i=t,t=0,r=e.length;else if(typeof r=="function")i=r,r=e.length-t;else if(typeof i!="function")throw new TypeError('"cb" argument must be a function');return eO(t,e.length),tO(r,t,e.length),rO(e,t,r,i)}function rO(e,t,r,i){if(A.default.browser){var n=e.buffer,o=new Uint8Array(n,t,r);if(Cm.getRandomValues(o),i){A.default.nextTick(function(){i(null,e)});return}return e}if(i){YI(r,function(s,u){if(s)return i(s);u.copy(e,t),i(null,e)});return}var a=YI(r);return a.copy(e,t),e}function v$(e,t,r){if(typeof t>"u"&&(t=0),!XI.isBuffer(e)&&!(e instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return eO(t,e.length),r===void 0&&(r=e.length-t),tO(r,t,e.length),rO(e,t,r)}});var _r=k(ot=>{"use strict";v();ot.randomBytes=ot.rng=ot.pseudoRandomBytes=ot.prng=wu();ot.createHash=ot.Hash=zh();ot.createHmac=ot.Hmac=QS();var m$=ls(),y$=Object.keys(m$),b$=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(y$);ot.getHashes=function(){return b$};var nO=Cv();ot.pbkdf2=nO.pbkdf2;ot.pbkdf2Sync=nO.pbkdf2Sync;var Io=EE();ot.Cipher=Io.Cipher;ot.createCipher=Io.createCipher;ot.Cipheriv=Io.Cipheriv;ot.createCipheriv=Io.createCipheriv;ot.Decipher=Io.Decipher;ot.createDecipher=Io.createDecipher;ot.Decipheriv=Io.Decipheriv;ot.createDecipheriv=Io.createDecipheriv;ot.getCiphers=Io.getCiphers;ot.listCiphers=Io.listCiphers;var i0=qE();ot.DiffieHellmanGroup=i0.DiffieHellmanGroup;ot.createDiffieHellmanGroup=i0.createDiffieHellmanGroup;ot.getDiffieHellman=i0.getDiffieHellman;ot.createDiffieHellman=i0.createDiffieHellman;ot.DiffieHellman=i0.DiffieHellman;var K2=ls();ot.createSign=K2.createSign;ot.Sign=K2.Sign;ot.createVerify=K2.createVerify;ot.Verify=K2.Verify;ot.createECDH=ls();var V2=ZI();ot.publicEncrypt=V2.publicEncrypt;ot.privateEncrypt=V2.privateEncrypt;ot.publicDecrypt=V2.publicDecrypt;ot.privateDecrypt=V2.privateDecrypt;var oO=iO();ot.randomFill=oO.randomFill;ot.randomFillSync=oO.randomFillSync;ot.createCredentials=function(){throw new Error(`sorry, createCredentials is not implemented yet
|
|
16
16
|
we accept pull requests
|
|
17
|
-
https://github.com/browserify/crypto-browserify`)};ot.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var zi=k((r2e,aO)=>{"use strict";v();function Mc(){}Mc.getRandomBuffer=function(e){return A.default.browser?Mc.getRandomBufferBrowser(e):Mc.getRandomBufferNode(e)};Mc.getRandomBufferNode=function(e){var t=_r();return t.randomBytes(e)};Mc.getRandomBufferBrowser=function(e){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var t;if(window.crypto&&window.crypto.getRandomValues)t=window.crypto;else if(window.msCrypto&&window.msCrypto.getRandomValues)t=window.msCrypto;else throw new Error("window.crypto.getRandomValues not available");var r=new Uint8Array(e);t.getRandomValues(r);var i=h.Buffer.from(r);return i};aO.exports=Mc});var bt=k((n2e,sO)=>{"use strict";v();var _$=zi(),Wt={};Wt.isArray=e=>Array.isArray(e);Wt.isNumber=e=>typeof e=="number";Wt.isObject=e=>e&&typeof e=="object";Wt.isString=e=>typeof e=="string";Wt.isUndefined=e=>typeof e>"u";Wt.isFunction=e=>typeof e=="function";Wt.isNull=e=>e===null;Wt.isDate=e=>e instanceof Date;Wt.extend=(e,t)=>Object.assign(e,t);Wt.noop=()=>{};Wt.every=(e,t)=>e.every(t||(r=>r));Wt.map=(e,t)=>Array.from(e).map(t||(r=>r));Wt.includes=(e,t)=>e.includes(t);Wt.each=(e,t)=>e.forEach(t);Wt.clone=e=>Object.assign({},e);Wt.pick=(e,t)=>{let r={};return t.forEach(i=>{typeof e[i]<"u"&&(r[i]=e[i])}),r};Wt.values=e=>Object.values(e);Wt.filter=(e,t)=>e.filter(t);Wt.reduce=(e,t,r)=>e.reduce(t,r);Wt.without=(e,t)=>e.filter(r=>r!==t);Wt.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let n=_$.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(n*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};Wt.difference=(e,t)=>e.filter(r=>!t.includes(r));Wt.findIndex=(e,t)=>e.findIndex(t);Wt.some=(e,t)=>e.some(t);Wt.range=e=>[...Array(e).keys()];sO.exports=Wt});var fO=k((a2e,uO)=>{"use strict";v();var G2=nt().Buffer;function w$(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var n=e.charAt(i),o=n.charCodeAt(0);if(t[o]!==255)throw new TypeError(n+" is ambiguous");t[o]=i}var a=e.length,s=e.charAt(0),u=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(E){if((Array.isArray(E)||E instanceof Uint8Array)&&(E=G2.from(E)),!G2.isBuffer(E))throw new TypeError("Expected Buffer");if(E.length===0)return"";for(var P=0,M=0,D=0,L=E.length;D!==L&&E[D]===0;)D++,P++;for(var U=(L-D)*c+1>>>0,K=new Uint8Array(U);D!==L;){for(var C=E[D],N=0,F=U-1;(C!==0||N<M)&&F!==-1;F--,N++)C+=256*K[F]>>>0,K[F]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");M=N,D++}for(var H=U-M;H!==U&&K[H]===0;)H++;for(var z=s.repeat(P);H<U;++H)z+=e.charAt(K[H]);return z}function m(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return G2.alloc(0);for(var P=0,M=0,D=0;E[P]===s;)M++,P++;for(var L=(E.length-P)*u+1>>>0,U=new Uint8Array(L);P<E.length;){var K=E.charCodeAt(P);if(K>255)return;var C=t[K];if(C===255)return;for(var N=0,F=L-1;(C!==0||N<D)&&F!==-1;F--,N++)C+=a*U[F]>>>0,U[F]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");D=N,P++}for(var H=L-D;H!==L&&U[H]===0;)H++;var z=G2.allocUnsafe(M+(L-H));z.fill(0,0,M);for(var G=M;H!==L;)z[G++]=U[H++];return z}function w(E){var P=m(E);if(P)return P;throw new Error("Non-base"+a+" character")}return{encode:l,decodeUnsafe:m,decode:w}}uO.exports=w$});var Z2=k((u2e,cO)=>{v();var S$=fO(),x$="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";cO.exports=S$(x$)});var Nm=k((c2e,lO)=>{"use strict";v();lO.exports="7.10.
|
|
17
|
+
https://github.com/browserify/crypto-browserify`)};ot.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var zi=k((r2e,aO)=>{"use strict";v();function Mc(){}Mc.getRandomBuffer=function(e){return A.default.browser?Mc.getRandomBufferBrowser(e):Mc.getRandomBufferNode(e)};Mc.getRandomBufferNode=function(e){var t=_r();return t.randomBytes(e)};Mc.getRandomBufferBrowser=function(e){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var t;if(window.crypto&&window.crypto.getRandomValues)t=window.crypto;else if(window.msCrypto&&window.msCrypto.getRandomValues)t=window.msCrypto;else throw new Error("window.crypto.getRandomValues not available");var r=new Uint8Array(e);t.getRandomValues(r);var i=h.Buffer.from(r);return i};aO.exports=Mc});var bt=k((n2e,sO)=>{"use strict";v();var _$=zi(),Wt={};Wt.isArray=e=>Array.isArray(e);Wt.isNumber=e=>typeof e=="number";Wt.isObject=e=>e&&typeof e=="object";Wt.isString=e=>typeof e=="string";Wt.isUndefined=e=>typeof e>"u";Wt.isFunction=e=>typeof e=="function";Wt.isNull=e=>e===null;Wt.isDate=e=>e instanceof Date;Wt.extend=(e,t)=>Object.assign(e,t);Wt.noop=()=>{};Wt.every=(e,t)=>e.every(t||(r=>r));Wt.map=(e,t)=>Array.from(e).map(t||(r=>r));Wt.includes=(e,t)=>e.includes(t);Wt.each=(e,t)=>e.forEach(t);Wt.clone=e=>Object.assign({},e);Wt.pick=(e,t)=>{let r={};return t.forEach(i=>{typeof e[i]<"u"&&(r[i]=e[i])}),r};Wt.values=e=>Object.values(e);Wt.filter=(e,t)=>e.filter(t);Wt.reduce=(e,t,r)=>e.reduce(t,r);Wt.without=(e,t)=>e.filter(r=>r!==t);Wt.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let n=_$.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(n*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};Wt.difference=(e,t)=>e.filter(r=>!t.includes(r));Wt.findIndex=(e,t)=>e.findIndex(t);Wt.some=(e,t)=>e.some(t);Wt.range=e=>[...Array(e).keys()];sO.exports=Wt});var fO=k((a2e,uO)=>{"use strict";v();var G2=nt().Buffer;function w$(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var n=e.charAt(i),o=n.charCodeAt(0);if(t[o]!==255)throw new TypeError(n+" is ambiguous");t[o]=i}var a=e.length,s=e.charAt(0),u=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(E){if((Array.isArray(E)||E instanceof Uint8Array)&&(E=G2.from(E)),!G2.isBuffer(E))throw new TypeError("Expected Buffer");if(E.length===0)return"";for(var P=0,M=0,D=0,L=E.length;D!==L&&E[D]===0;)D++,P++;for(var U=(L-D)*c+1>>>0,K=new Uint8Array(U);D!==L;){for(var C=E[D],N=0,F=U-1;(C!==0||N<M)&&F!==-1;F--,N++)C+=256*K[F]>>>0,K[F]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");M=N,D++}for(var H=U-M;H!==U&&K[H]===0;)H++;for(var z=s.repeat(P);H<U;++H)z+=e.charAt(K[H]);return z}function m(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return G2.alloc(0);for(var P=0,M=0,D=0;E[P]===s;)M++,P++;for(var L=(E.length-P)*u+1>>>0,U=new Uint8Array(L);P<E.length;){var K=E.charCodeAt(P);if(K>255)return;var C=t[K];if(C===255)return;for(var N=0,F=L-1;(C!==0||N<D)&&F!==-1;F--,N++)C+=a*U[F]>>>0,U[F]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");D=N,P++}for(var H=L-D;H!==L&&U[H]===0;)H++;var z=G2.allocUnsafe(M+(L-H));z.fill(0,0,M);for(var G=M;H!==L;)z[G++]=U[H++];return z}function w(E){var P=m(E);if(P)return P;throw new Error("Non-base"+a+" character")}return{encode:l,decodeUnsafe:m,decode:w}}uO.exports=w$});var Z2=k((u2e,cO)=>{v();var S$=fO(),x$="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";cO.exports=S$(x$)});var Nm=k((c2e,lO)=>{"use strict";v();lO.exports="7.10.1"});var dO=k((h2e,hO)=>{"use strict";v();var E$="https://docs.moneybutton.com/";hO.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+E$+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var ci=k((p2e,Lm)=>{"use strict";v();var Dm=bt();function I$(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var pO=function(e,t){var r=function(){if(Dm.isString(t.message))this.message=I$(t.message,arguments);else if(Dm.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
|
|
18
18
|
`+new Error().stack};return r.prototype=Object.create(e.prototype),r.prototype.name=e.prototype.name+t.name,e[t.name]=r,t.errors&&gO(r,t.errors),r},gO=function(e,t){Dm.each(t,function(r){pO(e,r)})},O$=function(e,t){return gO(e,t),e},Cc={};Cc.Error=function(){this.message="Internal error",this.stack=this.message+`
|
|
19
19
|
`+new Error().stack};Cc.Error.prototype=Object.create(Error.prototype);Cc.Error.prototype.name="bsv.Error";var A$=dO();O$(Cc.Error,A$);Lm.exports=Cc.Error;Lm.exports.extend=function(e){return pO(Cc.Error,e)}});var Be=k((v2e,vO)=>{"use strict";v();var n0=ci(),P$=bt();vO.exports={checkState:function(e,t){if(!e)throw new n0.InvalidState(t)},checkArgument:function(e,t,r,i){if(!e)throw new n0.InvalidArgument(t,r,i)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",P$.isString(t)){if(t==="Buffer"){var i=Zt();if(!i.Buffer.isBuffer(e))throw new n0.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new n0.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new n0.InvalidArgumentType(e,t.name,r)}}});var _t=k((y2e,yO)=>{"use strict";v();var Pt=Ln(),qm=Be(),mO=bt(),W2=function(e){for(var t=h.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};Pt.Zero=new Pt(0);Pt.One=new Pt(1);Pt.Minus1=new Pt(-1);Pt.fromNumber=function(e){return qm.checkArgument(mO.isNumber(e)),new Pt(e)};Pt.fromString=function(e,t){return qm.checkArgument(mO.isString(e)),new Pt(e,t)};Pt.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=W2(e));var r=e.toString("hex"),i=new Pt(r,16);return i};Pt.fromSM=function(e,t){var r;if(e.length===0)return Pt.fromBuffer(h.Buffer.from([0]));var i="big";return t&&(i=t.endian),i==="little"&&(e=W2(e)),e[0]&128?(e[0]=e[0]&127,r=Pt.fromBuffer(e),r.neg().copy(r)):r=Pt.fromBuffer(e),r};Pt.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Pt.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var i=r.length/2;t=h.Buffer.from(r,"hex"),i===e.size||(i>e.size?t=Pt.trim(t,i):i<e.size&&(t=Pt.pad(t,i,e.size)))}else r=this.toString(16,2),t=h.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=W2(t)),t};Pt.prototype.toSMBigEndian=function(){var e;return this.cmp(Pt.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=h.Buffer.concat([h.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=h.Buffer.concat([h.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=h.Buffer.from([])),e};Pt.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=W2(r)),r};Pt.fromScriptNumBuffer=function(e,t,r){var i=r||4;if(qm.checkArgument(e.length<=i,new Error("script number overflow")),t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw new Error("non-minimally encoded script number");return Pt.fromSM(e,{endian:"little"})};Pt.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Pt.trim=function(e,t){return e.slice(t-e.length,e.length)};Pt.pad=function(e,t,r){for(var i=h.Buffer.alloc(r),n=0;n<e.length;n++)i[i.length-1-n]=e[e.length-1-n];for(n=0;n<r-t;n++)i[n]=0;return i};Pt.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};Pt.fromHex=function(e,...t){return Pt.fromBuffer(h.Buffer.from(e,"hex"),...t)};yO.exports=Pt});function Um(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function gs(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function Oo(e,t,r=""){let i=Um(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let a=r&&`"${r}" `,s=o?` of length ${t}`:"",u=i?`length=${n}`:`type=${typeof e}`,c=a+"expected Uint8Array"+s+", got "+u;throw i?new RangeError(c):new TypeError(c)}return e}function Y2(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(gs(e.outputLen),gs(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Nc(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function $2(e,t){Oo(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Aa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function X2(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function zn(e,t){return e<<32-t|e>>>t}function J2(e){if(Oo(e),_O)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=T$[e[r]];return t}function bO(e){if(e>=Oa._0&&e<=Oa._9)return e-Oa._0;if(e>=Oa.A&&e<=Oa.F)return e-(Oa.A-10);if(e>=Oa.a&&e<=Oa.f)return e-(Oa.a-10)}function Fm(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(_O)try{return Uint8Array.fromHex(e)}catch(n){throw n instanceof SyntaxError?new RangeError(n.message):n}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let a=bO(e.charCodeAt(o)),s=bO(e.charCodeAt(o+1));if(a===void 0||s===void 0){let u=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+u+'" at index '+o)}i[n]=a*16+s}return i}function Pa(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function wO(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];Oo(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function Zu(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.canXOF=i.canXOF,r.create=n=>e(n),Object.assign(r,t),Object.freeze(r)}function o0(e=32){gs(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var _O,T$,Oa,Wu,vs=Yr(()=>{v();_O=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",T$=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Oa={_0:48,_9:57,A:65,F:70,a:97,f:102};Wu=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function SO(e,t,r){return e&t^~e&r}function xO(e,t,r){return e&t^e&r^t&r}var a0,Ta,ka,Xr,Jr,EO=Yr(()=>{v();vs();a0=class{constructor(t,r,i,n){Z(this,"blockLen");Z(this,"outputLen");Z(this,"canXOF",!1);Z(this,"padOffset");Z(this,"isLE");Z(this,"buffer");Z(this,"view");Z(this,"finished",!1);Z(this,"length",0);Z(this,"pos",0);Z(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(t),this.view=X2(this.buffer)}update(t){Nc(this),Oo(t);let{view:r,buffer:i,blockLen:n}=this,o=t.length;for(let a=0;a<o;){let s=Math.min(n-this.pos,o-a);if(s===n){let u=X2(t);for(;n<=o-a;a+=n)this.process(u,a);continue}i.set(t.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Nc(this),$2(t,this),this.finished=!0;let{buffer:r,view:i,blockLen:n,isLE:o}=this,{pos:a}=this;r[a++]=128,Aa(this.buffer.subarray(a)),this.padOffset>n-a&&(this.process(i,0),a=0);for(let m=a;m<n;m++)r[m]=0;i.setBigUint64(n-8,BigInt(this.length*8),o),this.process(i,0);let s=X2(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let c=u/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<c;m++)s.setUint32(4*m,l[m],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let i=t.slice(0,r);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:i,length:n,finished:o,destroyed:a,pos:s}=this;return t.destroyed=a,t.finished=o,t.length=n,t.pos=s,n%r&&t.buffer.set(i),t}clone(){return this._cloneInto()}},Ta=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ka=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Xr=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Jr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function k$(e,t=!1){return t?{h:Number(e&Q2),l:Number(e>>IO&Q2)}:{h:Number(e>>IO&Q2)|0,l:Number(e&Q2)|0}}function OO(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:a,l:s}=k$(e[o],t);[i[o],n[o]]=[a,s]}return[i,n]}function Ao(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var Q2,IO,Hm,jm,Yu,$u,s0,u0,AO,PO,TO,kO,RO,BO,MO=Yr(()=>{v();Q2=BigInt(4294967295),IO=BigInt(32);Hm=(e,t,r)=>e>>>r,jm=(e,t,r)=>e<<32-r|t>>>r,Yu=(e,t,r)=>e>>>r|t<<32-r,$u=(e,t,r)=>e<<32-r|t>>>r,s0=(e,t,r)=>e<<64-r|t>>>r-32,u0=(e,t,r)=>e>>>r-32|t<<64-r;AO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),PO=(e,t,r,i)=>t+r+i+(e/2**32|0)|0,TO=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),kO=(e,t,r,i,n)=>t+r+i+n+(e/2**32|0)|0,RO=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),BO=(e,t,r,i,n,o)=>t+r+i+n+o+(e/2**32|0)|0});var zm={};X1(zm,{_SHA224:()=>rp,_SHA256:()=>tp,_SHA384:()=>np,_SHA512:()=>ip,_SHA512_224:()=>op,_SHA512_256:()=>ap,sha224:()=>N$,sha256:()=>_s,sha384:()=>L$,sha512:()=>D$,sha512_224:()=>U$,sha512_256:()=>q$});var B$,ms,ep,tp,rp,CO,M$,C$,ys,bs,Dc,ip,np,li,hi,op,ap,_s,N$,D$,L$,q$,U$,sp=Yr(()=>{v();EO();MO();vs();B$=Uint32Array.from([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]),ms=new Uint32Array(64),ep=class extends a0{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:i,D:n,E:o,F:a,G:s,H:u}=this;return[t,r,i,n,o,a,s,u]}set(t,r,i,n,o,a,s,u){this.A=t|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=o|0,this.F=a|0,this.G=s|0,this.H=u|0}process(t,r){for(let m=0;m<16;m++,r+=4)ms[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let w=ms[m-15],E=ms[m-2],P=zn(w,7)^zn(w,18)^w>>>3,M=zn(E,17)^zn(E,19)^E>>>10;ms[m]=M+ms[m-7]+P+ms[m-16]|0}let{A:i,B:n,C:o,D:a,E:s,F:u,G:c,H:l}=this;for(let m=0;m<64;m++){let w=zn(s,6)^zn(s,11)^zn(s,25),E=l+w+SO(s,u,c)+B$[m]+ms[m]|0,M=(zn(i,2)^zn(i,13)^zn(i,22))+xO(i,n,o)|0;l=c,c=u,u=s,s=a+E|0,a=o,o=n,n=i,i=E+M|0}i=i+this.A|0,n=n+this.B|0,o=o+this.C|0,a=a+this.D|0,s=s+this.E|0,u=u+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(i,n,o,a,s,u,c,l)}roundClean(){Aa(ms)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Aa(this.buffer)}},tp=class extends ep{constructor(){super(32);Z(this,"A",Ta[0]|0);Z(this,"B",Ta[1]|0);Z(this,"C",Ta[2]|0);Z(this,"D",Ta[3]|0);Z(this,"E",Ta[4]|0);Z(this,"F",Ta[5]|0);Z(this,"G",Ta[6]|0);Z(this,"H",Ta[7]|0)}},rp=class extends ep{constructor(){super(28);Z(this,"A",ka[0]|0);Z(this,"B",ka[1]|0);Z(this,"C",ka[2]|0);Z(this,"D",ka[3]|0);Z(this,"E",ka[4]|0);Z(this,"F",ka[5]|0);Z(this,"G",ka[6]|0);Z(this,"H",ka[7]|0)}},CO=OO(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),M$=CO[0],C$=CO[1],ys=new Uint32Array(80),bs=new Uint32Array(80),Dc=class extends a0{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:i,Bl:n,Ch:o,Cl:a,Dh:s,Dl:u,Eh:c,El:l,Fh:m,Fl:w,Gh:E,Gl:P,Hh:M,Hl:D}=this;return[t,r,i,n,o,a,s,u,c,l,m,w,E,P,M,D]}set(t,r,i,n,o,a,s,u,c,l,m,w,E,P,M,D){this.Ah=t|0,this.Al=r|0,this.Bh=i|0,this.Bl=n|0,this.Ch=o|0,this.Cl=a|0,this.Dh=s|0,this.Dl=u|0,this.Eh=c|0,this.El=l|0,this.Fh=m|0,this.Fl=w|0,this.Gh=E|0,this.Gl=P|0,this.Hh=M|0,this.Hl=D|0}process(t,r){for(let K=0;K<16;K++,r+=4)ys[K]=t.getUint32(r),bs[K]=t.getUint32(r+=4);for(let K=16;K<80;K++){let C=ys[K-15]|0,N=bs[K-15]|0,F=Yu(C,N,1)^Yu(C,N,8)^Hm(C,N,7),H=$u(C,N,1)^$u(C,N,8)^jm(C,N,7),z=ys[K-2]|0,G=bs[K-2]|0,R=Yu(z,G,19)^s0(z,G,61)^Hm(z,G,6),g=$u(z,G,19)^u0(z,G,61)^jm(z,G,6),I=TO(H,g,bs[K-7],bs[K-16]),y=kO(I,F,R,ys[K-7],ys[K-16]);ys[K]=y|0,bs[K]=I|0}let{Ah:i,Al:n,Bh:o,Bl:a,Ch:s,Cl:u,Dh:c,Dl:l,Eh:m,El:w,Fh:E,Fl:P,Gh:M,Gl:D,Hh:L,Hl:U}=this;for(let K=0;K<80;K++){let C=Yu(m,w,14)^Yu(m,w,18)^s0(m,w,41),N=$u(m,w,14)^$u(m,w,18)^u0(m,w,41),F=m&E^~m&M,H=w&P^~w&D,z=RO(U,N,H,C$[K],bs[K]),G=BO(z,L,C,F,M$[K],ys[K]),R=z|0,g=Yu(i,n,28)^s0(i,n,34)^s0(i,n,39),I=$u(i,n,28)^u0(i,n,34)^u0(i,n,39),y=i&o^i&s^o&s,f=n&a^n&u^a&u;L=M|0,U=D|0,M=E|0,D=P|0,E=m|0,P=w|0,{h:m,l:w}=Ao(c|0,l|0,G|0,R|0),c=s|0,l=u|0,s=o|0,u=a|0,o=i|0,a=n|0;let d=AO(R,I,f);i=PO(d,G,g,y),n=d|0}({h:i,l:n}=Ao(this.Ah|0,this.Al|0,i|0,n|0)),{h:o,l:a}=Ao(this.Bh|0,this.Bl|0,o|0,a|0),{h:s,l:u}=Ao(this.Ch|0,this.Cl|0,s|0,u|0),{h:c,l}=Ao(this.Dh|0,this.Dl|0,c|0,l|0),{h:m,l:w}=Ao(this.Eh|0,this.El|0,m|0,w|0),{h:E,l:P}=Ao(this.Fh|0,this.Fl|0,E|0,P|0),{h:M,l:D}=Ao(this.Gh|0,this.Gl|0,M|0,D|0),{h:L,l:U}=Ao(this.Hh|0,this.Hl|0,L|0,U|0),this.set(i,n,o,a,s,u,c,l,m,w,E,P,M,D,L,U)}roundClean(){Aa(ys,bs)}destroy(){this.destroyed=!0,Aa(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ip=class extends Dc{constructor(){super(64);Z(this,"Ah",Jr[0]|0);Z(this,"Al",Jr[1]|0);Z(this,"Bh",Jr[2]|0);Z(this,"Bl",Jr[3]|0);Z(this,"Ch",Jr[4]|0);Z(this,"Cl",Jr[5]|0);Z(this,"Dh",Jr[6]|0);Z(this,"Dl",Jr[7]|0);Z(this,"Eh",Jr[8]|0);Z(this,"El",Jr[9]|0);Z(this,"Fh",Jr[10]|0);Z(this,"Fl",Jr[11]|0);Z(this,"Gh",Jr[12]|0);Z(this,"Gl",Jr[13]|0);Z(this,"Hh",Jr[14]|0);Z(this,"Hl",Jr[15]|0)}},np=class extends Dc{constructor(){super(48);Z(this,"Ah",Xr[0]|0);Z(this,"Al",Xr[1]|0);Z(this,"Bh",Xr[2]|0);Z(this,"Bl",Xr[3]|0);Z(this,"Ch",Xr[4]|0);Z(this,"Cl",Xr[5]|0);Z(this,"Dh",Xr[6]|0);Z(this,"Dl",Xr[7]|0);Z(this,"Eh",Xr[8]|0);Z(this,"El",Xr[9]|0);Z(this,"Fh",Xr[10]|0);Z(this,"Fl",Xr[11]|0);Z(this,"Gh",Xr[12]|0);Z(this,"Gl",Xr[13]|0);Z(this,"Hh",Xr[14]|0);Z(this,"Hl",Xr[15]|0)}},li=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),hi=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),op=class extends Dc{constructor(){super(28);Z(this,"Ah",li[0]|0);Z(this,"Al",li[1]|0);Z(this,"Bh",li[2]|0);Z(this,"Bl",li[3]|0);Z(this,"Ch",li[4]|0);Z(this,"Cl",li[5]|0);Z(this,"Dh",li[6]|0);Z(this,"Dl",li[7]|0);Z(this,"Eh",li[8]|0);Z(this,"El",li[9]|0);Z(this,"Fh",li[10]|0);Z(this,"Fl",li[11]|0);Z(this,"Gh",li[12]|0);Z(this,"Gl",li[13]|0);Z(this,"Hh",li[14]|0);Z(this,"Hl",li[15]|0)}},ap=class extends Dc{constructor(){super(32);Z(this,"Ah",hi[0]|0);Z(this,"Al",hi[1]|0);Z(this,"Bh",hi[2]|0);Z(this,"Bl",hi[3]|0);Z(this,"Ch",hi[4]|0);Z(this,"Cl",hi[5]|0);Z(this,"Dh",hi[6]|0);Z(this,"Dl",hi[7]|0);Z(this,"Eh",hi[8]|0);Z(this,"El",hi[9]|0);Z(this,"Fh",hi[10]|0);Z(this,"Fl",hi[11]|0);Z(this,"Gh",hi[12]|0);Z(this,"Gl",hi[13]|0);Z(this,"Hh",hi[14]|0);Z(this,"Hl",hi[15]|0)}},_s=Zu(()=>new tp,Wu(1)),N$=Zu(()=>new rp,Wu(4)),D$=Zu(()=>new ip,Wu(3)),L$=Zu(()=>new np,Wu(2)),q$=Zu(()=>new ap,Wu(6)),U$=Zu(()=>new op,Wu(5))});function Ju(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function cp(e){if(typeof e=="bigint"){if(!up(e))throw new RangeError("positive bigint expected, got "+e)}else Vm(e);return e}function dn(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function f0(e){let t=cp(e).toString(16);return t.length&1?"0"+t:t}function NO(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?fp:BigInt("0x"+e)}function yi(e){return NO(J2(e))}function qc(e){return NO(J2(hp(Oo(e)).reverse()))}function lp(e,t){if(gs(t),t===0)throw new RangeError("zero length");e=cp(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return Fm(r.padStart(t*2,"0"))}function Gm(e,t){return lp(e,t).reverse()}function hp(e){return Uint8Array.from(Ft(e))}function Uc(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}function F$(e,t,r){return up(e)&&up(t)&&up(r)&&t<=e&&e<r}function Zm(e,t,r,i){if(!F$(t,r,i))throw new RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function Qu(e){if(e<fp)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>fp;e>>=Km,t+=1);return t}function DO(e,t,r){if(gs(e,"hashLen"),gs(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let i=D=>new Uint8Array(D),n=Uint8Array.of(),o=Uint8Array.of(0),a=Uint8Array.of(1),s=1e3,u=i(e),c=i(e),l=0,m=()=>{u.fill(1),c.fill(0),l=0},w=(...D)=>r(c,Bt(u,...D)),E=(D=n)=>{c=w(o,D),u=w(),D.length!==0&&(c=w(a,D),u=w())},P=()=>{if(l++>=s)throw new Error("drbg: tried max amount of iterations");let D=0,L=[];for(;D<t;){u=w();let U=u.slice();L.push(U),D+=u.length}return Bt(...L)};return(D,L)=>{m(),E(D);let U;for(;(U=L(P()))===void 0;)E();return m(),U}}function pn(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function i(o,a,s){if(!s&&a!=="function"&&!Object.hasOwn(e,o))throw new TypeError(`param "${o}" is invalid: expected own property`);let u=e[o];if(s&&u===void 0)return;let c=typeof u;if(c!==a||u===null)throw new TypeError(`param "${o}" is invalid: expected ${a}, got ${c}`)}let n=(o,a)=>Object.entries(o).forEach(([s,u])=>i(s,u,a));n(t,!1),n(r,!0)}var Ft,Vm,Ra,Bt,Lc,Xu,ki,fp,Km,up,Fc,ef=Yr(()=>{v();vs();Ft=(e,t,r)=>Oo(e,t,r),Vm=gs,Ra=J2,Bt=(...e)=>wO(...e),Lc=e=>Fm(e),Xu=Um,ki=e=>o0(e),fp=BigInt(0),Km=BigInt(1);up=e=>typeof e=="bigint"&&fp<=e;Fc=e=>(Km<<BigInt(e))-Km});function Ki(e,t){if(t<=Qr)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Qr?r:t+r}function Vi(e,t,r){if(t<Qr)throw new Error("pow2: expected non-negative exponent, got "+t);let i=e;for(;t-- >Qr;)i*=i,i%=r;return i}function LO(e,t){if(e===Qr)throw new Error("invert: expected non-zero number");if(t<=Qr)throw new Error("invert: expected positive modulus, got "+t);let r=Ki(e,t),i=t,n=Qr,o=wr,a=wr,s=Qr;for(;r!==Qr;){let c=i/r,l=i-r*c,m=n-a*c,w=o-s*c;i=r,r=l,n=a,o=s,a=m,s=w}if(i!==wr)throw new Error("invert: does not exist");return Ki(n,t)}function Ym(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw new Error("Cannot find square root")}function KO(e,t){let r=e,i=(r.ORDER+wr)/FO,n=r.pow(t,i);return Ym(r,n,t),n}function z$(e,t){let r=e,i=(r.ORDER-HO)/jO,n=r.mul(t,tf),o=r.pow(n,i),a=r.mul(t,o),s=r.mul(r.mul(a,tf),o),u=r.mul(a,r.sub(s,r.ONE));return Ym(r,u,t),u}function K$(e){let t=Hc(e),r=VO(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),a=(e+H$)/zO;return((s,u)=>{let c=s,l=c.pow(u,a),m=c.mul(l,i),w=c.mul(l,n),E=c.mul(l,o),P=c.eql(c.sqr(m),u),M=c.eql(c.sqr(w),u);l=c.cmov(l,m,P),m=c.cmov(E,w,M);let D=c.eql(c.sqr(m),u),L=c.cmov(l,m,D);return Ym(c,L,u),L})}function VO(e){if(e<UO)throw new Error("sqrt is not defined for small field");let t=e-wr,r=0;for(;t%tf===Qr;)t/=tf,r++;let i=tf,n=Hc(e);for(;Wm(n,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return KO;let o=n.pow(i,t),a=(t+wr)/tf;return function(u,c){let l=u;if(l.is0(c))return c;if(Wm(l,c)!==1)throw new Error("Cannot find square root");let m=r,w=l.mul(l.ONE,o),E=l.pow(c,t),P=l.pow(c,a);for(;!l.eql(E,l.ONE);){if(l.is0(E))return l.ZERO;let M=1,D=l.sqr(E);for(;!l.eql(D,l.ONE);)if(M++,D=l.sqr(D),M===m)throw new Error("Cannot find square root");let L=wr<<BigInt(m-M-1),U=l.pow(w,L);m=M,w=l.sqr(U),E=l.mul(E,w),P=l.mul(P,U)}return P}}function V$(e){return e%FO===UO?KO:e%jO===HO?z$:e%zO===j$?K$(e):VO(e)}function rf(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=G$.reduce((i,n)=>(i[n]="function",i),t);if(pn(e,r),dn(e.BYTES,"BYTES"),dn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=wr)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Z$(e,t,r){let i=e;if(r<Qr)throw new Error("invalid exponent, negatives unsupported");if(r===Qr)return i.ONE;if(r===wr)return t;let n=i.ONE,o=t;for(;r>Qr;)r&wr&&(n=i.mul(n,o)),o=i.sqr(o),r>>=wr;return n}function nf(e,t,r=!1){let i=e,n=new Array(t.length).fill(r?i.ZERO:void 0),o=t.reduce((s,u,c)=>i.is0(u)?s:(n[c]=s,i.mul(s,u)),i.ONE),a=i.inv(o);return t.reduceRight((s,u,c)=>i.is0(u)?s:(n[c]=i.mul(s,n[c]),i.mul(s,u)),a),n}function Wm(e,t){let r=e,i=(r.ORDER-wr)/tf,n=r.pow(t,i),o=r.eql(n,r.ONE),a=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!a&&!s)throw new Error("invalid Legendre symbol result");return o?1:a?0:-1}function $m(e,t){return Wm(e,t)!==-1}function W$(e,t){if(t!==void 0&&Vm(t),e<=Qr)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Qu(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let i=t!==void 0?t:r,n=Math.ceil(i/8);return{nBitLength:i,nByteLength:n}}function Hc(e,t={}){return new dp(e,t)}function GO(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=wr)throw new Error("field order must be greater than 1");let t=Qu(e-wr);return Math.ceil(t/8)}function c0(e){let t=GO(e);return t+Math.ceil(t/2)}function jc(e,t,r=!1){Ft(e);let i=e.length,n=GO(t),o=Math.max(c0(t),16);if(i<o||i>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+i);let a=r?qc(e):yi(e),s=Ki(a,t-wr)+wr;return r?Gm(s,n):lp(s,n)}var Qr,wr,tf,UO,FO,HO,H$,jO,j$,zO,G$,qO,dp,zc=Yr(()=>{v();ef();Qr=BigInt(0),wr=BigInt(1),tf=BigInt(2),UO=BigInt(3),FO=BigInt(4),HO=BigInt(5),H$=BigInt(7),jO=BigInt(8),j$=BigInt(9),zO=BigInt(16);G$=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];qO=new WeakMap,dp=class{constructor(t,r={}){Z(this,"ORDER");Z(this,"BITS");Z(this,"BYTES");Z(this,"isLE");Z(this,"ZERO",Qr);Z(this,"ONE",wr);Z(this,"_lengths");Z(this,"_mod");if(t<=wr)throw new Error("invalid field: expected ORDER > 1, got "+t);let i;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(i=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:n,nByteLength:o}=W$(t,i);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=n,this.BYTES=o,Object.freeze(this)}create(t){return Ki(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Qr<=t&&t<this.ORDER}is0(t){return t===Qr}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&wr)===wr}neg(t){return Ki(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return Ki(t*t,this.ORDER)}add(t,r){return Ki(t+r,this.ORDER)}sub(t,r){return Ki(t-r,this.ORDER)}mul(t,r){return Ki(t*r,this.ORDER)}pow(t,r){return Z$(this,t,r)}div(t,r){return Ki(t*LO(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return LO(t,this.ORDER)}sqrt(t){let r=qO.get(this);return r||qO.set(this,r=V$(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?Gm(t,this.BYTES):lp(t,this.BYTES)}fromBytes(t,r=!1){Ft(t);let{_lengths:i,BYTES:n,isLE:o,ORDER:a,_mod:s}=this;if(i){if(t.length<1||!i.includes(t.length)||t.length>n)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let c=new Uint8Array(n);c.set(t,o?0:c.length-t.length),t=c}if(t.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let u=o?qc(t):yi(t);if(s&&(u=Ki(u,a)),!r&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(t){return nf(this,t)}cmov(t,r,i){return Ju(i,"condition"),i?r:t}};Object.freeze(dp.prototype)});function $O(e){let t=e;if(typeof t!="function")throw new TypeError("Point must be a constructor");pn({Fp:t.Fp,Fn:t.Fn,fromAffine:t.fromAffine,fromBytes:t.fromBytes,fromHex:t.fromHex},{Fp:"object",Fn:"object",fromAffine:"function",fromBytes:"function",fromHex:"function"}),rf(t.Fp),rf(t.Fn)}function l0(e,t){let r=t.negate();return e?r:t}function ey(e,t){let r=nf(e.Fp,t.map(i=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function XO(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Xm(e,t){XO(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Fc(e),a=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:a}}function ZO(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:a}=r,s=Number(e&n),u=e>>a;s>i&&(s-=o,u+=of);let c=t*i,l=c+Math.abs(s)-1,m=s===0,w=s<0,E=t%2!==0;return{nextN:u,offset:l,isZero:m,isNeg:w,isNegF:E,offsetF:c}}function Y$(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,i)=>{if(!(r instanceof t))throw new Error("invalid point at index "+i)})}function $$(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,i)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+i)})}function Qm(e){return JO.get(e)||1}function WO(e){if(e!==Kc)throw new Error("invalid wNAF")}function QO(e,t,r,i){let n=t,o=e.ZERO,a=e.ZERO;for(;r>Kc||i>Kc;)r&of&&(o=o.add(n)),i&of&&(a=a.add(n)),n=n.double(),r>>=of,i>>=of;return{p1:o,p2:a}}function eA(e,t,r){let i=e.Fn;Y$(t,e),$$(r,i);let n=t.length,o=r.length;if(n!==o)throw new Error("arrays of points and scalars must have equal length");let a=e.ZERO,s=Qu(BigInt(n)),u=1;s>12?u=s-3:s>4?u=s-2:s>0&&(u=2);let c=Fc(u),l=new Array(Number(c)+1).fill(a),m=Math.floor((i.BITS-1)/u)*u,w=a;for(let E=m;E>=0;E-=u){l.fill(a);for(let M=0;M<o;M++){let D=r[M],L=Number(D>>BigInt(E)&c);l[L]=l[L].add(t[M])}let P=a;for(let M=l.length-1,D=a;M>0;M--)D=D.add(l[M]),P=P.add(D);if(w=w.add(P),E!==0)for(let M=0;M<u;M++)w=w.double()}return w}function YO(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return rf(t),t}else return Hc(e,{isLE:r})}function tA(e,t,r={},i){if(i===void 0&&(i=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let u of["p","n","h"]){let c=t[u];if(!(typeof c=="bigint"&&c>Kc))throw new Error(`CURVE.${u} must be positive bigint`)}let n=YO(t.p,r.Fp,i),o=YO(t.n,r.Fn,i),s=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let u of s)if(!n.isValid(t[u]))throw new Error(`CURVE.${u} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:o}}function gp(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}var Kc,of,Jm,JO,pp,vp=Yr(()=>{v();ef();zc();Kc=BigInt(0),of=BigInt(1);Jm=new WeakMap,JO=new WeakMap;pp=class{constructor(t,r){Z(this,"BASE");Z(this,"ZERO");Z(this,"Fn");Z(this,"bits");this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,i=this.ZERO){let n=t;for(;r>Kc;)r&of&&(i=i.add(n)),n=n.double(),r>>=of;return i}precomputeWindow(t,r){let{windows:i,windowSize:n}=Xm(r,this.bits),o=[],a=t,s=a;for(let u=0;u<i;u++){s=a,o.push(s);for(let c=1;c<n;c++)s=s.add(a),o.push(s);a=s.double()}return o}wNAF(t,r,i){if(!this.Fn.isValid(i))throw new Error("invalid scalar");let n=this.ZERO,o=this.BASE,a=Xm(t,this.bits);for(let s=0;s<a.windows;s++){let{nextN:u,offset:c,isZero:l,isNeg:m,isNegF:w,offsetF:E}=ZO(i,s,a);i=u,l?o=o.add(l0(w,r[E])):n=n.add(l0(m,r[c]))}return WO(i),{p:n,f:o}}wNAFUnsafe(t,r,i,n=this.ZERO){let o=Xm(t,this.bits);for(let a=0;a<o.windows&&i!==Kc;a++){let{nextN:s,offset:u,isZero:c,isNeg:l}=ZO(i,a,o);if(i=s,!c){let m=r[u];n=n.add(l?m.negate():m)}}return WO(i),n}getPrecomputes(t,r,i){let n=Jm.get(r);return n||(n=this.precomputeWindow(r,t),t!==1&&(typeof i=="function"&&(n=i(n)),Jm.set(r,n))),n}cached(t,r,i){let n=Qm(t);return this.wNAF(n,this.getPrecomputes(n,t,i),r)}unsafe(t,r,i,n){let o=Qm(t);return o===1?this._unsafeLadder(t,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),r,n)}createCache(t,r){XO(r,this.bits),JO.set(t,r),Jm.delete(t)}hasCache(t){return Qm(t)!==1}}});function rA(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error("wrong u32 integer:"+e);return e}function X$(e){if(rA(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<ty(e-1)+1>>>0}function ty(e){return rA(e),31-Math.clz32(e)}function iA(e,t,r,i,n){let o=e,a=r||((l,m)=>new Array(l).fill(m??o.ZERO)),s=l=>{if(Array.isArray(l))return!0;if(!ArrayBuffer.isView(l))return!1;let m=l;return typeof m.length=="number"&&typeof m.slice=="function"&&typeof m[Symbol.iterator]=="function"},u=(...l)=>{if(!l.length)return 0;for(let w of l)if(!s(w))throw new Error("poly: not polynomial: "+w);let m=l[0].length;for(let w=1;w<l.length;w++)if(l[w].length!==m)throw new Error(`poly: mismatched lengths ${m} vs ${l[w].length}`);if(n!==void 0&&m!==n)throw new Error(`poly: expected fixed length ${n}, got ${m}`);return m};function c(l,m,w=!1){let E=ty(m),P=w?t.brp(E):t.roots(E);for(let M=0;M<m;M++)if(o.eql(l,P[M]))return M;return-1}return{roots:t,create:a,length:n,extend:(l,m)=>{u(l);let w=a(m,o.ZERO);for(let E=0;E<Math.min(l.length,m);E++)w[E]=l[E];return w},degree:l=>{u(l);for(let m=l.length-1;m>=0;m--)if(!o.is0(l[m]))return m;return-1},add:(l,m)=>{let w=u(l,m),E=a(w);for(let P=0;P<w;P++)E[P]=o.add(l[P],m[P]);return E},sub:(l,m)=>{let w=u(l,m),E=a(w);for(let P=0;P<w;P++)E[P]=o.sub(l[P],m[P]);return E},dot:(l,m)=>{let w=u(l,m),E=a(w);for(let P=0;P<w;P++)E[P]=o.mul(l[P],m[P]);return E},mul:(l,m)=>{if(s(m)){let w=u(l,m);if(i){let E=i.direct(l,!1,!0),P=i.direct(m,!1,!0);for(let M=0;M<E.length;M++)E[M]=o.mul(E[M],P[M]);return i.inverse(E,!0,!1)}else{let E=a(w);for(let P=0;P<w;P++)for(let M=0;M<w;M++){let D=(P+M)%w;E[D]=o.add(E[D],o.mul(l[P],m[M]))}return E}}else{let w=a(u(l));for(let E=0;E<w.length;E++)w[E]=o.mul(l[E],m);return w}},convolve(l,m){let w=X$(l.length+m.length-1);return this.mul(this.extend(l,w),this.extend(m,w))},shift(l,m){let w=a(u(l));w[0]=l[0];for(let E=1,P=o.ONE;E<l.length;E++)P=o.mul(P,m),w[E]=o.mul(l[E],P);return w},clone:l=>{u(l);let m=a(l.length);for(let w=0;w<l.length;w++)m[w]=l[w];return m},eval:(l,m)=>{u(l,m);let w=o.ZERO;for(let E=0;E<l.length;E++)w=o.add(w,o.mul(l[E],m[E]));return w},monomial:{basis:(l,m)=>{let w=a(m),E=o.ONE;for(let P=0;P<m;P++)w[P]=E,E=o.mul(E,l);return w},eval:(l,m)=>{u(l);let w=o.ZERO;for(let E=l.length-1;E>=0;E--)w=o.add(o.mul(w,m),l[E]);return w}},lagrange:{basis:(l,m,w=!1,E)=>{let P=ty(m),M=E||(w?t.brp(P):t.roots(P)),D=a(m),L=c(l,m,w);if(L!==-1)return D[L]=o.ONE,D;let U=o.pow(l,BigInt(m)),K=o.mul(o.sub(U,o.ONE),o.inv(BigInt(m))),C=a(m);for(let F=0;F<m;F++)C[F]=o.sub(l,M[F]);let N=o.invertBatch(C);for(let F=0;F<m;F++)D[F]=o.mul(K,o.mul(M[F],N[F]));return D},eval(l,m,w=!1){u(l);let E=c(m,l.length,w);if(E!==-1)return l[E];let P=this.basis(m,l.length,w),M=o.ZERO;for(let D=0;D<l.length;D++)o.is0(l[D])||(M=o.add(M,o.mul(l[D],P[D])));return M}},vanishing(l){u(l);let m=a(l.length+1,o.ZERO);m[0]=o.ONE;for(let w of l){let E=o.neg(w);for(let P=m.length-1;P>0;P--)m[P]=o.add(o.mul(m[P],E),m[P-1]);m[0]=o.mul(m[0],E)}return m}}}var nA=Yr(()=>{v()});function af(e,t){if(dn(e),dn(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let i=t-1;i>=0;i--)r[i]=e&255,e>>>=8;return new Uint8Array(r)}function Q$(e,t){let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e[i]^t[i];return r}function oA(e){if(!Xu(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Uc(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function eX(e,t,r,i){Ft(e),dn(r),t=oA(t),t.length>255&&(t=i(Bt(Uc("H2C-OVERSIZE-DST-"),t)));let{outputLen:n,blockLen:o}=i,a=Math.ceil(r/n);if(r>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");let s=Bt(t,af(t.length,1)),u=new Uint8Array(o),c=af(r,2),l=new Array(a),m=i(Bt(u,e,c,af(0,1),s));l[0]=i(Bt(m,af(1,1),s));for(let E=1;E<a;E++){let P=[Q$(m,l[E-1]),af(E+1,1),s];l[E]=i(Bt(...P))}return Bt(...l).slice(0,r)}function tX(e,t,r,i,n){if(Ft(e),dn(r),t=oA(t),t.length>255){let o=Math.ceil(2*i/8);t=n.create({dkLen:o}).update(Uc("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return n.create({dkLen:r}).update(e).update(af(r,2)).update(t).update(af(t.length,1)).digest()}function ry(e,t,r){pn(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:i,k:n,m:o,hash:a,expand:s,DST:u}=r;if(dn(a.outputLen,"valid hash"),Ft(e),dn(t),t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");let c=i.toString(2).length,l=Math.ceil((c+n)/8),m=t*o*l,w;if(s==="xmd")w=eX(e,u,m,a);else if(s==="xof")w=tX(e,u,m,n,a);else if(s==="_internal_pass")w=e;else throw new Error('expand must be "xmd" or "xof"');let E=new Array(t);for(let P=0;P<t;P++){let M=new Array(o);for(let D=0;D<o;D++){let L=l*(D+P*o),U=w.subarray(L,L+l);M[D]=Ki(J$(U),i)}E[P]=M}return E}function aA(e,t){let r=t.map(i=>Array.from(i).reverse());return(i,n)=>{let[o,a,s,u]=r.map(m=>m.reduce((w,E)=>e.add(e.mul(w,i),E))),[c,l]=nf(e,[a,u],!0);return i=e.mul(o,c),n=e.mul(n,e.mul(s,l)),{x:i,y:n}}}function sA(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");let i=s=>Object.freeze({...s,DST:Xu(s.DST)?hp(s.DST):s.DST,...s.encodeDST===void 0?{}:{encodeDST:Xu(s.encodeDST)?hp(s.encodeDST):s.encodeDST}}),n=i(r);function o(s){return e.fromAffine(t(s))}function a(s){let u=s.clearCofactor();return u.equals(e.ZERO)?e.ZERO:(u.assertValidity(),u)}return Object.freeze({get defaults(){return i(n)},Point:e,hashToCurve(s,u){let c=Object.assign({},n,u),l=ry(s,2,c),m=o(l[0]),w=o(l[1]);return a(m.add(w))},encodeToCurve(s,u){let c=n.encodeDST?{DST:n.encodeDST}:{},l=Object.assign({},n,c,u),m=ry(s,1,l),w=o(m[0]);return a(w)},mapToCurve(s){if(n.m===1){if(typeof s!="bigint")throw new Error("expected bigint (m=1)");return a(o([s]))}if(!Array.isArray(s))throw new Error("expected array of bigints");for(let u of s)if(typeof u!="bigint")throw new Error("expected array of bigints");return a(o(s))},hashToScalar(s,u){let c=e.Fn.ORDER,l=Object.assign({},n,{p:c,m:1,DST:rX},u);return ry(s,1,l)[0][0]}})}var J$,rX,uA=Yr(()=>{v();ef();zc();J$=yi;rX="HashToScalar-"});function iy(e){pn(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustDKG:"function"}),$O(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,i=e.hash,n=e.hashToScalar===void 0?(q,W={DST:new Uint8Array})=>{let X=i(Bt(W.DST,q));return r.create(r.isLE?qc(X):yi(X))}:e.hashToScalar,o=Pa(e.H1!==void 0?e.H1:e.name+"rho"),a=Pa(e.H2!==void 0?e.H2:e.name+"chal"),s=Pa(e.H3!==void 0?e.H3:e.name+"nonce"),u=Pa(e.H4!==void 0?e.H4:e.name+"msg"),c=Pa(e.H5!==void 0?e.H5:e.name+"com"),l=Pa(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),m=Pa(e.HID!==void 0?e.HID:e.name+"id"),w=q=>n(q,{DST:o}),E=q=>n(q,{DST:a}),P=q=>n(q,{DST:s}),M=q=>i(Bt(u,q)),D=q=>i(Bt(c,q)),L=q=>n(q,{DST:l}),U=q=>n(q,{DST:m}),K=(q=ki)=>{let W=jc(q(c0(r.ORDER)),r.ORDER,r.isLE);return r.isLE?qc(W):yi(W)},C=q=>q.toBytes(),N=q=>{let W=t.fromBytes(q);return e.validatePoint&&e.validatePoint(W),W},F=(q,W)=>({identifier:q,hiding:C(t.BASE.multiply(r.fromBytes(W.hiding))),binding:C(t.BASE.multiply(r.fromBytes(W.binding)))}),H=e.adjustPoint===void 0?q=>q:e.adjustPoint,z=q=>{if(!r.isValid(q)||r.is0(q))throw new Error("Invalid identifier "+q);return q},G=q=>Ra(r.toBytes(z(q))),R=q=>{let W=z(r.fromBytes(Lc(q)));if(G(W)!==q)throw new Error("expected canonical identifier hex");return W},g={encode:(q,W)=>{let X=Bt(C(q),r.toBytes(W));return e.adjustTx&&(X=e.adjustTx.encode(X)),X},decode:q=>{e.adjustTx&&(q=e.adjustTx.decode(q));let W=N(q.subarray(0,-r.BYTES)),X=r.fromBytes(q.subarray(-r.BYTES));return{R:W,z:X}}},I=(q=ki)=>{let W=K(q);e.adjustScalar&&(W=e.adjustScalar(W));let X=t.BASE.multiply(W);return{scalar:W,point:X}},y="roots are unavailable in FROST polynomial mode",f={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(y)},brp(){throw new Error(y)},inverse(){throw new Error(y)},omega(){throw new Error(y)},clear(){}},d=iA(r,f),_=(q,W)=>eA(t,q,W),x=(q,W)=>{if(!W.length)throw new Error("empty coefficients");return d.monomial.eval(W,q)},b=(q,W)=>{let X="invalid parameters";if(!q.some(fe=>r.eql(fe,W)))throw new Error(X);let te=new Set(q);if(te.size!==q.length)throw new Error(X);if(!te.has(W))throw new Error(X);let me=r.ONE,se=r.ONE;for(let fe of q)r.eql(fe,W)||(me=r.mul(me,fe),se=r.mul(se,r.sub(fe,W)));return r.div(me,se)},p=(q,W)=>{let X=d.monomial.basis(q,W.length);return _(W,X)},O=(q,W,X,te=ki)=>{mp(q);let me=W===void 0?K(te):r.fromBytes(W);if(!X){X=[];for(let xe=0;xe<q.min-1;xe++)X.push(K(te))}if(X.length!==q.min-1)throw new Error("wrong coefficients length");let se=[me,...X],fe=se.map(xe=>t.BASE.multiply(xe));return{coefficients:se,commitment:fe,secret:me}},T={challenge:(q,W,X)=>L(Bt(r.toBytes(q),C(W),C(X))),compute(q,W,X,te=ki){if(W.length<1)throw new Error("coefficients should have at least one element");let{point:me,scalar:se}=I(te),fe=X[0],xe=this.challenge(q,fe,me),le=r.add(se,r.mul(W[0],xe));return g.encode(me,le)},validate(q,W,X){if(W.length<1)throw new Error("commitment should have at least one element");let{R:te,z:me}=g.decode(X),se=N(W[0]),fe=this.challenge(q,se,te);if(!te.equals(t.BASE.multiply(me).subtract(se.multiply(fe))))throw new Error("invalid proof of knowledge")}},S={challenge:(q,W,X)=>e.challenge?e.challenge(q,W,X):E(Bt(C(q),C(W),X)),sign(q,W,X=ki){let{point:te,scalar:me}=I(X),se=t.BASE.multiply(W),fe=this.challenge(te,se,q),xe=r.add(me,r.mul(fe,W));return[te,xe]},verify(q,W,X,te){e.adjustPoint&&(te=e.adjustPoint(te)),e.adjustPoint&&(W=e.adjustPoint(W));let me=this.challenge(W,te,q),se=t.BASE.multiply(X),fe=te.multiply(me),xe=se.subtract(fe).subtract(W);return xe.clearCofactor&&(xe=xe.clearCofactor()),t.ZERO.equals(xe)}},B=(q,W,X)=>{if(!t.BASE.multiply(X).equals(p(q,W)))throw new Error("invalid secret share")},Y={fromNumber(q){if(!Number.isSafeInteger(q))throw new Error("expected safe interger");return G(BigInt(q))},derive(q){if(typeof q!="string")throw new Error("wrong identifier string: "+q);return G(U(Pa(q)))}},$=(q,W=ki)=>P(Bt(W(32),r.toBytes(q))),ne=(q,W,X)=>{let te=W.map(ce=>[ce.identifier,R(ce.identifier),N(ce.hiding),N(ce.binding)]);te.sort((ce,Te)=>ce[1]<Te[1]?-1:ce[1]>Te[1]?1:0);let me=[];for(let[ce,Te,be,_e]of te)me.push(r.toBytes(Te),C(be),C(_e));let se=D(Bt(...me)),fe=Bt(C(q),M(X),se),xe={};for(let[ce,Te]of te)xe[ce]=w(Bt(fe,r.toBytes(Te)));let le=[],ve=[];for(let[ce,Te,be,_e]of te){if(t.ZERO.equals(be)||t.ZERO.equals(_e))throw new Error("infinity commitment");le.push(be,_e),ve.push(r.ONE,xe[ce])}let Ht=_(le,ve);return{identifiers:te.map(ce=>ce[1]),groupCommitment:Ht,bindingFactors:xe}},he=(q,W,X,te)=>{let me=H(N(q)),se=R(te),{identifiers:fe,groupCommitment:xe,bindingFactors:le}=ne(me,W,X),ve=le[te],Ht=b(fe,se),Se=S.challenge(xe,me,X);return{lambda:Ht,challenge:Se,bindingFactor:ve,groupCommitment:xe}};Object.freeze(Y);let pe={Identifier:Y,DKG:Object.freeze({round1:(q,W,X,te=ki)=>{mp(W);let me=R(q),{coefficients:se,commitment:fe}=O(W,X,void 0,te),xe=T.compute(me,se,fe,te),le=fe.map(C),ve={identifier:G(me),commitment:le,proofOfKnowledge:xe},Ht={identifier:me,coefficients:se,commitment:fe.map(C),signers:{min:W.min,max:W.max},step:1};return{public:ve,secret:Ht}},round2:(q,W)=>{if(W.length!==q.signers.max-1)throw new Error("wrong number of round1 packages");if(!q.coefficients||q.step===3)throw new Error("round3 package used in round2");let X={};for(let te of W){if(te.commitment.length!==q.signers.min)throw new Error("wrong number of commitments");let me=R(te.identifier);if(me===q.identifier)throw new Error("duplicate id="+G(me));T.validate(me,te.commitment,te.proofOfKnowledge);for(let fe of te.commitment)N(fe);if(X[te.identifier])throw new Error("Duplicate id="+me);let se=r.toBytes(x(me,q.coefficients));X[te.identifier]={identifier:G(q.identifier),signingShare:se}}return q.step=2,X},round3:(q,W,X)=>{if(W.length!==q.signers.max-1)throw new Error("wrong length of round1 packages");if(!q.coefficients||q.step!==2)throw new Error("round2 package used in round3");if(X.length!==W.length)throw new Error("wrong length of round2 packages");let te={};for(let Te of W){if(!Te.identifier||!Te.commitment)throw new Error("wrong round1 share");te[Te.identifier]={...Te}}for(let Te of X){if(!Te.identifier||!Te.signingShare)throw new Error("wrong round2 share");if(!te[Te.identifier])throw new Error("round1 share for "+Te.identifier+" is missing");te[Te.identifier].signingShare=Te.signingShare}if(Object.keys(te).length!==W.length)throw new Error("mismatch identifiers between rounds");let me=r.ZERO;if(q.commitment.length!==q.signers.min)throw new Error("wrong commitments length");let se=q.commitment.map(N),fe=x(q.identifier,q.coefficients);B(q.identifier,se,fe);let xe=se.map(C),le={[G(q.identifier)]:xe};for(let Te in te){let be=te[Te];if(!be.signingShare||!be.commitment)throw new Error("mismatch identifiers");let _e=R(Te),en=r.fromBytes(be.signingShare),Ce=be.commitment.map(N);B(q.identifier,Ce,en),me=r.add(me,en);let Re=G(_e);if(le[Re])throw new Error("duplicated id="+Re);le[Re]=be.commitment}me=r.add(me,fe);let ve=new Array(q.signers.min).fill(t.ZERO);for(let Te in le){let be=le[Te];if(be.length!==q.signers.min)throw new Error("wrong commitments length");for(let _e=0;_e<be.length;_e++)ve[_e]=ve[_e].add(N(be[_e]))}let Ht=ve.map(C),Se={};for(let Te in le)Se[Te]=C(p(R(Te),ve));let ce={public:{signers:{min:q.signers.min,max:q.signers.max},commitments:Ht,verifyingShares:Object.fromEntries(Object.entries(Se).map(([Te,be])=>[Te,be.slice()]))},secret:{identifier:G(q.identifier),signingShare:r.toBytes(me)}};e.adjustDKG&&(ce=e.adjustDKG(ce));for(let Te=0;Te<q.coefficients.length;Te++)q.coefficients[Te]-=q.coefficients[Te];return delete q.coefficients,q.step=3,ce},clean(q){if(q.identifier-=q.identifier,q.coefficients)for(let W=0;W<q.coefficients.length;W++)q.coefficients[W]-=q.coefficients[W];q.step=3}}),trustedDealer(q,W,X,te=ki){if(mp(q),W===void 0){W=[];for(let ve=1;ve<=q.max;ve++)W.push(Y.fromNumber(ve))}else if(!Array.isArray(W)||W.length!==q.max)throw new Error("identifiers should be array of "+q.max);let me={};for(let ve of W){let Ht=R(ve);if(ve in me)throw new Error("duplicated id="+ve);me[ve]=Ht}let se=O(q,X,void 0,te),fe=se.commitment.map(C),xe={},le={};for(let ve of W){let Ht=x(me[ve],se.coefficients);le[ve]=C(t.BASE.multiply(Ht)),xe[ve]={identifier:ve,signingShare:r.toBytes(Ht)}}return{public:{signers:{min:q.min,max:q.max},commitments:fe,verifyingShares:le},secretShares:xe}},validateSecret(q,W){let X=R(q.identifier),te=W.commitments.map(N),me=r.fromBytes(q.signingShare);B(X,te,me)},commit(q,W=ki){let X=r.fromBytes(q.signingShare),te=$(X,W),me=$(X,W),se={hiding:r.toBytes(te),binding:r.toBytes(me)};return{nonces:se,commitments:F(q.identifier,se)}},signShare(q,W,X,te,me){fA(W.signers,te.length);let se=r.fromBytes(X.hiding),fe=r.fromBytes(X.binding);if(r.is0(se)||r.is0(fe))throw new Error("signing nonces already used");let xe={identifier:q.identifier,hiding:C(t.BASE.multiply(se)),binding:C(t.BASE.multiply(fe))},le=te.find(Ne=>Ne.identifier===q.identifier);if(!le)throw new Error("missing signer commitment");if(Ra(le.hiding)!==Ra(xe.hiding)||Ra(le.binding)!==Ra(xe.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(q=e.adjustSecret(q,W)),e.adjustPublic&&(W=e.adjustPublic(W));let ve=r.fromBytes(q.signingShare),{lambda:Ht,challenge:Se,bindingFactor:ce,groupCommitment:Te}=he(W.commitments[0],te,me,q.identifier),be=e.adjustNonces?e.adjustNonces(Te,X):X,_e=e.adjustNonces?r.fromBytes(be.hiding):se,en=e.adjustNonces?r.fromBytes(be.binding):fe,Ce=r.mul(r.mul(Ht,ve),Se),Re=r.mul(en,ce),eu=r.toBytes(r.add(r.add(_e,Re),Ce));return X.hiding.fill(0),X.binding.fill(0),eu},verifyShare(q,W,X,te,me){e.adjustPublic&&(q=e.adjustPublic(q));let se=W.find(en=>en.identifier===te);if(!se)throw new Error("cannot find identifier commitment");let fe=N(q.verifyingShares[te]),xe=N(se.hiding),le=N(se.binding),{lambda:ve,challenge:Ht,bindingFactor:Se,groupCommitment:ce}=he(q.commitments[0],W,X,te),Te=xe.add(le.multiply(Se));e.adjustGroupCommitmentShare&&(Te=e.adjustGroupCommitmentShare(ce,Te));let be=t.BASE.multiply(r.fromBytes(me)),_e=Te.add(fe.multiply(r.mul(Ht,ve)));return be.equals(_e)},aggregate(q,W,X,te){e.adjustPublic&&(q=e.adjustPublic(q));try{fA(q.signers,W.length)}catch{throw new Vc("aggregation failed",[])}let me=W.map(le=>le.identifier);if(me.length!==Object.keys(te).length)throw new Vc("aggregation failed",[]);for(let le of me)if(!(le in te)||!(le in q.verifyingShares))throw new Vc("aggregation failed",[]);let se=N(q.commitments[0]),{groupCommitment:fe}=ne(se,W,X),xe=r.ZERO;for(let le of me)xe=r.add(xe,r.fromBytes(te[le]));if(!S.verify(X,fe,xe,se)){let le=[];for(let ve of me)this.verifyShare(q,W,X,ve,te[ve])||le.push(ve);throw new Vc("aggregation failed",le)}return g.encode(fe,xe)},sign(q,W){let X=r.fromBytes(W);e.adjustScalar&&(X=e.adjustScalar(X));let[te,me]=S.sign(q,X);return g.encode(te,me)},verify(q,W,X){let te=e.parsePublicKey?e.parsePublicKey(X):N(X),{R:me,z:se}=g.decode(q);return S.verify(W,me,se,te)},combineSecret(q,W){if(mp(W),!Array.isArray(q)||q.length<W.min)throw new Error("wrong secret shares array");let X=[],te={};for(let fe of q){let xe=R(fe.identifier),le=G(xe);if(te[le])throw new Error("duplicated id="+le);te[le]=!0,X.push([xe,r.fromBytes(fe.signingShare)])}let me=X.map(([fe])=>fe),se=r.ZERO;for(let[fe,xe]of X)se=r.add(se,r.mul(xe,b(me,fe)));return r.toBytes(se)},utils:Object.freeze({Fn:r,randomScalar:(q=ki)=>r.toBytes(I(q).scalar),generateSecretPolynomial:(q,W,X,te)=>{let me=O(q,W,X,te);return{...me,commitment:me.commitment.map(C)}}})};return Object.freeze(pe)}var mp,fA,Vc,cA=Yr(()=>{v();vs();ef();vp();nA();zc();mp=e=>{if(!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))throw new Error("Wrong signers info: min="+e.min+" max="+e.max);if(e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},fA=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Vc=class extends Error{constructor(r,i){super(r);Z(this,"cheaters");this.cheaters=i}}});var oy={};X1(oy,{_HMAC:()=>h0,hmac:()=>ny});var h0,ny,yp=Yr(()=>{v();vs();h0=class{constructor(t,r){Z(this,"oHash");Z(this,"iHash");Z(this,"blockLen");Z(this,"outputLen");Z(this,"canXOF",!1);Z(this,"finished",!1);Z(this,"destroyed",!1);if(Y2(t),Oo(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,n=new Uint8Array(i);n.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=t.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),Aa(n)}update(t){return Nc(this),this.iHash.update(t),this}digestInto(t){Nc(this),$2(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:i,finished:n,destroyed:o,blockLen:a,outputLen:s}=this;return t=t,t.finished=n,t.destroyed=o,t.blockLen=a,t.outputLen=s,t.oHash=r._cloneInto(t.oHash),t.iHash=i._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ny=(()=>{let e=((t,r,i)=>new h0(t,r).update(i).digest());return e.create=(t,r)=>new h0(t,r),e})()});function iX(e,t,r){Zm("scalar",e,gn,r);let[[i,n],[o,a]]=t,s=lA(a*e,r),u=lA(-n*e,r),c=e-s*i-u*o,l=-s*n-u*a,m=c<gn,w=l<gn;m&&(c=-c),w&&(l=-l);let E=Fc(Math.ceil(Qu(r)/2))+zr;if(c<gn||c>=E||l<gn||l>=E)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:m,k1:c,k2neg:w,k2:l}}function sy(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function ay(e,t){pn(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];return Ju(r.lowS,"lowS"),Ju(r.prehash,"prehash"),r.format!==void 0&&sy(r.format),r}function hA(e,t={}){let r=tA("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:a,n:s}=o;pn(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:u,allowInfinityPoint:c}=t;if(u&&(!i.is0(o.a)||typeof u.beta!="bigint"||!Array.isArray(u.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=gA(i,n);function m(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function w(I,y,f){if(c&&y.is0())return Uint8Array.of(0);let{x:d,y:_}=y.toAffine(),x=i.toBytes(d);if(Ju(f,"isCompressed"),f){m();let b=!i.isOdd(_);return Bt(dA(b),x)}else return Bt(Uint8Array.of(4),x,i.toBytes(_))}function E(I){Ft(I,void 0,"Point");let{publicKey:y,publicKeyUncompressed:f}=l,d=I.length,_=I[0],x=I.subarray(1);if(c&&d===1&&_===0)return{x:i.ZERO,y:i.ZERO};if(d===y&&(_===2||_===3)){let b=i.fromBytes(x);if(!i.isValid(b))throw new Error("bad point: is not on curve, wrong x");let p=D(b),O;try{O=i.sqrt(p)}catch(B){let Y=B instanceof Error?": "+B.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}m();let T=i.isOdd(O);return(_&1)===1!==T&&(O=i.neg(O)),{x:b,y:O}}else if(d===f&&_===4){let b=i.BYTES,p=i.fromBytes(x.subarray(0,b)),O=i.fromBytes(x.subarray(b,b*2));if(!L(p,O))throw new Error("bad point: is not on curve");return{x:p,y:O}}else throw new Error(`bad point: got length ${d}, expected compressed=${y} or uncompressed=${f}`)}let P=t.toBytes===void 0?w:t.toBytes,M=t.fromBytes===void 0?E:t.fromBytes;function D(I){let y=i.sqr(I),f=i.mul(y,I);return i.add(i.add(f,i.mul(I,o.a)),o.b)}function L(I,y){let f=i.sqr(y),d=D(I);return i.eql(f,d)}if(!L(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let U=i.mul(i.pow(o.a,Gc),fy),K=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(U,K)))throw new Error("bad curve params: a or b");function C(I,y,f=!1){if(!i.isValid(y)||f&&i.is0(y))throw new Error(`bad point coordinate ${I}`);return y}function N(I){if(!(I instanceof z))throw new Error("Weierstrass Point expected")}function F(I){if(!u||!u.basises)throw new Error("no endo");return iX(I,u.basises,n.ORDER)}function H(I,y,f,d,_){return f=new z(i.mul(f.X,I),f.Y,f.Z),y=l0(d,y),f=l0(_,f),y.add(f)}let g=class g{constructor(y,f,d){Z(this,"X");Z(this,"Y");Z(this,"Z");this.X=C("x",y),this.Y=C("y",f,!0),this.Z=C("z",d),Object.freeze(this)}static CURVE(){return o}static fromAffine(y){let{x:f,y:d}=y||{};if(!y||!i.isValid(f)||!i.isValid(d))throw new Error("invalid affine point");if(y instanceof g)throw new Error("projective point not allowed");return i.is0(f)&&i.is0(d)?g.ZERO:new g(f,d,i.ONE)}static fromBytes(y){let f=g.fromAffine(M(Ft(y,void 0,"point")));return f.assertValidity(),f}static fromHex(y){return g.fromBytes(Lc(y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,f=!0){return R.createCache(this,y),f||this.multiply(Gc),this}assertValidity(){let y=this;if(y.is0()){if(t.allowInfinityPoint&&i.is0(y.X)&&i.eql(y.Y,i.ONE)&&i.is0(y.Z))return;throw new Error("bad point: ZERO")}let{x:f,y:d}=y.toAffine();if(!i.isValid(f)||!i.isValid(d))throw new Error("bad point: x or y not field elements");if(!L(f,d))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(y)}equals(y){N(y);let{X:f,Y:d,Z:_}=this,{X:x,Y:b,Z:p}=y,O=i.eql(i.mul(f,p),i.mul(x,_)),T=i.eql(i.mul(d,p),i.mul(b,_));return O&&T}negate(){return new g(this.X,i.neg(this.Y),this.Z)}double(){let{a:y,b:f}=o,d=i.mul(f,Gc),{X:_,Y:x,Z:b}=this,p=i.ZERO,O=i.ZERO,T=i.ZERO,S=i.mul(_,_),B=i.mul(x,x),Y=i.mul(b,b),$=i.mul(_,x);return $=i.add($,$),T=i.mul(_,b),T=i.add(T,T),p=i.mul(y,T),O=i.mul(d,Y),O=i.add(p,O),p=i.sub(B,O),O=i.add(B,O),O=i.mul(p,O),p=i.mul($,p),T=i.mul(d,T),Y=i.mul(y,Y),$=i.sub(S,Y),$=i.mul(y,$),$=i.add($,T),T=i.add(S,S),S=i.add(T,S),S=i.add(S,Y),S=i.mul(S,$),O=i.add(O,S),Y=i.mul(x,b),Y=i.add(Y,Y),S=i.mul(Y,$),p=i.sub(p,S),T=i.mul(Y,B),T=i.add(T,T),T=i.add(T,T),new g(p,O,T)}add(y){N(y);let{X:f,Y:d,Z:_}=this,{X:x,Y:b,Z:p}=y,O=i.ZERO,T=i.ZERO,S=i.ZERO,B=o.a,Y=i.mul(o.b,Gc),$=i.mul(f,x),ne=i.mul(d,b),he=i.mul(_,p),pe=i.add(f,d),q=i.add(x,b);pe=i.mul(pe,q),q=i.add($,ne),pe=i.sub(pe,q),q=i.add(f,_);let W=i.add(x,p);return q=i.mul(q,W),W=i.add($,he),q=i.sub(q,W),W=i.add(d,_),O=i.add(b,p),W=i.mul(W,O),O=i.add(ne,he),W=i.sub(W,O),S=i.mul(B,q),O=i.mul(Y,he),S=i.add(O,S),O=i.sub(ne,S),S=i.add(ne,S),T=i.mul(O,S),ne=i.add($,$),ne=i.add(ne,$),he=i.mul(B,he),q=i.mul(Y,q),ne=i.add(ne,he),he=i.sub($,he),he=i.mul(B,he),q=i.add(q,he),$=i.mul(ne,q),T=i.add(T,$),$=i.mul(W,q),O=i.mul(pe,O),O=i.sub(O,$),$=i.mul(pe,ne),S=i.mul(W,S),S=i.add(S,$),new g(O,T,S)}subtract(y){return N(y),this.add(y.negate())}is0(){return this.equals(g.ZERO)}multiply(y){let{endo:f}=t;if(!n.isValidNot0(y))throw new RangeError("invalid scalar: out of range");let d,_,x=b=>R.cached(this,b,p=>ey(g,p));if(f){let{k1neg:b,k1:p,k2neg:O,k2:T}=F(y),{p:S,f:B}=x(p),{p:Y,f:$}=x(T);_=B.add($),d=H(f.beta,S,Y,b,O)}else{let{p:b,f:p}=x(y);d=b,_=p}return ey(g,[d,_])[0]}multiplyUnsafe(y){let{endo:f}=t,d=this,_=y;if(!n.isValid(_))throw new RangeError("invalid scalar: out of range");if(_===gn||d.is0())return g.ZERO;if(_===zr)return d;if(R.hasCache(this))return this.multiply(_);if(f){let{k1neg:x,k1:b,k2neg:p,k2:O}=F(_),{p1:T,p2:S}=QO(g,d,b,O);return H(f.beta,T,S,x,p)}else return R.unsafe(d,_)}toAffine(y){let f=this,d=y,{X:_,Y:x,Z:b}=f;if(i.eql(b,i.ONE))return{x:_,y:x};let p=f.is0();d==null&&(d=p?i.ONE:i.inv(b));let O=i.mul(_,d),T=i.mul(x,d),S=i.mul(b,d);if(p)return{x:i.ZERO,y:i.ZERO};if(!i.eql(S,i.ONE))throw new Error("invZ was invalid");return{x:O,y:T}}isTorsionFree(){let{isTorsionFree:y}=t;return a===zr?!0:y?y(g,this):R.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:y}=t;return a===zr?this:y?y(g,this):this.multiplyUnsafe(a)}isSmallOrder(){return a===zr?this.is0():this.clearCofactor().is0()}toBytes(y=!0){return Ju(y,"isCompressed"),this.assertValidity(),P(g,this,y)}toHex(y=!0){return Ra(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};Z(g,"BASE",new g(o.Gx,o.Gy,i.ONE)),Z(g,"ZERO",new g(i.ZERO,i.ONE,i.ZERO)),Z(g,"Fp",i),Z(g,"Fn",n);let z=g,G=n.BITS,R=new pp(z,t.endo?Math.ceil(G/2):G);return G>=8&&z.BASE.precompute(8),Object.freeze(z.prototype),Object.freeze(z),z}function dA(e){return Uint8Array.of(e?2:3)}function nX(e,t){let r=rf(e),i=r.ORDER,n=gn;for(let M=i-zr;M%Po===gn;M/=Po)n+=zr;let o=n,a=Po<<o-zr-zr,s=a*Po,u=(i-zr)/s,c=(u-zr)/Po,l=s-zr,m=a,w=r.pow(t,u),E=r.pow(t,(u+zr)/Po),P=(M,D)=>{let L=w,U=r.pow(D,l),K=r.sqr(U);K=r.mul(K,D);let C=r.mul(M,K);C=r.pow(C,c),C=r.mul(C,U),U=r.mul(C,D),K=r.mul(C,M);let N=r.mul(K,U);C=r.pow(N,m);let F=r.eql(C,r.ONE);U=r.mul(K,E),C=r.mul(N,L),K=r.cmov(U,K,F),N=r.cmov(C,N,F);for(let H=o;H>zr;H--){let z=H-Po;z=Po<<z-zr;let G=r.pow(N,z),R=r.eql(G,r.ONE);U=r.mul(K,L),L=r.mul(L,L),G=r.mul(N,L),K=r.cmov(U,K,R),N=r.cmov(G,N,R)}return{isValid:!r.is0(D)&&(F||r.is0(M)),value:K}};if(r.ORDER%fy===Gc){let M=(r.ORDER-Gc)/fy,D=r.sqrt(r.neg(t));P=(L,U)=>{let K=r.sqr(U),C=r.mul(L,U);K=r.mul(K,C);let N=r.pow(K,M);N=r.mul(N,C);let F=r.mul(N,D),H=r.mul(r.sqr(N),U),z=r.eql(H,L),G=r.cmov(F,N,z);return{isValid:!r.is0(U)&&z,value:G}}}return P}function pA(e,t){let r=rf(e),{A:i,B:n,Z:o}=t;if(!r.isValidNot0(i)||!r.isValidNot0(n)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||$m(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let a=r.mul(n,r.inv(r.mul(o,i))),s=r.add(r.add(r.mul(r.sqr(a),a),r.mul(i,a)),n);if(!$m(r,s))throw new Error("mapToCurveSimpleSWU: invalid opts");let u=nX(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return c=>{let l,m,w,E,P,M,D,L;l=r.sqr(c),l=r.mul(l,o),m=r.sqr(l),m=r.add(m,l),w=r.add(m,r.ONE),w=r.mul(w,n),E=r.cmov(o,r.neg(m),!r.eql(m,r.ZERO)),E=r.mul(E,i),m=r.sqr(w),M=r.sqr(E),P=r.mul(M,i),m=r.add(m,P),m=r.mul(m,w),M=r.mul(M,E),P=r.mul(M,n),m=r.add(m,P),D=r.mul(l,w);let{isValid:U,value:K}=u(m,M);L=r.mul(l,c),L=r.mul(L,K),D=r.cmov(D,w,U),L=r.cmov(L,K,U);let C=r.isOdd(c)===r.isOdd(L);L=r.cmov(r.neg(L),L,C);let N=nf(r,[E],!0)[0];return D=r.mul(D,N),{x:D,y:L}}}function gA(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function oX(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?ki:t.randomBytes,n=Object.assign(gA(e.Fp,r),{seed:Math.max(c0(r.ORDER),16)});function o(E){try{let P=r.fromBytes(E);return r.isValidNot0(P)}catch{return!1}}function a(E,P){let{publicKey:M,publicKeyUncompressed:D}=n;try{let L=E.length;return P===!0&&L!==M||P===!1&&L!==D?!1:!!e.fromBytes(E)}catch{return!1}}function s(E){return E=E===void 0?i(n.seed):E,jc(Ft(E,n.seed,"seed"),r.ORDER)}function u(E,P=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(P)}function c(E){let{secretKey:P,publicKey:M,publicKeyUncompressed:D}=n,L=r._lengths;if(!Xu(E))return;let U=Ft(E,void 0,"key").length,K=U===M||U===D,C=U===P||!!L?.includes(U);if(!(K&&C))return K}function l(E,P,M=!0){if(c(E)===!0)throw new Error("first arg must be private key");if(c(P)===!1)throw new Error("second arg must be public key");let D=r.fromBytes(E);return e.fromBytes(P).multiply(D).toBytes(M)}let m={isValidSecretKey:o,isValidPublicKey:a,randomSecretKey:s},w=gp(s,u);return Object.freeze(m),Object.freeze(n),Object.freeze({getPublicKey:u,getSharedSecret:l,keygen:w,Point:e,utils:m,lengths:n})}function vA(e,t,r={}){let i=t;Y2(i),pn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?ki:r.randomBytes,o=r.hmac===void 0?(d,_)=>ny(i,d,_):r.hmac,{Fp:a,Fn:s}=e,{ORDER:u,BITS:c}=s,{keygen:l,getPublicKey:m,getSharedSecret:w,utils:E,lengths:P}=oX(e,r),M={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},D=u*Po+zr<a.ORDER;function L(d){let _=u>>zr;return d>_}function U(d,_){if(!s.isValidNot0(_))throw new Error(`invalid signature ${d}: out of range 1..Point.Fn.ORDER`);return _}function K(){if(D)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function C(d,_){sy(_);let x=P.signature,b=_==="compact"?x:_==="recovered"?x+1:void 0;return Ft(d,b)}class N{constructor(_,x,b){Z(this,"r");Z(this,"s");Z(this,"recovery");if(this.r=U("r",_),this.s=U("s",x),b!=null){if(K(),![0,1,2,3].includes(b))throw new Error("invalid recovery id");this.recovery=b}Object.freeze(this)}static fromBytes(_,x=M.format){C(_,x);let b;if(x==="der"){let{r:S,s:B}=Kn.toSig(Ft(_));return new N(S,B)}x==="recovered"&&(b=_[0],x="compact",_=_.subarray(1));let p=P.signature/2,O=_.subarray(0,p),T=_.subarray(p,p*2);return new N(s.fromBytes(O),s.fromBytes(T),b)}static fromHex(_,x){return this.fromBytes(Lc(_),x)}assertRecovery(){let{recovery:_}=this;if(_==null)throw new Error("invalid recovery id: must be present");return _}addRecoveryBit(_){return new N(this.r,this.s,_)}recoverPublicKey(_){let{r:x,s:b}=this,p=this.assertRecovery(),O=p===2||p===3?x+u:x;if(!a.isValid(O))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let T=a.toBytes(O),S=e.fromBytes(Bt(dA((p&1)===0),T)),B=s.inv(O),Y=H(Ft(_,void 0,"msgHash")),$=s.create(-Y*B),ne=s.create(b*B),he=e.BASE.multiplyUnsafe($).add(S.multiplyUnsafe(ne));if(he.is0())throw new Error("invalid recovery: point at infinify");return he.assertValidity(),he}hasHighS(){return L(this.s)}toBytes(_=M.format){if(sy(_),_==="der")return Lc(Kn.hexFromSig(this));let{r:x,s:b}=this,p=s.toBytes(x),O=s.toBytes(b);return _==="recovered"?(K(),Bt(Uint8Array.of(this.assertRecovery()),p,O)):Bt(p,O)}toHex(_){return Ra(this.toBytes(_))}}Object.freeze(N.prototype),Object.freeze(N);let F=r.bits2int===void 0?function(_){if(_.length>8192)throw new Error("input is too large");let x=yi(_),b=_.length*8-c;return b>0?x>>BigInt(b):x}:r.bits2int,H=r.bits2int_modN===void 0?function(_){return s.create(F(_))}:r.bits2int_modN,z=Fc(c);function G(d){return Zm("num < 2^"+c,d,gn,z),s.toBytes(d)}function R(d,_){return Ft(d,void 0,"message"),_?Ft(i(d),void 0,"prehashed message"):d}function g(d,_,x){let{lowS:b,prehash:p,extraEntropy:O}=ay(x,M);d=R(d,p);let T=H(d),S=s.fromBytes(_);if(!s.isValidNot0(S))throw new Error("invalid private key");let B=[G(S),G(T)];if(O!=null&&O!==!1){let he=O===!0?n(P.secretKey):O;B.push(Ft(he,void 0,"extraEntropy"))}let Y=Bt(...B),$=T;function ne(he){let pe=F(he);if(!s.isValidNot0(pe))return;let q=s.inv(pe),W=e.BASE.multiply(pe).toAffine(),X=s.create(W.x);if(X===gn)return;let te=s.create(q*s.create($+X*S));if(te===gn)return;let me=(W.x===X?0:2)|Number(W.y&zr),se=te;return b&&L(te)&&(se=s.neg(te),me^=1),new N(X,se,D?void 0:me)}return{seed:Y,k2sig:ne}}function I(d,_,x={}){let{seed:b,k2sig:p}=g(d,_,x);return DO(i.outputLen,s.BYTES,o)(b,p).toBytes(x.format)}function y(d,_,x,b={}){let{lowS:p,prehash:O,format:T}=ay(b,M);if(x=Ft(x,void 0,"publicKey"),_=R(_,O),!Xu(d)){let S=d instanceof N?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+S)}C(d,T);try{let S=N.fromBytes(d,T),B=e.fromBytes(x);if(p&&S.hasHighS())return!1;let{r:Y,s:$}=S,ne=H(_),he=s.inv($),pe=s.create(ne*he),q=s.create(Y*he),W=e.BASE.multiplyUnsafe(pe).add(B.multiplyUnsafe(q));return W.is0()?!1:s.create(W.x)===Y}catch{return!1}}function f(d,_,x={}){let{prehash:b}=ay(x,M);return _=R(_,b),N.fromBytes(d,"recovered").recoverPublicKey(_).toBytes()}return Object.freeze({keygen:l,getPublicKey:m,getSharedSecret:w,utils:E,lengths:P,Point:e,sign:I,verify:y,recoverPublicKey:f,Signature:N,hash:i})}var lA,uy,Kn,gn,zr,Po,Gc,fy,mA=Yr(()=>{v();yp();vs();ef();vp();zc();lA=(e,t)=>(e+(e>=0?t:-t)/Po)/t;uy=class extends Error{constructor(t=""){super(t)}},Kn={Err:uy,_tlv:{encode:(e,t)=>{let{Err:r}=Kn;if(dn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let i=t.length/2,n=f0(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?f0(n.length/2|128):"";return f0(e)+o+n+t},decode(e,t){let{Err:r}=Kn;t=Ft(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),a=0;if(!o)a=n;else{let u=n&127;if(!u)throw new r("tlv.decode(long): indefinite length not supported");if(u>4)throw new r("tlv.decode(long): byte length is too big");let c=t.subarray(i,i+u);if(c.length!==u)throw new r("tlv.decode: length bytes not complete");if(c[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let l of c)a=a<<8|l;if(i+=u,a<128)throw new r("tlv.decode(long): not minimal encoding")}let s=t.subarray(i,i+a);if(s.length!==a)throw new r("tlv.decode: wrong value length");return{v:s,l:t.subarray(i+a)}}},_int:{encode(e){let{Err:t}=Kn;if(cp(e),e<gn)throw new t("integer: negative integers are not allowed");let r=f0(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Kn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return yi(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Kn,n=Ft(e,void 0,"signature"),{v:o,l:a}=i.decode(48,n);if(a.length)throw new t("invalid signature: left bytes after parsing");let{v:s,l:u}=i.decode(2,o),{v:c,l}=i.decode(2,u);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(s),s:r.decode(c)}},hexFromSig(e){let{_tlv:t,_int:r}=Kn,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}};Object.freeze(Kn._tlv);Object.freeze(Kn._int);Object.freeze(Kn);gn=BigInt(0),zr=BigInt(1),Po=BigInt(2),Gc=BigInt(3),fy=BigInt(4)});var p0={};X1(p0,{__TEST:()=>cX,schnorr:()=>lX,schnorr_FROST:()=>yX,secp256k1:()=>uX,secp256k1_FROST:()=>pX,secp256k1_hasher:()=>hy});function sX(e){let t=bp.p,r=BigInt(3),i=BigInt(6),n=BigInt(11),o=BigInt(22),a=BigInt(23),s=BigInt(44),u=BigInt(88),c=e*e*e%t,l=c*c*e%t,m=Vi(l,r,t)*l%t,w=Vi(m,r,t)*l%t,E=Vi(w,cy,t)*c%t,P=Vi(E,n,t)*E%t,M=Vi(P,o,t)*P%t,D=Vi(M,s,t)*M%t,L=Vi(D,u,t)*D%t,U=Vi(L,s,t)*M%t,K=Vi(U,r,t)*l%t,C=Vi(K,a,t)*P%t,N=Vi(C,i,t)*c%t,F=Vi(N,cy,t);if(!Ba.eql(Ba.sqr(F),e))throw new Error("Cannot find square root");return F}function d0(e,...t){let r=yA[e];if(r===void 0){let i=_s(Uc(e));r=Bt(i,i),yA[e]=r}return _s(Bt(r,...t))}function SA(e){let{Fn:t,BASE:r}=jt,i=t.fromBytes(e),n=r.multiply(i);return{scalar:To(n.y)?i:t.neg(i),bytes:sf(n)}}function _p(e){let t=Ba;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.create(e*e),i=t.create(r*e+BigInt(7)),n=t.sqrt(i);To(n)||(n=t.neg(n));let o=jt.fromAffine({x:e,y:n});return o.assertValidity(),o}function ly(...e){return jt.Fn.create(Zc(d0("BIP0340/challenge",...e)))}function bA(e){return SA(e).bytes}function fX(e,t,r=o0(32)){let{Fn:i,BASE:n}=jt,o=Ft(e,void 0,"message"),{bytes:a,scalar:s}=SA(t),u=Ft(r,32,"auxRand"),c=i.toBytes(s^Zc(d0("BIP0340/aux",u))),l=d0("BIP0340/nonce",c,a,o),m=i.create(Zc(l));if(m===0n)throw new Error("sign failed: k is zero");let w=n.multiply(m),E=To(w.y)?m:i.neg(m),P=sf(w),M=ly(P,a,o),D=new Uint8Array(64);if(D.set(P,0),D.set(i.toBytes(i.create(E+M*s)),32),!xA(D,o,a))throw new Error("sign: Invalid signature produced");return D}function xA(e,t,r){let{Fp:i,Fn:n,BASE:o}=jt,a=Ft(e,64,"signature"),s=Ft(t,void 0,"message"),u=Ft(r,32,"publicKey");try{let c=_p(Zc(u)),l=Zc(a.subarray(0,32));if(!i.isValidNot0(l))return!1;let m=Zc(a.subarray(32,64));if(!n.isValidNot0(m))return!1;let w=ly(n.toBytes(l),sf(c),s),E=o.multiplyUnsafe(m).add(c.multiplyUnsafe(n.neg(w))),{x:P,y:M}=E.toAffine();return!(E.is0()||!To(M)||P!==l)}catch{return!1}}function EA(e,t){if(t===void 0)return wA;let r=sf(e),i=yi(d0("TapTweak",r,t));if(!jt.Fn.isValid(i))throw new Error("invalid TapTweak hash");return i}function dy(e){let t=jt.fromBytes(e.commitments[0]);return To(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>jt.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,i])=>[r,jt.fromBytes(i).negate().toBytes()]))}}function IA(e,t){let r=jt.fromBytes(t.commitments[0]);if(To(r.y))return e;let i=jt.Fn;return{...e,signingShare:i.toBytes(i.neg(i.fromBytes(e.signingShare)))}}function gX(e,t){if(To(e.y))return t;let r=jt.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function vX(e,t,r){let i=jt.Fn,n=IA(e,t),o=dy(t),a=EA(jt.fromBytes(o.commitments[0]),r),s=i.toBytes(i.add(i.fromBytes(n.signingShare),a));return{identifier:n.identifier,signingShare:s}}function mX(e,t){let r=dy(e),i=EA(jt.fromBytes(r.commitments[0]),t),n=jt.BASE.multiply(i),o=r.commitments.map((s,u)=>(u===0?jt.fromBytes(s).add(n):jt.fromBytes(s)).toBytes()),a={};for(let s in r.verifyingShares)a[s]=jt.fromBytes(r.verifyingShares[s]).add(n).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:a}}var bp,aX,wA,cy,Ba,jt,uX,yA,sf,To,Zc,cX,lX,hX,_A,dX,hy,pX,yX,g0=Yr(()=>{v();sp();vs();vp();cA();uA();zc();mA();ef();bp={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},aX={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},wA=BigInt(0),cy=BigInt(2);Ba=Hc(bp.p,{sqrt:sX}),jt=hA(bp,{Fp:Ba,endo:aX}),uX=vA(jt,_s),yA={};sf=e=>e.toBytes(!0).slice(1),To=e=>e%cy===wA;Zc=yi;cX=Object.freeze({lift_x:_p}),lX=(()=>{let r=i=>(i=i===void 0?o0(48):i,jc(i,bp.n));return Object.freeze({keygen:gp(r,bA),getPublicKey:bA,sign:fX,verify:xA,Point:jt,utils:Object.freeze({randomSecretKey:r,taggedHash:d0,lift_x:_p,pointToBytes:sf}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),hX=aA(Ba,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),dX=()=>_A||(_A=pA(Ba,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Ba.create(BigInt("-11"))})),hy=sA(jt,e=>{let{x:t,y:r}=dX()(Ba.create(e[0]));return hX(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Ba.ORDER,m:1,k:128,expand:"xmd",hash:_s}),pX=iy({name:"FROST-secp256k1-SHA256-v1",Point:jt,hashToScalar:hy.hashToScalar,hash:_s});yX=iy({name:"FROST-secp256k1-SHA256-TR-v1",Point:jt,hashToScalar:hy.hashToScalar,hash:_s,parsePublicKey(e){if(e.length===32)return _p(yi(e));if(e.length===33)return jt.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=jt.BASE.multiply(e);return To(t.y)?e:jt.Fn.neg(e)},adjustPoint:e=>To(e.y)?e:e.negate(),challenge(e,t,r){return ly(sf(e),sf(t),r)},adjustNonces:gX,adjustGroupCommitmentShare:(e,t)=>To(e.y)?t:t.negate(),adjustPublic:dy,adjustSecret:IA,adjustTx:{encode:e=>e.subarray(1),decode:e=>Bt(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:mX(e.public,t),secret:vX(e.secret,e.public,t)}}})});var vn=k((xpe,TA)=>{"use strict";v();var OA=_t(),{secp256k1:bX}=(g0(),po(p0)),m0=bX.Point,wp=m0.Fn.ORDER;function _X(e){return BigInt("0x"+(e.toString(16)||"0"))}function py(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new OA(t,16)}function Sp(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return _X(e);throw new Error("Invalid Point")}function v0(e){var t=Object.create(zt.prototype);return t._p=e,t}function AA(e,t){var r=Sp(t).toString(16).padStart(64,"0");return m0.fromHex((e?"03":"02")+r)}function PA(e,t){var r;try{r=AA((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function zt(e,t,r){if(!(this instanceof zt))return new zt(e,t,r);var i,n;try{i=Sp(e),n=Sp(t)}catch{throw new Error("Invalid Point")}PA(i,n);try{this._p=m0.fromAffine({x:i,y:n})}catch{throw new Error("Invalid Point")}return this}zt.fromX=function(t,r){try{var i=v0(AA(t,r))}catch{throw new Error("Invalid X")}return i.validate(),i};zt.getG=function(){return v0(m0.BASE)};zt.getN=function(){return py(wp)};zt.prototype.getX=function(){return py(this._p.toAffine().x)};zt.prototype.getY=function(){return py(this._p.toAffine().y)};Object.defineProperty(zt.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(zt.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});zt.prototype.mul=function(t){var r=(Sp(t)%wp+wp)%wp;return r===0n||this._p.is0()?v0(m0.ZERO):v0(this._p.multiply(r))};zt.prototype.add=function(t){return v0(this._p.add(t._p))};zt.prototype.mulAdd=function(t,r,i){return this.mul(t).add(r.mul(i))};zt.prototype.eq=function(t){return this._p.equals(t._p)};zt.prototype.isInfinity=function(){return this._p.is0()};zt.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return PA(t.x,t.y),this};zt.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),i=t.getY().toBuffer({size:32}),n,o=i[i.length-1]%2;return o?n=h.Buffer.from([3]):n=h.Buffer.from([2]),h.Buffer.concat([n,r])};zt.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var i=OA.fromBuffer(e.slice(1,33));return zt.fromX(r,i)};zt.prototype.toBuffer=function(){return zt.pointToCompressed(this)};zt.prototype.toHex=function(){return this.toBuffer().toString("hex")};zt.fromBuffer=function(e){return zt.pointFromCompressed(e)};zt.fromHex=function(e){return zt.fromBuffer(h.Buffer.from(e,"hex"))};TA.exports=zt});var ei=k((Ipe,BA)=>{"use strict";v();var RA=bt(),wX=Be(),kA=function(t){return RA.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};BA.exports={isValidJSON:function(t){var r;if(!RA.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:kA,isHexaString:kA,defineImmutable:function(t,r){return Object.keys(r).forEach(function(i){Object.defineProperty(t,i,{configurable:!1,enumerable:!0,value:r[i]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){wX.checkArgumentType(t,"number","integer");let r=h.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var Mt=k((Ape,CA)=>{"use strict";v();var uf=_t(),SX=bt(),bi=Be(),xX=ei(),vt=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof uf)this.set({r:t,s:r});else if(t){var i=t;this.set(i)}};vt.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};vt.fromCompact=function(e){bi.checkArgument(h.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new vt,r=!0,i=e.slice(0,1)[0]-27-4;i<0&&(r=!1,i=i+4);var n=e.slice(1,33),o=e.slice(33,65);return bi.checkArgument(i===0||i===1||i===2||i===3,new Error("i must be 0, 1, 2, or 3")),bi.checkArgument(n.length===32,new Error("r must be 32 bytes")),bi.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=i,t.r=uf.fromBuffer(n),t.s=uf.fromBuffer(o),t};vt.fromDER=vt.fromBuffer=function(e,t){var r=vt.parseDER(e,t),i=new vt;return i.r=r.r,i.s=r.s,i};vt.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),i=vt.fromDER(r,!1);return i.nhashtype=t,i};vt.fromString=function(e){var t=h.Buffer.from(e,"hex");return vt.fromDER(t)};function MA(e,t){bi.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),bi.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),bi.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}vt.parseDER=function(e,t){bi.checkArgument(h.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),SX.isUndefined(t)&&(t=!0);var r=e[0];bi.checkArgument(r===48,new Error("Header byte should be 0x30"));var i=e[1],n=e.slice(2).length;bi.checkArgument(!t||i===n,new Error("Length byte should length of what follows")),i=i<n?i:n;var o=e[2];bi.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var a=e[3],s=e.slice(4,4+a),u=uf.fromBuffer(s),c=e[4]===0;bi.checkArgument(a===s.length,new Error("Length of r incorrect"));var l=e[4+a+0];bi.checkArgument(l===2,new Error("Integer byte for s should be 0x02"));var m=e[4+a+1],w=e.slice(4+a+2,4+a+2+m),E=uf.fromBuffer(w),P=e[4+a+2]===0;bi.checkArgument(m===w.length,new Error("Length of s incorrect"));var M=4+a+2+m;bi.checkArgument(i===M-2,new Error("Length of signature incorrect")),t&&(MA("r",s),MA("s",w));var D={header:r,length:i,rheader:o,rlength:a,rneg:c,rbuf:s,r:u,sheader:l,slength:m,sneg:P,sbuf:w,s:E};return D};vt.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var i=h.Buffer.from([r]),n=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return h.Buffer.concat([i,n,o])};vt.prototype.toBuffer=vt.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),i=!!(t[0]&128),n=r?h.Buffer.concat([h.Buffer.from([0]),e]):e,o=i?h.Buffer.concat([h.Buffer.from([0]),t]):t,a=n.length,s=o.length,u=2+a+2+s,c=2,l=2,m=48,w=h.Buffer.concat([h.Buffer.from([m,u,c,a]),n,h.Buffer.from([l,s]),o]);return w};vt.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};vt.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var i=e.slice(4);if(e[2]!==2||t===0||i[0]&128||t>1&&i[0]===0&&!(i[1]&128))return!1;var n=e.slice(6+t);return!(e[6+t-2]!==2||r===0||n[0]&128||r>1&&n[0]===0&&!(n[1]&128))};vt.prototype.hasLowS=function(){return!(this.s.lt(new uf(1))||this.s.gt(new uf("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};vt.prototype.hasDefinedHashtype=function(){if(!xX.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<vt.SIGHASH_ALL||e>vt.SIGHASH_SINGLE)};vt.prototype.toTxFormat=function(){var e=this.toDER(),t=h.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),h.Buffer.concat([e,t])};vt.SIGHASH_ALL=1;vt.SIGHASH_NONE=2;vt.SIGHASH_SINGLE=3;vt.SIGHASH_CHRONICLE=32;vt.SIGHASH_FORKID=64;vt.SIGHASH_ANYONECANPAY=128;vt.prototype.isCanonical=function(){var e=vn(),t=e.getN().shrn(1);return this.s.lte(t)};vt.prototype.toCanonical=function(){if(this.isCanonical())return new vt({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=vn(),t=e.getN(),r=t.sub(this.s);return new vt({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};vt.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=vn(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};vt.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};vt.prototype.applySecurityPatches=function(){var e=vn(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};CA.exports=vt});var Vn=k(Kt=>{"use strict";v();var EX=Cn(),IX=ke();Kt.inherits=IX;function OX(e,t){return(e.charCodeAt(t)&64512)!==55296||t<0||t+1>=e.length?!1:(e.charCodeAt(t+1)&64512)===56320}function AX(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if(typeof e=="string")if(t){if(t==="hex")for(e=e.replace(/[^a-z0-9]+/ig,""),e.length%2!==0&&(e="0"+e),n=0;n<e.length;n+=2)r.push(parseInt(e[n]+e[n+1],16))}else for(var i=0,n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?r[i++]=o:o<2048?(r[i++]=o>>6|192,r[i++]=o&63|128):OX(e,n)?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),r[i++]=o>>18|240,r[i++]=o>>12&63|128,r[i++]=o>>6&63|128,r[i++]=o&63|128):(r[i++]=o>>12|224,r[i++]=o>>6&63|128,r[i++]=o&63|128)}else for(n=0;n<e.length;n++)r[n]=e[n]|0;return r}Kt.toArray=AX;function PX(e){for(var t="",r=0;r<e.length;r++)t+=DA(e[r].toString(16));return t}Kt.toHex=PX;function NA(e){var t=e>>>24|e>>>8&65280|e<<8&16711680|(e&255)<<24;return t>>>0}Kt.htonl=NA;function TX(e,t){for(var r="",i=0;i<e.length;i++){var n=e[i];t==="little"&&(n=NA(n)),r+=LA(n.toString(16))}return r}Kt.toHex32=TX;function DA(e){return e.length===1?"0"+e:e}Kt.zero2=DA;function LA(e){return e.length===7?"0"+e:e.length===6?"00"+e:e.length===5?"000"+e:e.length===4?"0000"+e:e.length===3?"00000"+e:e.length===2?"000000"+e:e.length===1?"0000000"+e:e}Kt.zero8=LA;function kX(e,t,r,i){var n=r-t;EX(n%4===0);for(var o=new Array(n/4),a=0,s=t;a<o.length;a++,s+=4){var u;i==="big"?u=e[s]<<24|e[s+1]<<16|e[s+2]<<8|e[s+3]:u=e[s+3]<<24|e[s+2]<<16|e[s+1]<<8|e[s],o[a]=u>>>0}return o}Kt.join32=kX;function RX(e,t){for(var r=new Array(e.length*4),i=0,n=0;i<e.length;i++,n+=4){var o=e[i];t==="big"?(r[n]=o>>>24,r[n+1]=o>>>16&255,r[n+2]=o>>>8&255,r[n+3]=o&255):(r[n+3]=o>>>24,r[n+2]=o>>>16&255,r[n+1]=o>>>8&255,r[n]=o&255)}return r}Kt.split32=RX;function BX(e,t){return e>>>t|e<<32-t}Kt.rotr32=BX;function MX(e,t){return e<<t|e>>>32-t}Kt.rotl32=MX;function CX(e,t){return e+t>>>0}Kt.sum32=CX;function NX(e,t,r){return e+t+r>>>0}Kt.sum32_3=NX;function DX(e,t,r,i){return e+t+r+i>>>0}Kt.sum32_4=DX;function LX(e,t,r,i,n){return e+t+r+i+n>>>0}Kt.sum32_5=LX;function qX(e,t,r,i){var n=e[t],o=e[t+1],a=i+o>>>0,s=(a<i?1:0)+r+n;e[t]=s>>>0,e[t+1]=a}Kt.sum64=qX;function UX(e,t,r,i){var n=t+i>>>0,o=(n<t?1:0)+e+r;return o>>>0}Kt.sum64_hi=UX;function FX(e,t,r,i){var n=t+i;return n>>>0}Kt.sum64_lo=FX;function HX(e,t,r,i,n,o,a,s){var u=0,c=t;c=c+i>>>0,u+=c<t?1:0,c=c+o>>>0,u+=c<o?1:0,c=c+s>>>0,u+=c<s?1:0;var l=e+r+n+a+u;return l>>>0}Kt.sum64_4_hi=HX;function jX(e,t,r,i,n,o,a,s){var u=t+i+o+s;return u>>>0}Kt.sum64_4_lo=jX;function zX(e,t,r,i,n,o,a,s,u,c){var l=0,m=t;m=m+i>>>0,l+=m<t?1:0,m=m+o>>>0,l+=m<o?1:0,m=m+s>>>0,l+=m<s?1:0,m=m+c>>>0,l+=m<c?1:0;var w=e+r+n+a+u+l;return w>>>0}Kt.sum64_5_hi=zX;function KX(e,t,r,i,n,o,a,s,u,c){var l=t+i+o+s+c;return l>>>0}Kt.sum64_5_lo=KX;function VX(e,t,r){var i=t<<32-r|e>>>r;return i>>>0}Kt.rotr64_hi=VX;function GX(e,t,r){var i=e<<32-r|t>>>r;return i>>>0}Kt.rotr64_lo=GX;function ZX(e,t,r){return e>>>r}Kt.shr64_hi=ZX;function WX(e,t,r){var i=e<<32-r|t>>>r;return i>>>0}Kt.shr64_lo=WX});var Wc=k(UA=>{"use strict";v();var qA=Vn(),YX=Cn();function xp(){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}UA.BlockHash=xp;xp.prototype.update=function(t,r){if(t=qA.toArray(t,r),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){t=this.pending;var i=t.length%this._delta8;this.pending=t.slice(t.length-i,t.length),this.pending.length===0&&(this.pending=null),t=qA.join32(t,0,t.length-i,this.endian);for(var n=0;n<t.length;n+=this._delta32)this._update(t,n,n+this._delta32)}return this};xp.prototype.digest=function(t){return this.update(this._pad()),YX(this.pending===null),this._digest(t)};xp.prototype._pad=function(){var t=this.pendingTotal,r=this._delta8,i=r-(t+this.padLength)%r,n=new Array(i+this.padLength);n[0]=128;for(var o=1;o<i;o++)n[o]=0;if(t<<=3,this.endian==="big"){for(var a=8;a<this.padLength;a++)n[o++]=0;n[o++]=0,n[o++]=0,n[o++]=0,n[o++]=0,n[o++]=t>>>24&255,n[o++]=t>>>16&255,n[o++]=t>>>8&255,n[o++]=t&255}else for(n[o++]=t&255,n[o++]=t>>>8&255,n[o++]=t>>>16&255,n[o++]=t>>>24&255,n[o++]=0,n[o++]=0,n[o++]=0,n[o++]=0,a=8;a<this.padLength;a++)n[o++]=0;return n}});var gy=k(Ma=>{"use strict";v();var $X=Vn(),ko=$X.rotr32;function XX(e,t,r,i){if(e===0)return FA(t,r,i);if(e===1||e===3)return jA(t,r,i);if(e===2)return HA(t,r,i)}Ma.ft_1=XX;function FA(e,t,r){return e&t^~e&r}Ma.ch32=FA;function HA(e,t,r){return e&t^e&r^t&r}Ma.maj32=HA;function jA(e,t,r){return e^t^r}Ma.p32=jA;function JX(e){return ko(e,2)^ko(e,13)^ko(e,22)}Ma.s0_256=JX;function QX(e){return ko(e,6)^ko(e,11)^ko(e,25)}Ma.s1_256=QX;function eJ(e){return ko(e,7)^ko(e,18)^e>>>3}Ma.g0_256=eJ;function tJ(e){return ko(e,17)^ko(e,19)^e>>>10}Ma.g1_256=tJ});var VA=k((Npe,KA)=>{"use strict";v();var Yc=Vn(),rJ=Wc(),iJ=gy(),vy=Yc.rotl32,y0=Yc.sum32,nJ=Yc.sum32_5,oJ=iJ.ft_1,zA=rJ.BlockHash,aJ=[1518500249,1859775393,2400959708,3395469782];function Ro(){if(!(this instanceof Ro))return new Ro;zA.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Yc.inherits(Ro,zA);KA.exports=Ro;Ro.blockSize=512;Ro.outSize=160;Ro.hmacStrength=80;Ro.padLength=64;Ro.prototype._update=function(t,r){for(var i=this.W,n=0;n<16;n++)i[n]=t[r+n];for(;n<i.length;n++)i[n]=vy(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var o=this.h[0],a=this.h[1],s=this.h[2],u=this.h[3],c=this.h[4];for(n=0;n<i.length;n++){var l=~~(n/20),m=nJ(vy(o,5),oJ(l,a,s,u),c,i[n],aJ[l]);c=u,u=s,s=vy(a,30),a=o,o=m}this.h[0]=y0(this.h[0],o),this.h[1]=y0(this.h[1],a),this.h[2]=y0(this.h[2],s),this.h[3]=y0(this.h[3],u),this.h[4]=y0(this.h[4],c)};Ro.prototype._digest=function(t){return t==="hex"?Yc.toHex32(this.h,"big"):Yc.split32(this.h,"big")}});var my=k((Lpe,ZA)=>{"use strict";v();var $c=Vn(),sJ=Wc(),Xc=gy(),uJ=Cn(),Gn=$c.sum32,fJ=$c.sum32_4,cJ=$c.sum32_5,lJ=Xc.ch32,hJ=Xc.maj32,dJ=Xc.s0_256,pJ=Xc.s1_256,gJ=Xc.g0_256,vJ=Xc.g1_256,GA=sJ.BlockHash,mJ=[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];function Bo(){if(!(this instanceof Bo))return new Bo;GA.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=mJ,this.W=new Array(64)}$c.inherits(Bo,GA);ZA.exports=Bo;Bo.blockSize=512;Bo.outSize=256;Bo.hmacStrength=192;Bo.padLength=64;Bo.prototype._update=function(t,r){for(var i=this.W,n=0;n<16;n++)i[n]=t[r+n];for(;n<i.length;n++)i[n]=fJ(vJ(i[n-2]),i[n-7],gJ(i[n-15]),i[n-16]);var o=this.h[0],a=this.h[1],s=this.h[2],u=this.h[3],c=this.h[4],l=this.h[5],m=this.h[6],w=this.h[7];for(uJ(this.k.length===i.length),n=0;n<i.length;n++){var E=cJ(w,pJ(c),lJ(c,l,m),this.k[n],i[n]),P=Gn(dJ(o),hJ(o,a,s));w=m,m=l,l=c,c=Gn(u,E),u=s,s=a,a=o,o=Gn(E,P)}this.h[0]=Gn(this.h[0],o),this.h[1]=Gn(this.h[1],a),this.h[2]=Gn(this.h[2],s),this.h[3]=Gn(this.h[3],u),this.h[4]=Gn(this.h[4],c),this.h[5]=Gn(this.h[5],l),this.h[6]=Gn(this.h[6],m),this.h[7]=Gn(this.h[7],w)};Bo.prototype._digest=function(t){return t==="hex"?$c.toHex32(this.h,"big"):$c.split32(this.h,"big")}});var $A=k((Upe,YA)=>{"use strict";v();var yy=Vn(),WA=my();function Ca(){if(!(this instanceof Ca))return new Ca;WA.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}yy.inherits(Ca,WA);YA.exports=Ca;Ca.blockSize=512;Ca.outSize=224;Ca.hmacStrength=192;Ca.padLength=64;Ca.prototype._digest=function(t){return t==="hex"?yy.toHex32(this.h.slice(0,7),"big"):yy.split32(this.h.slice(0,7),"big")}});var wy=k((Hpe,eP)=>{"use strict";v();var Ri=Vn(),yJ=Wc(),bJ=Cn(),Mo=Ri.rotr64_hi,Co=Ri.rotr64_lo,XA=Ri.shr64_hi,JA=Ri.shr64_lo,ws=Ri.sum64,by=Ri.sum64_hi,_y=Ri.sum64_lo,_J=Ri.sum64_4_hi,wJ=Ri.sum64_4_lo,SJ=Ri.sum64_5_hi,xJ=Ri.sum64_5_lo,QA=yJ.BlockHash,EJ=[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];function Zn(){if(!(this instanceof Zn))return new Zn;QA.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=EJ,this.W=new Array(160)}Ri.inherits(Zn,QA);eP.exports=Zn;Zn.blockSize=1024;Zn.outSize=512;Zn.hmacStrength=192;Zn.padLength=128;Zn.prototype._prepareBlock=function(t,r){for(var i=this.W,n=0;n<32;n++)i[n]=t[r+n];for(;n<i.length;n+=2){var o=NJ(i[n-4],i[n-3]),a=DJ(i[n-4],i[n-3]),s=i[n-14],u=i[n-13],c=MJ(i[n-30],i[n-29]),l=CJ(i[n-30],i[n-29]),m=i[n-32],w=i[n-31];i[n]=_J(o,a,s,u,c,l,m,w),i[n+1]=wJ(o,a,s,u,c,l,m,w)}};Zn.prototype._update=function(t,r){this._prepareBlock(t,r);var i=this.W,n=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],u=this.h[4],c=this.h[5],l=this.h[6],m=this.h[7],w=this.h[8],E=this.h[9],P=this.h[10],M=this.h[11],D=this.h[12],L=this.h[13],U=this.h[14],K=this.h[15];bJ(this.k.length===i.length);for(var C=0;C<i.length;C+=2){var N=U,F=K,H=RJ(w,E),z=BJ(w,E),G=IJ(w,E,P,M,D,L),R=OJ(w,E,P,M,D,L),g=this.k[C],I=this.k[C+1],y=i[C],f=i[C+1],d=SJ(N,F,H,z,G,R,g,I,y,f),_=xJ(N,F,H,z,G,R,g,I,y,f);N=TJ(n,o),F=kJ(n,o),H=AJ(n,o,a,s,u,c),z=PJ(n,o,a,s,u,c);var x=by(N,F,H,z),b=_y(N,F,H,z);U=D,K=L,D=P,L=M,P=w,M=E,w=by(l,m,d,_),E=_y(m,m,d,_),l=u,m=c,u=a,c=s,a=n,s=o,n=by(d,_,x,b),o=_y(d,_,x,b)}ws(this.h,0,n,o),ws(this.h,2,a,s),ws(this.h,4,u,c),ws(this.h,6,l,m),ws(this.h,8,w,E),ws(this.h,10,P,M),ws(this.h,12,D,L),ws(this.h,14,U,K)};Zn.prototype._digest=function(t){return t==="hex"?Ri.toHex32(this.h,"big"):Ri.split32(this.h,"big")};function IJ(e,t,r,i,n){var o=e&r^~e&n;return o<0&&(o+=4294967296),o}function OJ(e,t,r,i,n,o){var a=t&i^~t&o;return a<0&&(a+=4294967296),a}function AJ(e,t,r,i,n){var o=e&r^e&n^r&n;return o<0&&(o+=4294967296),o}function PJ(e,t,r,i,n,o){var a=t&i^t&o^i&o;return a<0&&(a+=4294967296),a}function TJ(e,t){var r=Mo(e,t,28),i=Mo(t,e,2),n=Mo(t,e,7),o=r^i^n;return o<0&&(o+=4294967296),o}function kJ(e,t){var r=Co(e,t,28),i=Co(t,e,2),n=Co(t,e,7),o=r^i^n;return o<0&&(o+=4294967296),o}function RJ(e,t){var r=Mo(e,t,14),i=Mo(e,t,18),n=Mo(t,e,9),o=r^i^n;return o<0&&(o+=4294967296),o}function BJ(e,t){var r=Co(e,t,14),i=Co(e,t,18),n=Co(t,e,9),o=r^i^n;return o<0&&(o+=4294967296),o}function MJ(e,t){var r=Mo(e,t,1),i=Mo(e,t,8),n=XA(e,t,7),o=r^i^n;return o<0&&(o+=4294967296),o}function CJ(e,t){var r=Co(e,t,1),i=Co(e,t,8),n=JA(e,t,7),o=r^i^n;return o<0&&(o+=4294967296),o}function NJ(e,t){var r=Mo(e,t,19),i=Mo(t,e,29),n=XA(e,t,6),o=r^i^n;return o<0&&(o+=4294967296),o}function DJ(e,t){var r=Co(e,t,19),i=Co(t,e,29),n=JA(e,t,6),o=r^i^n;return o<0&&(o+=4294967296),o}});var iP=k((zpe,rP)=>{"use strict";v();var Sy=Vn(),tP=wy();function Na(){if(!(this instanceof Na))return new Na;tP.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Sy.inherits(Na,tP);rP.exports=Na;Na.blockSize=1024;Na.outSize=384;Na.hmacStrength=192;Na.padLength=128;Na.prototype._digest=function(t){return t==="hex"?Sy.toHex32(this.h.slice(0,12),"big"):Sy.split32(this.h.slice(0,12),"big")}});var nP=k(Jc=>{"use strict";v();Jc.sha1=VA();Jc.sha224=$A();Jc.sha256=my();Jc.sha384=iP();Jc.sha512=wy()});var cP=k(fP=>{"use strict";v();var ff=Vn(),LJ=Wc(),Ep=ff.rotl32,oP=ff.sum32,b0=ff.sum32_3,aP=ff.sum32_4,uP=LJ.BlockHash;function No(){if(!(this instanceof No))return new No;uP.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}ff.inherits(No,uP);fP.ripemd160=No;No.blockSize=512;No.outSize=160;No.hmacStrength=192;No.padLength=64;No.prototype._update=function(t,r){for(var i=this.h[0],n=this.h[1],o=this.h[2],a=this.h[3],s=this.h[4],u=i,c=n,l=o,m=a,w=s,E=0;E<80;E++){var P=oP(Ep(aP(i,sP(E,n,o,a),t[FJ[E]+r],qJ(E)),jJ[E]),s);i=s,s=a,a=Ep(o,10),o=n,n=P,P=oP(Ep(aP(u,sP(79-E,c,l,m),t[HJ[E]+r],UJ(E)),zJ[E]),w),u=w,w=m,m=Ep(l,10),l=c,c=P}P=b0(this.h[1],o,m),this.h[1]=b0(this.h[2],a,w),this.h[2]=b0(this.h[3],s,u),this.h[3]=b0(this.h[4],i,c),this.h[4]=b0(this.h[0],n,l),this.h[0]=P};No.prototype._digest=function(t){return t==="hex"?ff.toHex32(this.h,"little"):ff.split32(this.h,"little")};function sP(e,t,r,i){return e<=15?t^r^i:e<=31?t&r|~t&i:e<=47?(t|~r)^i:e<=63?t&i|r&~i:t^(r|~i)}function qJ(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function UJ(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}var FJ=[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],HJ=[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],jJ=[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],zJ=[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]});var hP=k((Ype,lP)=>{"use strict";v();var KJ=Vn(),VJ=Cn();function Qc(e,t,r){if(!(this instanceof Qc))return new Qc(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(KJ.toArray(t,r))}lP.exports=Qc;Qc.prototype._init=function(t){t.length>this.blockSize&&(t=new this.Hash().update(t).digest()),VJ(t.length<=this.blockSize);for(var r=t.length;r<this.blockSize;r++)t.push(0);for(r=0;r<t.length;r++)t[r]^=54;for(this.inner=new this.Hash().update(t),r=0;r<t.length;r++)t[r]^=106;this.outer=new this.Hash().update(t)};Qc.prototype.update=function(t,r){return this.inner.update(t,r),this};Qc.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}});var pP=k(dP=>{v();var ti=dP;ti.utils=Vn();ti.common=Wc();ti.sha=nP();ti.ripemd=cP();ti.hmac=hP();ti.sha1=ti.sha.sha1;ti.sha256=ti.sha.sha256;ti.sha224=ti.sha.sha224;ti.sha384=ti.sha.sha384;ti.sha512=ti.sha.sha512;ti.ripemd160=ti.ripemd.ripemd160});var vP=k((Qpe,gP)=>{"use strict";v();var Ip=pP(),Da=Be(),Sr=gP.exports;Sr.sha1=function(e){return Da.checkArgument(h.Buffer.isBuffer(e)),h.Buffer.from(Ip.sha1().update(e).digest("hex"),"hex")};Sr.sha1.blocksize=512;Sr.sha256=function(e){return Da.checkArgument(h.Buffer.isBuffer(e)),h.Buffer.from(Ip.sha256().update(e).digest("hex"),"hex")};Sr.sha256.blocksize=512;Sr.sha256sha256=function(e){return Da.checkArgument(h.Buffer.isBuffer(e)),Sr.sha256(Sr.sha256(e))};Sr.ripemd160=function(e){return Da.checkArgument(h.Buffer.isBuffer(e)),h.Buffer.from(Ip.ripemd160().update(e).digest("hex"),"hex")};Sr.sha256ripemd160=function(e){return Da.checkArgument(h.Buffer.isBuffer(e)),Sr.ripemd160(Sr.sha256(e))};Sr.sha512=function(e){return Da.checkArgument(h.Buffer.isBuffer(e)),h.Buffer.from(Ip.sha512().update(e).digest("hex"),"hex")};Sr.sha512.blocksize=1024;Sr.hmac=function(e,t,r){Da.checkArgument(h.Buffer.isBuffer(t)),Da.checkArgument(h.Buffer.isBuffer(r)),Da.checkArgument(e.blocksize);var i=e.blocksize/8;if(r.length>i)r=e(r);else if(r.length<i){var n=h.Buffer.alloc(i);n.fill(0),r.copy(n),r=n}var o=h.Buffer.alloc(i);o.fill(92);var a=h.Buffer.alloc(i);a.fill(54);for(var s=h.Buffer.alloc(i),u=h.Buffer.alloc(i),c=0;c<i;c++)s[c]=o[c]^r[c],u[c]=a[c]^r[c];return e(h.Buffer.concat([s,e(h.Buffer.concat([u,t]))]))};Sr.sha256hmac=function(e,t){return Sr.hmac(Sr.sha256,e,t)};Sr.sha512hmac=function(e,t){return Sr.hmac(Sr.sha512,e,t)}});var yP=k((t6e,mP)=>{"use strict";v();var Op=_r(),La=Be(),xr=mP.exports;xr.sha1=function(e){return La.checkArgument(h.Buffer.isBuffer(e)),Op.createHash("sha1").update(e).digest()};xr.sha1.blocksize=512;xr.sha256=function(e){return La.checkArgument(h.Buffer.isBuffer(e)),Op.createHash("sha256").update(e).digest()};xr.sha256.blocksize=512;xr.sha256sha256=function(e){return La.checkArgument(h.Buffer.isBuffer(e)),xr.sha256(xr.sha256(e))};xr.ripemd160=function(e){return La.checkArgument(h.Buffer.isBuffer(e)),Op.createHash("ripemd160").update(e).digest()};xr.sha256ripemd160=function(e){return La.checkArgument(h.Buffer.isBuffer(e)),xr.ripemd160(xr.sha256(e))};xr.sha512=function(e){return La.checkArgument(h.Buffer.isBuffer(e)),Op.createHash("sha512").update(e).digest()};xr.sha512.blocksize=1024;xr.hmac=function(e,t,r){La.checkArgument(h.Buffer.isBuffer(t)),La.checkArgument(h.Buffer.isBuffer(r)),La.checkArgument(e.blocksize);var i=e.blocksize/8;if(r.length>i)r=e(r);else if(r.length<i){var n=h.Buffer.alloc(i);n.fill(0),r.copy(n),r=n}var o=h.Buffer.alloc(i);o.fill(92);var a=h.Buffer.alloc(i);a.fill(54);for(var s=h.Buffer.alloc(i),u=h.Buffer.alloc(i),c=0;c<i;c++)s[c]=o[c]^r[c],u[c]=a[c]^r[c];return e(h.Buffer.concat([s,e(h.Buffer.concat([u,t]))]))};xr.sha256hmac=function(e,t){return xr.hmac(xr.sha256,e,t)};xr.sha512hmac=function(e,t){return xr.hmac(xr.sha512,e,t)}});var at=k((i6e,xy)=>{v();A.default.browser?xy.exports=vP():xy.exports=yP()});var Fa=k((o6e,wP)=>{"use strict";v();var qa=bt(),_0=ei(),cf=[],w0={};function bP(){}bP.prototype.toString=function(){return this.name};function S0(e,t){if(~cf.indexOf(e))return e;if(t){qa.isArray(t)||(t=[t]);for(var r=0;r<cf.length;r++){var i=cf[r],n=qa.pick(i,t),o=qa.values(n);if(~o.indexOf(e))return i}return}return w0[e]}function Ap(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function x0(e){var t=new bP;_0.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&qa.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:Ap(e.cashAddrPrefix)}),e.networkMagic&&qa.extend(t,{networkMagic:_0.integerAsBuffer(e.networkMagic)}),e.port&&qa.extend(t,{port:e.port}),e.dnsSeeds&&qa.extend(t,{dnsSeeds:e.dnsSeeds}),cf.push(t),GJ(t,r),t}function GJ(e,t){for(var r=0;r<t.length;r++){var i=t[r],n=e[i];!qa.isUndefined(n)&&!qa.isObject(n)&&(w0[n]=e)}}function ZJ(e,t){for(var r=0;r<t.length;r++){var i=t[r];w0[i]===e&&delete w0[i]}}function WJ(e){for(var t=0;t<cf.length;t++)cf[t]===e&&cf.splice(t,1);ZJ(e,Object.keys(w0))}var Pp={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},_P=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],Ss={PORT:18333,NETWORK_MAGIC:Pp.testnet,DNS_SEEDS:_P,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},Ua={PORT:18444,NETWORK_MAGIC:Pp.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},xs={PORT:9333,NETWORK_MAGIC:Pp.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},YJ={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:Pp.livenet,port:8333,dnsSeeds:_P},$J={name:"testnet",prefix:Ss.PREFIX,cashAddrPrefix:Ss.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Ss.NETWORK_MAGIC},XJ={name:"regtest",prefix:Ua.PREFIX,cashAddrPrefix:Ua.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Ua.NETWORK_MAGIC,port:Ua.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},JJ={name:"stn",prefix:xs.PREFIX,cashAddrPrefix:xs.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:xs.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};x0($J);x0(JJ);x0(XJ);x0(YJ);var Ey=S0("livenet"),QJ=S0("regtest"),Do=S0("testnet"),eQ=S0("stn");Object.defineProperty(Do,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ua.PORT:this.stnEnabled?xs.PORT:Ss.PORT}});Object.defineProperty(Do,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?_0.integerAsBuffer(Ua.NETWORK_MAGIC):this.stnEnabled?_0.integerAsBuffer(xs.NETWORK_MAGIC):_0.integerAsBuffer(Ss.NETWORK_MAGIC)}});Object.defineProperty(Do,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ua.DNS_SEEDS:this.stnEnabled?xs.DNS_SEEDS:Ss.DNS_SEEDS}});Object.defineProperty(Do,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ua.CASHADDRPREFIX:this.stnEnabled?xs.CASHADDRPREFIX:Ss.CASHADDRPREFIX}});Object.defineProperty(Do,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ap(Ua.CASHADDRPREFIX):this.stnEnabled?Ap(xs.CASHADDRPREFIX):Ap(Ss.CASHADDRPREFIX)}});function tQ(){Do.regtestEnabled=!0}function rQ(){Do.regtestEnabled=!1}function iQ(){Do.stnEnabled=!0}function nQ(){Do.stnEnabled=!1}wP.exports={add:x0,remove:WJ,defaultNetwork:Ey,livenet:Ey,mainnet:Ey,testnet:Do,regtest:QJ,stn:eQ,get:S0,enableRegtest:tQ,disableRegtest:rQ,enableStn:iQ,disableStn:nQ}});var E0=k((s6e,EP)=>{"use strict";v();var Iy=bt(),SP=Z2(),xP=Zt(),oQ="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),Kr=function e(t){if(!(this instanceof e))return new e(t);if(h.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var i=t;this.fromString(i)}};Kr.validCharacters=function(t){return xP.Buffer.isBuffer(t)&&(t=t.toString()),Iy.every(Iy.map(t,function(r){return Iy.includes(oQ,r)}))};Kr.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Kr.encode=function(e){if(!xP.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return SP.encode(e)};Kr.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return h.Buffer.from(SP.decode(e))};Kr.prototype.fromBuffer=function(e){return this.buf=e,this};Kr.fromBuffer=function(e){return new Kr().fromBuffer(e)};Kr.fromHex=function(e){return Kr.fromBuffer(h.Buffer.from(e,"hex"))};Kr.prototype.fromString=function(e){var t=Kr.decode(e);return this.buf=t,this};Kr.fromString=function(e){return new Kr().fromString(e)};Kr.prototype.toBuffer=function(){return this.buf};Kr.prototype.toHex=function(){return this.toBuffer().toString("hex")};Kr.prototype.toString=function(){return Kr.encode(this.buf)};EP.exports=Kr});var el=k((f6e,PP)=>{"use strict";v();var IP=bt(),Tp=E0(),OP=Zt(),AP=at().sha256sha256,cr=function e(t){if(!(this instanceof e))return new e(t);if(h.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var i=t;this.fromString(i)}};cr.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};cr.validChecksum=function(t,r){return IP.isString(t)&&(t=OP.Buffer.from(Tp.decode(t))),IP.isString(r)&&(r=OP.Buffer.from(Tp.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),cr.checksum(t).toString("hex")===r.toString("hex")};cr.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=h.Buffer.from(Tp.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),i=t.slice(-4),n=AP(r),o=n.slice(0,4);if(i.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};cr.checksum=function(e){return AP(e).slice(0,4)};cr.encode=function(e){if(!h.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=h.Buffer.alloc(e.length+4),r=cr.checksum(e);return e.copy(t),r.copy(t,e.length),Tp.encode(t)};cr.prototype.fromBuffer=function(e){return this.buf=e,this};cr.fromBuffer=function(e){return new cr().fromBuffer(e)};cr.fromHex=function(e){return cr.fromBuffer(h.Buffer.from(e,"hex"))};cr.prototype.fromString=function(e){var t=cr.decode(e);return this.buf=t,this};cr.fromString=function(e){var t=cr.decode(e);return new cr(t)};cr.prototype.toBuffer=function(){return this.buf};cr.prototype.toHex=function(){return this.toBuffer().toString("hex")};cr.prototype.toString=function(){return cr.encode(this.buf)};PP.exports=cr});var Lo=k((l6e,kP)=>{"use strict";v();var I0=bt(),TP=Be(),tl=_t(),pr=function e(t){if(!(this instanceof e))return new e(t);if(!I0.isUndefined(t))if(h.Buffer.isBuffer(t))this.set({buf:t});else if(I0.isString(t)){var r=h.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(I0.isObject(t)){var i=t;this.set(i)}else throw new TypeError("Unrecognized argument for BufferReader")};pr.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};pr.prototype.eof=function(){return this.pos>=this.buf.length};pr.prototype.finished=pr.prototype.eof;pr.prototype.read=function(e){TP.checkArgument(!I0.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};pr.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};pr.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};pr.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};pr.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};pr.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};pr.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};pr.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};pr.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=tl.fromBuffer(e);return this.pos=this.pos+8,t};pr.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,i;if(r<=9007199254740991)i=new tl(r);else{var n=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);i=new tl(n,10,"le")}return this.pos=this.pos+8,i};pr.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};pr.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return TP.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};pr.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};pr.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new tl(this.readUInt16LE());case 254:return new tl(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new tl(e)}};pr.prototype.reverse=function(){for(var e=h.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};pr.prototype.readReverse=function(e){I0.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,h.Buffer.from(t).reverse()};kP.exports=pr});var Py=k((d6e,CP)=>{"use strict";v();function Es(e){"@babel/helpers - typeof";return Es=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Es(e)}function RP(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,sQ(i.key),i)}}function aQ(e,t,r){return t&&RP(e.prototype,t),r&&RP(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function sQ(e){var t=uQ(e,"string");return Es(t)==="symbol"?t:String(t)}function uQ(e,t){if(Es(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(Es(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function fQ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function cQ(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ay(e,t)}function Ay(e,t){return Ay=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,n){return i.__proto__=n,i},Ay(e,t)}function lQ(e){var t=pQ();return function(){var i=kp(e),n;if(t){var o=kp(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return hQ(this,n)}}function hQ(e,t){if(t&&(Es(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return dQ(e)}function dQ(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function pQ(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function kp(e){return kp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},kp(e)}var MP={},rl,Oy;function O0(e,t,r){r||(r=Error);function i(o,a,s){return typeof t=="string"?t:t(o,a,s)}var n=(function(o){cQ(s,o);var a=lQ(s);function s(u,c,l){var m;return fQ(this,s),m=a.call(this,i(u,c,l)),m.code=e,m}return aQ(s)})(r);MP[e]=n}function BP(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(i){return String(i)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function gQ(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function vQ(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function mQ(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}O0("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);O0("ERR_INVALID_ARG_TYPE",function(e,t,r){rl===void 0&&(rl=Is()),rl(typeof e=="string","'name' must be a string");var i;typeof t=="string"&&gQ(t,"not ")?(i="must not be",t=t.replace(/^not /,"")):i="must be";var n;if(vQ(e," argument"))n="The ".concat(e," ").concat(i," ").concat(BP(t,"type"));else{var o=mQ(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(o," ").concat(i," ").concat(BP(t,"type"))}return n+=". Received type ".concat(Es(r)),n},TypeError);O0("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";Oy===void 0&&(Oy=nn());var i=Oy.inspect(t);return i.length>128&&(i="".concat(i.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(i)},TypeError,RangeError);O0("ERR_INVALID_RETURN_VALUE",function(e,t,r){var i;return r&&r.constructor&&r.constructor.name?i="instance of ".concat(r.constructor.name):i="type ".concat(Es(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(i,".")},TypeError);O0("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];rl===void 0&&(rl=Is()),rl(t.length>0,"At least one arg needs to be specified");var i="The ",n=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),n){case 1:i+="".concat(t[0]," argument");break;case 2:i+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:i+=t.slice(0,n-1).join(", "),i+=", and ".concat(t[n-1]," arguments");break}return"".concat(i," must be specified")},TypeError);CP.exports.codes=MP});var KP=k((g6e,zP)=>{"use strict";v();function NP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function DP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?NP(Object(r),!0).forEach(function(i){yQ(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):NP(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function yQ(e,t,r){return t=FP(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bQ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function LP(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,FP(i.key),i)}}function _Q(e,t,r){return t&&LP(e.prototype,t),r&&LP(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function FP(e){var t=wQ(e,"string");return Bi(t)==="symbol"?t:String(t)}function wQ(e,t){if(Bi(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(Bi(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function SQ(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&k0(e,t)}function xQ(e){var t=jP();return function(){var i=R0(e),n;if(t){var o=R0(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return HP(this,n)}}function HP(e,t){if(t&&(Bi(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ty(e)}function Ty(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ky(e){var t=typeof Map=="function"?new Map:void 0;return ky=function(i){if(i===null||!EQ(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(i))return t.get(i);t.set(i,n)}function n(){return Rp(i,arguments,R0(this).constructor)}return n.prototype=Object.create(i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),k0(n,i)},ky(e)}function Rp(e,t,r){return jP()?Rp=Reflect.construct.bind():Rp=function(n,o,a){var s=[null];s.push.apply(s,o);var u=Function.bind.apply(n,s),c=new u;return a&&k0(c,a.prototype),c},Rp.apply(null,arguments)}function jP(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function EQ(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function k0(e,t){return k0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,n){return i.__proto__=n,i},k0(e,t)}function R0(e){return R0=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},R0(e)}function Bi(e){"@babel/helpers - typeof";return Bi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bi(e)}var IQ=nn(),Ry=IQ.inspect,OQ=Py(),AQ=OQ.codes.ERR_INVALID_ARG_TYPE;function qP(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function PQ(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Wn="",A0="",P0="",ri="",lf={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},TQ=10;function UP(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(i){r[i]=e[i]}),Object.defineProperty(r,"message",{value:e.message}),r}function T0(e){return Ry(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function kQ(e,t,r){var i="",n="",o=0,a="",s=!1,u=T0(e),c=u.split(`
|
|
20
20
|
`),l=T0(t).split(`
|
package/build/esbuild.js
CHANGED
|
@@ -182,8 +182,9 @@ function buildOne (cfg, opts) {
|
|
|
182
182
|
inject: [path.join(__dirname, 'esbuild/globals.js')],
|
|
183
183
|
define: { global: 'globalThis' },
|
|
184
184
|
footer: { js: umdFooter(cfg.global) },
|
|
185
|
-
// Opt-in build graph
|
|
186
|
-
// shared primitives instead of embedding a second
|
|
185
|
+
// Opt-in build graph. test/build/bundle_externals.js consumes it to assert that
|
|
186
|
+
// feature bundles externalise the shared primitives instead of embedding a second
|
|
187
|
+
// copy — this comment used to claim that assertion existed when nothing performed it.
|
|
187
188
|
metafile: opts.metafile === true,
|
|
188
189
|
write: opts.write !== false,
|
|
189
190
|
outfile: opts.write === false ? undefined : path.join(ROOT, cfg.file),
|
|
@@ -200,7 +201,7 @@ function buildAll () {
|
|
|
200
201
|
return Promise.all(BUNDLES.map(function (c) { return buildOne(c) }))
|
|
201
202
|
}
|
|
202
203
|
|
|
203
|
-
module.exports = { buildFullBundle, buildAll, buildOne, BUNDLES }
|
|
204
|
+
module.exports = { buildFullBundle, buildAll, buildOne, BUNDLES, LIB_GLOBALS }
|
|
204
205
|
|
|
205
206
|
if (require.main === module) {
|
|
206
207
|
buildAll().then(function () {
|