UNPKG

@chainsafe/libp2p-noise

Version:
2 lines 134 kB
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.ChainsafeLibp2PNoise = factory()}(typeof self !== 'undefined' ? self : this, function () { "use strict";var ChainsafeLibp2PNoise=(()=>{var gn=Object.defineProperty;var Va=Object.getOwnPropertyDescriptor;var Fa=Object.getOwnPropertyNames;var za=Object.prototype.hasOwnProperty;var yt=(r,t)=>{for(var e in t)gn(r,e,{get:t[e],enumerable:!0})},Ga=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Fa(t))!za.call(r,o)&&o!==e&&gn(r,o,{get:()=>t[o],enumerable:!(n=Va(t,o))||n.enumerable});return r};var Za=r=>Ga(gn({},"__esModule",{value:!0}),r);var uh={};yt(uh,{noise:()=>fh,pureJsCrypto:()=>ln});var xn=Symbol.for("@libp2p/peer-id");var yr=class extends Error{static name="UnexpectedPeerError";constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError"}},gr=class extends Error{static name="InvalidCryptoExchangeError";constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError"}},gt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},be=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var we=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Ss=Symbol.for("@libp2p/service-capabilities"),ph=Symbol.for("@libp2p/service-dependencies");var An={};yt(An,{base58btc:()=>nt,base58flickr:()=>Ja});var Mh=new Uint8Array(0);function As(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Pt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Bs(r){return new TextEncoder().encode(r)}function vs(r){return new TextDecoder().decode(r)}function Xa(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var y=0,h=0,g=0,w=b.length;g!==w&&b[g]===0;)g++,y++;for(var d=(w-g)*f+1>>>0,L=new Uint8Array(d);g!==w;){for(var R=b[g],U=0,_=d-1;(R!==0||U<h)&&_!==-1;_--,U++)R+=256*L[_]>>>0,L[_]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");h=U,g++}for(var T=d-h;T!==d&&L[T]===0;)T++;for(var v=c.repeat(y);T<d;++T)v+=r.charAt(L[T]);return v}function p(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var y=0;if(b[y]!==" "){for(var h=0,g=0;b[y]===c;)h++,y++;for(var w=(b.length-y)*u+1>>>0,d=new Uint8Array(w);b[y];){var L=e[b.charCodeAt(y)];if(L===255)return;for(var R=0,U=w-1;(L!==0||R<g)&&U!==-1;U--,R++)L+=a*d[U]>>>0,d[U]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");g=R,y++}if(b[y]!==" "){for(var _=w-g;_!==w&&d[_]===0;)_++;for(var T=new Uint8Array(h+(w-_)),v=h;_!==w;)T[v++]=d[_++];return T}}}function S(b){var y=p(b);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:p,decode:S}}var Ya=Xa,ja=Ya,Is=ja;var bn=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},wn=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return _s(this,t)}},En=class{decoders;constructor(t){this.decoders=t}or(t){return _s(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function _s(r,t){return new En({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Sn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new bn(t,e,n),this.decoder=new wn(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ee({name:r,prefix:t,encode:e,decode:n}){return new Sn(r,t,e,n)}function Xt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Is(e,r);return Ee({prefix:t,name:r,encode:n,decode:s=>Pt(o(s))})}function Wa(r,t,e,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,c=0,u=0;for(let f=0;f<s;++f){let l=o[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|l,a+=e,a>=8&&(a-=8,i[u++]=255&c>>a)}if(a>=e||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return i}function $a(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function rt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Ee({prefix:t,name:r,encode(o){return $a(o,n,e)},decode(o){return Wa(o,n,e,r)}})}var nt=Xt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ja=Xt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bn={};yt(Bn,{base32:()=>Se,base32hex:()=>rc,base32hexpad:()=>oc,base32hexpadupper:()=>sc,base32hexupper:()=>nc,base32pad:()=>tc,base32padupper:()=>ec,base32upper:()=>Qa,base32z:()=>ic});var Se=rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qa=rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),tc=rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ec=rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),rc=rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nc=rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),oc=rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),sc=rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ic=rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vn={};yt(vn,{base36:()=>ze,base36upper:()=>ac});var ze=Xt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ac=Xt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var cc=Rs,Ts=128,fc=127,uc=~fc,hc=Math.pow(2,31);function Rs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=hc;)t[e++]=r&255|Ts,r/=128;for(;r&uc;)t[e++]=r&255|Ts,r>>>=7;return t[e]=r|0,Rs.bytes=e-n+1,t}var lc=Ln,dc=128,Us=127;function Ln(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Ln.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Us)<<o:(i&Us)*Math.pow(2,o),o+=7}while(i>=dc);return Ln.bytes=s-n,e}var pc=Math.pow(2,7),mc=Math.pow(2,14),yc=Math.pow(2,21),gc=Math.pow(2,28),xc=Math.pow(2,35),bc=Math.pow(2,42),wc=Math.pow(2,49),Ec=Math.pow(2,56),Sc=Math.pow(2,63),Ac=function(r){return r<pc?1:r<mc?2:r<yc?3:r<gc?4:r<xc?5:r<bc?6:r<wc?7:r<Ec?8:r<Sc?9:10},Bc={encode:cc,decode:lc,encodingLength:Ac},vc=Bc,Ge=vc;function Ze(r,t=0){return[Ge.decode(r,t),Ge.decode.bytes]}function Ae(r,t,e=0){return Ge.encode(r,t,e),t}function Be(r){return Ge.encodingLength(r)}function Lt(r,t){let e=t.byteLength,n=Be(r),o=n+Be(e),s=new Uint8Array(o+e);return Ae(r,s,0),Ae(e,s,n),s.set(t,o),new ve(r,e,t,s)}function In(r){let t=Pt(r),[e,n]=Ze(t),[o,s]=Ze(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ve(e,o,i,t)}function Cs(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&As(r.bytes,e.bytes)}}var ve=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Ns(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Ic(e,_n(r),t??nt.encoder);default:return _c(e,_n(r),t??Se.encoder)}}var Ks=new WeakMap;function _n(r){let t=Ks.get(r);if(t==null){let e=new Map;return Ks.set(r,e),e}return t}var wt=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Tc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Lt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Cs(t.multihash,n.multihash)}toString(t){return Ns(this,t)}toJSON(){return{"/":Ns(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Ds(n,o,s.bytes))}else if(e[Uc]===!0){let{version:n,multihash:o,code:s}=e,i=In(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Xe)throw new Error(`Version 0 CID must use dag-pb (code: ${Xe}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Ds(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Xe,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Pt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new ve(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,p]=Ze(t.subarray(e));return e+=p,l},o=n(),s=Xe;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),u=e+c,f=u-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,e){let[n,o]=Lc(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return _n(s).set(n,t),s}};function Lc(r,t){switch(r[0]){case"Q":{let e=t??nt;return[nt.prefix,e.decode(`${nt.prefix}${r}`)]}case nt.prefix:{let e=t??nt;return[nt.prefix,e.decode(r)]}case Se.prefix:{let e=t??Se;return[Se.prefix,e.decode(r)]}case ze.prefix:{let e=t??ze;return[ze.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Ic(r,t,e){let{prefix:n}=e;if(n!==nt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function _c(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Xe=112,Tc=18;function Ds(r,t,e){let n=Be(r),o=n+Be(t),s=new Uint8Array(o+e.byteLength);return Ae(r,s,0),Ae(t,s,n),s.set(e,o),s}var Uc=Symbol.for("@ipld/js-cid/CID");var Tn={};yt(Tn,{identity:()=>Yt});var Ps=0,Rc="identity",Ms=Pt;function Cc(r){return Lt(Ps,Ms(r))}var Yt={code:Ps,name:Rc,encode:Ms,digest:Cc};function Et(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function br(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Nc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ie(r,...t){if(!Nc(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Ye(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");br(r.outputLen),br(r.blockLen)}function _e(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function ks(r,t){Ie(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var se=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function wr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function It(r,t){return r<<32-t|r>>>t}function Os(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function jt(r){return typeof r=="string"&&(r=Os(r)),Ie(r),r}function Un(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ie(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Te=class{clone(){return this._cloneInto()}};function Er(r){let t=n=>r().update(jt(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function je(r=32){if(se&&typeof se.getRandomValues=="function")return se.getRandomValues(new Uint8Array(r));if(se&&typeof se.randomBytes=="function")return se.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Kc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),a=Number(e&s),c=n?4:0,u=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+u,a,n)}function Hs(r,t,e){return r&t^~r&e}function qs(r,t,e){return r&t^r&e^t&e}var Ue=class extends Te{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=wr(this.buffer)}update(t){_e(this);let{view:e,buffer:n,blockLen:o}=this;t=jt(t);let s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=wr(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){_e(this),ks(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;Kc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=wr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.length=o,t.pos=a,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Sr=BigInt(4294967295),Rn=BigInt(32);function Vs(r,t=!1){return t?{h:Number(r&Sr),l:Number(r>>Rn&Sr)}:{h:Number(r>>Rn&Sr)|0,l:Number(r&Sr)|0}}function Dc(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Vs(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var Pc=(r,t)=>BigInt(r>>>0)<<Rn|BigInt(t>>>0),Mc=(r,t,e)=>r>>>e,kc=(r,t,e)=>r<<32-e|t>>>e,Oc=(r,t,e)=>r>>>e|t<<32-e,Hc=(r,t,e)=>r<<32-e|t>>>e,qc=(r,t,e)=>r<<64-e|t>>>e-32,Vc=(r,t,e)=>r>>>e-32|t<<64-e,Fc=(r,t)=>t,zc=(r,t)=>r,Gc=(r,t,e)=>r<<e|t>>>32-e,Zc=(r,t,e)=>t<<e|r>>>32-e,Xc=(r,t,e)=>t<<e-32|r>>>64-e,Yc=(r,t,e)=>r<<e-32|t>>>64-e;function jc(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Wc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),$c=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Jc=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Qc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,tf=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),ef=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var rf={fromBig:Vs,split:Dc,toBig:Pc,shrSH:Mc,shrSL:kc,rotrSH:Oc,rotrSL:Hc,rotrBH:qc,rotrBL:Vc,rotr32H:Fc,rotr32L:zc,rotlSH:Gc,rotlSL:Zc,rotlBH:Xc,rotlBL:Yc,add:jc,add3L:Wc,add3H:$c,add4L:Jc,add4H:Qc,add5H:ef,add5L:tf},V=rf;var[nf,of]=V.split(["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(r=>BigInt(r))),Wt=new Uint32Array(80),$t=new Uint32Array(80),Cn=class extends Ue{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:p,Gh:S,Gl:b,Hh:y,Hl:h}=this;return[t,e,n,o,s,i,a,c,u,f,l,p,S,b,y,h]}set(t,e,n,o,s,i,a,c,u,f,l,p,S,b,y,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=p|0,this.Gh=S|0,this.Gl=b|0,this.Hh=y|0,this.Hl=h|0}process(t,e){for(let d=0;d<16;d++,e+=4)Wt[d]=t.getUint32(e),$t[d]=t.getUint32(e+=4);for(let d=16;d<80;d++){let L=Wt[d-15]|0,R=$t[d-15]|0,U=V.rotrSH(L,R,1)^V.rotrSH(L,R,8)^V.shrSH(L,R,7),_=V.rotrSL(L,R,1)^V.rotrSL(L,R,8)^V.shrSL(L,R,7),T=Wt[d-2]|0,v=$t[d-2]|0,k=V.rotrSH(T,v,19)^V.rotrBH(T,v,61)^V.shrSH(T,v,6),K=V.rotrSL(T,v,19)^V.rotrBL(T,v,61)^V.shrSL(T,v,6),M=V.add4L(_,K,$t[d-7],$t[d-16]),H=V.add4H(M,U,k,Wt[d-7],Wt[d-16]);Wt[d]=H|0,$t[d]=M|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:p,Fh:S,Fl:b,Gh:y,Gl:h,Hh:g,Hl:w}=this;for(let d=0;d<80;d++){let L=V.rotrSH(l,p,14)^V.rotrSH(l,p,18)^V.rotrBH(l,p,41),R=V.rotrSL(l,p,14)^V.rotrSL(l,p,18)^V.rotrBL(l,p,41),U=l&S^~l&y,_=p&b^~p&h,T=V.add5L(w,R,_,of[d],$t[d]),v=V.add5H(T,g,L,U,nf[d],Wt[d]),k=T|0,K=V.rotrSH(n,o,28)^V.rotrBH(n,o,34)^V.rotrBH(n,o,39),M=V.rotrSL(n,o,28)^V.rotrBL(n,o,34)^V.rotrBL(n,o,39),H=n&s^n&a^s&a,B=o&i^o&c^i&c;g=y|0,w=h|0,y=S|0,h=b|0,S=l|0,b=p|0,{h:l,l:p}=V.add(u|0,f|0,v|0,k|0),u=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let I=V.add3L(k,M,B);n=V.add3H(I,v,K,H),o=I|0}({h:n,l:o}=V.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=V.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=V.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=V.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:p}=V.add(this.Eh|0,this.El|0,l|0,p|0),{h:S,l:b}=V.add(this.Fh|0,this.Fl|0,S|0,b|0),{h:y,l:h}=V.add(this.Gh|0,this.Gl|0,y|0,h|0),{h:g,l:w}=V.add(this.Hh|0,this.Hl|0,g|0,w|0),this.set(n,o,s,i,a,c,u,f,l,p,S,b,y,h,g,w)}roundClean(){Wt.fill(0),$t.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Fs=Er(()=>new Cn);var vr={};yt(vr,{aInRange:()=>ct,abool:()=>_t,abytes:()=>Re,bitGet:()=>hf,bitLen:()=>Pn,bitMask:()=>$e,bitSet:()=>lf,bytesToHex:()=>kt,bytesToNumberBE:()=>Ot,bytesToNumberLE:()=>Tt,concatBytes:()=>qt,createHmacDrbg:()=>Mn,ensureBytes:()=>Y,equalBytes:()=>ff,hexToBytes:()=>ae,hexToNumber:()=>Dn,inRange:()=>We,isBytes:()=>Jt,memoized:()=>ce,notImplemented:()=>pf,numberToBytesBE:()=>Qt,numberToBytesLE:()=>Ht,numberToHexUnpadded:()=>ie,numberToVarBytesBE:()=>cf,utf8ToBytes:()=>uf,validateObject:()=>Bt});var Ar=BigInt(0),Br=BigInt(1),sf=BigInt(2);function Jt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Re(r){if(!Jt(r))throw new Error("Uint8Array expected")}function _t(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var af=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function kt(r){Re(r);let t="";for(let e=0;e<r.length;e++)t+=af[r[e]];return t}function ie(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Dn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Ar:BigInt("0x"+r)}var Mt={_0:48,_9:57,A:65,F:70,a:97,f:102};function zs(r){if(r>=Mt._0&&r<=Mt._9)return r-Mt._0;if(r>=Mt.A&&r<=Mt.F)return r-(Mt.A-10);if(r>=Mt.a&&r<=Mt.f)return r-(Mt.a-10)}function ae(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=zs(r.charCodeAt(s)),a=zs(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Ot(r){return Dn(kt(r))}function Tt(r){return Re(r),Dn(kt(Uint8Array.from(r).reverse()))}function Qt(r,t){return ae(r.toString(16).padStart(t*2,"0"))}function Ht(r,t){return Qt(r,t).reverse()}function cf(r){return ae(ie(r))}function Y(r,t,e){let n;if(typeof t=="string")try{n=ae(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Jt(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function qt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Re(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function ff(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function uf(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var Nn=r=>typeof r=="bigint"&&Ar<=r;function We(r,t,e){return Nn(r)&&Nn(t)&&Nn(e)&&t<=r&&r<e}function ct(r,t,e,n){if(!We(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Pn(r){let t;for(t=0;r>Ar;r>>=Br,t+=1);return t}function hf(r,t){return r>>BigInt(t)&Br}function lf(r,t,e){return r|(e?Br:Ar)<<BigInt(t)}var $e=r=>(sf<<BigInt(r-1))-Br,Kn=r=>new Uint8Array(r),Gs=r=>Uint8Array.from(r);function Mn(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=Kn(r),o=Kn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>e(o,n,...l),c=(l=Kn())=>{o=a(Gs([0]),l),n=a(),l.length!==0&&(o=a(Gs([1]),l),n=a())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<t;){n=a();let S=n.slice();p.push(S),l+=n.length}return qt(...p)};return(l,p)=>{i(),c(l);let S;for(;!(S=p(u()));)c();return i(),S}}var df={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Jt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Bt(r,t,e={}){let n=(o,s,i)=>{let a=df[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var pf=()=>{throw new Error("not implemented")};function ce(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var ot=BigInt(0),Q=BigInt(1),fe=BigInt(2),mf=BigInt(3),kn=BigInt(4),Zs=BigInt(5),Xs=BigInt(8),yf=BigInt(9),gf=BigInt(16);function G(r,t){let e=r%t;return e>=ot?e:t+e}function On(r,t,e){if(t<ot)throw new Error("invalid exponent, negatives unsupported");if(e<=ot)throw new Error("invalid modulus");if(e===Q)return ot;let n=Q;for(;t>ot;)t&Q&&(n=n*r%e),r=r*r%e,t>>=Q;return n}function $(r,t,e){let n=r;for(;t-- >ot;)n*=n,n%=e;return n}function Lr(r,t){if(r===ot)throw new Error("invert: expected non-zero number");if(t<=ot)throw new Error("invert: expected positive modulus, got "+t);let e=G(r,t),n=t,o=ot,s=Q,i=Q,a=ot;for(;e!==ot;){let u=n/e,f=n%e,l=o-i*u,p=s-a*u;n=e,e=f,o=i,s=a,i=l,a=p}if(n!==Q)throw new Error("invert: does not exist");return G(o,t)}function xf(r){let t=(r-Q)/fe,e,n,o;for(e=r-Q,n=0;e%fe===ot;e/=fe,n++);for(o=fe;o<r&&On(o,t,r)!==r-Q;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+Q)/kn;return function(c,u){let f=c.pow(u,i);if(!c.eql(c.sqr(f),u))throw new Error("Cannot find square root");return f}}let s=(e+Q)/fe;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,f=a.pow(a.mul(a.ONE,o),e),l=a.pow(c,s),p=a.pow(c,e);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let S=1;for(let y=a.sqr(p);S<u&&!a.eql(y,a.ONE);S++)y=a.sqr(y);let b=a.pow(f,Q<<BigInt(u-S-1));f=a.sqr(b),l=a.mul(l,b),p=a.mul(p,f),u=S}return l}}function bf(r){if(r%kn===mf){let t=(r+Q)/kn;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Xs===Zs){let t=(r-Zs)/Xs;return function(n,o){let s=n.mul(o,fe),i=n.pow(s,t),a=n.mul(o,i),c=n.mul(n.mul(a,fe),i),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),o))throw new Error("Cannot find square root");return u}}return r%gf,xf(r)}var Ys=(r,t)=>(G(r,t)&Q)===Q,wf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Hn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=wf.reduce((n,o)=>(n[o]="function",n),t);return Bt(r,e)}function Ef(r,t,e){if(e<ot)throw new Error("invalid exponent, negatives unsupported");if(e===ot)return r.ONE;if(e===Q)return t;let n=r.ONE,o=t;for(;e>ot;)e&Q&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Q;return n}function Sf(r,t){let e=new Array(t.length),n=t.reduce((s,i,a)=>r.is0(i)?s:(e[a]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,a)=>r.is0(i)?s:(e[a]=r.mul(s,e[a]),r.mul(s,i)),o),e}function qn(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function te(r,t,e=!1,n={}){if(r<=ot)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=qn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:$e(o),ZERO:ot,ONE:Q,create:c=>G(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ot<=c&&c<r},is0:c=>c===ot,isOdd:c=>(c&Q)===Q,neg:c=>G(-c,r),eql:(c,u)=>c===u,sqr:c=>G(c*c,r),add:(c,u)=>G(c+u,r),sub:(c,u)=>G(c-u,r),mul:(c,u)=>G(c*u,r),pow:(c,u)=>Ef(a,c,u),div:(c,u)=>G(c*Lr(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Lr(c,r),sqrt:n.sqrt||(c=>(i||(i=bf(r)),i(a,c))),invertBatch:c=>Sf(a,c),cmov:(c,u,f)=>f?u:c,toBytes:c=>e?Ht(c,s):Qt(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?Tt(c):Ot(c)}});return Object.freeze(a)}function js(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Vn(r){let t=js(r);return t+Math.ceil(t/2)}function Ws(r,t,e=!1){let n=r.length,o=js(t),s=Vn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Tt(r):Ot(r),a=G(i,t-Q)+Q;return e?Ht(a,o):Qt(a,o)}var $s=BigInt(0),Ir=BigInt(1);function Fn(r,t){let e=t.negate();return r?e:t}function Js(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function zn(r,t){Js(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function Af(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Bf(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Gn=new WeakMap,Qs=new WeakMap;function Zn(r){return Qs.get(r)||1}function _r(r,t){return{constTimeNegate:Fn,hasPrecomputes(e){return Zn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>$s;)n&Ir&&(o=o.add(s)),s=s.double(),n>>=Ir;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=zn(n,t),i=[],a=e,c=a;for(let u=0;u<o;u++){c=a,i.push(c);for(let f=1;f<s;f++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let{windows:s,windowSize:i}=zn(e,t),a=r.ZERO,c=r.BASE,u=BigInt(2**e-1),f=2**e,l=BigInt(e);for(let p=0;p<s;p++){let S=p*i,b=Number(o&u);o>>=l,b>i&&(b-=f,o+=Ir);let y=S,h=S+Math.abs(b)-1,g=p%2!==0,w=b<0;b===0?c=c.add(Fn(g,n[y])):a=a.add(Fn(w,n[h]))}return{p:a,f:c}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:i,windowSize:a}=zn(e,t),c=BigInt(2**e-1),u=2**e,f=BigInt(e);for(let l=0;l<i;l++){let p=l*a;if(o===$s)break;let S=Number(o&c);if(o>>=f,S>a&&(S-=u,o+=Ir),S===0)continue;let b=n[p+Math.abs(S)-1];S<0&&(b=b.negate()),s=s.add(b)}return s},getPrecomputes(e,n,o){let s=Gn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Gn.set(n,o(s))),s},wNAFCached(e,n,o){let s=Zn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Zn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Js(n,t),Qs.set(e,n),Gn.delete(e)}}}function Tr(r,t,e,n){if(Af(e,r),Bf(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=Pn(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,a=(1<<i)-1,c=new Array(a+1).fill(o),u=Math.floor((t.BITS-1)/i)*i,f=o;for(let l=u;l>=0;l-=i){c.fill(o);for(let S=0;S<n.length;S++){let b=n[S],y=Number(b>>BigInt(l)&BigInt(a));c[y]=c[y].add(e[S])}let p=o;for(let S=c.length-1,b=o;S>0;S--)b=b.add(c[S]),p=p.add(b);if(f=f.add(p),l!==0)for(let S=0;S<i;S++)f=f.double()}return f}function Je(r){return Hn(r.Fp),Bt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...qn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ut=BigInt(0),bt=BigInt(1),Ur=BigInt(2),vf=BigInt(8),Lf={zip215:!0};function If(r){let t=Je(r);return Bt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ti(r){let t=If(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=t,u=Ur<<BigInt(a*8)-bt,f=e.create,l=te(t.n,t.nBitLength),p=t.uvRatio||((x,m)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(m))}}catch{return{isValid:!1,value:Ut}}}),S=t.adjustScalarBytes||(x=>x),b=t.domain||((x,m,A)=>{if(_t("phflag",A),m.length||A)throw new Error("Contexts/pre-hash are not supported");return x});function y(x,m){ct("coordinate "+x,m,Ut,u)}function h(x){if(!(x instanceof d))throw new Error("ExtendedPoint expected")}let g=ce((x,m)=>{let{ex:A,ey:E,ez:C}=x,N=x.is0();m==null&&(m=N?vf:e.inv(C));let P=f(A*m),q=f(E*m),O=f(C*m);if(N)return{x:Ut,y:bt};if(O!==bt)throw new Error("invZ was invalid");return{x:P,y:q}}),w=ce(x=>{let{a:m,d:A}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:E,ey:C,ez:N,et:P}=x,q=f(E*E),O=f(C*C),F=f(N*N),z=f(F*F),j=f(q*m),W=f(F*f(j+O)),J=f(z+f(A*f(q*O)));if(W!==J)throw new Error("bad point: equation left != right (1)");let ht=f(E*C),xt=f(N*P);if(ht!==xt)throw new Error("bad point: equation left != right (2)");return!0});class d{constructor(m,A,E,C){this.ex=m,this.ey=A,this.ez=E,this.et=C,y("x",m),y("y",A),y("z",E),y("t",C),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof d)throw new Error("extended point not allowed");let{x:A,y:E}=m||{};return y("x",A),y("y",E),new d(A,E,bt,f(A*E))}static normalizeZ(m){let A=e.invertBatch(m.map(E=>E.ez));return m.map((E,C)=>E.toAffine(A[C])).map(d.fromAffine)}static msm(m,A){return Tr(d,l,m,A)}_setWindowSize(m){U.setWindowSize(this,m)}assertValidity(){w(this)}equals(m){h(m);let{ex:A,ey:E,ez:C}=this,{ex:N,ey:P,ez:q}=m,O=f(A*q),F=f(N*C),z=f(E*q),j=f(P*C);return O===F&&z===j}is0(){return this.equals(d.ZERO)}negate(){return new d(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:m}=t,{ex:A,ey:E,ez:C}=this,N=f(A*A),P=f(E*E),q=f(Ur*f(C*C)),O=f(m*N),F=A+E,z=f(f(F*F)-N-P),j=O+P,W=j-q,J=O-P,ht=f(z*W),xt=f(j*J),mt=f(z*J),Nt=f(W*j);return new d(ht,xt,Nt,mt)}add(m){h(m);let{a:A,d:E}=t,{ex:C,ey:N,ez:P,et:q}=this,{ex:O,ey:F,ez:z,et:j}=m;if(A===BigInt(-1)){let ms=f((N-C)*(F+O)),ys=f((N+C)*(F-O)),yn=f(ys-ms);if(yn===Ut)return this.double();let gs=f(P*Ur*j),xs=f(q*Ur*z),bs=xs+gs,ws=ys+ms,Es=xs-gs,ka=f(bs*yn),Oa=f(ws*Es),Ha=f(bs*Es),qa=f(yn*ws);return new d(ka,Oa,qa,Ha)}let W=f(C*O),J=f(N*F),ht=f(q*E*j),xt=f(P*z),mt=f((C+N)*(O+F)-W-J),Nt=xt-ht,Dt=xt+ht,Fe=f(J-A*W),Ka=f(mt*Nt),Da=f(Dt*Fe),Pa=f(mt*Fe),Ma=f(Nt*Dt);return new d(Ka,Da,Ma,Pa)}subtract(m){return this.add(m.negate())}wNAF(m){return U.wNAFCached(this,m,d.normalizeZ)}multiply(m){let A=m;ct("scalar",A,bt,n);let{p:E,f:C}=this.wNAF(A);return d.normalizeZ([E,C])[0]}multiplyUnsafe(m,A=d.ZERO){let E=m;return ct("scalar",E,Ut,n),E===Ut?R:this.is0()||E===bt?this:U.wNAFCachedUnsafe(this,E,d.normalizeZ,A)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(m){return g(this,m)}clearCofactor(){let{h:m}=t;return m===bt?this:this.multiplyUnsafe(m)}static fromHex(m,A=!1){let{d:E,a:C}=t,N=e.BYTES;m=Y("pointHex",m,N),_t("zip215",A);let P=m.slice(),q=m[N-1];P[N-1]=q&-129;let O=Tt(P),F=A?u:e.ORDER;ct("pointHex.y",O,Ut,F);let z=f(O*O),j=f(z-bt),W=f(E*z-C),{isValid:J,value:ht}=p(j,W);if(!J)throw new Error("Point.fromHex: invalid y coordinate");let xt=(ht&bt)===bt,mt=(q&128)!==0;if(!A&&ht===Ut&&mt)throw new Error("Point.fromHex: x=0 and x_0=1");return mt!==xt&&(ht=f(-ht)),d.fromAffine({x:ht,y:O})}static fromPrivateKey(m){return v(m).point}toRawBytes(){let{x:m,y:A}=this.toAffine(),E=Ht(A,e.BYTES);return E[E.length-1]|=m&bt?128:0,E}toHex(){return kt(this.toRawBytes())}}d.BASE=new d(t.Gx,t.Gy,bt,f(t.Gx*t.Gy)),d.ZERO=new d(Ut,bt,bt,Ut);let{BASE:L,ZERO:R}=d,U=_r(d,a*8);function _(x){return G(x,n)}function T(x){return _(Tt(x))}function v(x){let m=e.BYTES;x=Y("private key",x,m);let A=Y("hashed private key",s(x),2*m),E=S(A.slice(0,m)),C=A.slice(m,2*m),N=T(E),P=L.multiply(N),q=P.toRawBytes();return{head:E,prefix:C,scalar:N,point:P,pointBytes:q}}function k(x){return v(x).pointBytes}function K(x=new Uint8Array,...m){let A=qt(...m);return T(s(b(A,Y("context",x),!!o)))}function M(x,m,A={}){x=Y("message",x),o&&(x=o(x));let{prefix:E,scalar:C,pointBytes:N}=v(m),P=K(A.context,E,x),q=L.multiply(P).toRawBytes(),O=K(A.context,q,N,x),F=_(P+O*C);ct("signature.s",F,Ut,n);let z=qt(q,Ht(F,e.BYTES));return Y("result",z,e.BYTES*2)}let H=Lf;function B(x,m,A,E=H){let{context:C,zip215:N}=E,P=e.BYTES;x=Y("signature",x,2*P),m=Y("message",m),A=Y("publicKey",A,P),N!==void 0&&_t("zip215",N),o&&(m=o(m));let q=Tt(x.slice(P,2*P)),O,F,z;try{O=d.fromHex(A,N),F=d.fromHex(x.slice(0,P),N),z=L.multiplyUnsafe(q)}catch{return!1}if(!N&&O.isSmallOrder())return!1;let j=K(C,F.toRawBytes(),O.toRawBytes(),m);return F.add(O.multiplyUnsafe(j)).subtract(z).clearCofactor().equals(d.ZERO)}return L._setWindowSize(8),{CURVE:t,getPublicKey:k,sign:M,verify:B,ExtendedPoint:d,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,m=d.BASE){return m._setWindowSize(x),m.multiply(BigInt(3)),m}}}}var Ce=BigInt(0),Xn=BigInt(1);function _f(r){return Bt(r,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r})}function ei(r){let t=_f(r),{P:e}=t,n=w=>G(w,e),o=t.montgomeryBits,s=Math.ceil(o/8),i=t.nByteLength,a=t.adjustScalarBytes||(w=>w),c=t.powPminus2||(w=>On(w,e-BigInt(2),e));function u(w,d,L){let R=n(w*(d-L));return d=n(d-R),L=n(L+R),[d,L]}let f=(t.a-BigInt(2))/BigInt(4);function l(w,d){ct("u",w,Ce,e),ct("scalar",d,Ce,e);let L=d,R=w,U=Xn,_=Ce,T=w,v=Xn,k=Ce,K;for(let H=BigInt(o-1);H>=Ce;H--){let B=L>>H&Xn;k^=B,K=u(k,U,T),U=K[0],T=K[1],K=u(k,_,v),_=K[0],v=K[1],k=B;let I=U+_,x=n(I*I),m=U-_,A=n(m*m),E=x-A,C=T+v,N=T-v,P=n(N*I),q=n(C*m),O=P+q,F=P-q;T=n(O*O),v=n(R*n(F*F)),U=n(x*A),_=n(E*(x+n(f*E)))}K=u(k,U,T),U=K[0],T=K[1],K=u(k,_,v),_=K[0],v=K[1];let M=c(_);return n(U*M)}function p(w){return Ht(n(w),s)}function S(w){let d=Y("u coordinate",w,s);return i===32&&(d[31]&=127),Tt(d)}function b(w){let d=Y("scalar",w),L=d.length;if(L!==s&&L!==i){let R=""+s+" or "+i;throw new Error("invalid scalar, expected "+R+" bytes, got "+L)}return Tt(a(d))}function y(w,d){let L=S(d),R=b(w),U=l(L,R);if(U===Ce)throw new Error("invalid private or public key received");return p(U)}let h=p(t.Gu);function g(w){return y(w,h)}return{scalarMult:y,scalarMultBase:g,getSharedSecret:(w,d)=>y(w,d),getPublicKey:w=>g(w),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:h}}var Qe=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ri=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Nl=BigInt(0),Tf=BigInt(1),ni=BigInt(2),Uf=BigInt(3),Rf=BigInt(5),Cf=BigInt(8);function oi(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Qe,a=r*r%s*r%s,c=$(a,ni,s)*a%s,u=$(c,Tf,s)*r%s,f=$(u,Rf,s)*u%s,l=$(f,t,s)*f%s,p=$(l,e,s)*l%s,S=$(p,n,s)*p%s,b=$(S,o,s)*S%s,y=$(b,o,s)*S%s,h=$(y,t,s)*f%s;return{pow_p_5_8:$(h,ni,s)*r%s,b2:a}}function si(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Nf(r,t){let e=Qe,n=G(t*t*t,e),o=G(n*n*t,e),s=oi(r*o).pow_p_5_8,i=G(r*n*s,e),a=G(t*i*i,e),c=i,u=G(i*ri,e),f=a===r,l=a===G(-r,e),p=a===G(-r*ri,e);return f&&(i=c),(l||p)&&(i=u),Ys(i,e)&&(i=G(-i,e)),{isValid:f||l,value:i}}var Kf=te(Qe,void 0,!0),Df={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Kf,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Cf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Fs,randomBytes:je,adjustScalarBytes:si,uvRatio:Nf},ii=ti(Df);var tr=ei({P:Qe,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:r=>{let t=Qe,{pow_p_5_8:e,b2:n}=oi(r);return G($(e,Uf,t)*n,t)},adjustScalarBytes:si,randomBytes:je});var Rr=32;function ai(r,t,e){return ii.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Cr=class{type="Ed25519";raw;constructor(t){this.raw=Yn(t,Rr)}toMultihash(){return Yt.digest(Ne(this))}toCID(){return wt.createV1(114,this.toMultihash())}toString(){return nt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Et(this.raw,t.raw)}verify(t,e){return ai(this.raw,e,t)}};function fi(r){return r=Yn(r,Rr),new Cr(r)}function Yn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new gt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function st(r=0){return new Uint8Array(r)}function it(r=0){return new Uint8Array(r)}var Mf=Math.pow(2,7),kf=Math.pow(2,14),Of=Math.pow(2,21),jn=Math.pow(2,28),Wn=Math.pow(2,35),$n=Math.pow(2,42),Jn=Math.pow(2,49),Z=128,lt=127;function St(r){if(r<Mf)return 1;if(r<kf)return 2;if(r<Of)return 3;if(r<jn)return 4;if(r<Wn)return 5;if(r<$n)return 6;if(r<Jn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Qn(r,t,e=0){switch(St(r)){case 8:t[e++]=r&255|Z,r/=128;case 7:t[e++]=r&255|Z,r/=128;case 6:t[e++]=r&255|Z,r/=128;case 5:t[e++]=r&255|Z,r/=128;case 4:t[e++]=r&255|Z,r>>>=7;case 3:t[e++]=r&255|Z,r>>>=7;case 2:t[e++]=r&255|Z,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Hf(r,t,e=0){switch(St(r)){case 8:t.set(e++,r&255|Z),r/=128;case 7:t.set(e++,r&255|Z),r/=128;case 6:t.set(e++,r&255|Z),r/=128;case 5:t.set(e++,r&255|Z),r/=128;case 4:t.set(e++,r&255|Z),r>>>=7;case 3:t.set(e++,r&255|Z),r>>>=7;case 2:t.set(e++,r&255|Z),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function to(r,t){let e=r[t],n=0;if(n+=e&lt,e<Z||(e=r[t+1],n+=(e&lt)<<7,e<Z)||(e=r[t+2],n+=(e&lt)<<14,e<Z)||(e=r[t+3],n+=(e&lt)<<21,e<Z)||(e=r[t+4],n+=(e&lt)*jn,e<Z)||(e=r[t+5],n+=(e&lt)*Wn,e<Z)||(e=r[t+6],n+=(e&lt)*$n,e<Z)||(e=r[t+7],n+=(e&lt)*Jn,e<Z))return n;throw new RangeError("Could not decode varint")}function qf(r,t){let e=r.get(t),n=0;if(n+=e&lt,e<Z||(e=r.get(t+1),n+=(e&lt)<<7,e<Z)||(e=r.get(t+2),n+=(e&lt)<<14,e<Z)||(e=r.get(t+3),n+=(e&lt)<<21,e<Z)||(e=r.get(t+4),n+=(e&lt)*jn,e<Z)||(e=r.get(t+5),n+=(e&lt)*Wn,e<Z)||(e=r.get(t+6),n+=(e&lt)*$n,e<Z)||(e=r.get(t+7),n+=(e&lt)*Jn,e<Z))return n;throw new RangeError("Could not decode varint")}function Nr(r,t,e=0){return t==null&&(t=it(St(r))),t instanceof Uint8Array?Qn(r,t,e):Hf(r,t,e)}function Kr(r,t=0){return r instanceof Uint8Array?to(r,t):qf(r,t)}var ro=new Float32Array([-0]),ee=new Uint8Array(ro.buffer);function ui(r,t,e){ro[0]=r,t[e]=ee[0],t[e+1]=ee[1],t[e+2]=ee[2],t[e+3]=ee[3]}function hi(r,t){return ee[0]=r[t],ee[1]=r[t+1],ee[2]=r[t+2],ee[3]=r[t+3],ro[0]}var no=new Float64Array([-0]),dt=new Uint8Array(no.buffer);function li(r,t,e){no[0]=r,t[e]=dt[0],t[e+1]=dt[1],t[e+2]=dt[2],t[e+3]=dt[3],t[e+4]=dt[4],t[e+5]=dt[5],t[e+6]=dt[6],t[e+7]=dt[7]}function di(r,t){return dt[0]=r[t],dt[1]=r[t+1],dt[2]=r[t+2],dt[3]=r[t+3],dt[4]=r[t+4],dt[5]=r[t+5],dt[6]=r[t+6],dt[7]=r[t+7],no[0]}var Vf=BigInt(Number.MAX_SAFE_INTEGER),Ff=BigInt(Number.MIN_SAFE_INTEGER),At=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ue;if(t<Vf&&t>Ff)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>pi&&(o=0n,++n>pi&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ue;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ue}},ue=new At(0,0);ue.toBigInt=function(){return 0n};ue.zzEncode=ue.zzDecode=function(){return this};ue.length=function(){return 1};var pi=4294967296n;function mi(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function yi(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function oo(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Rt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Dr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var so=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Rt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Rt(this,4);return Dr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Rt(this,4);return Dr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Rt(this,4);let t=hi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Rt(this,4);let t=di(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Rt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return yi(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Rt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Rt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new At(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Rt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf