diff --git a/relay-angular-chat/index.html b/relay-angular-chat/index.html index fee6c7f..6ab5bae 100644 --- a/relay-angular-chat/index.html +++ b/relay-angular-chat/index.html @@ -7,6 +7,6 @@ - + \ No newline at end of file diff --git a/relay-angular-chat/main.5bb44346dd9a0067.js b/relay-angular-chat/main.5bb44346dd9a0067.js new file mode 100644 index 0000000..9e39e14 --- /dev/null +++ b/relay-angular-chat/main.5bb44346dd9a0067.js @@ -0,0 +1 @@ +var m$=Object.defineProperty,v$=(Y,U,x)=>U in Y?m$(Y,U,{enumerable:!0,configurable:!0,writable:!0,value:x}):Y[U]=x,rb=(Y,U,x)=>(v$(Y,"symbol"!=typeof U?U+"":U,x),x),ZA=(Y,U,x)=>{if(!U.has(Y))throw TypeError("Cannot "+x)},aa=(Y,U,x)=>(ZA(Y,U,"read from private field"),x?x.call(Y):U.get(Y)),dp=(Y,U,x)=>{if(U.has(Y))throw TypeError("Cannot add the same private member more than once");U instanceof WeakSet?U.add(Y):U.set(Y,x)},So=(Y,U,x,y)=>(ZA(Y,U,"write to private field"),y?y.call(Y,x):U.set(Y,x),x),ib=(Y,U,x,y)=>({set _(u){So(Y,U,u,x)},get _(){return aa(Y,U,y)}});(self.webpackChunkrelay_angular_chat=self.webpackChunkrelay_angular_chat||[]).push([[179],{1873:(Y,U,x)=>{"use strict";Y.exports=x(4729)},4729:(Y,U,x)=>{"use strict";var y=U;function u(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(3542),y.BufferWriter=x(989),y.Reader=x(6913),y.BufferReader=x(1872),y.util=x(6138),y.rpc=x(9852),y.roots=x(935),y.configure=u,u()},6913:(Y,U,x)=>{"use strict";Y.exports=h;var u,y=x(6138),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new u(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){u=E,h.create=f(),u._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},1872:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(6913);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(6138);function g(w){y.call(this,w)}g._configure=function(){u.Buffer&&(g.prototype._slice=u.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},935:Y=>{"use strict";Y.exports={}},9852:(Y,U,x)=>{"use strict";U.Service=x(3939)},3939:(Y,U,x)=>{"use strict";Y.exports=u;var y=x(6138);function u(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(u.prototype=Object.create(y.EventEmitter.prototype)).constructor=u,u.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},u.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},6723:(Y,U,x)=>{"use strict";Y.exports=u;var y=x(6138);function u(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=u.zero=new u(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=u.zeroHash="\0\0\0\0\0\0\0\0";u.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new u(d,b)},u.from=function(c){if("number"==typeof c)return u.fromNumber(c);if(y.isString(c)){if(!y.Long)return u.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new u(c.low>>>0,c.high>>>0):g},u.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},u.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;u.fromHash=function(c){return c===w?g:new u((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},u.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},u.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},u.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},u.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},6138:function(Y,U,x){"use strict";var y=U;function u(w,m,h){for(var c=Object.keys(m),f=0;f0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=u,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Y.exports=d;var u,y=x(6138),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new u})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){u=P,d.create=b(),u._configure()}},989:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(3542);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(6138);function g(){y.call(this)}function w(m,h,c){m.length<40?u.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=u._Buffer_allocUnsafe,g.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&"set"===u.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=u.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},8487:(Y,U,x)=>{var js,Va,Ha,y={};x.r(y),x.d(y,{identity:()=>YB});var u={};x.r(u),x.d(u,{base2:()=>QB});var g={};x.r(g),x.d(g,{base8:()=>ZB});var w={};x.r(w),x.d(w,{base10:()=>XB});var m={};x.r(m),x.d(m,{base16:()=>JB,base16upper:()=>e6});var h={};x.r(h),x.d(h,{base32:()=>co,base32hex:()=>i6,base32hexpad:()=>o6,base32hexpadupper:()=>a6,base32hexupper:()=>s6,base32pad:()=>n6,base32padupper:()=>r6,base32upper:()=>t6,base32z:()=>c6});var c={};x.r(c),x.d(c,{base36:()=>u6,base36upper:()=>l6});var f={};x.r(f),x.d(f,{base58btc:()=>ui,base58flickr:()=>f6});var d={};x.r(d),x.d(d,{base64:()=>jd,base64pad:()=>d6,base64url:()=>h6,base64urlpad:()=>p6});var b={};x.r(b),x.d(b,{base256emoji:()=>E6});var S={};x.r(S),x.d(S,{sha256:()=>mi,sha512:()=>V6});var E={};x.r(E),x.d(E,{identity:()=>Uc});var v={};x.r(v),x.d(v,{code:()=>$6,decode:()=>z6,encode:()=>j6,name:()=>K6});var p={};x.r(p),x.d(p,{code:()=>Y6,decode:()=>Z6,encode:()=>Q6,name:()=>q6});var I={};x.r(I),x.d(I,{RsaPrivateKey:()=>rh,RsaPublicKey:()=>Q0,fromJwk:()=>$F,generateKeyPair:()=>jF,unmarshalRsaPrivateKey:()=>HF,unmarshalRsaPublicKey:()=>KF});var A={};x.r(A),x.d(A,{Ed25519PrivateKey:()=>Al,Ed25519PublicKey:()=>mm,generateKeyPair:()=>y5,generateKeyPairFromSeed:()=>m5,unmarshalEd25519PrivateKey:()=>p5,unmarshalEd25519PublicKey:()=>g5});var P={};function D(n){return"function"==typeof n}function T(n){const t=n(r=>{Error.call(r),r.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}x.r(P),x.d(P,{Secp256k1PrivateKey:()=>Dm,Secp256k1PublicKey:()=>_m,generateKeyPair:()=>I5,unmarshalSecp256k1PrivateKey:()=>S5,unmarshalSecp256k1PublicKey:()=>C5});const M=T(n=>function(t){n(this),this.message=t?`${t.length} errors occurred during unsubscription:\n${t.map((r,i)=>`${i+1}) ${r.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=t});function k(n,e){if(n){const t=n.indexOf(e);0<=t&&n.splice(t,1)}}class F{constructor(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}unsubscribe(){let e;if(!this.closed){this.closed=!0;const{_parentage:t}=this;if(t)if(this._parentage=null,Array.isArray(t))for(const s of t)s.remove(this);else t.remove(this);const{initialTeardown:r}=this;if(D(r))try{r()}catch(s){e=s instanceof M?s.errors:[s]}const{_finalizers:i}=this;if(i){this._finalizers=null;for(const s of i)try{O(s)}catch(o){e=e??[],o instanceof M?e=[...e,...o.errors]:e.push(o)}}if(e)throw new M(e)}}add(e){var t;if(e&&e!==this)if(this.closed)O(e);else{if(e instanceof F){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(t=this._finalizers)&&void 0!==t?t:[]).push(e)}}_hasParent(e){const{_parentage:t}=this;return t===e||Array.isArray(t)&&t.includes(e)}_addParent(e){const{_parentage:t}=this;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e}_removeParent(e){const{_parentage:t}=this;t===e?this._parentage=null:Array.isArray(t)&&k(t,e)}remove(e){const{_finalizers:t}=this;t&&k(t,e),e instanceof F&&e._removeParent(this)}}F.EMPTY=(()=>{const n=new F;return n.closed=!0,n})();const j=F.EMPTY;function C(n){return n instanceof F||n&&"closed"in n&&D(n.remove)&&D(n.add)&&D(n.unsubscribe)}function O(n){D(n)?n():n.unsubscribe()}const V={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},L={setTimeout(n,e,...t){const{delegate:r}=L;return r?.setTimeout?r.setTimeout(n,e,...t):setTimeout(n,e,...t)},clearTimeout(n){const{delegate:e}=L;return(e?.clearTimeout||clearTimeout)(n)},delegate:void 0};function K(n){L.setTimeout(()=>{const{onUnhandledError:e}=V;if(!e)throw n;e(n)})}function re(){}const G=q("C",void 0,void 0);function q(n,e,t){return{kind:n,value:e,error:t}}let ne=null;function oe(n){if(V.useDeprecatedSynchronousErrorHandling){const e=!ne;if(e&&(ne={errorThrown:!1,error:null}),n(),e){const{errorThrown:t,error:r}=ne;if(ne=null,t)throw r}}else n()}class pe extends F{constructor(e){super(),this.isStopped=!1,e?(this.destination=e,C(e)&&e.add(this)):this.destination=Ie}static create(e,t,r){return new be(e,t,r)}next(e){this.isStopped?Ee(function X(n){return q("N",n,void 0)}(e),this):this._next(e)}error(e){this.isStopped?Ee(function te(n){return q("E",void 0,n)}(e),this):(this.isStopped=!0,this._error(e))}complete(){this.isStopped?Ee(G,this):(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe(),this.destination=null)}_next(e){this.destination.next(e)}_error(e){try{this.destination.error(e)}finally{this.unsubscribe()}}_complete(){try{this.destination.complete()}finally{this.unsubscribe()}}}const Le=Function.prototype.bind;function Se(n,e){return Le.call(n,e)}class Ne{constructor(e){this.partialObserver=e}next(e){const{partialObserver:t}=this;if(t.next)try{t.next(e)}catch(r){je(r)}}error(e){const{partialObserver:t}=this;if(t.error)try{t.error(e)}catch(r){je(r)}else je(e)}complete(){const{partialObserver:e}=this;if(e.complete)try{e.complete()}catch(t){je(t)}}}class be extends pe{constructor(e,t,r){let i;if(super(),D(e)||!e)i={next:e??void 0,error:t??void 0,complete:r??void 0};else{let s;this&&V.useDeprecatedNextContext?(s=Object.create(e),s.unsubscribe=()=>this.unsubscribe(),i={next:e.next&&Se(e.next,s),error:e.error&&Se(e.error,s),complete:e.complete&&Se(e.complete,s)}):i=e}this.destination=new Ne(i)}}function je(n){V.useDeprecatedSynchronousErrorHandling?function de(n){V.useDeprecatedSynchronousErrorHandling&&ne&&(ne.errorThrown=!0,ne.error=n)}(n):K(n)}function Ee(n,e){const{onStoppedNotification:t}=V;t&&L.setTimeout(()=>t(n,e))}const Ie={closed:!0,next:re,error:function H(n){throw n},complete:re},xe="function"==typeof Symbol&&Symbol.observable||"@@observable";function He(n){return n}let Xe=(()=>{class n{constructor(t){t&&(this._subscribe=t)}lift(t){const r=new n;return r.source=this,r.operator=t,r}subscribe(t,r,i){const s=function _t(n){return n&&n instanceof pe||function pt(n){return n&&D(n.next)&&D(n.error)&&D(n.complete)}(n)&&C(n)}(t)?t:new be(t,r,i);return oe(()=>{const{operator:o,source:a}=this;s.add(o?o.call(s,a):a?this._subscribe(s):this._trySubscribe(s))}),s}_trySubscribe(t){try{return this._subscribe(t)}catch(r){t.error(r)}}forEach(t,r){return new(r=Nt(r))((i,s)=>{const o=new be({next:a=>{try{t(a)}catch(l){s(l),o.unsubscribe()}},error:s,complete:i});this.subscribe(o)})}_subscribe(t){var r;return null===(r=this.source)||void 0===r?void 0:r.subscribe(t)}[xe](){return this}pipe(...t){return function Je(n){return 0===n.length?He:1===n.length?n[0]:function(t){return n.reduce((r,i)=>i(r),t)}}(t)(this)}toPromise(t){return new(t=Nt(t))((r,i)=>{let s;this.subscribe(o=>s=o,o=>i(o),()=>r(s))})}}return n.create=e=>new n(e),n})();function Nt(n){var e;return null!==(e=n??V.Promise)&&void 0!==e?e:Promise}const Or=T(n=>function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let pr=(()=>{class n extends Xe{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(t){const r=new Hr(this,this);return r.operator=t,r}_throwIfClosed(){if(this.closed)throw new Or}next(t){oe(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(const r of this.currentObservers)r.next(t)}})}error(t){oe(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=t;const{observers:r}=this;for(;r.length;)r.shift().error(t)}})}complete(){oe(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;const{observers:t}=this;for(;t.length;)t.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0}_trySubscribe(t){return this._throwIfClosed(),super._trySubscribe(t)}_subscribe(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)}_innerSubscribe(t){const{hasError:r,isStopped:i,observers:s}=this;return r||i?j:(this.currentObservers=null,s.push(t),new F(()=>{this.currentObservers=null,k(s,t)}))}_checkFinalizedStatuses(t){const{hasError:r,thrownError:i,isStopped:s}=this;r?t.error(i):s&&t.complete()}asObservable(){const t=new Xe;return t.source=this,t}}return n.create=(e,t)=>new Hr(e,t),n})();class Hr extends pr{constructor(e,t){super(),this.destination=e,this.source=t}next(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)}error(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)}complete(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)}_subscribe(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:j}}function fe(n){return e=>{if(function ie(n){return D(n?.lift)}(e))return e.lift(function(t){try{return n(t,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function ye(n,e,t,r,i){return new me(n,e,t,r,i)}class me extends pe{constructor(e,t,r,i,s,o){super(e),this.onFinalize=s,this.shouldUnsubscribe=o,this._next=t?function(a){try{t(a)}catch(l){e.error(l)}}:super._next,this._error=i?function(a){try{i(a)}catch(l){e.error(l)}finally{this.unsubscribe()}}:super._error,this._complete=r?function(){try{r()}catch(a){e.error(a)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){const{closed:t}=this;super.unsubscribe(),!t&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}}}function Bt(n){return this instanceof Bt?(this.v=n,this):new Bt(n)}function gn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=t.apply(n,e||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(B){r[B]&&(i[B]=function(z){return new Promise(function(Z,J){s.push([B,z,Z,J])>1||a(B,z)})})}function a(B,z){try{!function l(B){B.value instanceof Bt?Promise.resolve(B.value.v).then(_,R):N(s[0][2],B)}(r[B](z))}catch(Z){N(s[0][3],Z)}}function _(B){a("next",B)}function R(B){a("throw",B)}function N(B,z){B(z),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ft(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,e=n[Symbol.asyncIterator];return e?e.call(n):(n=function dt(n){var e="function"==typeof Symbol&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&"number"==typeof n.length)return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){!function i(s,o,a,l){Promise.resolve(l).then(function(_){s({value:_,done:a})},o)}(a,l,(o=n[s](o)).done,o.value)})}}}const En=n=>n&&"number"==typeof n.length&&"function"!=typeof n;function ur(n){return D(n?.then)}function Zn(n){return D(n[xe])}function bn(n){return Symbol.asyncIterator&&D(n?.[Symbol.asyncIterator])}function Ft(n){return new TypeError(`You provided ${null!==n&&"object"==typeof n?"an invalid object":`'${n}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}const ce=function ct(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}();function ve(n){return D(n?.[ce])}function mt(n){return gn(this,arguments,function*(){const t=n.getReader();try{for(;;){const{value:r,done:i}=yield Bt(t.read());if(i)return yield Bt(void 0);yield yield Bt(r)}}finally{t.releaseLock()}})}function Dt(n){return D(n?.getReader)}function yn(n){if(n instanceof Xe)return n;if(null!=n){if(Zn(n))return function ze(n){return new Xe(e=>{const t=n[xe]();if(D(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}(n);if(En(n))return function Ye(n){return new Xe(e=>{for(let t=0;t{n.then(t=>{e.closed||(e.next(t),e.complete())},t=>e.error(t)).then(null,K)})}(n);if(bn(n))return ht(n);if(ve(n))return function Ge(n){return new Xe(e=>{for(const t of n)if(e.next(t),e.closed)return;e.complete()})}(n);if(Dt(n))return function Et(n){return ht(mt(n))}(n)}throw Ft(n)}function ht(n){return new Xe(e=>{(function ut(n,e){var t,r,i,s;return function ge(n,e,t,r){return new(t||(t=Promise))(function(s,o){function a(R){try{_(r.next(R))}catch(N){o(N)}}function l(R){try{_(r.throw(R))}catch(N){o(N)}}function _(R){R.done?s(R.value):function i(s){return s instanceof t?s:new t(function(o){o(s)})}(R.value).then(a,l)}_((r=r.apply(n,e||[])).next())})}(this,void 0,void 0,function*(){try{for(t=ft(n);!(r=yield t.next()).done;)if(e.next(r.value),e.closed)return}catch(o){i={error:o}}finally{try{r&&!r.done&&(s=t.return)&&(yield s.call(t))}finally{if(i)throw i.error}}e.complete()})})(n,e).catch(t=>e.error(t))})}function St(n,e,t,r=0,i=!1){const s=e.schedule(function(){t(),i?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(s),!i)return s}function Ut(n,e,t=1/0){return D(e)?Ut((r,i)=>function _e(n,e){return fe((t,r)=>{let i=0;t.subscribe(ye(r,s=>{r.next(n.call(e,s,i++))}))})}((s,o)=>e(r,s,i,o))(yn(n(r,i))),t):("number"==typeof e&&(t=e),fe((r,i)=>function $t(n,e,t,r,i,s,o,a){const l=[];let _=0,R=0,N=!1;const B=()=>{N&&!l.length&&!_&&e.complete()},z=J=>_{s&&e.next(J),_++;let se=!1;yn(t(J,R++)).subscribe(ye(e,he=>{i?.(he),s?z(he):e.next(he)},()=>{se=!0},void 0,()=>{if(se)try{for(_--;l.length&&_Z(he)):Z(he)}B()}catch(he){e.error(he)}}))};return n.subscribe(ye(e,z,()=>{N=!0,B()})),()=>{a?.()}}(r,i,n,t)))}const Sn=new Xe(n=>n.complete());function Co(n){return n[n.length-1]}function Q(n,e=0){return fe((t,r)=>{t.subscribe(ye(r,i=>St(r,n,()=>r.next(i),e),()=>St(r,n,()=>r.complete(),e),i=>St(r,n,()=>r.error(i),e)))})}function ee(n,e=0){return fe((t,r)=>{r.add(n.schedule(()=>t.subscribe(r),e))})}function Ze(n,e){if(!n)throw new Error("Iterable cannot be null");return new Xe(t=>{St(t,e,()=>{const r=n[Symbol.asyncIterator]();St(t,e,()=>{r.next().then(i=>{i.done?t.complete():t.next(i.value)})},0,!0)})})}function ei(...n){const e=function ua(n){return function ca(n){return n&&D(n.schedule)}(Co(n))?n.pop():void 0}(n),t=function W(n,e){return"number"==typeof Co(n)?n.pop():e}(n,1/0),r=n;return r.length?1===r.length?yn(r[0]):function xn(n=1/0){return Ut(He,n)}(t)(function di(n,e){return e?function gr(n,e){if(null!=n){if(Zn(n))return function le(n,e){return yn(n).pipe(ee(e),Q(e))}(n,e);if(En(n))return function Ve(n,e){return new Xe(t=>{let r=0;return e.schedule(function(){r===n.length?t.complete():(t.next(n[r++]),t.closed||this.schedule())})})}(n,e);if(ur(n))return function ke(n,e){return yn(n).pipe(ee(e),Q(e))}(n,e);if(bn(n))return Ze(n,e);if(ve(n))return function tt(n,e){return new Xe(t=>{let r;return St(t,e,()=>{r=n[ce](),St(t,e,()=>{let i,s;try{({value:i,done:s}=r.next())}catch(o){return void t.error(o)}s?t.complete():t.next(i)},0,!0)}),()=>D(r?.return)&&r.return()})}(n,e);if(Dt(n))return function sn(n,e){return Ze(mt(n),e)}(n,e)}throw Ft(n)}(n,e):yn(n)}(r,e)):Sn}function Io(n,e,...t){if(!0===e)return void n();if(!1===e)return;const r=new be({next:()=>{r.unsubscribe(),n()}});return e(...t).subscribe(r)}function Jt(n){for(let e in n)if(n[e]===Jt)return e;throw Error("Could not find renamed property on target object.")}function wn(n){if("string"==typeof n)return n;if(Array.isArray(n))return"["+n.map(wn).join(", ")+"]";if(null==n)return""+n;if(n.overriddenName)return`${n.overriddenName}`;if(n.name)return`${n.name}`;const e=n.toString();if(null==e)return""+e;const t=e.indexOf("\n");return-1===t?e:e.substring(0,t)}function Li(n,e){return null==n||""===n?null===e?"":e:null==e||""===e?n:n+" "+e}const vu=Jt({__forward_ref__:Jt});function hp(n){return n.__forward_ref__=hp,n.toString=function(){return wn(this())},n}function Rt(n){return function pp(n){return"function"==typeof n&&n.hasOwnProperty(vu)&&n.__forward_ref__===hp}(n)?n():n}class Tt extends Error{constructor(e,t){super(function af(n,e){return`NG0${Math.abs(n)}${e?": "+e.trim():""}`}(e,t)),this.code=e}}function Vt(n){return"string"==typeof n?n:null==n?"":String(n)}function cf(n,e){throw new Tt(-201,!1)}function Ci(n,e){null==n&&function Rn(n,e,t,r){throw new Error(`ASSERTION ERROR: ${n}`+(null==r?"":` [Expected=> ${t} ${r} ${e} <=Actual]`))}(e,n,null,"!=")}function Wn(n){return{token:n.token,providedIn:n.providedIn||null,factory:n.factory,value:void 0}}function Ka(n){return{providers:n.providers||[],imports:n.imports||[]}}function uf(n){return sb(n,lf)||sb(n,ab)}function sb(n,e){return n.hasOwnProperty(e)?n[e]:null}function ob(n){return n&&(n.hasOwnProperty(gp)||n.hasOwnProperty(sx))?n[gp]:null}const lf=Jt({\u0275prov:Jt}),gp=Jt({\u0275inj:Jt}),ab=Jt({ngInjectableDef:Jt}),sx=Jt({ngInjectorDef:Jt});var Mt=(()=>((Mt=Mt||{})[Mt.Default=0]="Default",Mt[Mt.Host=1]="Host",Mt[Mt.Self=2]="Self",Mt[Mt.SkipSelf=4]="SkipSelf",Mt[Mt.Optional=8]="Optional",Mt))();let yp;function Bi(n){const e=yp;return yp=n,e}function cb(n,e,t){const r=uf(n);return r&&"root"==r.providedIn?void 0===r.value?r.value=r.factory():r.value:t&Mt.Optional?null:void 0!==e?e:void cf(wn(n))}function To(n){return{toString:n}.toString()}var rs=(()=>((rs=rs||{})[rs.OnPush=0]="OnPush",rs[rs.Default=1]="Default",rs))(),Is=(()=>{return(n=Is||(Is={}))[n.Emulated=0]="Emulated",n[n.None=2]="None",n[n.ShadowDom=3]="ShadowDom",Is;var n})();const Fn=(()=>typeof globalThis<"u"&&globalThis||typeof global<"u"&&global||typeof window<"u"&&window||typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self)(),$a={},In=[],ff=Jt({\u0275cmp:Jt}),mp=Jt({\u0275dir:Jt}),vp=Jt({\u0275pipe:Jt}),ub=Jt({\u0275mod:Jt}),Gs=Jt({\u0275fac:Jt}),Eu=Jt({__NG_ELEMENT_ID__:Jt});let ax=0;function df(n){return To(()=>{const t=!0===n.standalone,r={},i={type:n.type,providersResolver:null,decls:n.decls,vars:n.vars,factory:null,template:n.template||null,consts:n.consts||null,ngContentSelectors:n.ngContentSelectors,hostBindings:n.hostBindings||null,hostVars:n.hostVars||0,hostAttrs:n.hostAttrs||null,contentQueries:n.contentQueries||null,declaredInputs:r,inputs:null,outputs:null,exportAs:n.exportAs||null,onPush:n.changeDetection===rs.OnPush,directiveDefs:null,pipeDefs:null,standalone:t,dependencies:t&&n.dependencies||null,getStandaloneInjector:null,selectors:n.selectors||In,viewQuery:n.viewQuery||null,features:n.features||null,data:n.data||{},encapsulation:n.encapsulation||Is.Emulated,id:"c"+ax++,styles:n.styles||In,_:null,setInput:null,schemas:n.schemas||null,tView:null},s=n.dependencies,o=n.features;return i.inputs=db(n.inputs,r),i.outputs=db(n.outputs),o&&o.forEach(a=>a(i)),i.directiveDefs=s?()=>("function"==typeof s?s():s).map(lb).filter(fb):null,i.pipeDefs=s?()=>("function"==typeof s?s():s).map(ri).filter(fb):null,i})}function lb(n){return Nn(n)||ni(n)}function fb(n){return null!==n}function bu(n){return To(()=>({type:n.type,bootstrap:n.bootstrap||In,declarations:n.declarations||In,imports:n.imports||In,exports:n.exports||In,transitiveCompileScopes:null,schemas:n.schemas||null,id:n.id||null}))}function db(n,e){if(null==n)return $a;const t={};for(const r in n)if(n.hasOwnProperty(r)){let i=n[r],s=i;Array.isArray(i)&&(s=i[1],i=i[0]),t[i]=r,e&&(e[i]=s)}return t}const Fi=df;function Nn(n){return n[ff]||null}function ni(n){return n[mp]||null}function ri(n){return n[vp]||null}function pi(n){return Array.isArray(n)&&"object"==typeof n[1]}function ss(n){return Array.isArray(n)&&!0===n[1]}function wp(n){return 0!=(8&n.flags)}function yf(n){return 2==(2&n.flags)}function mf(n){return 1==(1&n.flags)}function os(n){return null!==n.template}function hx(n){return 0!=(256&n[2])}function pa(n,e){return n.hasOwnProperty(Gs)?n[Gs]:null}class yx{constructor(e,t,r){this.previousValue=e,this.currentValue=t,this.firstChange=r}isFirstChange(){return this.firstChange}}function gb(n){return n.type.prototype.ngOnChanges&&(n.setInput=vx),mx}function mx(){const n=mb(this),e=n?.current;if(e){const t=n.previous;if(t===$a)n.previous=e;else for(let r in e)t[r]=e[r];n.current=null,this.ngOnChanges(e)}}function vx(n,e,t,r){const i=mb(n)||function Ex(n,e){return n[yb]=e}(n,{previous:$a,current:null}),s=i.current||(i.current={}),o=i.previous,a=this.declaredInputs[t],l=o[a];s[a]=new yx(l&&l.currentValue,e,o===$a),n[r]=e}const yb="__ngSimpleChanges__";function mb(n){return n[yb]||null}function yr(n){for(;Array.isArray(n);)n=n[0];return n}function Hi(n,e){return yr(e[n.index])}function Ip(n,e){return n.data[e]}function Ai(n,e){const t=e[n];return pi(t)?t:t[0]}function bf(n){return 64==(64&n[2])}function Ao(n,e){return null==e?null:n[e]}function vb(n){n[18]=0}function Tp(n,e){n[5]+=e;let t=n,r=n[3];for(;null!==r&&(1===e&&1===t[5]||-1===e&&0===t[5]);)r[5]+=e,t=r,r=r[3]}const kt={lFrame:Ab(null),bindingsEnabled:!0};function bb(){return kt.bindingsEnabled}function Ue(){return kt.lFrame.lView}function dn(){return kt.lFrame.tView}function Tr(){let n=wb();for(;null!==n&&64===n.type;)n=n.parent;return n}function wb(){return kt.lFrame.currentTNode}function Ts(n,e){const t=kt.lFrame;t.currentTNode=n,t.isParent=e}function Ap(){return kt.lFrame.isParent}function qa(){return kt.lFrame.bindingIndex++}function Lx(n,e){const t=kt.lFrame;t.bindingIndex=t.bindingRootIndex=n,Rp(e)}function Rp(n){kt.lFrame.currentDirectiveIndex=n}function Np(n){kt.lFrame.currentQueryIndex=n}function Fx(n){const e=n[1];return 2===e.type?e.declTNode:1===e.type?n[6]:null}function Ib(n,e,t){if(t&Mt.SkipSelf){let i=e,s=n;for(;!(i=i.parent,null!==i||t&Mt.Host||(i=Fx(s),null===i||(s=s[15],10&i.type))););if(null===i)return!1;e=i,n=s}const r=kt.lFrame=Tb();return r.currentTNode=e,r.lView=n,!0}function Mp(n){const e=Tb(),t=n[1];kt.lFrame=e,e.currentTNode=t.firstChild,e.lView=n,e.tView=t,e.contextLView=n,e.bindingIndex=t.bindingStartIndex,e.inI18n=!1}function Tb(){const n=kt.lFrame,e=null===n?null:n.child;return null===e?Ab(n):e}function Ab(n){const e={currentTNode:null,isParent:!0,lView:null,tView:null,selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:n,child:null,inI18n:!1};return null!==n&&(n.child=e),e}function xb(){const n=kt.lFrame;return kt.lFrame=n.parent,n.currentTNode=null,n.lView=null,n}const Rb=xb;function Op(){const n=xb();n.isParent=!0,n.tView=null,n.selectedIndex=-1,n.contextLView=null,n.elementDepthCount=0,n.currentDirectiveIndex=-1,n.currentNamespace=null,n.bindingRootIndex=-1,n.bindingIndex=-1,n.currentQueryIndex=0}function si(){return kt.lFrame.selectedIndex}function xo(n){kt.lFrame.selectedIndex=n}function wf(n,e){for(let t=e.directiveStart,r=e.directiveEnd;t=r)break}else e[l]<0&&(n[18]+=65536),(a>11>16&&(3&n[2])===e){n[2]+=2048;try{s.call(a)}finally{}}}else try{s.call(a)}finally{}}class Tu{constructor(e,t,r){this.factory=e,this.resolving=!1,this.canSeeViewProviders=t,this.injectImpl=r}}function Sf(n,e,t){let r=0;for(;re){o=s-1;break}}}for(;s>16}(n),r=e;for(;t>0;)r=r[15],t--;return r}let Bp=!0;function If(n){const e=Bp;return Bp=n,e}let Jx=0;const As={};function xu(n,e){const t=Up(n,e);if(-1!==t)return t;const r=e[1];r.firstCreatePass&&(n.injectorIndex=e.length,Fp(r.data,n),Fp(e,null),Fp(r.blueprint,null));const i=Tf(n,e),s=n.injectorIndex;if(kb(i)){const o=Ya(i),a=Qa(i,e),l=a[1].data;for(let _=0;_<8;_++)e[s+_]=a[o+_]|l[o+_]}return e[s+8]=i,s}function Fp(n,e){n.push(0,0,0,0,0,0,0,0,e)}function Up(n,e){return-1===n.injectorIndex||n.parent&&n.parent.injectorIndex===n.injectorIndex||null===e[n.injectorIndex+8]?-1:n.injectorIndex}function Tf(n,e){if(n.parent&&-1!==n.parent.injectorIndex)return n.parent.injectorIndex;let t=0,r=null,i=e;for(;null!==i;){if(r=jb(i),null===r)return-1;if(t++,i=i[15],-1!==r.injectorIndex)return r.injectorIndex|t<<16}return-1}function Af(n,e,t){!function eR(n,e,t){let r;"string"==typeof t?r=t.charCodeAt(0)||0:t.hasOwnProperty(Eu)&&(r=t[Eu]),null==r&&(r=t[Eu]=Jx++);const i=255&r;e.data[n+(i>>5)]|=1<=0?255&e:iR:e}(t);if("function"==typeof s){if(!Ib(e,n,r))return r&Mt.Host?Fb(i,0,r):Ub(e,t,r,i);try{const o=s(r);if(null!=o||r&Mt.Optional)return o;cf()}finally{Rb()}}else if("number"==typeof s){let o=null,a=Up(n,e),l=-1,_=r&Mt.Host?e[16][6]:null;for((-1===a||r&Mt.SkipSelf)&&(l=-1===a?Tf(n,e):e[a+8],-1!==l&&$b(r,!1)?(o=e[1],a=Ya(l),e=Qa(l,e)):a=-1);-1!==a;){const R=e[1];if(Kb(s,a,R.data)){const N=nR(a,e,t,o,r,_);if(N!==As)return N}l=e[a+8],-1!==l&&$b(r,e[1].data[a+8]===_)&&Kb(s,a,e)?(o=R,a=Ya(l),e=Qa(l,e)):a=-1}}return i}function nR(n,e,t,r,i,s){const o=e[1],a=o.data[n+8],R=function xf(n,e,t,r,i){const s=n.providerIndexes,o=e.data,a=1048575&s,l=n.directiveStart,R=s>>20,B=i?a+R:n.directiveEnd;for(let z=r?a:a+R;z=l&&Z.type===t)return z}if(i){const z=o[l];if(z&&os(z)&&z.type===t)return l}return null}(a,o,t,null==r?yf(a)&&Bp:r!=o&&0!=(3&a.type),i&Mt.Host&&s===a);return null!==R?Ru(e,o,R,a):As}function Ru(n,e,t,r){let i=n[t];const s=e.data;if(function qx(n){return n instanceof Tu}(i)){const o=i;o.resolving&&function XA(n,e){const t=e?`. Dependency path: ${e.join(" > ")} > ${n}`:"";throw new Tt(-200,`Circular dependency in DI detected for ${n}${t}`)}(function Cn(n){return"function"==typeof n?n.name||n.toString():"object"==typeof n&&null!=n&&"function"==typeof n.type?n.type.name||n.type.toString():Vt(n)}(s[t]));const a=If(o.canSeeViewProviders);o.resolving=!0;const l=o.injectImpl?Bi(o.injectImpl):null;Ib(n,r,Mt.Default);try{i=n[t]=o.factory(void 0,s,n,r),e.firstCreatePass&&t>=r.directiveStart&&function Gx(n,e,t){const{ngOnChanges:r,ngOnInit:i,ngDoCheck:s}=e.type.prototype;if(r){const o=gb(e);(t.preOrderHooks||(t.preOrderHooks=[])).push(n,o),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,o)}i&&(t.preOrderHooks||(t.preOrderHooks=[])).push(0-n,i),s&&((t.preOrderHooks||(t.preOrderHooks=[])).push(n,s),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,s))}(t,s[t],e)}finally{null!==l&&Bi(l),If(a),o.resolving=!1,Rb()}}return i}function Kb(n,e,t){return!!(t[e+(n>>5)]&1<{const r=function Kp(n){return function(...t){if(n){const r=n(...t);for(const i in r)this[i]=r[i]}}}(e);function i(...s){if(this instanceof i)return r.apply(this,s),this;const o=new i(...s);return a.annotation=o,a;function a(l,_,R){const N=l.hasOwnProperty(Ja)?l[Ja]:Object.defineProperty(l,Ja,{value:[]})[Ja];for(;N.length<=R;)N.push(null);return(N[R]=N[R]||[]).push(o),l}}return t&&(i.prototype=Object.create(t.prototype)),i.prototype.ngMetadataName=n,i.annotationCls=i,i})}class on{constructor(e,t){this._desc=e,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,"number"==typeof t?this.__NG_ELEMENT_ID__=t:void 0!==t&&(this.\u0275prov=Wn({token:this,providedIn:t.providedIn||"root",factory:t.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}}function Ys(n,e){n.forEach(t=>Array.isArray(t)?Ys(t,e):e(t))}function Gb(n,e,t){e>=n.length?n.push(t):n.splice(e,0,t)}function Rf(n,e){return e>=n.length-1?n.pop():n.splice(e,1)[0]}const Ou={},Gp="__NG_DI_FLAG__",Nf="ngTempTokenPath",vR=/\n/gm,Qb="__source";let ku;function rc(n){const e=ku;return ku=n,e}function bR(n,e=Mt.Default){if(void 0===ku)throw new Tt(-203,!1);return null===ku?cb(n,void 0,e):ku.get(n,e&Mt.Optional?null:void 0,e)}function Pn(n,e=Mt.Default){return(function ox(){return yp}()||bR)(Rt(n),e)}function Wp(n){const e=[];for(let t=0;t{const o=s;ng(o,t,[],r)&&(i||(i=[]),i.push(o))}),void 0!==i&&Dw(i,t),t}function Dw(n,e){for(let t=0;t{e.push(s)})}}function ng(n,e,t,r){if(!(n=Rt(n)))return!1;let i=null,s=ob(n);const o=!s&&Nn(n);if(s||o){if(o&&!o.standalone)return!1;i=n}else{const l=n.ngModule;if(s=ob(l),!s)return!1;i=l}const a=r.has(i);if(o){if(a)return!1;if(r.add(i),o.dependencies){const l="function"==typeof o.dependencies?o.dependencies():o.dependencies;for(const _ of l)ng(_,e,t,r)}}else{if(!s)return!1;{if(null!=s.imports&&!a){let _;r.add(i);try{Ys(s.imports,R=>{ng(R,e,t,r)&&(_||(_=[]),_.push(R))})}finally{}void 0!==_&&Dw(_,e)}if(!a){const _=pa(i)||(()=>new i);e.push({provide:i,useFactory:_,deps:In},{provide:bw,useValue:i,multi:!0},{provide:vw,useValue:()=>Pn(i),multi:!0})}const l=s.providers;null==l||a||Ys(l,R=>{e.push(R)})}}return i!==n&&void 0!==n.providers}const aP=Jt({provide:String,useValue:Jt});function rg(n){return null!==n&&"object"==typeof n&&aP in n}function ga(n){return"function"==typeof n}const ig=new on("Set Injector scope."),Vf={},uP={};let sg;function Hf(){return void 0===sg&&(sg=new ww),sg}class oc{}class Iw extends oc{constructor(e,t,r,i){super(),this.parent=t,this.source=r,this.scopes=i,this.records=new Map,this._ngOnDestroyHooks=new Set,this._onDestroyHooks=[],this._destroyed=!1,ag(e,o=>this.processProvider(o)),this.records.set(Ew,ac(void 0,this)),i.has("environment")&&this.records.set(oc,ac(void 0,this));const s=this.records.get(ig);null!=s&&"string"==typeof s.value&&this.scopes.add(s.value),this.injectorDefTypes=new Set(this.get(bw.multi,In,Mt.Self))}get destroyed(){return this._destroyed}destroy(){this.assertNotDestroyed(),this._destroyed=!0;try{for(const e of this._ngOnDestroyHooks)e.ngOnDestroy();for(const e of this._onDestroyHooks)e()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear(),this._onDestroyHooks.length=0}}onDestroy(e){this._onDestroyHooks.push(e)}runInContext(e){this.assertNotDestroyed();const t=rc(this),r=Bi(void 0);try{return e()}finally{rc(t),Bi(r)}}get(e,t=Ou,r=Mt.Default){this.assertNotDestroyed();const i=rc(this),s=Bi(void 0);try{if(!(r&Mt.SkipSelf)){let a=this.records.get(e);if(void 0===a){const l=function pP(n){return"function"==typeof n||"object"==typeof n&&n instanceof on}(e)&&uf(e);a=l&&this.injectableDefInScope(l)?ac(og(e),Vf):null,this.records.set(e,a)}if(null!=a)return this.hydrate(e,a)}return(r&Mt.Self?Hf():this.parent).get(e,t=r&Mt.Optional&&t===Ou?null:t)}catch(o){if("NullInjectorError"===o.name){if((o[Nf]=o[Nf]||[]).unshift(wn(e)),i)throw o;return function DR(n,e,t,r){const i=n[Nf];throw e[Qb]&&i.unshift(e[Qb]),n.message=function SR(n,e,t,r=null){n=n&&"\n"===n.charAt(0)&&"\u0275"==n.charAt(1)?n.slice(2):n;let i=wn(e);if(Array.isArray(e))i=e.map(wn).join(" -> ");else if("object"==typeof e){let s=[];for(let o in e)if(e.hasOwnProperty(o)){let a=e[o];s.push(o+":"+("string"==typeof a?JSON.stringify(a):wn(a)))}i=`{${s.join(", ")}}`}return`${t}${r?"("+r+")":""}[${i}]: ${n.replace(vR,"\n ")}`}("\n"+n.message,i,t,r),n.ngTokenPath=i,n[Nf]=null,n}(o,e,"R3InjectorError",this.source)}throw o}finally{Bi(s),rc(i)}}resolveInjectorInitializers(){const e=rc(this),t=Bi(void 0);try{const r=this.get(vw.multi,In,Mt.Self);for(const i of r)i()}finally{rc(e),Bi(t)}}toString(){const e=[],t=this.records;for(const r of t.keys())e.push(wn(r));return`R3Injector[${e.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new Tt(205,!1)}processProvider(e){let t=ga(e=Rt(e))?e:Rt(e&&e.provide);const r=function fP(n){return rg(n)?ac(void 0,n.useValue):ac(function Tw(n,e,t){let r;if(ga(n)){const i=Rt(n);return pa(i)||og(i)}if(rg(n))r=()=>Rt(n.useValue);else if(function Cw(n){return!(!n||!n.useFactory)}(n))r=()=>n.useFactory(...Wp(n.deps||[]));else if(function Sw(n){return!(!n||!n.useExisting)}(n))r=()=>Pn(Rt(n.useExisting));else{const i=Rt(n&&(n.useClass||n.provide));if(!function dP(n){return!!n.deps}(n))return pa(i)||og(i);r=()=>new i(...Wp(n.deps))}return r}(n),Vf)}(e);if(ga(e)||!0!==e.multi)this.records.get(t);else{let i=this.records.get(t);i||(i=ac(void 0,Vf,!0),i.factory=()=>Wp(i.multi),this.records.set(t,i)),t=e,i.multi.push(e)}this.records.set(t,r)}hydrate(e,t){return t.value===Vf&&(t.value=uP,t.value=t.factory()),"object"==typeof t.value&&t.value&&function hP(n){return null!==n&&"object"==typeof n&&"function"==typeof n.ngOnDestroy}(t.value)&&this._ngOnDestroyHooks.add(t.value),t.value}injectableDefInScope(e){if(!e.providedIn)return!1;const t=Rt(e.providedIn);return"string"==typeof t?"any"===t||this.scopes.has(t):this.injectorDefTypes.has(t)}}function og(n){const e=uf(n),t=null!==e?e.factory:pa(n);if(null!==t)return t;if(n instanceof on)throw new Tt(204,!1);if(n instanceof Function)return function lP(n){const e=n.length;if(e>0)throw function Mu(n,e){const t=[];for(let r=0;rt.factory(n):()=>new n}(n);throw new Tt(204,!1)}function ac(n,e,t=!1){return{factory:n,value:e,multi:t?[]:void 0}}function gP(n){return!!n.\u0275providers}function ag(n,e){for(const t of n)Array.isArray(t)?ag(t,e):gP(t)?ag(t.\u0275providers,e):e(t)}class Aw{}class vP{resolveComponentFactory(e){throw function mP(n){const e=Error(`No component factory found for ${wn(n)}. Did you add it to @NgModule.entryComponents?`);return e.ngComponent=n,e}(e)}}let Kf=(()=>{class n{}return n.NULL=new vP,n})();function EP(){return cc(Tr(),Ue())}function cc(n,e){return new uc(Hi(n,e))}let uc=(()=>{class n{constructor(t){this.nativeElement=t}}return n.__NG_ELEMENT_ID__=EP,n})();class Rw{}let _P=(()=>{class n{}return n.\u0275prov=Wn({token:n,providedIn:"root",factory:()=>null}),n})();class cg{constructor(e){this.full=e,this.major=e.split(".")[0],this.minor=e.split(".")[1],this.patch=e.split(".").slice(2).join(".")}}const DP=new cg("14.2.2"),ug={};function pg(n){return n.ngOriginalError}class lc{constructor(){this._console=console}handleError(e){const t=this._findOriginalError(e);this._console.error("ERROR",e),t&&this._console.error("ORIGINAL ERROR",t)}_findOriginalError(e){let t=e&&pg(e);for(;t&&pg(t);)t=pg(t);return t||null}}const gg=new Map;let kP=0;const mg="__ngContext__";function jr(n,e){pi(e)?(n[mg]=e[20],function BP(n){gg.set(n[20],n)}(e)):n[mg]=e}var gi=(()=>((gi=gi||{})[gi.Important=1]="Important",gi[gi.DashCase=2]="DashCase",gi))();function Eg(n,e){return undefined(n,e)}function $u(n){const e=n[3];return ss(e)?e[3]:e}function bg(n){return zw(n[13])}function wg(n){return zw(n[4])}function zw(n){for(;null!==n&&!ss(n);)n=n[4];return n}function dc(n,e,t,r,i){if(null!=r){let s,o=!1;ss(r)?s=r:pi(r)&&(o=!0,r=r[0]);const a=yr(r);0===n&&null!==t?null==i?Zw(e,t,a):ya(e,t,a,i||null,!0):1===n&&null!==t?ya(e,t,a,i||null,!0):2===n?function i_(n,e,t){const r=$f(n,e);r&&function lN(n,e,t,r){n.removeChild(e,t,r)}(n,r,e,t)}(e,a,o):3===n&&e.destroyNode(a),null!=s&&function hN(n,e,t,r,i){const s=t[7];s!==yr(t)&&dc(e,n,r,s,i);for(let a=10;a0&&(n[t-1][4]=r[4]);const s=Rf(n,10+e);!function nN(n,e){ju(n,e,e[11],2,null,null),e[0]=null,e[6]=null}(r[1],r);const o=s[19];null!==o&&o.detachView(s[1]),r[3]=null,r[4]=null,r[2]&=-65}return r}function qw(n,e){if(!(128&e[2])){const t=e[11];t.destroyNode&&ju(n,e,t,3,null,null),function sN(n){let e=n[13];if(!e)return Cg(n[1],n);for(;e;){let t=null;if(pi(e))t=e[13];else{const r=e[10];r&&(t=r)}if(!t){for(;e&&!e[4]&&e!==n;)pi(e)&&Cg(e[1],e),e=e[3];null===e&&(e=n),pi(e)&&Cg(e[1],e),t=e&&e[4]}e=t}}(e)}}function Cg(n,e){if(!(128&e[2])){e[2]&=-65,e[2]|=128,function uN(n,e){let t;if(null!=n&&null!=(t=n.destroyHooks))for(let r=0;r=0?r[i=_]():r[i=-_].unsubscribe(),s+=2}else{const o=r[i=t[s+1]];t[s].call(o)}if(null!==r){for(let s=i+1;ss?"":i[N+1].toLowerCase();const z=8&r?B:null;if(z&&-1!==a_(z,_,0)||2&r&&_!==B){if(as(r))return!1;o=!0}}}}else{if(!o&&!as(r)&&!as(l))return!1;if(o&&as(l))continue;o=!1,r=l|1&r}}return as(r)||o}function as(n){return 0==(1&n)}function vN(n,e,t,r){if(null===e)return-1;let i=0;if(r||!t){let s=!1;for(;i-1)for(t++;t0?'="'+a+'"':"")+"]"}else 8&r?i+="."+o:4&r&&(i+=" "+o);else""!==i&&!as(o)&&(e+=f_(s,i),i=""),r=o,s=s||!as(r);t++}return""!==i&&(e+=f_(s,i)),e}const Ht={};function zu(n){d_(dn(),Ue(),si()+n,!1)}function d_(n,e,t,r){if(!r)if(3==(3&e[2])){const s=n.preOrderCheckHooks;null!==s&&_f(e,s,t)}else{const s=n.preOrderHooks;null!==s&&Df(e,s,0,t)}xo(t)}function y_(n,e=null,t=null,r){const i=m_(n,e,t,r);return i.resolveInjectorInitializers(),i}function m_(n,e=null,t=null,r,i=new Set){const s=[t||In,oP(n)];return r=r||("object"==typeof n?void 0:wn(n)),new Iw(s,e||Hf(),r||null,i)}let ma=(()=>{class n{static create(t,r){if(Array.isArray(t))return y_({name:""},r,t,"");{const i=t.name??"";return y_({name:i},t.parent,t.providers,i)}}}return n.THROW_IF_NOT_FOUND=Ou,n.NULL=new ww,n.\u0275prov=Wn({token:n,providedIn:"any",factory:()=>Pn(Ew)}),n.__NG_ELEMENT_ID__=-1,n})();function Zt(n,e=Mt.Default){const t=Ue();return null===t?Pn(n,e):Vb(Tr(),t,Rt(n),e)}function O_(n,e){const t=n.contentQueries;if(null!==t)for(let r=0;r22&&d_(n,e,22,!1),t(r,i)}finally{xo(s)}}function Gg(n,e,t){!bb()||(function fM(n,e,t,r){const i=t.directiveStart,s=t.directiveEnd;n.firstCreatePass||xu(t,e),jr(r,e);const o=t.initialInputs;for(let a=i;a0;){const t=n[--e];if("number"==typeof t&&t<0)return t}return 0})(a)!=l&&a.push(l),a.push(r,i,o)}}function $_(n,e){null!==n.hostBindings&&n.hostBindings(1,e)}function j_(n,e){e.flags|=2,(n.components||(n.components=[])).push(e.index)}function gM(n,e,t){if(t){if(e.exportAs)for(let r=0;r0&&Zg(t)}}function Zg(n){for(let r=bg(n);null!==r;r=wg(r))for(let i=10;i0&&Zg(s)}const t=n[1].components;if(null!==t)for(let r=0;r0&&Zg(i)}}function _M(n,e){const t=Ai(e,n),r=t[1];(function DM(n,e){for(let t=e.length;t-1&&(Sg(e,r),Rf(t,r))}this._attachedToViewContainer=!1}qw(this._lView[1],this._lView)}onDestroy(e){!function F_(n,e,t,r){const i=q_(e);null===t?i.push(r):(i.push(t),n.firstCreatePass&&Y_(n).push(r,i.length-1))}(this._lView[1],this._lView,null,e)}markForCheck(){Xg(this._cdRefInjectingView||this._lView)}detach(){this._lView[2]&=-65}reattach(){this._lView[2]|=64}detectChanges(){Jf(this._lView[1],this._lView,this.context)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new Tt(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,function iN(n,e){ju(n,e,e[11],2,null,null)}(this._lView[1],this._lView)}attachToAppRef(e){if(this._attachedToViewContainer)throw new Tt(902,!1);this._appRef=e}}class SM extends Gu{constructor(e){super(e),this._view=e}detectChanges(){const e=this._view;Jf(e[1],e,e[8],!1)}checkNoChanges(){}get context(){return null}}class ty extends Kf{constructor(e){super(),this.ngModule=e}resolveComponentFactory(e){const t=Nn(e);return new Wu(t,this.ngModule)}}function X_(n){const e=[];for(let t in n)n.hasOwnProperty(t)&&e.push({propName:n[t],templateName:t});return e}class IM{constructor(e,t){this.injector=e,this.parentInjector=t}get(e,t,r){const i=this.injector.get(e,ug,r);return i!==ug||t===ug?i:this.parentInjector.get(e,t,r)}}class Wu extends Aw{constructor(e,t){super(),this.componentDef=e,this.ngModule=t,this.componentType=e.type,this.selector=function SN(n){return n.map(DN).join(",")}(e.selectors),this.ngContentSelectors=e.ngContentSelectors?e.ngContentSelectors:[],this.isBoundToModule=!!t}get inputs(){return X_(this.componentDef.inputs)}get outputs(){return X_(this.componentDef.outputs)}create(e,t,r,i){let s=(i=i||this.ngModule)instanceof oc?i:i?.injector;s&&null!==this.componentDef.getStandaloneInjector&&(s=this.componentDef.getStandaloneInjector(s)||s);const o=s?new IM(e,s):e,a=o.get(Rw,null);if(null===a)throw new Tt(407,!1);const l=o.get(_P,null),_=a.createRenderer(null,this.componentDef),R=this.componentDef.selectors[0][0]||"div",N=r?function sM(n,e,t){return n.selectRootElement(e,t===Is.ShadowDom)}(_,r,this.componentDef.encapsulation):Dg(a.createRenderer(null,this.componentDef),R,function CM(n){const e=n.toLowerCase();return"svg"===e?"svg":"math"===e?"math":null}(R)),B=this.componentDef.onPush?288:272,z=qg(0,null,null,1,0,null,null,null,null,null),Z=Qf(null,z,null,B,null,null,a,_,l,o,null);let J,se;Mp(Z);try{const he=function xM(n,e,t,r,i,s){const o=t[1];t[22]=n;const l=pc(o,22,2,"#host",null),_=l.mergedAttrs=e.hostAttrs;null!==_&&(ed(l,_,!0),null!==n&&(Sf(i,n,_),null!==l.classes&&xg(i,n,l.classes),null!==l.styles&&o_(i,n,l.styles)));const R=r.createRenderer(n,e),N=Qf(t,B_(e),null,e.onPush?32:16,t[22],l,r,R,s||null,null,null);return o.firstCreatePass&&(Af(xu(l,t),o,e.type),j_(o,l),z_(l,t.length,1)),Xf(t,N),t[22]=N}(N,this.componentDef,Z,a,_);if(N)if(r)Sf(_,N,["ng-version",DP.full]);else{const{attrs:Te,classes:ue}=function CN(n){const e=[],t=[];let r=1,i=2;for(;r0&&xg(_,N,ue.join(" "))}if(se=Ip(z,22),void 0!==t){const Te=se.projection=[];for(let ue=0;uea(yr($e[r.index])):r.index;let Re=null;if(!a&&l&&(Re=function QM(n,e,t,r){const i=n.cleanup;if(null!=i)for(let s=0;sl?a[l]:null}"string"==typeof o&&(s+=2)}return null}(n,e,i,r.index)),null!==Re)(Re.__ngLastListenerFn__||Re).__ngNextListenerFn__=s,Re.__ngLastListenerFn__=s,z=!1;else{s=m1(r,e,N,s,!1);const $e=t.listen(he,i,s);B.push(s,$e),R&&R.push(i,ue,Te,Te+1)}}else s=m1(r,e,N,s,!1);const Z=r.outputs;let J;if(z&&null!==Z&&(J=Z[i])){const se=J.length;if(se)for(let he=0;het()),this.destroyCbs=null}onDestroy(e){this.destroyCbs.push(e)}}class by extends class F3{}{constructor(e){super(),this.moduleType=e}create(e){return new OD(this.moduleType,e)}}function _y(n){return e=>{setTimeout(n,void 0,e)}}const no=class pk extends pr{constructor(e=!1){super(),this.__isAsync=e}emit(e){super.next(e)}subscribe(e,t,r){let i=e,s=t||(()=>null),o=r;if(e&&"object"==typeof e){const l=e;i=l.next?.bind(l),s=l.error?.bind(l),o=l.complete?.bind(l)}this.__isAsync&&(s=_y(s),i&&(i=_y(i)),o&&(o=_y(o)));const a=super.subscribe({next:i,error:s,complete:o});return e instanceof F&&e.add(a),a}};let ro=(()=>{class n{}return n.__NG_ELEMENT_ID__=vk,n})();const yk=ro,mk=class extends yk{constructor(e,t,r){super(),this._declarationLView=e,this._declarationTContainer=t,this.elementRef=r}createEmbeddedView(e,t){const r=this._declarationTContainer.tViews,i=Qf(this._declarationLView,r,e,16,null,r.declTNode,null,null,null,null,t||null);i[17]=this._declarationLView[this._declarationTContainer.index];const o=this._declarationLView[19];return null!==o&&(i[19]=o.createEmbeddedView(r)),zg(r,i,e),new Gu(i)}};function vk(){return function fd(n,e){return 4&n.type?new mk(e,n,cc(n,e)):null}(Tr(),Ue())}let Ms=(()=>{class n{}return n.__NG_ELEMENT_ID__=Ek,n})();function Ek(){return function YD(n,e){let t;const r=e[n.index];if(ss(r))t=r;else{let i;if(8&n.type)i=yr(r);else{const s=e[11];i=s.createComment("");const o=Hi(n,e);ya(s,$f(s,o),i,function fN(n,e){return n.nextSibling(e)}(s,o),!1)}e[n.index]=t=W_(r,e,i,n),Xf(e,t)}return new WD(t,n,e)}(Tr(),Ue())}const bk=Ms,WD=class extends bk{constructor(e,t,r){super(),this._lContainer=e,this._hostTNode=t,this._hostLView=r}get element(){return cc(this._hostTNode,this._hostLView)}get injector(){return new Za(this._hostTNode,this._hostLView)}get parentInjector(){const e=Tf(this._hostTNode,this._hostLView);if(kb(e)){const t=Qa(e,this._hostLView),r=Ya(e);return new Za(t[1].data[r+8],t)}return new Za(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(e){const t=qD(this._lContainer);return null!==t&&t[e]||null}get length(){return this._lContainer.length-10}createEmbeddedView(e,t,r){let i,s;"number"==typeof r?i=r:null!=r&&(i=r.index,s=r.injector);const o=e.createEmbeddedView(t||{},s);return this.insert(o,i),o}createComponent(e,t,r,i,s){const o=e&&!function Nu(n){return"function"==typeof n}(e);let a;if(o)a=t;else{const N=t||{};a=N.index,r=N.injector,i=N.projectableNodes,s=N.environmentInjector||N.ngModuleRef}const l=o?e:new Wu(Nn(e)),_=r||this.parentInjector;if(!s&&null==l.ngModule){const B=(o?_:this.parentInjector).get(oc,null);B&&(s=B)}const R=l.create(_,i,void 0,s);return this.insert(R.hostView,a),R}insert(e,t){const r=e._lView,i=r[1];if(function Ix(n){return ss(n[3])}(r)){const R=this.indexOf(e);if(-1!==R)this.detach(R);else{const N=r[3],B=new WD(N,N[6],N[3]);B.detach(B.indexOf(e))}}const s=this._adjustIndex(t),o=this._lContainer;!function oN(n,e,t,r){const i=10+r,s=t.length;r>0&&(t[i-1][4]=e),r{class n{constructor(t){this.appInits=t,this.resolve=hd,this.reject=hd,this.initialized=!1,this.done=!1,this.donePromise=new Promise((r,i)=>{this.resolve=r,this.reject=i})}runInitializers(){if(this.initialized)return;const t=[],r=()=>{this.done=!0,this.resolve()};if(this.appInits)for(let i=0;i{s.subscribe({complete:a,error:l})});t.push(o)}}Promise.all(t).then(()=>{r()}).catch(i=>{this.reject(i)}),0===t.length&&r(),this.initialized=!0}}return n.\u0275fac=function(t){return new(t||n)(Pn(ES,8))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();const sl=new on("AppId",{providedIn:"root",factory:function bS(){return`${Oy()}${Oy()}${Oy()}`}});function Oy(){return String.fromCharCode(97+Math.floor(25*Math.random()))}const wS=new on("Platform Initializer"),_S=new on("Platform ID",{providedIn:"platform",factory:()=>"unknown"}),Jk=new on("appBootstrapListener"),io=new on("LocaleId",{providedIn:"root",factory:()=>function wR(n,e=Mt.Default){return"number"!=typeof e&&(e=0|(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)),Pn(n,e)}(io,Mt.Optional|Mt.SkipSelf)||function eL(){return typeof $localize<"u"&&$localize.locale||Ac}()}),sL=(()=>Promise.resolve(0))();function ky(n){typeof Zone>"u"?sL.then(()=>{n&&n.apply(null,null)}):Zone.current.scheduleMicroTask("scheduleMicrotask",n)}class Gr{constructor({enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:t=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new no(!1),this.onMicrotaskEmpty=new no(!1),this.onStable=new no(!1),this.onError=new no(!1),typeof Zone>"u")throw new Tt(908,!1);Zone.assertZonePatched();const i=this;if(i._nesting=0,i._outer=i._inner=Zone.current,Zone.AsyncStackTaggingZoneSpec){const s=Zone.AsyncStackTaggingZoneSpec;i._inner=i._inner.fork(new s("Angular"))}Zone.TaskTrackingZoneSpec&&(i._inner=i._inner.fork(new Zone.TaskTrackingZoneSpec)),e&&Zone.longStackTraceZoneSpec&&(i._inner=i._inner.fork(Zone.longStackTraceZoneSpec)),i.shouldCoalesceEventChangeDetection=!r&&t,i.shouldCoalesceRunChangeDetection=r,i.lastRequestAnimationFrameId=-1,i.nativeRequestAnimationFrame=function oL(){let n=Fn.requestAnimationFrame,e=Fn.cancelAnimationFrame;if(typeof Zone<"u"&&n&&e){const t=n[Zone.__symbol__("OriginalDelegate")];t&&(n=t);const r=e[Zone.__symbol__("OriginalDelegate")];r&&(e=r)}return{nativeRequestAnimationFrame:n,nativeCancelAnimationFrame:e}}().nativeRequestAnimationFrame,function uL(n){const e=()=>{!function cL(n){n.isCheckStableRunning||-1!==n.lastRequestAnimationFrameId||(n.lastRequestAnimationFrameId=n.nativeRequestAnimationFrame.call(Fn,()=>{n.fakeTopEventTask||(n.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{n.lastRequestAnimationFrameId=-1,By(n),n.isCheckStableRunning=!0,Ly(n),n.isCheckStableRunning=!1},void 0,()=>{},()=>{})),n.fakeTopEventTask.invoke()}),By(n))}(n)};n._inner=n._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(t,r,i,s,o,a)=>{try{return CS(n),t.invokeTask(i,s,o,a)}finally{(n.shouldCoalesceEventChangeDetection&&"eventTask"===s.type||n.shouldCoalesceRunChangeDetection)&&e(),IS(n)}},onInvoke:(t,r,i,s,o,a,l)=>{try{return CS(n),t.invoke(i,s,o,a,l)}finally{n.shouldCoalesceRunChangeDetection&&e(),IS(n)}},onHasTask:(t,r,i,s)=>{t.hasTask(i,s),r===i&&("microTask"==s.change?(n._hasPendingMicrotasks=s.microTask,By(n),Ly(n)):"macroTask"==s.change&&(n.hasPendingMacrotasks=s.macroTask))},onHandleError:(t,r,i,s)=>(t.handleError(i,s),n.runOutsideAngular(()=>n.onError.emit(s)),!1)})}(i)}static isInAngularZone(){return typeof Zone<"u"&&!0===Zone.current.get("isAngularZone")}static assertInAngularZone(){if(!Gr.isInAngularZone())throw new Tt(909,!1)}static assertNotInAngularZone(){if(Gr.isInAngularZone())throw new Tt(909,!1)}run(e,t,r){return this._inner.run(e,t,r)}runTask(e,t,r,i){const s=this._inner,o=s.scheduleEventTask("NgZoneEvent: "+i,e,aL,hd,hd);try{return s.runTask(o,t,r)}finally{s.cancelTask(o)}}runGuarded(e,t,r){return this._inner.runGuarded(e,t,r)}runOutsideAngular(e){return this._outer.run(e)}}const aL={};function Ly(n){if(0==n._nesting&&!n.hasPendingMicrotasks&&!n.isStable)try{n._nesting++,n.onMicrotaskEmpty.emit(null)}finally{if(n._nesting--,!n.hasPendingMicrotasks)try{n.runOutsideAngular(()=>n.onStable.emit(null))}finally{n.isStable=!0}}}function By(n){n.hasPendingMicrotasks=!!(n._hasPendingMicrotasks||(n.shouldCoalesceEventChangeDetection||n.shouldCoalesceRunChangeDetection)&&-1!==n.lastRequestAnimationFrameId)}function CS(n){n._nesting++,n.isStable&&(n.isStable=!1,n.onUnstable.emit(null))}function IS(n){n._nesting--,Ly(n)}class lL{constructor(){this.hasPendingMicrotasks=!1,this.hasPendingMacrotasks=!1,this.isStable=!0,this.onUnstable=new no,this.onMicrotaskEmpty=new no,this.onStable=new no,this.onError=new no}run(e,t,r){return e.apply(t,r)}runGuarded(e,t,r){return e.apply(t,r)}runOutsideAngular(e){return e()}runTask(e,t,r,i){return e.apply(t,r)}}const TS=new on(""),gd=new on("");let Vy,Fy=(()=>{class n{constructor(t,r,i){this._ngZone=t,this.registry=r,this._pendingCount=0,this._isZoneStable=!0,this._didWork=!1,this._callbacks=[],this.taskTrackingZone=null,Vy||(function fL(n){Vy=n}(i),i.addToWindow(r)),this._watchAngularEvents(),t.run(()=>{this.taskTrackingZone=typeof Zone>"u"?null:Zone.current.get("TaskTrackingZone")})}_watchAngularEvents(){this._ngZone.onUnstable.subscribe({next:()=>{this._didWork=!0,this._isZoneStable=!1}}),this._ngZone.runOutsideAngular(()=>{this._ngZone.onStable.subscribe({next:()=>{Gr.assertNotInAngularZone(),ky(()=>{this._isZoneStable=!0,this._runCallbacksIfReady()})}})})}increasePendingRequestCount(){return this._pendingCount+=1,this._didWork=!0,this._pendingCount}decreasePendingRequestCount(){if(this._pendingCount-=1,this._pendingCount<0)throw new Error("pending async requests below zero");return this._runCallbacksIfReady(),this._pendingCount}isStable(){return this._isZoneStable&&0===this._pendingCount&&!this._ngZone.hasPendingMacrotasks}_runCallbacksIfReady(){if(this.isStable())ky(()=>{for(;0!==this._callbacks.length;){let t=this._callbacks.pop();clearTimeout(t.timeoutId),t.doneCb(this._didWork)}this._didWork=!1});else{let t=this.getPendingTasks();this._callbacks=this._callbacks.filter(r=>!r.updateCb||!r.updateCb(t)||(clearTimeout(r.timeoutId),!1)),this._didWork=!0}}getPendingTasks(){return this.taskTrackingZone?this.taskTrackingZone.macroTasks.map(t=>({source:t.source,creationLocation:t.creationLocation,data:t.data})):[]}addCallback(t,r,i){let s=-1;r&&r>0&&(s=setTimeout(()=>{this._callbacks=this._callbacks.filter(o=>o.timeoutId!==s),t(this._didWork,this.getPendingTasks())},r)),this._callbacks.push({doneCb:t,timeoutId:s,updateCb:i})}whenStable(t,r,i){if(i&&!this.taskTrackingZone)throw new Error('Task tracking zone is required when passing an update callback to whenStable(). Is "zone.js/plugins/task-tracking" loaded?');this.addCallback(t,r,i),this._runCallbacksIfReady()}getPendingRequestCount(){return this._pendingCount}registerApplication(t){this.registry.registerApplication(t,this)}unregisterApplication(t){this.registry.unregisterApplication(t)}findProviders(t,r,i){return[]}}return n.\u0275fac=function(t){return new(t||n)(Pn(Gr),Pn(Uy),Pn(gd))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})(),Uy=(()=>{class n{constructor(){this._applications=new Map}registerApplication(t,r){this._applications.set(t,r)}unregisterApplication(t){this._applications.delete(t)}unregisterAllApplications(){this._applications.clear()}getTestability(t){return this._applications.get(t)||null}getAllTestabilities(){return Array.from(this._applications.values())}getAllRootElements(){return Array.from(this._applications.keys())}findTestabilityInTree(t,r=!0){return Vy?.findTestabilityInTree(this,t,r)??null}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})(),Oo=null;const AS=new on("AllowMultipleToken"),Hy=new on("PlatformDestroyListeners");function RS(n,e,t=[]){const r=`Platform: ${e}`,i=new on(r);return(s=[])=>{let o=Ky();if(!o||o.injector.get(AS,!1)){const a=[...t,...s,{provide:i,useValue:!0}];n?n(a):function pL(n){if(Oo&&!Oo.get(AS,!1))throw new Tt(400,!1);Oo=n;const e=n.get(NS);(function xS(n){const e=n.get(wS,null);e&&e.forEach(t=>t())})(n)}(function PS(n=[],e){return ma.create({name:e,providers:[{provide:ig,useValue:"platform"},{provide:Hy,useValue:new Set([()=>Oo=null])},...n]})}(a,r))}return function yL(n){const e=Ky();if(!e)throw new Tt(401,!1);return e}()}}function Ky(){return Oo?.get(NS)??null}let NS=(()=>{class n{constructor(t){this._injector=t,this._modules=[],this._destroyListeners=[],this._destroyed=!1}bootstrapModuleFactory(t,r){const i=function OS(n,e){let t;return t="noop"===n?new lL:("zone.js"===n?void 0:n)||new Gr(e),t}(r?.ngZone,function MS(n){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:!(!n||!n.ngZoneEventCoalescing)||!1,shouldCoalesceRunChangeDetection:!(!n||!n.ngZoneRunCoalescing)||!1}}(r)),s=[{provide:Gr,useValue:i}];return i.run(()=>{const o=ma.create({providers:s,parent:this.injector,name:t.moduleType.name}),a=t.create(o),l=a.injector.get(lc,null);if(!l)throw new Tt(402,!1);return i.runOutsideAngular(()=>{const _=i.onError.subscribe({next:R=>{l.handleError(R)}});a.onDestroy(()=>{yd(this._modules,a),_.unsubscribe()})}),function kS(n,e,t){try{const r=t();return cy(r)?r.catch(i=>{throw e.runOutsideAngular(()=>n.handleError(i)),i}):r}catch(r){throw e.runOutsideAngular(()=>n.handleError(r)),r}}(l,i,()=>{const _=a.injector.get(pd);return _.runInitializers(),_.donePromise.then(()=>(function uD(n){Ci(n,"Expected localeId to be defined"),"string"==typeof n&&(cD=n.toLowerCase().replace(/_/g,"-"))}(a.injector.get(io,Ac)||Ac),this._moduleDoBootstrap(a),a))})})}bootstrapModule(t,r=[]){const i=LS({},r);return function dL(n,e,t){const r=new by(t);return Promise.resolve(r)}(0,0,t).then(s=>this.bootstrapModuleFactory(s,i))}_moduleDoBootstrap(t){const r=t.injector.get($y);if(t._bootstrapComponents.length>0)t._bootstrapComponents.forEach(i=>r.bootstrap(i));else{if(!t.instance.ngDoBootstrap)throw new Tt(403,!1);t.instance.ngDoBootstrap(r)}this._modules.push(t)}onDestroy(t){this._destroyListeners.push(t)}get injector(){return this._injector}destroy(){if(this._destroyed)throw new Tt(404,!1);this._modules.slice().forEach(r=>r.destroy()),this._destroyListeners.forEach(r=>r());const t=this._injector.get(Hy,null);t&&(t.forEach(r=>r()),t.clear()),this._destroyed=!0}get destroyed(){return this._destroyed}}return n.\u0275fac=function(t){return new(t||n)(Pn(ma))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})();function LS(n,e){return Array.isArray(e)?e.reduce(LS,n):{...n,...e}}let $y=(()=>{class n{constructor(t,r,i){this._zone=t,this._injector=r,this._exceptionHandler=i,this._bootstrapListeners=[],this._views=[],this._runningTick=!1,this._stable=!0,this._destroyed=!1,this._destroyListeners=[],this.componentTypes=[],this.components=[],this._onMicrotaskEmptySubscription=this._zone.onMicrotaskEmpty.subscribe({next:()=>{this._zone.run(()=>{this.tick()})}});const s=new Xe(a=>{this._stable=this._zone.isStable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks,this._zone.runOutsideAngular(()=>{a.next(this._stable),a.complete()})}),o=new Xe(a=>{let l;this._zone.runOutsideAngular(()=>{l=this._zone.onStable.subscribe(()=>{Gr.assertNotInAngularZone(),ky(()=>{!this._stable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks&&(this._stable=!0,a.next(!0))})})});const _=this._zone.onUnstable.subscribe(()=>{Gr.assertInAngularZone(),this._stable&&(this._stable=!1,this._zone.runOutsideAngular(()=>{a.next(!1)}))});return()=>{l.unsubscribe(),_.unsubscribe()}});this.isStable=ei(s,o.pipe(function ns(n={}){const{connector:e=(()=>new pr),resetOnError:t=!0,resetOnComplete:r=!0,resetOnRefCountZero:i=!0}=n;return s=>{let o,a,l,_=0,R=!1,N=!1;const B=()=>{a?.unsubscribe(),a=void 0},z=()=>{B(),o=l=void 0,R=N=!1},Z=()=>{const J=o;z(),J?.unsubscribe()};return fe((J,se)=>{_++,!N&&!R&&B();const he=l=l??e();se.add(()=>{_--,0===_&&!N&&!R&&(a=Io(Z,i))}),he.subscribe(se),!o&&_>0&&(o=new be({next:Te=>he.next(Te),error:Te=>{N=!0,B(),a=Io(z,t,Te),he.error(Te)},complete:()=>{R=!0,B(),a=Io(z,r),he.complete()}}),yn(J).subscribe(o))})(s)}}()))}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(t,r){const i=t instanceof Aw;if(!this._injector.get(pd).done)throw!i&&function wu(n){const e=Nn(n)||ni(n)||ri(n);return null!==e&&e.standalone}(t),new Tt(405,false);let o;o=i?t:this._injector.get(Kf).resolveComponentFactory(t),this.componentTypes.push(o.componentType);const a=function hL(n){return n.isBoundToModule}(o)?void 0:this._injector.get(xc),_=o.create(ma.NULL,[],r||o.selector,a),R=_.location.nativeElement,N=_.injector.get(TS,null);return N?.registerApplication(R),_.onDestroy(()=>{this.detachView(_.hostView),yd(this.components,_),N?.unregisterApplication(R)}),this._loadComponent(_),_}tick(){if(this._runningTick)throw new Tt(101,!1);try{this._runningTick=!0;for(let t of this._views)t.detectChanges()}catch(t){this._zone.runOutsideAngular(()=>this._exceptionHandler.handleError(t))}finally{this._runningTick=!1}}attachView(t){const r=t;this._views.push(r),r.attachToAppRef(this)}detachView(t){const r=t;yd(this._views,r),r.detachFromAppRef()}_loadComponent(t){this.attachView(t.hostView),this.tick(),this.components.push(t),this._injector.get(Jk,[]).concat(this._bootstrapListeners).forEach(i=>i(t))}ngOnDestroy(){if(!this._destroyed)try{this._destroyListeners.forEach(t=>t()),this._views.slice().forEach(t=>t.destroy()),this._onMicrotaskEmptySubscription.unsubscribe()}finally{this._destroyed=!0,this._views=[],this._bootstrapListeners=[],this._destroyListeners=[]}}onDestroy(t){return this._destroyListeners.push(t),()=>yd(this._destroyListeners,t)}destroy(){if(this._destroyed)throw new Tt(406,!1);const t=this._injector;t.destroy&&!t.destroyed&&t.destroy()}get viewCount(){return this._views.length}warnIfDestroyed(){}}return n.\u0275fac=function(t){return new(t||n)(Pn(Gr),Pn(oc),Pn(lc))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function yd(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}let FS=!0;class $S{constructor(){}supports(e){return qu(e)}create(e){return new TL(e)}}const IL=(n,e)=>e;class TL{constructor(e){this.length=0,this._linkedRecords=null,this._unlinkedRecords=null,this._previousItHead=null,this._itHead=null,this._itTail=null,this._additionsHead=null,this._additionsTail=null,this._movesHead=null,this._movesTail=null,this._removalsHead=null,this._removalsTail=null,this._identityChangesHead=null,this._identityChangesTail=null,this._trackByFn=e||IL}forEachItem(e){let t;for(t=this._itHead;null!==t;t=t._next)e(t)}forEachOperation(e){let t=this._itHead,r=this._removalsHead,i=0,s=null;for(;t||r;){const o=!r||t&&t.currentIndex{o=this._trackByFn(i,a),null!==t&&Object.is(t.trackById,o)?(r&&(t=this._verifyReinsertion(t,a,o,i)),Object.is(t.item,a)||this._addIdentityChange(t,a)):(t=this._mismatch(t,a,o,i),r=!0),t=t._next,i++}),this.length=i;return this._truncate(t),this.collection=e,this.isDirty}get isDirty(){return null!==this._additionsHead||null!==this._movesHead||null!==this._removalsHead||null!==this._identityChangesHead}_reset(){if(this.isDirty){let e;for(e=this._previousItHead=this._itHead;null!==e;e=e._next)e._nextPrevious=e._next;for(e=this._additionsHead;null!==e;e=e._nextAdded)e.previousIndex=e.currentIndex;for(this._additionsHead=this._additionsTail=null,e=this._movesHead;null!==e;e=e._nextMoved)e.previousIndex=e.currentIndex;this._movesHead=this._movesTail=null,this._removalsHead=this._removalsTail=null,this._identityChangesHead=this._identityChangesTail=null}}_mismatch(e,t,r,i){let s;return null===e?s=this._itTail:(s=e._prev,this._remove(e)),null!==(e=null===this._unlinkedRecords?null:this._unlinkedRecords.get(r,null))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._reinsertAfter(e,s,i)):null!==(e=null===this._linkedRecords?null:this._linkedRecords.get(r,i))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._moveAfter(e,s,i)):e=this._addAfter(new AL(t,r),s,i),e}_verifyReinsertion(e,t,r,i){let s=null===this._unlinkedRecords?null:this._unlinkedRecords.get(r,null);return null!==s?e=this._reinsertAfter(s,e._prev,i):e.currentIndex!=i&&(e.currentIndex=i,this._addToMoves(e,i)),e}_truncate(e){for(;null!==e;){const t=e._next;this._addToRemovals(this._unlink(e)),e=t}null!==this._unlinkedRecords&&this._unlinkedRecords.clear(),null!==this._additionsTail&&(this._additionsTail._nextAdded=null),null!==this._movesTail&&(this._movesTail._nextMoved=null),null!==this._itTail&&(this._itTail._next=null),null!==this._removalsTail&&(this._removalsTail._nextRemoved=null),null!==this._identityChangesTail&&(this._identityChangesTail._nextIdentityChange=null)}_reinsertAfter(e,t,r){null!==this._unlinkedRecords&&this._unlinkedRecords.remove(e);const i=e._prevRemoved,s=e._nextRemoved;return null===i?this._removalsHead=s:i._nextRemoved=s,null===s?this._removalsTail=i:s._prevRemoved=i,this._insertAfter(e,t,r),this._addToMoves(e,r),e}_moveAfter(e,t,r){return this._unlink(e),this._insertAfter(e,t,r),this._addToMoves(e,r),e}_addAfter(e,t,r){return this._insertAfter(e,t,r),this._additionsTail=null===this._additionsTail?this._additionsHead=e:this._additionsTail._nextAdded=e,e}_insertAfter(e,t,r){const i=null===t?this._itHead:t._next;return e._next=i,e._prev=t,null===i?this._itTail=e:i._prev=e,null===t?this._itHead=e:t._next=e,null===this._linkedRecords&&(this._linkedRecords=new jS),this._linkedRecords.put(e),e.currentIndex=r,e}_remove(e){return this._addToRemovals(this._unlink(e))}_unlink(e){null!==this._linkedRecords&&this._linkedRecords.remove(e);const t=e._prev,r=e._next;return null===t?this._itHead=r:t._next=r,null===r?this._itTail=t:r._prev=t,e}_addToMoves(e,t){return e.previousIndex===t||(this._movesTail=null===this._movesTail?this._movesHead=e:this._movesTail._nextMoved=e),e}_addToRemovals(e){return null===this._unlinkedRecords&&(this._unlinkedRecords=new jS),this._unlinkedRecords.put(e),e.currentIndex=null,e._nextRemoved=null,null===this._removalsTail?(this._removalsTail=this._removalsHead=e,e._prevRemoved=null):(e._prevRemoved=this._removalsTail,this._removalsTail=this._removalsTail._nextRemoved=e),e}_addIdentityChange(e,t){return e.item=t,this._identityChangesTail=null===this._identityChangesTail?this._identityChangesHead=e:this._identityChangesTail._nextIdentityChange=e,e}}class AL{constructor(e,t){this.item=e,this.trackById=t,this.currentIndex=null,this.previousIndex=null,this._nextPrevious=null,this._prev=null,this._next=null,this._prevDup=null,this._nextDup=null,this._prevRemoved=null,this._nextRemoved=null,this._nextAdded=null,this._nextMoved=null,this._nextIdentityChange=null}}class xL{constructor(){this._head=null,this._tail=null}add(e){null===this._head?(this._head=this._tail=e,e._nextDup=null,e._prevDup=null):(this._tail._nextDup=e,e._prevDup=this._tail,e._nextDup=null,this._tail=e)}get(e,t){let r;for(r=this._head;null!==r;r=r._nextDup)if((null===t||t<=r.currentIndex)&&Object.is(r.trackById,e))return r;return null}remove(e){const t=e._prevDup,r=e._nextDup;return null===t?this._head=r:t._nextDup=r,null===r?this._tail=t:r._prevDup=t,null===this._head}}class jS{constructor(){this.map=new Map}put(e){const t=e.trackById;let r=this.map.get(t);r||(r=new xL,this.map.set(t,r)),r.add(e)}get(e,t){const i=this.map.get(e);return i?i.get(e,t):null}remove(e){const t=e.trackById;return this.map.get(t).remove(e)&&this.map.delete(t),e}get isEmpty(){return 0===this.map.size}clear(){this.map.clear()}}function zS(n,e,t){const r=n.previousIndex;if(null===r)return r;let i=0;return t&&r{class n{constructor(t){this.factories=t}static create(t,r){if(null!=r){const i=r.factories.slice();t=t.concat(i)}return new n(t)}static extend(t){return{provide:n,useFactory:r=>n.create(t,r||WS()),deps:[[n,new Of,new Mf]]}}find(t){const r=this.factories.find(i=>i.supports(t));if(null!=r)return r;throw new Tt(901,!1)}}return n.\u0275prov=Wn({token:n,providedIn:"root",factory:WS}),n})();const OL=RS(null,"core",[]);let kL=(()=>{class n{constructor(t){}}return n.\u0275fac=function(t){return new(t||n)(Pn($y))},n.\u0275mod=bu({type:n}),n.\u0275inj=Ka({}),n})(),bd=null;function al(){return bd}const oo=new on("DocumentToken");class I8{constructor(e,t,r,i){this.$implicit=e,this.ngForOf=t,this.index=r,this.count=i}get first(){return 0===this.index}get last(){return this.index===this.count-1}get even(){return this.index%2==0}get odd(){return!this.even}}let oC=(()=>{class n{constructor(t,r,i){this._viewContainer=t,this._template=r,this._differs=i,this._ngForOf=null,this._ngForOfDirty=!0,this._differ=null}set ngForOf(t){this._ngForOf=t,this._ngForOfDirty=!0}set ngForTrackBy(t){this._trackByFn=t}get ngForTrackBy(){return this._trackByFn}set ngForTemplate(t){t&&(this._template=t)}ngDoCheck(){if(this._ngForOfDirty){this._ngForOfDirty=!1;const t=this._ngForOf;!this._differ&&t&&(this._differ=this._differs.find(t).create(this.ngForTrackBy))}if(this._differ){const t=this._differ.diff(this._ngForOf);t&&this._applyChanges(t)}}_applyChanges(t){const r=this._viewContainer;t.forEachOperation((i,s,o)=>{if(null==i.previousIndex)r.createEmbeddedView(this._template,new I8(i.item,this._ngForOf,-1,-1),null===o?void 0:o);else if(null==o)r.remove(null===s?void 0:s);else if(null!==s){const a=r.get(s);r.move(a,o),aC(a,i)}});for(let i=0,s=r.length;i{aC(r.get(i.currentIndex),i)})}static ngTemplateContextGuard(t,r){return!0}}return n.\u0275fac=function(t){return new(t||n)(Zt(Ms),Zt(ro),Zt(Ed))},n.\u0275dir=Fi({type:n,selectors:[["","ngFor","","ngForOf",""]],inputs:{ngForOf:"ngForOf",ngForTrackBy:"ngForTrackBy",ngForTemplate:"ngForTemplate"},standalone:!0}),n})();function aC(n,e){n.context.$implicit=e.item}let n4=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=bu({type:n}),n.\u0275inj=Ka({}),n})();class l0 extends class I4 extends class FL{}{constructor(){super(...arguments),this.supportsDOMEvents=!0}}{static makeCurrent(){!function BL(n){bd||(bd=n)}(new l0)}onAndCancel(e,t,r){return e.addEventListener(t,r,!1),()=>{e.removeEventListener(t,r,!1)}}dispatchEvent(e,t){e.dispatchEvent(t)}remove(e){e.parentNode&&e.parentNode.removeChild(e)}createElement(e,t){return(t=t||this.getDefaultDocument()).createElement(e)}createHtmlDocument(){return document.implementation.createHTMLDocument("fakeTitle")}getDefaultDocument(){return document}isElementNode(e){return e.nodeType===Node.ELEMENT_NODE}isShadowRoot(e){return e instanceof DocumentFragment}getGlobalEventTarget(e,t){return"window"===t?window:"document"===t?e:"body"===t?e.body:null}getBaseHref(e){const t=function T4(){return fl=fl||document.querySelector("base"),fl?fl.getAttribute("href"):null}();return null==t?null:function A4(n){Pd=Pd||document.createElement("a"),Pd.setAttribute("href",n);const e=Pd.pathname;return"/"===e.charAt(0)?e:`/${e}`}(t)}resetBaseElement(){fl=null}getUserAgent(){return window.navigator.userAgent}getCookie(e){return function D8(n,e){e=encodeURIComponent(e);for(const t of n.split(";")){const r=t.indexOf("="),[i,s]=-1==r?[t,""]:[t.slice(0,r),t.slice(r+1)];if(i.trim()===e)return decodeURIComponent(s)}return null}(document.cookie,e)}}let Pd,fl=null;const yC=new on("TRANSITION_ID"),R4=[{provide:ES,useFactory:function x4(n,e,t){return()=>{t.get(pd).donePromise.then(()=>{const r=al(),i=e.querySelectorAll(`style[ng-transition="${n}"]`);for(let s=0;s{class n{build(){return new XMLHttpRequest}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();const Nd=new on("EventManagerPlugins");let Md=(()=>{class n{constructor(t,r){this._zone=r,this._eventNameToPlugin=new Map,t.forEach(i=>i.manager=this),this._plugins=t.slice().reverse()}addEventListener(t,r,i){return this._findPluginFor(r).addEventListener(t,r,i)}addGlobalEventListener(t,r,i){return this._findPluginFor(r).addGlobalEventListener(t,r,i)}getZone(){return this._zone}_findPluginFor(t){const r=this._eventNameToPlugin.get(t);if(r)return r;const i=this._plugins;for(let s=0;s{class n{constructor(){this._stylesSet=new Set}addStyles(t){const r=new Set;t.forEach(i=>{this._stylesSet.has(i)||(this._stylesSet.add(i),r.add(i))}),this.onStylesAdded(r)}onStylesAdded(t){}getAllStyles(){return Array.from(this._stylesSet)}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})(),dl=(()=>{class n extends vC{constructor(t){super(),this._doc=t,this._hostNodes=new Map,this._hostNodes.set(t.head,[])}_addStylesToHost(t,r,i){t.forEach(s=>{const o=this._doc.createElement("style");o.textContent=s,i.push(r.appendChild(o))})}addHost(t){const r=[];this._addStylesToHost(this._stylesSet,t,r),this._hostNodes.set(t,r)}removeHost(t){const r=this._hostNodes.get(t);r&&r.forEach(EC),this._hostNodes.delete(t)}onStylesAdded(t){this._hostNodes.forEach((r,i)=>{this._addStylesToHost(t,i,r)})}ngOnDestroy(){this._hostNodes.forEach(t=>t.forEach(EC))}}return n.\u0275fac=function(t){return new(t||n)(Pn(oo))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();function EC(n){al().remove(n)}const f0={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/",math:"http://www.w3.org/1998/MathML/"},d0=/%COMP%/g;function Od(n,e,t){for(let r=0;r{if("__ngUnwrap__"===e)return n;!1===n(e)&&(e.preventDefault(),e.returnValue=!1)}}let h0=(()=>{class n{constructor(t,r,i){this.eventManager=t,this.sharedStylesHost=r,this.appId=i,this.rendererByCompId=new Map,this.defaultRenderer=new p0(t)}createRenderer(t,r){if(!t||!r)return this.defaultRenderer;switch(r.encapsulation){case Is.Emulated:{let i=this.rendererByCompId.get(r.id);return i||(i=new F4(this.eventManager,this.sharedStylesHost,r,this.appId),this.rendererByCompId.set(r.id,i)),i.applyToHost(t),i}case 1:case Is.ShadowDom:return new U4(this.eventManager,this.sharedStylesHost,t,r);default:if(!this.rendererByCompId.has(r.id)){const i=Od(r.id,r.styles,[]);this.sharedStylesHost.addStyles(i),this.rendererByCompId.set(r.id,this.defaultRenderer)}return this.defaultRenderer}}begin(){}end(){}}return n.\u0275fac=function(t){return new(t||n)(Pn(Md),Pn(dl),Pn(sl))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();class p0{constructor(e){this.eventManager=e,this.data=Object.create(null),this.destroyNode=null}destroy(){}createElement(e,t){return t?document.createElementNS(f0[t]||t,e):document.createElement(e)}createComment(e){return document.createComment(e)}createText(e){return document.createTextNode(e)}appendChild(e,t){(SC(e)?e.content:e).appendChild(t)}insertBefore(e,t,r){e&&(SC(e)?e.content:e).insertBefore(t,r)}removeChild(e,t){e&&e.removeChild(t)}selectRootElement(e,t){let r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error(`The selector "${e}" did not match any elements`);return t||(r.textContent=""),r}parentNode(e){return e.parentNode}nextSibling(e){return e.nextSibling}setAttribute(e,t,r,i){if(i){t=i+":"+t;const s=f0[i];s?e.setAttributeNS(s,t,r):e.setAttribute(t,r)}else e.setAttribute(t,r)}removeAttribute(e,t,r){if(r){const i=f0[r];i?e.removeAttributeNS(i,t):e.removeAttribute(`${r}:${t}`)}else e.removeAttribute(t)}addClass(e,t){e.classList.add(t)}removeClass(e,t){e.classList.remove(t)}setStyle(e,t,r,i){i&(gi.DashCase|gi.Important)?e.style.setProperty(t,r,i&gi.Important?"important":""):e.style[t]=r}removeStyle(e,t,r){r&gi.DashCase?e.style.removeProperty(t):e.style[t]=""}setProperty(e,t,r){e[t]=r}setValue(e,t){e.nodeValue=t}listen(e,t,r){return"string"==typeof e?this.eventManager.addGlobalEventListener(e,t,_C(r)):this.eventManager.addEventListener(e,t,_C(r))}}function SC(n){return"TEMPLATE"===n.tagName&&void 0!==n.content}class F4 extends p0{constructor(e,t,r,i){super(e),this.component=r;const s=Od(i+"-"+r.id,r.styles,[]);t.addStyles(s),this.contentAttr=function k4(n){return"_ngcontent-%COMP%".replace(d0,n)}(i+"-"+r.id),this.hostAttr=function L4(n){return"_nghost-%COMP%".replace(d0,n)}(i+"-"+r.id)}applyToHost(e){super.setAttribute(e,this.hostAttr,"")}createElement(e,t){const r=super.createElement(e,t);return super.setAttribute(r,this.contentAttr,""),r}}class U4 extends p0{constructor(e,t,r,i){super(e),this.sharedStylesHost=t,this.hostEl=r,this.shadowRoot=r.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);const s=Od(i.id,i.styles,[]);for(let o=0;o{class n extends mC{constructor(t){super(t)}supports(t){return!0}addEventListener(t,r,i){return t.addEventListener(r,i,!1),()=>this.removeEventListener(t,r,i)}removeEventListener(t,r,i){return t.removeEventListener(r,i)}}return n.\u0275fac=function(t){return new(t||n)(Pn(oo))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();const CC=["alt","control","meta","shift"],H4={"\b":"Backspace","\t":"Tab","\x7f":"Delete","\x1b":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},K4={alt:n=>n.altKey,control:n=>n.ctrlKey,meta:n=>n.metaKey,shift:n=>n.shiftKey};let $4=(()=>{class n extends mC{constructor(t){super(t)}supports(t){return null!=n.parseEventName(t)}addEventListener(t,r,i){const s=n.parseEventName(r),o=n.eventCallback(s.fullKey,i,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>al().onAndCancel(t,s.domEventName,o))}static parseEventName(t){const r=t.toLowerCase().split("."),i=r.shift();if(0===r.length||"keydown"!==i&&"keyup"!==i)return null;const s=n._normalizeKey(r.pop());let o="",a=r.indexOf("code");if(a>-1&&(r.splice(a,1),o="code."),CC.forEach(_=>{const R=r.indexOf(_);R>-1&&(r.splice(R,1),o+=_+".")}),o+=s,0!=r.length||0===s.length)return null;const l={};return l.domEventName=i,l.fullKey=o,l}static matchEventFullKeyCode(t,r){let i=H4[t.key]||t.key,s="";return r.indexOf("code.")>-1&&(i=t.code,s="code."),!(null==i||!i)&&(i=i.toLowerCase()," "===i?i="space":"."===i&&(i="dot"),CC.forEach(o=>{o!==i&&(0,K4[o])(t)&&(s+=o+".")}),s+=i,s===r)}static eventCallback(t,r,i){return s=>{n.matchEventFullKeyCode(s,t)&&i.runGuarded(()=>r(s))}}static _normalizeKey(t){return"esc"===t?"escape":t}}return n.\u0275fac=function(t){return new(t||n)(Pn(oo))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();const TC=[{provide:_S,useValue:"browser"},{provide:wS,useValue:function j4(){l0.makeCurrent()},multi:!0},{provide:oo,useFactory:function G4(){return function OR(n){Yp=n}(document),document},deps:[]}],W4=RS(OL,"browser",TC),AC=new on(""),xC=[{provide:gd,useClass:class P4{addToWindow(e){Fn.getAngularTestability=(r,i=!0)=>{const s=e.findTestabilityInTree(r,i);if(null==s)throw new Error("Could not find testability for element.");return s},Fn.getAllAngularTestabilities=()=>e.getAllTestabilities(),Fn.getAllAngularRootElements=()=>e.getAllRootElements(),Fn.frameworkStabilizers||(Fn.frameworkStabilizers=[]),Fn.frameworkStabilizers.push(r=>{const i=Fn.getAllAngularTestabilities();let s=i.length,o=!1;const a=function(l){o=o||l,s--,0==s&&r(o)};i.forEach(function(l){l.whenStable(a)})})}findTestabilityInTree(e,t,r){return null==t?null:e.getTestability(t)??(r?al().isShadowRoot(t)?this.findTestabilityInTree(e,t.host,!0):this.findTestabilityInTree(e,t.parentElement,!0):null)}},deps:[]},{provide:TS,useClass:Fy,deps:[Gr,Uy,gd]},{provide:Fy,useClass:Fy,deps:[Gr,Uy,gd]}],RC=[{provide:ig,useValue:"root"},{provide:lc,useFactory:function z4(){return new lc},deps:[]},{provide:Nd,useClass:V4,multi:!0,deps:[oo,Gr,_S]},{provide:Nd,useClass:$4,multi:!0,deps:[oo]},{provide:h0,useClass:h0,deps:[Md,dl,sl]},{provide:Rw,useExisting:h0},{provide:vC,useExisting:dl},{provide:dl,useClass:dl,deps:[oo]},{provide:Md,useClass:Md,deps:[Nd,Gr]},{provide:class a4{},useClass:N4,deps:[]},[]];let q4=(()=>{class n{constructor(t){}static withServerTransition(t){return{ngModule:n,providers:[{provide:sl,useValue:t.appId},{provide:yC,useExisting:sl},R4]}}}return n.\u0275fac=function(t){return new(t||n)(Pn(AC,12))},n.\u0275mod=bu({type:n}),n.\u0275inj=Ka({providers:[...RC,...xC],imports:[n4,kL]}),n})();typeof window<"u"&&window;class iB extends pr{constructor(e){super(),this._value=e}get value(){return this.getValue()}_subscribe(e){const t=super._subscribe(e);return!t.closed&&e.next(this._value),t}getValue(){const{hasError:e,thrownError:t,_value:r}=this;if(e)throw t;return this._throwIfClosed(),r}next(e){super.next(this._value=e)}}function MC(n,e,t,r,i,s,o){try{var a=n[s](o),l=a.value}catch(_){return void t(_)}a.done?e(l):Promise.resolve(l).then(r,i)}function $(n){return function(){var e=this,t=arguments;return new Promise(function(r,i){var s=n.apply(e,t);function o(l){MC(s,r,i,o,a,"next",l)}function a(l){MC(s,r,i,o,a,"throw",l)}o(void 0)})}}var sB=x(5705),m0=x(5006),OC=x(893),kC=x(5876);const oB={hashSHA256:n=>(0,OC.vp)(n),getHKDF(n,e){const i=new sB.t(OC.mE,e,n).expand(96);return[i.subarray(0,32),i.subarray(32,64),i.subarray(64,96)]},generateX25519KeyPair(){const n=m0.Au();return{publicKey:n.publicKey,privateKey:n.secretKey}},generateX25519KeyPairFromSeed(n){const e=m0._w(n);return{publicKey:e.publicKey,privateKey:e.secretKey}},generateX25519SharedKey:(n,e)=>m0.gi(n,e),chaCha20Poly1305Encrypt:(n,e,t,r)=>new kC.OK(r).seal(e,n,t),chaCha20Poly1305Decrypt:(n,e,t,r)=>new kC.OK(r).open(e,n,t)};function LC(n){this.wrapped=n}function hl(n){var e,t;function i(o,a){try{var l=n[o](a),_=l.value,R=_ instanceof LC;Promise.resolve(R?_.wrapped:_).then(function(N){R?i("return"===o?"return":"next",N):s(l.done?"return":"normal",N)},function(N){i("throw",N)})}catch(N){s("throw",N)}}function s(o,a){switch(o){case"return":e.resolve({value:a,done:!0});break;case"throw":e.reject(a);break;default:e.resolve({value:a,done:!1})}(e=e.next)?i(e.key,e.arg):t=null}this._invoke=function r(o,a){return new Promise(function(l,_){var R={key:o,arg:a,resolve:l,reject:_,next:null};t?t=t.next=R:(e=t=R,i(o,a))})},"function"!=typeof n.return&&(this.return=void 0)}function hn(n){return function(){return new hl(n.apply(this,arguments))}}function lt(n){return new LC(n)}function Pt(n){var e,t,r,i=2;for(typeof Symbol<"u"&&(t=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(t&&null!=(e=n[t]))return e.call(n);if(r&&null!=(e=n[r]))return new kd(e.call(n));t="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function kd(n){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var r=t.done;return Promise.resolve(t.value).then(function(i){return{value:i,done:r}})}return(kd=function(r){this.s=r,this.n=r.next}).prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(r){var i=this.s.return;return void 0===i?Promise.resolve({value:r,done:!0}):e(i.apply(this.s,arguments))},throw:function(r){var i=this.s.return;return void 0===i?Promise.reject(r):e(i.apply(this.s,arguments))}},new kd(n)}function Mr(n,e){var t={},r=!1;function i(s,o){return r=!0,o=new Promise(function(a){a(n[s](o))}),{done:!1,value:e(o)}}return t[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},t.next=function(s){return r?(r=!1,s):i("next",s)},"function"==typeof n.throw&&(t.throw=function(s){if(r)throw r=!1,s;return i("throw",s)}),"function"==typeof n.return&&(t.return=function(s){return r?(r=!1,s):i("return",s)}),t}function Lo(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.alloc?globalThis.Buffer.alloc(n):new Uint8Array(n)}function Nc(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}function br(n,e){e||(e=n.reduce((i,s)=>i+s.length,0));const t=Nc(e);let r=0;for(const i of n)t.set(i,r),r+=i.length;return t}function kr(n,e){if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(const r of e)if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.push(r);else{if(!v0(r))throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.push(...r.bufs)}this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(const r of e.reverse())if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.unshift(r);else{if(!v0(r))throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.unshift(...r.bufs)}this.length+=t}get(e){const t=FC(this.bufs,e);return t.buf[t.index]}set(e,t){const r=FC(this.bufs,e);r.buf[r.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let r=0;r0;){if(!(e>=this.bufs[0].byteLength)){this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift()}}slice(e,t){const{bufs:r,length:i}=this._subList(e,t);return br(r,i)}subarray(e,t){const{bufs:r,length:i}=this._subList(e,t);return 1===r.length?r[0]:br(r,i)}sublist(e,t){const{bufs:r,length:i}=this._subList(e,t),s=new qr;return s.length=i,s.bufs=r,s}_subList(e,t){if((e=e??0)<0&&(e=this.length+e),(t=t??this.length)<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:[...this.bufs],length:this.length};const r=[];let i=0;for(let s=0;s=l)continue;const _=e>=a&&ea&&t<=l;if(_&&R){if(e===a&&t===l){r.push(o);break}const N=e-a;r.push(o.subarray(N,N+(t-e)));break}if(_){if(0===e){r.push(o);continue}r.push(o.subarray(e-a))}else{if(R){if(t===l){r.push(o);break}r.push(o.subarray(0,t-a));break}r.push(o)}}return{bufs:r,length:t-e}}getInt8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=Nc(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}getInt16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}setInt16(e,t,r){const i=Lo(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,t,r),this.write(i,e)}getInt32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}setInt32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,t,r),this.write(i,e)}getBigInt64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}setBigInt64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,t,r),this.write(i,e)}getUint8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){const r=Nc(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}getUint16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}setUint16(e,t,r){const i=Lo(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,t,r),this.write(i,e)}getUint32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}setUint32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,t,r),this.write(i,e)}getBigUint64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}setBigUint64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,t,r),this.write(i,e)}getFloat32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}setFloat32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,t,r),this.write(i,e)}getFloat64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}setFloat64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,r),this.write(i,e)}equals(e){if(null==e||!(e instanceof qr)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;ti+s.byteLength,0)),r.length=t,r}}class UC{constructor(e){if(!(e>0)||0!=(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class E0{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new UC(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=e?.byteLength?e.byteLength:1}push(e){null!=e?.value&&(this.size+=this.calculateSize(e.value)),this.head.push(e)||(this.head=this.head.next=new UC(2*this.head.buffer.length),this.head.push(e))}shift(){let e=this.tail.shift();if(void 0===e&&null!=this.tail.next){const t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return null!=e?.value&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}}function Mc(n={}){return VC(t=>{const r=t.shift();if(null==r)return{done:!0};if(null!=r.error)throw r.error;return{done:!0===r.done,value:r.value}},n)}function VC(n,e){let i,s,o,t=(e=e??{}).onEnd,r=new E0;const a=function(){var J=$(function*(){return r.isEmpty()?o?{done:!0}:yield new Promise((se,he)=>{s=Te=>{s=null,r.push(Te);try{se(n(r))}catch(ue){he(ue)}return i}}):n(r)});return function(){return J.apply(this,arguments)}}(),l=J=>null!=s?s(J):(r.push(J),i),R=J=>{if(o)return i;if(!0!==e?.objectMode&&null==J?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:J})},N=J=>o?i:(o=!0,null!=J?(J=>(r=new E0,null!=s?s({error:J}):(r.push({error:J}),i)))(J):l({done:!0}));if(i={[Symbol.asyncIterator](){return this},next:a,return:()=>(r=new E0,N(),{done:!0}),throw:J=>(N(J),{done:!0}),push:R,end:N,get readableLength(){return r.size}},null==t)return i;const Z=i;return i={[Symbol.asyncIterator](){return this},next:()=>Z.next(),throw:J=>(Z.throw(J),null!=t&&(t(J),t=void 0),{done:!0}),return:()=>(Z.return(),null!=t&&(t(),t=void 0),{done:!0}),push:R,end:J=>(Z.end(J),null!=t&&(t(J),t=void 0),i),get readableLength(){return Z.readableLength}},i}function b0(){const n={};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),n}function Ld(n){const e=Mc(),t=function aB(n){const e=hn(function*(){let t=yield,r=new qr;var o,i=!1,s=!1;try{for(var l,a=Pt(n);i=!(l=yield lt(a.next())).done;i=!1){const _=l.value;if(null!=t)for(r.append(_);r.length>=t;){const R=r.sublist(0,t);if(r.consume(t),t=yield R,null==t){r.length>0&&(t=yield r,r=new qr);break}}else r.append(_),t=yield r,r=new qr}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}if(null!=t)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:r})})();return e.next(),e}(n.source),r=b0();let i;const s=n.sink(hn(function*(){yield*Mr(Pt(e),lt);const a=yield lt(r.promise);yield*Mr(Pt(a),lt)})());s.catch(a=>{i=a});const o={sink:(a=$(function*(l){return null!=i?yield Promise.reject(i):(r.resolve(l),yield s)}),function(_){return a.apply(this,arguments)}),source:t};var a;return{reader:t,writer:e,stream:o,rest:()=>e.end(),write:e.push,read:function(){var a=$(function*(){const l=yield t.next();if(null!=l.value)return l.value});return function(){return a.apply(this,arguments)}}()}}function HC(n){return n instanceof Uint8Array?{get:e=>n[e],set(e,t){n[e]=t}}:{get:e=>n.get(e),set(e,t){n.set(e,t)}}}const KC=4294967296;class zi{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(!0===e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!=0){const t=1+~this.lo>>>0;let r=~this.hi>>>0;return 0===t&&(r=r+1>>>0),-(BigInt(t)+(BigInt(r)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){const e=-(1&this.lo);return new zi((this.hi>>>1^e)>>>0,((this.lo>>>1|this.hi<<31)^e)>>>0)}zzEncode(){const e=this.hi>>31;return new zi(((this.hi<<1|this.lo>>>31)^e)>>>0,(this.lo<<1^e)>>>0)}toBytes(e,t=0){const r=HC(e);for(;this.hi>0;)r.set(t++,127&this.lo|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)r.set(t++,127&this.lo|128),this.lo=this.lo>>>7;r.set(t++,this.lo)}static fromBigInt(e){if(0n===e)return new zi;const t=e<0;t&&(e=-e);let r=0|Number(e>>32n),i=0|Number(e-(BigInt(r)<<32n));return t&&(r=~r>>>0,i=~i>>>0,++i>KC&&(i=0,++r>KC&&(r=0))),new zi(r,i)}static fromNumber(e){if(0===e)return new zi;const t=e<0;t&&(e=-e);let r=e>>>0,i=(e-r)/4294967296>>>0;return t&&(i=~i>>>0,r=~r>>>0,++r>4294967295&&(r=0,++i>4294967295&&(i=0))),new zi(i,r)}static fromBytes(e,t=0){const r=HC(e),i=new zi;let s=0;if(e.length-t>4){for(;s<4;++s)if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i;if(i.lo=(i.lo|(127&r.get(t))<<28)>>>0,i.hi=(i.hi|(127&r.get(t))>>4)>>>0,r.get(t++)<128)return i;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i}if(e.length-t>4){for(;s<5;++s)if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}else if(t=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}throw RangeError("invalid varint encoding")}}const uB=Math.pow(2,7),lB=Math.pow(2,14),fB=Math.pow(2,21),dB=Math.pow(2,28),hB=Math.pow(2,35),pB=Math.pow(2,42),gB=Math.pow(2,49),yB=Math.pow(2,56),mB=Math.pow(2,63),Ni={encodingLength:n=>nNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return null==e&&(e=Nc(Ni.encodingLength(n))),zi.fromNumber(n).toBytes(e,t),e},decode:(n,e=0)=>zi.fromBytes(n,e).toNumber(!0)},Bd=n=>{const e=Ni.encodingLength(n),t=function EB(n){return null!=globalThis?.Buffer?.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}(e);return Ni.encode(n,t),Bd.bytes=e,t};function Os(n){const e=(n=n??{}).lengthEncoder??Bd;return function(){var r=hn(function*(i){var a,s=!1,o=!1;try{for(var _,l=Pt(i);s=!(_=yield lt(l.next())).done;s=!1){const R=_.value,N=e(R.byteLength);N instanceof Uint8Array?yield N:yield*Mr(Pt(N),lt),R instanceof Uint8Array?yield R:yield*Mr(Pt(R),lt)}}catch(R){o=!0,a=R}finally{try{s&&null!=l.return&&(yield lt(l.return()))}finally{if(o)throw a}}});return function(s){return r.apply(this,arguments)}}()}Bd.bytes=0,Os.single=(n,e)=>new qr(((e=e??{}).lengthEncoder??Bd)(n.byteLength),n);var ae=x(2535),Bo=(()=>{return(n=Bo||(Bo={}))[n.LENGTH=0]="LENGTH",n[n.DATA=1]="DATA",Bo;var n})();const w0=n=>{const e=Ni.decode(n);return w0.bytes=Ni.encodingLength(e),e};function ps(n){return function(){var t=hn(function*(r){const i=new qr;let s=Bo.LENGTH,o=-1;const a=n?.lengthDecoder??w0,l=n?.maxLengthLength??8,_=n?.maxDataLength??4194304;var B,R=!1,N=!1;try{for(var Z,z=Pt(r);R=!(Z=yield lt(z.next())).done;R=!1)for(i.append(Z.value);i.byteLength>0;){if(s===Bo.LENGTH)try{if(o=a(i),o<0)throw ae(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>_)throw ae(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");i.consume(a.bytes),null!=n?.onLength&&n.onLength(o),s=Bo.DATA}catch(se){if(se instanceof RangeError){if(i.byteLength>l)throw ae(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw se}if(s===Bo.DATA){if(i.byteLength0)throw ae(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")});return function(i){return t.apply(this,arguments)}}()}function $C(n,e={}){const t=Ld(n),r=ps.fromReader(t.reader,e),i={read:(s=$(function*(o){const{value:a}=yield t.reader.next(o);if(null==a)throw new Error("Value is null");return a}),function(a){return s.apply(this,arguments)}),readLP:function(){var s=$(function*(){const{value:o}=yield r.next();if(null==o)throw new Error("Value is null");return o});return function(){return s.apply(this,arguments)}}(),readPB:function(){var s=$(function*(o){const a=yield i.readLP();if(null==a)throw new Error("Value is null");const l=a instanceof Uint8Array?a:a.slice();return o.decode(l)});return function(a){return s.apply(this,arguments)}}(),write:s=>{s instanceof Uint8Array?t.writer.push(s):t.writer.push(s.slice())},writeLP:s=>{i.write(Os.single(s,e))},writePB:(s,o)=>{i.writeLP(o.encode(s))},pb:s=>{return{read:(o=$(function*(){return yield i.readPB(s)}),function(){return o.apply(this,arguments)}),write:o=>i.writePB(o,s)};var o},unwrap:()=>(t.rest(),t.stream)};var s;return i}function jC(){const n=b0();let e=!1;return{sink:(t=$(function*(r){if(e)throw new Error("already piped");e=!0,n.resolve(r)}),function(i){return t.apply(this,arguments)}),source:hn(function*(){const t=yield lt(n.promise);yield*Mr(Pt(t),lt)})()};var t}w0.bytes=0,ps.fromReader=(n,e)=>{let t=1;const r=hn(function*(){for(;;)try{const{done:s,value:o}=yield lt(n.next(t));if(!0===s)return;null!=o&&(yield o)}catch(s){if("ERR_UNDER_READ"===s.code)return{done:!0,value:null};throw s}finally{t=1}})();return ps({...e??{},onLength:s=>{t=s}})(r)};var Fd=x(5061);const zC=n=>null!=n&&("function"==typeof n[Symbol.asyncIterator]||"function"==typeof n[Symbol.iterator]||"function"==typeof n.next),_0=n=>null!=n&&"function"==typeof n.sink&&zC(n.source),SB=n=>e=>{const t=n.sink(e);if(null!=t.then){const r=Mc({objectMode:!0});return t.then(()=>{r.end()},s=>{r.end(s)}),Fd(r,function(){var s=hn(function*(){yield*Mr(Pt(n.source),lt),r.end()});return function(){return s.apply(this,arguments)}}()())}return n.source};function qn(n,...e){if(_0(n)){const r=n;n=()=>r.source}else if(zC(n)){const r=n;n=()=>r}const t=[n,...e];if(t.length>1&&_0(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let r=1;r{let e;for(;n.length>0;)e=n.shift()(e);return e})(...t)}const pl=65535,CB=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS),Ud=n=>{const e=globalThis.Buffer?globalThis.Buffer.allocUnsafe(2):new Uint8Array(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).setUint16(0,n,!1),e};Ud.bytes=2;const Vd=n=>{if(n.length<2)throw RangeError("Could not decode int16BE");return n instanceof Uint8Array?new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,!1):n.getUint16(0)};Vd.bytes=2;class Hd extends Error{constructor(e="Unexpected Peer"){super(e),this.code=Hd.code}static get code(){return"ERR_UNEXPECTED_PEER"}}class Oc extends Error{constructor(e="Invalid crypto exchange"){super(e),this.code=Oc.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}}Error;var D0=x(3863),S0=x.n(D0);const C0=D0.Reader;function Wt(n,e){const t=C0.create(n instanceof Uint8Array?n:n.subarray());return e.decode(t)}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=C0.prototype[n];C0.prototype[n]=function(){return BigInt(e.call(this).toString())}});const I0=D0.Writer;function qt(n,e){const t=I0.create();return e.encode(n,t,{lengthDelimited:!1}),t.finish()}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=I0.prototype[n];I0.prototype[n]=function(t){return e.call(this,t.toString())}});var gl=(()=>{return(n=gl||(gl={}))[n.VARINT=0]="VARINT",n[n.BIT64=1]="BIT64",n[n.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",n[n.START_GROUP=3]="START_GROUP",n[n.END_GROUP=4]="END_GROUP",n[n.BIT32=5]="BIT32",gl;var n})();function qC(n,e,t,r){return{name:n,type:e,encode:t,decode:r}}function Fo(n){function e(i){if(null==n[i.toString()])throw new Error("Invalid enum value");return n[i]}return qC("enum",gl.VARINT,function(s,o){const a=e(s);o.int32(a)},function(s){return e(s.uint32())})}function Yt(n,e){return qC("message",gl.LENGTH_DELIMITED,n,e)}var kc,Lc,nr=(()=>{return(n=nr||(nr={})).RSA="RSA",n.Ed25519="Ed25519",n.Secp256k1="Secp256k1",nr;var n})(),Kd=(()=>{return(n=Kd||(Kd={}))[n.RSA=0]="RSA",n[n.Ed25519=1]="Ed25519",n[n.Secp256k1=2]="Secp256k1",Kd;var n})();(nr||(nr={})).codec=()=>Fo(Kd),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(r.uint32(8),nr.codec().encode(t.Type,r),null==t.Data)throw new Error('Protocol error: required field "Data" was not found in object');r.uint32(18),r.bytes(t.Data),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={Type:nr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=nr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}if(null==i.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==i.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(kc||(kc={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(r.uint32(8),nr.codec().encode(t.Type,r),null==t.Data)throw new Error('Protocol error: required field "Data" was not found in object');r.uint32(18),r.bytes(t.Data),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={Type:nr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=nr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}if(null==i.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==i.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Lc||(Lc={})),x(7791),x(2158);var Un=x(8659);const FB=function kB(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,ue=new Uint8Array(Te);Z[J];){var Re=t[Z.charCodeAt(J)];if(255===Re)return;for(var $e=0,Pe=Te-1;(0!==Re||$e>>0)%256>>>0,Re=Re/256>>>0;if(0!==Re)throw new Error("Non-zero carry");he=$e,J++}if(" "!==Z[J]){for(var bt=Te-he;bt!==Te&&0===ue[bt];)bt++;for(var yt=new Uint8Array(se+(Te-bt)),Xt=se;bt!==Te;)yt[Xt++]=ue[bt++];return yt}}}return{encode:function N(Z){if(Z instanceof Uint8Array||(ArrayBuffer.isView(Z)?Z=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength):Array.isArray(Z)&&(Z=Uint8Array.from(Z))),!(Z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===Z.length)return"";for(var J=0,se=0,he=0,Te=Z.length;he!==Te&&0===Z[he];)he++,J++;for(var ue=(Te-he)*R+1>>>0,Re=new Uint8Array(ue);he!==Te;){for(var $e=Z[he],Pe=0,bt=ue-1;(0!==$e||Pe>>0)%a>>>0,$e=$e/a>>>0;if(0!==$e)throw new Error("Non-zero carry");se=Pe,he++}for(var yt=ue-se;yt!==ue&&0===Re[yt];)yt++;for(var Xt=l.repeat(J);yt{if(n instanceof Uint8Array&&"Uint8Array"===n.constructor.name)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")});class $B{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class jB{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return YC(this,e)}}class zB{constructor(e){this.decoders=e}or(e){return YC(this,e)}decode(e){const r=this.decoders[e[0]];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const YC=(n,e)=>new zB({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class GB{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new $B(e,t,r),this.decoder=new jB(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const $d=({name:n,prefix:e,encode:t,decode:r})=>new GB(n,e,t,r),yl=({prefix:n,name:e,alphabet:t})=>{const{encode:r,decode:i}=FB(t,e);return $d({prefix:n,name:e,encode:r,decode:s=>Bc(i(s))})},Lr=({name:n,prefix:e,bitsPerChar:t,alphabet:r})=>$d({prefix:e,name:n,encode:i=>((n,e,t)=>{const r="="===e[e.length-1],i=(1<t;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<((n,e,t,r)=>{const i={};for(let R=0;R=8&&(a-=8,o[_++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return o})(i,r,t,n)}),YB=$d({prefix:"\0",name:"identity",encode:n=>(n=>(new TextDecoder).decode(n))(n),decode:n=>(n=>(new TextEncoder).encode(n))(n)}),QB=Lr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),ZB=Lr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),XB=yl({prefix:"9",name:"base10",alphabet:"0123456789"}),JB=Lr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),e6=Lr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),co=Lr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),t6=Lr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),n6=Lr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),r6=Lr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),i6=Lr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),s6=Lr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),o6=Lr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),a6=Lr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),c6=Lr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),u6=yl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),l6=yl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ui=yl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),f6=yl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),jd=Lr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),d6=Lr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h6=Lr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),p6=Lr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),QC=Array.from("\u{1f680}\u{1fa90}\u2604\u{1f6f0}\u{1f30c}\u{1f311}\u{1f312}\u{1f313}\u{1f314}\u{1f315}\u{1f316}\u{1f317}\u{1f318}\u{1f30d}\u{1f30f}\u{1f30e}\u{1f409}\u2600\u{1f4bb}\u{1f5a5}\u{1f4be}\u{1f4bf}\u{1f602}\u2764\u{1f60d}\u{1f923}\u{1f60a}\u{1f64f}\u{1f495}\u{1f62d}\u{1f618}\u{1f44d}\u{1f605}\u{1f44f}\u{1f601}\u{1f525}\u{1f970}\u{1f494}\u{1f496}\u{1f499}\u{1f622}\u{1f914}\u{1f606}\u{1f644}\u{1f4aa}\u{1f609}\u263a\u{1f44c}\u{1f917}\u{1f49c}\u{1f614}\u{1f60e}\u{1f607}\u{1f339}\u{1f926}\u{1f389}\u{1f49e}\u270c\u2728\u{1f937}\u{1f631}\u{1f60c}\u{1f338}\u{1f64c}\u{1f60b}\u{1f497}\u{1f49a}\u{1f60f}\u{1f49b}\u{1f642}\u{1f493}\u{1f929}\u{1f604}\u{1f600}\u{1f5a4}\u{1f603}\u{1f4af}\u{1f648}\u{1f447}\u{1f3b6}\u{1f612}\u{1f92d}\u2763\u{1f61c}\u{1f48b}\u{1f440}\u{1f62a}\u{1f611}\u{1f4a5}\u{1f64b}\u{1f61e}\u{1f629}\u{1f621}\u{1f92a}\u{1f44a}\u{1f973}\u{1f625}\u{1f924}\u{1f449}\u{1f483}\u{1f633}\u270b\u{1f61a}\u{1f61d}\u{1f634}\u{1f31f}\u{1f62c}\u{1f643}\u{1f340}\u{1f337}\u{1f63b}\u{1f613}\u2b50\u2705\u{1f97a}\u{1f308}\u{1f608}\u{1f918}\u{1f4a6}\u2714\u{1f623}\u{1f3c3}\u{1f490}\u2639\u{1f38a}\u{1f498}\u{1f620}\u261d\u{1f615}\u{1f33a}\u{1f382}\u{1f33b}\u{1f610}\u{1f595}\u{1f49d}\u{1f64a}\u{1f639}\u{1f5e3}\u{1f4ab}\u{1f480}\u{1f451}\u{1f3b5}\u{1f91e}\u{1f61b}\u{1f534}\u{1f624}\u{1f33c}\u{1f62b}\u26bd\u{1f919}\u2615\u{1f3c6}\u{1f92b}\u{1f448}\u{1f62e}\u{1f646}\u{1f37b}\u{1f343}\u{1f436}\u{1f481}\u{1f632}\u{1f33f}\u{1f9e1}\u{1f381}\u26a1\u{1f31e}\u{1f388}\u274c\u270a\u{1f44b}\u{1f630}\u{1f928}\u{1f636}\u{1f91d}\u{1f6b6}\u{1f4b0}\u{1f353}\u{1f4a2}\u{1f91f}\u{1f641}\u{1f6a8}\u{1f4a8}\u{1f92c}\u2708\u{1f380}\u{1f37a}\u{1f913}\u{1f619}\u{1f49f}\u{1f331}\u{1f616}\u{1f476}\u{1f974}\u25b6\u27a1\u2753\u{1f48e}\u{1f4b8}\u2b07\u{1f628}\u{1f31a}\u{1f98b}\u{1f637}\u{1f57a}\u26a0\u{1f645}\u{1f61f}\u{1f635}\u{1f44e}\u{1f932}\u{1f920}\u{1f927}\u{1f4cc}\u{1f535}\u{1f485}\u{1f9d0}\u{1f43e}\u{1f352}\u{1f617}\u{1f911}\u{1f30a}\u{1f92f}\u{1f437}\u260e\u{1f4a7}\u{1f62f}\u{1f486}\u{1f446}\u{1f3a4}\u{1f647}\u{1f351}\u2744\u{1f334}\u{1f4a3}\u{1f438}\u{1f48c}\u{1f4cd}\u{1f940}\u{1f922}\u{1f445}\u{1f4a1}\u{1f4a9}\u{1f450}\u{1f4f8}\u{1f47b}\u{1f910}\u{1f92e}\u{1f3bc}\u{1f975}\u{1f6a9}\u{1f34e}\u{1f34a}\u{1f47c}\u{1f48d}\u{1f4e3}\u{1f942}"),g6=QC.reduce((n,e,t)=>(n[t]=e,n),[]),y6=QC.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]),E6=$d({prefix:"\u{1f680}",name:"base256emoji",encode:function m6(n){return n.reduce((e,t)=>e+g6[t],"")},decode:function v6(n){const e=[];for(const t of n){const r=y6[t.codePointAt(0)];if(void 0===r)throw new Error(`Non-base256emoji character: ${t}`);e.push(r)}return new Uint8Array(e)}});var D6=Math.pow(2,31),I6=Math.pow(2,7),T6=Math.pow(2,14),A6=Math.pow(2,21),x6=Math.pow(2,28),R6=Math.pow(2,35),P6=Math.pow(2,42),N6=Math.pow(2,49),M6=Math.pow(2,56),O6=Math.pow(2,63),L6={encode:function XC(n,e,t){e=e||[];for(var r=t=t||0;n>=D6;)e[t++]=255&n|128,n/=128;for(;-128&n;)e[t++]=255&n|128,n>>>=7;return e[t]=0|n,XC.bytes=t-r+1,e},decode:function T0(n,r){var o,t=0,i=0,s=r=r||0,a=n.length;do{if(s>=a)throw T0.bytes=0,new RangeError("Could not decode varint");o=n[s++],t+=i<28?(127&o)<=128);return T0.bytes=s-r,t},encodingLength:function(n){return n[zd.decode(n),zd.decode.bytes],Gd=(n,e,t=0)=>(zd.encode(n,e,t),e),Wd=n=>zd.encodingLength(n),Fc=(n,e)=>{const t=e.byteLength,r=Wd(n),i=r+Wd(t),s=new Uint8Array(i+t);return Gd(n,s,0),Gd(t,s,r),s.set(e,i),new x0(n,t,e,s)},qd=n=>{const e=Bc(n),[t,r]=A0(e),[i,s]=A0(e.subarray(r)),o=e.subarray(r+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new x0(t,i,o,e)};class x0{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const eI=({name:n,code:e,encode:t})=>new U6(n,e,t);class U6{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Fc(this.code,t):t.then(r=>Fc(this.code,r))}throw Error("Unknown type, must be binary type")}}const tI=n=>function(){var e=$(function*(t){return new Uint8Array(yield crypto.subtle.digest(n,t))});return function(t){return e.apply(this,arguments)}}(),mi=eI({name:"sha2-256",code:18,encode:tI("SHA-256")}),V6=eI({name:"sha2-512",code:19,encode:tI("SHA-512")}),rI=Bc,Uc={code:0,name:"identity",encode:rI,digest:n=>Fc(0,rI(n))},K6="raw",$6=85,j6=n=>Bc(n),z6=n=>Bc(n),G6=new TextEncoder,W6=new TextDecoder,q6="json",Y6=512,Q6=n=>G6.encode(JSON.stringify(n)),Z6=n=>JSON.parse(W6.decode(n));class wr{constructor(e,t,r,i){this.code=t,this.version=e,this.multihash=r,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Qd,byteLength:Qd,code:Yd,version:Yd,multihash:Yd,bytes:Yd,_baseCache:Qd,asCID:Qd})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==ml)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==tF)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return wr.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=Fc(e,t);return wr.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&((n,e)=>n===e||n.code===e.code&&n.size===e.size&&((n,e)=>{if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t{const[N,B]=A0(e.subarray(t));return t+=B,N};let i=r(),s=ml;if(18===i?(i=0,t=0):1===i&&(s=r()),0!==i&&1!==i)throw new RangeError(`Invalid CID version ${i}`);const o=t,a=r(),l=r(),_=t+l;return{version:i,codec:s,multihashCode:a,digestSize:l,multihashSize:_-o,size:_}}static parse(e,t){const[r,i]=X6(e,t),s=wr.decode(i);return s._baseCache.set(r,e),s}}const X6=(n,e)=>{switch(n[0]){case"Q":return[ui.prefix,(e||ui).decode(`${ui.prefix}${n}`)];case ui.prefix:return[ui.prefix,(e||ui).decode(n)];case co.prefix:return[co.prefix,(e||co).decode(n)];default:if(null==e)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[n[0],e.decode(n)]}},J6=(n,e,t)=>{const{prefix:r}=t;if(r!==ui.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);const i=e.get(r);if(null==i){const s=t.encode(n).slice(1);return e.set(r,s),s}return i},eF=(n,e,t)=>{const{prefix:r}=t,i=e.get(r);if(null==i){const s=t.encode(n);return e.set(r,s),s}return i},ml=112,tF=18,iI=(n,e,t)=>{const r=Wd(n),i=r+Wd(e),s=new Uint8Array(i+t.byteLength);return Gd(n,s,0),Gd(e,s,r),s.set(t,i),s},sI=Symbol.for("@ipld/js-cid/CID"),Yd={writable:!1,configurable:!1,enumerable:!0},Qd={writable:!1,enumerable:!1,configurable:!1},rF=(n,e)=>{if(!n.test("0.0.0-dev"))throw new Error(e);console.warn(e)},iF="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n",vl={...y,...u,...g,...w,...m,...h,...c,...f,...d,...b};function oI(n,e,t,r){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:r}}}const aI=oI("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>(new TextEncoder).encode(n.substring(1))),R0=oI("ascii","a",n=>{let e="a";for(let t=0;t{const e=Nc((n=n.substring(1)).length);for(let t=0;te)throw new Error("byte array longer than desired length");t=br([new Uint8Array(e-t.length),t])}return Lt(t,"base64url")}function gs(n){const e=function cF(n,e){let t=Ot(n,"base64urlpad");if(null!=e){if(t.length>e)throw new Error("byte array longer than desired length");t=br([new Uint8Array(e-t.length),t])}return t}(n);return new Un.jsbn.BigInteger(Lt(e,"base16"),16)}x(730);function hI(n){const e=n?.algorithm??"AES-GCM";let t=n?.keyLength??16;const r=n?.nonceLength??12,i=n?.digest??"SHA-256",s=n?.saltLength??16,o=n?.iterations??32767,a=ks.get();function _(){return(_=$(function*(z,Z){const J=a.getRandomValues(new Uint8Array(s)),se=a.getRandomValues(new Uint8Array(r)),he={name:e,iv:se};"string"==typeof Z&&(Z=Ot(Z));const Te={name:"PBKDF2",salt:J,iterations:o,hash:{name:i}},ue=yield a.subtle.importKey("raw",Z,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Re=yield a.subtle.deriveKey(Te,ue,{name:e,length:t},!0,["encrypt"]),$e=yield a.subtle.encrypt(he,Re,z);return br([J,he.iv,new Uint8Array($e)])})).apply(this,arguments)}function N(){return(N=$(function*(z,Z){const J=z.slice(0,s),se=z.slice(s,s+r),he=z.slice(s+r),Te={name:e,iv:se};"string"==typeof Z&&(Z=Ot(Z));const ue={name:"PBKDF2",salt:J,iterations:o,hash:{name:i}},Re=yield a.subtle.importKey("raw",Z,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),$e=yield a.subtle.deriveKey(ue,Re,{name:e,length:t},!0,["decrypt"]),Pe=yield a.subtle.decrypt(Te,$e,he);return new Uint8Array(Pe)})).apply(this,arguments)}return t*=8,{encrypt:function l(z,Z){return _.apply(this,arguments)},decrypt:function R(z,Z){return N.apply(this,arguments)}}}function fF(n,e){return k0.apply(this,arguments)}function k0(){return(k0=$(function*(n,e){const t=jd.decode(n);return yield hI().decrypt(t,e)})).apply(this,arguments)}Object.keys({"P-256":256,"P-384":384,"P-521":521}).join(" / "),x(8985);var dF=x(5856),hF=x.t(dF,2);const ln=BigInt(0),Yn=BigInt(1),Uo=BigInt(2),El=BigInt(3),pF=BigInt(8),Mn=Object.freeze({a:ln,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Yn,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});function pI(n){const{a:e,b:t}=Mn,r=at(n*n),i=at(r*n);return at(i+e*n+t)}const Zd=Mn.a===ln;class L0 extends Error{constructor(e){super(e)}}class On{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof Tn))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new On(e.x,e.y,Yn)}static toAffineBatch(e){const t=function EF(n,e=Mn.P){const t=new Array(n.length),i=$c(n.reduce((s,o,a)=>o===ln?s:(t[a]=s,at(s*o,e)),Yn),e);return n.reduceRight((s,o,a)=>o===ln?s:(t[a]=at(s*t[a],e),at(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return On.toAffineBatch(e).map(On.fromAffine)}equals(e){if(!(e instanceof On))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,l=at(i*i),_=at(a*a),R=at(t*_),N=at(s*l),B=at(at(r*a)*_),z=at(at(o*i)*l);return R===N&&B===z}negate(){return new On(this.x,at(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,i=at(e*e),s=at(t*t),o=at(s*s),a=e+s,l=at(Uo*(at(a*a)-i-o)),_=at(El*i),R=at(_*_),N=at(R-Uo*l),B=at(_*(l-N)-pF*o),z=at(Uo*t*r);return new On(N,B,z)}add(e){if(!(e instanceof On))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e;if(s===ln||o===ln)return this;if(t===ln||r===ln)return e;const l=at(i*i),_=at(a*a),R=at(t*_),N=at(s*l),B=at(at(r*a)*_),z=at(at(o*i)*l),Z=at(N-R),J=at(z-B);if(Z===ln)return J===ln?this.double():On.ZERO;const se=at(Z*Z),he=at(Z*se),Te=at(R*se),ue=at(J*J-he-Uo*Te),Re=at(J*(Te-ue)-B*he),$e=at(i*a*Z);return new On(ue,Re,$e)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=On.ZERO;if("bigint"==typeof e&&e===ln)return t;let r=mI(e);if(r===Yn)return this;if(!Zd){let N=t,B=this;for(;r>ln;)r&Yn&&(N=N.add(B)),B=B.double(),r>>=Yn;return N}let{k1neg:i,k1:s,k2neg:o,k2:a}=EI(r),l=t,_=t,R=this;for(;s>ln||a>ln;)s&Yn&&(l=l.add(R)),a&Yn&&(_=_.add(R)),R=R.double(),s>>=Yn,a>>=Yn;return i&&(l=l.negate()),o&&(_=_.negate()),_=new On(at(_.x*Mn.beta),_.y,_.z),l.add(_)}precomputeWindow(e){const t=Zd?128/e+1:256/e+1,r=[];let i=this,s=i;for(let o=0;o>=N,Z>l&&(Z-=R,e+=Yn),0===Z){let J=i[z];B%2&&(J=J.negate()),o=o.add(J)}else{let J=i[z+Math.abs(Z)-1];Z<0&&(J=J.negate()),s=s.add(J)}}return{p:s,f:o}}multiply(e,t){let i,s,r=mI(e);if(Zd){const{k1neg:o,k1:a,k2neg:l,k2:_}=EI(r);let{p:R,f:N}=this.wNAF(a,t),{p:B,f:z}=this.wNAF(_,t);o&&(R=R.negate()),l&&(B=B.negate()),B=new On(at(B.x*Mn.beta),B.y,B.z),i=R.add(B),s=N.add(z)}else{const{p:o,f:a}=this.wNAF(r,t);i=o,s=a}return On.normalizeZ([i,s])[0]}toAffine(e=$c(this.z)){const{x:t,y:r,z:i}=this,s=e,o=at(s*s),a=at(o*s),l=at(t*o),_=at(r*a);if(at(i*s)!==Yn)throw new Error("invZ was invalid");return new Tn(l,_)}}On.BASE=new On(Mn.Gx,Mn.Gy,Yn),On.ZERO=new On(ln,Yn,ln);const B0=new WeakMap;class Tn{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,B0.delete(this)}hasEvenY(){return this.y%Uo===ln}static fromCompressedHex(e){const t=32===e.length,r=vi(t?e:e.subarray(1));if(!Jd(r))throw new Error("Point is not on curve");let s=function vF(n){const{P:e}=Mn,t=BigInt(6),r=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),l=n*n*n%e,_=l*l*n%e,R=Gi(_,El)*_%e,N=Gi(R,El)*_%e,B=Gi(N,Uo)*l%e,z=Gi(B,r)*B%e,Z=Gi(z,i)*z%e,J=Gi(Z,o)*Z%e,se=Gi(J,a)*J%e,he=Gi(se,o)*Z%e,Te=Gi(he,El)*_%e,ue=Gi(Te,s)*z%e,Re=Gi(ue,t)*l%e;return Gi(Re,Uo)}(pI(r));const o=(s&Yn)===Yn;t?o&&(s=at(-s)):1==(1&e[0])!==o&&(s=at(-s));const a=new Tn(r,s);return a.assertValidity(),a}static fromUncompressedHex(e){const t=vi(e.subarray(1,33)),r=vi(e.subarray(33,65)),i=new Tn(t,r);return i.assertValidity(),i}static fromHex(e){const t=Bs(e),r=t.length,i=t[0];if(32===r||33===r&&(2===i||3===i))return this.fromCompressedHex(t);if(65===r&&4===i)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(e){return Tn.BASE.multiply(_a(e))}static fromSignature(e,t,r){const i=bI(e=Bs(e)),{r:s,s:o}=DI(t);if(0!==r&&1!==r)throw new Error("Cannot recover signature: invalid recovery bit");const l=Tn.fromHex((1&r?"03":"02")+Vo(s)),{n:_}=Mn,R=$c(s,_),N=at(-i*R,_),B=at(o*R,_),z=Tn.BASE.multiplyAndAddUnsafe(l,N,B);if(!z)throw new Error("Cannot recover signature: point at infinify");return z.assertValidity(),z}toRawBytes(e=!1){return Ho(this.toHex(e))}toHex(e=!1){const t=Vo(this.x);return e?`${this.hasEvenY()?"02":"03"}${t}`:`04${t}${Vo(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!Jd(t)||!Jd(r))throw new Error(e);const i=at(r*r);if(at(i-pI(t))!==ln)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Tn(this.x,at(-this.y))}double(){return On.fromAffine(this).double().toAffine()}add(e){return On.fromAffine(this).add(On.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return On.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const i=On.fromAffine(this),s=t===ln||t===Yn||this!==Tn.BASE?i.multiplyUnsafe(t):i.multiply(t),o=On.fromAffine(e).multiplyUnsafe(r),a=s.add(o);return a.equals(On.ZERO)?void 0:a.toAffine()}}function gI(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function yI(n){if(n.length<2||2!==n[0])throw new Error(`Invalid signature integer tag: ${Hc(n)}`);const e=n[1],t=n.subarray(2,e+2);if(!e||t.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===t[0]&&t[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:vi(t),left:n.subarray(e+2)}}Tn.BASE=new Tn(Mn.Gx,Mn.Gy),Tn.ZERO=new Tn(ln,ln);class uo{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${r}: Expected string or Uint8Array`);const i=t?Hc(e):e;if(128!==i.length)throw new Error(`${r}: Expected 64-byte hex`);return new uo(Xd(i.slice(0,64)),Xd(i.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:i}=function gF(n){if(n.length<2||48!=n[0])throw new Error(`Invalid signature tag: ${Hc(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:t}=yI(n.subarray(2)),{data:r,left:i}=yI(t);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${Hc(i)}`);return{r:e,s:r}}(t?e:Ho(e));return new uo(r,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!zc(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!zc(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){return this.s>Mn.n>>Yn}normalizeS(){return this.hasHighS()?new uo(this.r,Mn.n-this.s):this}toDERRawBytes(e=!1){return Ho(this.toDERHex(e))}toDERHex(e=!1){const t=gI(bl(this.s));if(e)return t;const r=gI(bl(this.r)),i=bl(r.length/2),s=bl(t.length/2);return`30${bl(r.length/2+t.length/2+4)}02${i}${r}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Ho(this.toCompactHex())}toCompactHex(){return Vo(this.r)+Vo(this.s)}}function Vc(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function Hc(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t0)return BigInt(n);if("bigint"==typeof n&&zc(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function at(n,e=Mn.P){const t=n%e;return t>=ln?t:e+t}function Gi(n,e){const{P:t}=Mn;let r=n;for(;e-- >ln;)r*=r,r%=t;return r}function $c(n,e=Mn.P){if(n===ln||e<=ln)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=at(n,e),r=e,i=ln,s=Yn,o=Yn,a=ln;for(;t!==ln;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==Yn)throw new Error("invert: does not exist");return at(i,e)}const vI=(n,e)=>(n+e/Uo)/e,bF={a1:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),b1:-Yn*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a2:BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),b2:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),POW_2_128:BigInt("0x100000000000000000000000000000000")};function EI(n){const{n:e}=Mn,{a1:t,b1:r,a2:i,b2:s,POW_2_128:o}=bF,a=vI(s*n,e),l=vI(-r*n,e);let _=at(n-a*t-l*i,e),R=at(-a*r-l*s,e);const N=_>o,B=R>o;if(N&&(_=e-_),B&&(R=e-R),_>o||R>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:N,k1:_,k2neg:B,k2:R}}function bI(n){const{n:e}=Mn,r=8*n.length-256;let i=vi(n);return r>0&&(i>>=BigInt(r)),i>=e&&(i-=e),i}let jc,wl;class wI{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return Yr.hmacSha256(this.k,...e)}hmacSync(...e){return wl(this.k,...e)}checkSync(){if("function"!=typeof wl)throw new L0("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}reseed(e=new Uint8Array){var t=this;return $(function*(){t.k=yield t.hmac(t.v,Uint8Array.from([0]),e),t.v=yield t.hmac(t.v),0!==e.length&&(t.k=yield t.hmac(t.v,Uint8Array.from([1]),e),t.v=yield t.hmac(t.v))})()}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}generate(){var e=this;return $(function*(){return e.incr(),e.v=yield e.hmac(e.v),e.v})()}generateSync(){return this.checkSync(),this.incr(),this.v=this.hmacSync(this.v),this.v}}function zc(n){return ln0)e=BigInt(n);else if("string"==typeof n){if(64!==n.length)throw new Error("Expected 32 bytes of private key");e=Xd(n)}else{if(!(n instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==n.length)throw new Error("Expected 32 bytes of private key");e=vi(n)}if(!zc(e))throw new Error("Expected private key: 0 < key < n");return e}function F0(n){return n instanceof Tn?(n.assertValidity(),n):Tn.fromHex(n)}function DI(n){if(n instanceof uo)return n.assertValidity(),n;try{return uo.fromDER(n)}catch{return uo.fromCompact(n)}}function _l(n,e=!1){return Tn.fromPrivateKey(n).toRawBytes(e)}function SI(n){const e=n instanceof Uint8Array,t="string"==typeof n,r=(e||t)&&n.length;return e?33===r||65===r:t?66===r||130===r:n instanceof Tn}function CI(n){return vi(n.length>32?n.slice(0,32):n)}function DF(n){const e=CI(n),t=at(e,Mn.n);return II(t{if((n=Bs(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Kc(at(vi(n),Mn.n-Yn)+Yn)},randomBytes:(n=32)=>{if(Mi.web)return Mi.web.getRandomValues(new Uint8Array(n));if(Mi.node){const{randomBytes:e}=Mi.node;return Uint8Array.from(e(n))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Yr.hashToPrivateKey(Yr.randomBytes(40)),sha256:(n=$(function*(...e){if(Mi.web){const t=yield Mi.web.subtle.digest("SHA-256",Vc(...e));return new Uint8Array(t)}if(Mi.node){const{createHash:t}=Mi.node,r=t("sha256");return e.forEach(i=>r.update(i)),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")}),function(){return n.apply(this,arguments)}),hmacSha256:function(){var n=$(function*(e,...t){if(Mi.web){const r=yield Mi.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=Vc(...t),s=yield Mi.web.subtle.sign("HMAC",r,i);return new Uint8Array(s)}if(Mi.node){const{createHmac:r}=Mi.node,i=r("sha256",e);return t.forEach(s=>i.update(s)),Uint8Array.from(i.digest())}throw new Error("The environment doesn't have hmac-sha256 function")});return function(t){return n.apply(this,arguments)}}(),sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:function(){var n=$(function*(e,...t){let r=th[e];if(void 0===r){const i=yield Yr.sha256(Uint8Array.from(e,s=>s.charCodeAt(0)));r=Vc(i,i),th[e]=r}return Yr.sha256(r,...t)});return function(t){return n.apply(this,arguments)}}(),taggedHashSync:(n,...e)=>{if("function"!=typeof jc)throw new L0("sha256Sync is undefined, you need to set it");let t=th[n];if(void 0===t){const r=jc(Uint8Array.from(n,i=>i.charCodeAt(0)));t=Vc(r,r),th[n]=t}return jc(t,...e)},precompute(n=8,e=Tn.BASE){const t=e===Tn.BASE?e:new Tn(e.x,e.y);return t._setWindowSize(n),t.multiply(El),t}};var n;function nh(n){if(isNaN(n)||n<=0)throw ae(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return Yr.randomBytes(n)}function xF(n){const e=Un.asn1.fromDer(Lt(n,"ascii")),t=Un.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:Ls(t.n),e:Ls(t.e),d:Ls(t.d),p:Ls(t.p),q:Ls(t.q),dp:Ls(t.dP),dq:Ls(t.dQ),qi:Ls(t.qInv),alg:"RS256"}}function kI(n,e){return e.map(t=>gs(n[t]))}function kF(n){return K0.apply(this,arguments)}function K0(){return K0=$(function*(n){const e=yield ks.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:n,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=yield BI(e);return{privateKey:t[0],publicKey:t[1]}}),K0.apply(this,arguments)}function LI(n){return $0.apply(this,arguments)}function $0(){return $0=$(function*(n){const t=[yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),yield FF(n)],r=yield BI({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}),$0.apply(this,arguments)}function j0(){return j0=$(function*(n,e){const t=yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),r=yield ks.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,Uint8Array.from(e));return new Uint8Array(r,0,r.byteLength)}),j0.apply(this,arguments)}function z0(){return z0=$(function*(n,e,t){const r=yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return yield ks.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},r,e,t)}),z0.apply(this,arguments)}function BI(n){return G0.apply(this,arguments)}function G0(){return G0=$(function*(n){if(null==n.privateKey||null==n.publicKey)throw ae(new Error("Private and public key are required"),"ERR_INVALID_PARAMETERS");return yield Promise.all([ks.get().subtle.exportKey("jwk",n.privateKey),ks.get().subtle.exportKey("jwk",n.publicKey)])}),G0.apply(this,arguments)}function FF(n){return W0.apply(this,arguments)}function W0(){return W0=$(function*(n){return yield ks.get().subtle.importKey("jwk",{kty:n.kty,n:n.n,e:n.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}),W0.apply(this,arguments)}function FI(n,e,t,r){const i=e?function OF(n){return Un.pki.setRsaPublicKey(...kI(n,["n","e"]))}(n):function MF(n){return Un.pki.setRsaPrivateKey(...kI(n,["n","e","d","p","q","dp","dq","qi"]))}(n);return Ot(r(Lt(Uint8Array.from(t),"ascii"),i),"ascii")}function q0(n,e){return Y0.apply(this,arguments)}function Y0(){return Y0=$(function*(n,e){const r=yield hI().encrypt(n,e);return jd.encode(r)}),Y0.apply(this,arguments)}Object.defineProperties(Yr,{sha256Sync:{configurable:!1,get:()=>jc,set(n){jc||(jc=n)}},hmacSha256Sync:{configurable:!1,get:()=>wl,set(n){wl||(wl=n)}}}),x(5517);class Q0{constructor(e){this._key=e}verify(e,t){var r=this;return $(function*(){return yield function BF(n,e,t){return z0.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function NF(n){if(null==n.n||null==n.e)throw ae(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Un.pki.publicKeyToAsn1({n:gs(n.n),e:gs(n.e)});return Ot(Un.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return kc.encode({Type:nr.RSA,Data:this.marshal()}).subarray()}encrypt(e){return function UF(n,e){return FI(n,!0,e,(t,r)=>r.encrypt(t))}(this._key,e)}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class rh{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return nh(16)}sign(e){var t=this;return $(function*(){return yield function LF(n,e){return j0.apply(this,arguments)}(t._key,e)})()}get public(){if(null==this._publicKey)throw ae(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new Q0(this._publicKey)}decrypt(e){return function VF(n,e){return FI(n,!1,e,(t,r)=>r.decrypt(t))}(this._key,e)}marshal(){return function RF(n){if(null==n.n||null==n.e||null==n.d||null==n.p||null==n.q||null==n.dp||null==n.dq||null==n.qi)throw ae(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Un.pki.privateKeyToAsn1({n:gs(n.n),e:gs(n.e),d:gs(n.d),p:gs(n.p),q:gs(n.q),dP:gs(n.dp),dQ:gs(n.dq),qInv:gs(n.qi)});return Ot(Un.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return Lc.encode({Type:nr.RSA,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return $(function*(){return Lt(yield e.public.hash(),"base58btc")})()}export(e,t="pkcs-8"){var r=this;return $(function*(){if("pkcs-8"===t){const i=new Un.util.ByteBuffer(r.marshal()),s=Un.asn1.fromDer(i),o=Un.pki.privateKeyFromAsn1(s);return Un.pki.encryptRsaPrivateKey(o,e,{algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"})}if("libp2p-key"===t)return yield q0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function HF(n){return Z0.apply(this,arguments)}function Z0(){return Z0=$(function*(n){const e=xF(n),t=yield LI(e);return new rh(t.privateKey,t.publicKey)}),Z0.apply(this,arguments)}function KF(n){const e=function PF(n){const e=Un.asn1.fromDer(Lt(n,"ascii")),t=Un.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:Ls(t.n),e:Ls(t.e)}}(n);return new Q0(e)}function $F(n){return X0.apply(this,arguments)}function X0(){return X0=$(function*(n){const e=yield LI(n);return new rh(e.privateKey,e.publicKey)}),X0.apply(this,arguments)}function jF(n){return J0.apply(this,arguments)}function J0(){return J0=$(function*(n){const e=yield kF(n);return new rh(e.privateKey,e.publicKey)}),J0.apply(this,arguments)}var zF=x(7420),GF=x.t(zF,2);const cr=BigInt(0),cn=BigInt(1),Wc=BigInt(2),UI=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),Vn=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:UI,n:UI,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),VI=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),Dl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),WF=(BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235")),qF=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),YF=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),QF=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class _n{constructor(e,t,r,i){this.x=e,this.y=t,this.z=r,this.t=i}static fromAffine(e){if(!(e instanceof rr))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(rr.ZERO)?_n.ZERO:new _n(e.x,e.y,cn,Oe(e.x*e.y))}static toAffineBatch(e){const t=function JF(n,e=Vn.P){const t=new Array(n.length),i=ih(n.reduce((s,o,a)=>o===cr?s:(t[a]=s,Oe(s*o,e)),cn),e);return n.reduceRight((s,o,a)=>o===cr?s:(t[a]=Oe(s*t[a],e),Oe(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){HI(e);const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,l=Oe(t*a),_=Oe(s*i),R=Oe(r*a),N=Oe(o*i);return l===_&&R===N}negate(){return new _n(Oe(-this.x),this.y,this.z,Oe(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:i}=Vn,s=Oe(e*e),o=Oe(t*t),a=Oe(Wc*Oe(r*r)),l=Oe(i*s),_=e+t,R=Oe(Oe(_*_)-s-o),N=l+o,B=N-a,z=l-o,Z=Oe(R*B),J=Oe(N*z),se=Oe(R*z),he=Oe(B*N);return new _n(Z,J,he,se)}add(e){HI(e);const{x:t,y:r,z:i,t:s}=this,{x:o,y:a,z:l,t:_}=e,R=Oe((r-t)*(a+o)),N=Oe((r+t)*(a-o)),B=Oe(N-R);if(B===cr)return this.double();const z=Oe(i*Wc*_),Z=Oe(s*Wc*l),J=Z+z,se=N+R,he=Z-z,Te=Oe(J*B),ue=Oe(se*he),Re=Oe(J*he),$e=Oe(B*se);return new _n(Te,ue,$e,Re)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,r=[];let i=this,s=i;for(let o=0;o>=N,Z>l&&(Z-=R,e+=cn),0===Z){let J=i[z];B%2&&(J=J.negate()),o=o.add(J)}else{let J=i[z+Math.abs(Z)-1];Z<0&&(J=J.negate()),s=s.add(J)}}return _n.normalizeZ([s,o])[0]}multiply(e,t){return this.wNAF(Zc(e,Vn.l),t)}multiplyUnsafe(e){let t=Zc(e,Vn.l,!1);const r=_n.BASE,i=_n.ZERO;if(t===cr)return i;if(this.equals(i)||t===cn)return this;if(this.equals(r))return this.wNAF(t);let s=i,o=this;for(;t>cr;)t&cn&&(s=s.add(o)),o=o.double(),t>>=cn;return s}isSmallOrder(){return this.multiplyUnsafe(Vn.h).equals(_n.ZERO)}isTorsionFree(){return this.multiplyUnsafe(Vn.l).equals(_n.ZERO)}toAffine(e=ih(this.z)){const{x:t,y:r,z:i}=this,s=Oe(t*e),o=Oe(r*e);if(Oe(i*e)!==cn)throw new Error("invZ was invalid");return new rr(s,o)}fromRistrettoBytes(){tm()}toRistrettoBytes(){tm()}fromRistrettoHash(){tm()}}function HI(n){if(!(n instanceof _n))throw new TypeError("ExtendedPoint expected")}function em(n){if(!(n instanceof Wi))throw new TypeError("RistrettoPoint expected")}function tm(){throw new Error("Legacy method: switch to RistrettoPoint")}_n.BASE=new _n(Vn.Gx,Vn.Gy,cn,Oe(Vn.Gx*Vn.Gy)),_n.ZERO=new _n(cr,cn,cn,cr);class Wi{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=Vn,r=Oe(Dl*e*e),i=Oe((r+cn)*YF);let s=BigInt(-1);const o=Oe((s-t*r)*Oe(r+t));let{isValid:a,value:l}=sm(i,o),_=Oe(l*e);$o(_)||(_=Oe(-_)),a||(l=_),a||(s=r);const R=Oe(s*(r-cn)*QF-o),N=l*l,B=Oe((l+l)*o),z=Oe(R*WF),Z=Oe(cn-N),J=Oe(cn+N);return new _n(Oe(B*J),Oe(Z*z),Oe(z*J),Oe(B*Z))}static hashToCurve(e){const t=im((e=ms(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),i=im(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return new Wi(r.add(s))}static fromHex(e){e=ms(e,32);const{a:t,d:r}=Vn,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",s=im(e);if(!function e5(n,e){if(n.length!==e.length)return!1;for(let t=0;t=i)throw new Error("Expected 0 < hex < P");if(!t&&o>=VI)throw new Error("Expected 0 < hex < 2**256");const a=Oe(o*o),l=Oe(a-cn),_=Oe(r*a+cn);let{isValid:R,value:N}=sm(l,_);if(!R)throw new Error("Point.fromHex: invalid y coordinate");return 0!=(128&e[31])!=((N&cn)===cn)&&(N=Oe(-N)),new rr(N,o)}static fromPrivateKey(e){return $(function*(){return(yield Il(e)).point})()}toRawBytes(){const e=Yc(this.y);return e[31]|=this.x&cn?128:0,e}toHex(){return Sl(this.toRawBytes())}toX25519(){const{y:e}=this;return Yc(Oe((cn+e)*ih(cn-e)))}isTorsionFree(){return _n.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new rr(Oe(-this.x),this.y)}add(e){return _n.fromAffine(this).add(_n.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return _n.fromAffine(this).multiply(e,this).toAffine()}}rr.BASE=new rr(Vn.Gx,Vn.Gy),rr.ZERO=new rr(cr,cn);class qc{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=ms(e,64),r=rr.fromHex(t.slice(0,32),!1),i=Da(t.slice(32,64));return new qc(r,i)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof rr))throw new Error("Expected Point instance");return Zc(t,Vn.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Yc(this.s),32),e}toHex(){return Sl(this.toRawBytes())}}function KI(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Expected Uint8Array list");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function Sl(n){if(!(n instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t=cr?t:e+t}function ih(n,e=Vn.P){if(n===cr||e<=cr)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Oe(n,e),r=e,i=cr,s=cn,o=cn,a=cr;for(;t!==cr;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==cn)throw new Error("invert: does not exist");return Oe(i,e)}function ys(n,e){const{P:t}=Vn;let r=n;for(;e-- >cr;)r*=r,r%=t;return r}function sm(n,e){const t=Oe(e*e*e),r=Oe(t*t*e);let s=Oe(n*t*function jI(n){const{P:e}=Vn,t=BigInt(5),r=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),l=n*n%e*n%e,_=ys(l,Wc)*l%e,R=ys(_,cn)*n%e,N=ys(R,t)*R%e,B=ys(N,r)*N%e,z=ys(B,i)*B%e,Z=ys(z,s)*z%e,J=ys(Z,o)*Z%e,se=ys(J,o)*Z%e,he=ys(se,r)*N%e;return{pow_p_5_8:ys(he,Wc)*n%e,b2:l}}(n*r).pow_p_5_8);const o=Oe(e*s*s),a=s,l=Oe(s*Dl),_=o===n,R=o===Oe(-n),N=o===Oe(-n*Dl);return _&&(s=a),(R||N)&&(s=l),$o(s)&&(s=Oe(-s)),{isValid:_||R,value:s}}function zI(n){return sm(cn,n)}function Qc(n){return Oe(Da(n),Vn.l)}function ms(n,e){const t=n instanceof Uint8Array?Uint8Array.from(n):rm(n);if("number"==typeof e&&t.length!==e)throw new Error(`Expected ${e} bytes`);return t}function Zc(n,e,t=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof n&&Number.isSafeInteger(n)&&(n=BigInt(n)),"bigint"==typeof n&&n{if((n=ms(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Oe(Da(n),Vn.l-cn)+cn},randomBytes:(n=32)=>{if(jo.web)return jo.web.getRandomValues(new Uint8Array(n));if(jo.node){const{randomBytes:e}=jo.node;return new Uint8Array(e(n).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Sa.randomBytes(32),sha512:function(){var n=$(function*(...e){const t=KI(...e);if(jo.web){const r=yield jo.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(r)}if(jo.node)return Uint8Array.from(jo.node.createHash("sha512").update(t).digest());throw new Error("The environment doesn't have sha512 function")});return function(){return n.apply(this,arguments)}}(),precompute(n=8,e=rr.BASE){const t=e.equals(rr.BASE)?e:new rr(e.x,e.y);return t._setWindowSize(n),t.multiply(Wc),t},sha512Sync:void 0};function l5(){return hm.apply(this,arguments)}function hm(){return hm=$(function*(){const n=Sa.randomPrivateKey(),e=yield YI(n);return{privateKey:XI(n,e),publicKey:e}}),hm.apply(this,arguments)}function f5(n){return pm.apply(this,arguments)}function pm(){return pm=$(function*(n){if(32!==n.length)throw new TypeError('"seed" must be 32 bytes in length.');if(!(n instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const e=n,t=yield YI(e);return{privateKey:XI(e,t),publicKey:t}}),pm.apply(this,arguments)}function gm(){return gm=$(function*(n,e){const t=n.slice(0,32);return yield r5(e,t)}),gm.apply(this,arguments)}function ym(){return ym=$(function*(n,e,t){return yield s5(e,t,n)}),ym.apply(this,arguments)}function XI(n,e){const t=new Uint8Array(64);for(let r=0;r<32;r++)t[r]=n[r],t[32+r]=e[r];return t}Object.defineProperties(Sa,{sha512Sync:{configurable:!1,get:()=>Cl,set(n){Cl||(Cl=n)}}});class mm{constructor(e){this._key=Xc(e,32)}verify(e,t){var r=this;return $(function*(){return yield function h5(n,e,t){return ym.apply(this,arguments)}(r._key,t,e)})()}marshal(){return this._key}get bytes(){return kc.encode({Type:nr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class Al{constructor(e,t){this._key=Xc(e,64),this._publicKey=Xc(t,32)}sign(e){var t=this;return $(function*(){return yield function d5(n,e){return gm.apply(this,arguments)}(t._key,e)})()}get public(){return new mm(this._publicKey)}marshal(){return this._key}get bytes(){return Lc.encode({Type:nr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return $(function*(){const t=yield Uc.digest(e.public.bytes);return ui.encode(t.bytes).substring(1)})()}export(e,t="libp2p-key"){var r=this;return $(function*(){if("libp2p-key"===t)return yield q0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function p5(n){if(n.length>64){const r=(n=Xc(n,96)).slice(0,64),i=n.slice(64,n.length);return new Al(r,i)}const e=(n=Xc(n,64)).slice(0,64),t=n.slice(32);return new Al(e,t)}function g5(n){return n=Xc(n,32),new mm(n)}function y5(){return vm.apply(this,arguments)}function vm(){return vm=$(function*(){const{privateKey:n,publicKey:e}=yield l5();return new Al(n,e)}),vm.apply(this,arguments)}function m5(n){return Em.apply(this,arguments)}function Em(){return Em=$(function*(n){const{privateKey:e,publicKey:t}=yield f5(n);return new Al(e,t)}),Em.apply(this,arguments)}function Xc(n,e){if((n=Uint8Array.from(n??[])).length!==e)throw ae(new Error(`Key must be a Uint8Array of length ${e}, got ${n.length}`),"ERR_INVALID_KEY_TYPE");return n}function v5(){return Yr.randomPrivateKey()}function bm(){return bm=$(function*(n,e){const{digest:t}=yield mi.digest(e);try{return yield xI(t,n)}catch(r){throw ae(r,"ERR_INVALID_INPUT")}}),bm.apply(this,arguments)}function wm(){return wm=$(function*(n,e,t){try{const{digest:r}=yield mi.digest(t);return CF(e,r,n)}catch(r){throw ae(r,"ERR_INVALID_INPUT")}}),wm.apply(this,arguments)}function JI(n){try{Tn.fromHex(n)}catch(e){throw ae(e,"ERR_INVALID_PUBLIC_KEY")}}class _m{constructor(e){JI(e),this._key=e}verify(e,t){var r=this;return $(function*(){return yield function b5(n,e,t){return wm.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function w5(n){return Tn.fromHex(n).toRawBytes(!0)}(this._key)}get bytes(){return kc.encode({Type:nr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class Dm{constructor(e,t){this._key=e,this._publicKey=t??function D5(n){try{return _l(n,!0)}catch(e){throw ae(e,"ERR_INVALID_PRIVATE_KEY")}}(e),function _5(n){try{_l(n,!0)}catch(e){throw ae(e,"ERR_INVALID_PRIVATE_KEY")}}(this._key),JI(this._publicKey)}sign(e){var t=this;return $(function*(){return yield function E5(n,e){return bm.apply(this,arguments)}(t._key,e)})()}get public(){return new _m(this._publicKey)}marshal(){return this._key}get bytes(){return Lc.encode({Type:nr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return $(function*(){return Lt(yield e.public.hash(),"base58btc")})()}export(e,t="libp2p-key"){var r=this;return $(function*(){if("libp2p-key"===t)return yield q0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function S5(n){return new Dm(n)}function C5(n){return new _m(n)}function I5(){return Sm.apply(this,arguments)}function Sm(){return Sm=$(function*(){const n=yield v5();return new Dm(n)}),Sm.apply(this,arguments)}const lo={rsa:I,ed25519:A,secp256k1:P};function Cm(n){const e=Object.keys(lo).join(" / ");return ae(new Error(`invalid or unsupported key type ${n}. Must be ${e}`),"ERR_UNSUPPORTED_KEY_TYPE")}function Im(n){if("rsa"===(n=n.toLowerCase())||"ed25519"===n||"secp256k1"===n)return lo[n];throw Cm(n)}function e2(n,e){return Tm.apply(this,arguments)}function Tm(){return Tm=$(function*(n,e){return yield Im(n).generateKeyPair(e??2048)}),Tm.apply(this,arguments)}function xl(n){const e=kc.decode(n),t=e.Data;switch(e.Type){case nr.RSA:return lo.rsa.unmarshalRsaPublicKey(t);case nr.Ed25519:return lo.ed25519.unmarshalEd25519PublicKey(t);case nr.Secp256k1:return lo.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Cm(e.Type)}}function t2(n,e){return Im(e=(e??"rsa").toLowerCase()),n.bytes}function Rl(n){return xm.apply(this,arguments)}function xm(){return xm=$(function*(n){const e=Lc.decode(n),t=e.Data;switch(e.Type){case nr.RSA:return yield lo.rsa.unmarshalRsaPrivateKey(t);case nr.Ed25519:return lo.ed25519.unmarshalEd25519PrivateKey(t);case nr.Secp256k1:return lo.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw Cm(e.Type)}}),xm.apply(this,arguments)}function T5(n,e){return Im(e=(e??"rsa").toLowerCase()),n.bytes}function Rm(n,e){return Pm.apply(this,arguments)}function Pm(){return Pm=$(function*(n,e){try{const i=yield fF(n,e);return yield Rl(i)}catch{}const t=Un.pki.decryptRsaPrivateKey(n,e);if(null===t)throw ae(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let r=Un.asn1.toDer(Un.pki.privateKeyToAsn1(t));return r=Ot(r.getBytes(),"ascii"),yield lo.rsa.unmarshalRsaPrivateKey(r)}),Pm.apply(this,arguments)}const n2=Symbol.for("@libp2p/peer-id");function r2(n){return null!=n&&Boolean(n[n2])}const i2=Object.values(vl).map(n=>n.decoder).reduce((n,e)=>n.or(e),vl.identity.decoder);class ch{constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[n2](){return!0}toString(){return null==this.string&&(this.string=ui.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return wr.createV1(114,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return kr(this.multihash.bytes,e);if("string"==typeof e)return fr(e).equals(this);if(null!=e?.multihash?.bytes)return kr(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}}class Pl extends ch{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}}class Nl extends ch{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}}class Ml extends ch{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}}function Br(n){if("RSA"===n.type)return new Pl(n);if("Ed25519"===n.type)return new Nl(n);if("secp256k1"===n.type)return new Ml(n);throw ae(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function fr(n,e){if(e=e??i2,"1"===n.charAt(0)||"Q"===n.charAt(0)){const t=qd(ui.decode(`z${n}`));return n.startsWith("12D")?new Nl({multihash:t}):n.startsWith("16U")?new Ml({multihash:t}):new Pl({multihash:t})}return Jc(i2.decode(n))}function Jc(n){try{const e=qd(n);if(e.code===Uc.code){if(36===e.digest.length)return new Nl({multihash:e});if(37===e.digest.length)return new Ml({multihash:e})}if(e.code===mi.code)return new Pl({multihash:e})}catch{return function A5(n){if(null==n||null==n.multihash||null==n.version||1===n.version&&114!==n.code)throw new Error("Supplied PeerID CID is invalid");const e=n.multihash;if(e.code===mi.code)return new Pl({multihash:n.multihash});if(e.code===Uc.code){if(36===e.digest.length)return new Nl({multihash:n.multihash});if(37===e.digest.length)return new Ml({multihash:n.multihash})}throw new Error("Supplied PeerID CID is invalid")}(wr.decode(n))}throw new Error("Supplied PeerID CID is invalid")}function Ol(n,e){return Om.apply(this,arguments)}function Om(){return Om=$(function*(n,e){return 36===n.length?new Nl({multihash:Fc(Uc.code,n),privateKey:e}):37===n.length?new Ml({multihash:Fc(Uc.code,n),privateKey:e}):new Pl({multihash:yield mi.digest(n),publicKey:n,privateKey:e})}),Om.apply(this,arguments)}var km;!function(n){let e;!function(t){let r;t.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.identityKey)throw new Error('Protocol error: required field "identityKey" was not found in object');if(s.uint32(10),s.bytes(i.identityKey),null==i.identitySig)throw new Error('Protocol error: required field "identitySig" was not found in object');if(s.uint32(18),s.bytes(i.identitySig),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(26),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0),data:new Uint8Array(0)},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.identityKey=i.bytes();break;case 2:o.identitySig=i.bytes();break;case 3:o.data=i.bytes();break;default:i.skipType(7&l)}}if(null==o.identityKey)throw new Error('Protocol error: value for required field "identityKey" was not found in protobuf');if(null==o.identitySig)throw new Error('Protocol error: value for required field "identitySig" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),t.encode=i=>qt(i,t.codec()),t.decode=i=>Wt(i,t.codec())}(e=n.NoiseHandshakePayload||(n.NoiseHandshakePayload={}))}(km||(km={}));const o2=km.NoiseHandshakePayload;function Lm(){return Lm=$(function*(n,e,t){const r=yield P5(n,u2(e)),i=t??new Uint8Array(0);if(null==n.publicKey)throw new Error("PublicKey was missing from local PeerId");return R5(n.publicKey,r,i)}),Lm.apply(this,arguments)}function R5(n,e,t){return o2.encode({identityKey:n,identitySig:e,data:t??new Uint8Array(0)}).subarray()}function P5(n,e){return Bm.apply(this,arguments)}function Bm(){return Bm=$(function*(n,e){if(null==n.privateKey)throw new Error("PrivateKey was missing from PeerId");return yield(yield Rl(n.privateKey)).sign(e)}),Bm.apply(this,arguments)}function a2(n){return Fm.apply(this,arguments)}function Fm(){return Fm=$(function*(n){return yield Ol(n.identityKey)}),Fm.apply(this,arguments)}function c2(n){return o2.decode(n)}function u2(n){const e=Ot("noise-libp2p-static-key:");return br([e,n],e.length+n.length)}function l2(n,e,t){return Um.apply(this,arguments)}function Um(){return Um=$(function*(n,e,t){const r=yield Ol(e.identityKey);if(!r.equals(t))throw new Error("Peer ID doesn't match libp2p public key.");const i=u2(n);if(null==r.publicKey)throw new Error("PublicKey was missing from PeerId");if(null==e.identitySig)throw new Error("Signature was missing from message");if(!(yield xl(r.publicKey).verify(i,e.identitySig)))throw new Error("Static key doesn't match to peer that signed payload!");return r}),Um.apply(this,arguments)}function uh(n){return!(!(n instanceof Uint8Array)||32!==n.length)}var _r=x(1455);function zt(n){return Object.assign(_r(n),{error:_r(`${n}:error`),trace:_r(`${n}:trace`)})}_r.formatters.b=n=>null==n?"undefined":ui.baseEncode(n),_r.formatters.t=n=>null==n?"undefined":co.baseEncode(n),_r.formatters.m=n=>null==n?"undefined":jd.baseEncode(n),_r.formatters.p=n=>null==n?"undefined":n.toString(),_r.formatters.c=n=>null==n?"undefined":n.toString(),_r.formatters.k=n=>null==n?"undefined":n.toString();const Qr=zt("libp2p:noise");let qi;function f2(n){n?(qi(`LOCAL_PUBLIC_EPHEMERAL_KEY ${Lt(n.publicKey,"hex")}`),qi(`LOCAL_PRIVATE_EPHEMERAL_KEY ${Lt(n.privateKey,"hex")}`)):qi("Missing local ephemeral keys.")}function d2(n){qi(`REMOTE_EPHEMERAL_PUBLIC_KEY ${Lt(n,"hex")}`)}qi=CB?Qr:Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});class F5{constructor(e=0){this.n=e,this.bytes=new Uint8Array(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>4294967295)throw new Error("Cipherstate has reached maximum n, a new handshake must be performed")}}class V5 extends class U5{constructor(e){this.crypto=e}encryptWithAd(e,t,r){const i=this.encrypt(e.k,e.n,t,r);return e.n.increment(),i}decryptWithAd(e,t,r){const{plaintext:i,valid:s}=this.decrypt(e.k,e.n,t,r);return s&&e.n.increment(),{plaintext:i,valid:s}}hasKey(e){return!this.isEmptyKey(e.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(e){return kr(this.createEmptyKey(),e)}encrypt(e,t,r,i){return t.assertValue(),this.crypto.chaCha20Poly1305Encrypt(i,t.getBytes(),r,e)}encryptAndHash(e,t){let r;return r=this.hasKey(e.cs)?this.encryptWithAd(e.cs,e.h,t):t,this.mixHash(e,r),r}decrypt(e,t,r,i){t.assertValue();const s=this.crypto.chaCha20Poly1305Decrypt(i,t.getBytes(),r,e);return s?{plaintext:s,valid:!0}:{plaintext:new Uint8Array(0),valid:!1}}decryptAndHash(e,t){let r,i=!0;return this.hasKey(e.cs)?({plaintext:r,valid:i}=this.decryptWithAd(e.cs,e.h,t)):r=t,this.mixHash(e,t),{plaintext:r,valid:i}}dh(e,t){try{const r=this.crypto.generateX25519SharedKey(e,t);return 32===r.length?r:r.subarray(0,32)}catch(r){return Qr(r.message),new Uint8Array(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(br([e,t],e.length+t.length))}mixKey(e,t){const[r,i]=this.crypto.getHKDF(e.ck,t);e.cs=this.initializeKey(i),e.ck=r}initializeKey(e){return{k:e,n:new F5}}initializeSymmetric(e){const t=Ot(e,"utf-8"),r=this.hashProtocolName(t),i=r,s=this.createEmptyKey();return{cs:this.initializeKey(s),ck:i,h:r}}hashProtocolName(e){if(e.length<=32){const t=new Uint8Array(32);return t.set(e),t}return this.getHash(e,new Uint8Array(0))}split(e){const[t,r]=this.crypto.getHKDF(e.ck,new Uint8Array(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,new Uint8Array(0),t);return{ne:this.createEmptyKey(),ns:new Uint8Array(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,new Uint8Array(0),t.ciphertext)}}{initializeInitiator(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}initializeResponder(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}writeMessageA(e,t,r){const i=new Uint8Array(0);e.e=void 0!==r?r:this.crypto.generateX25519KeyPair();const s=e.e.publicKey;return this.mixHash(e.ss,s),{ne:s,ns:i,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=this.crypto.generateX25519KeyPair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const s=this.encryptAndHash(e.ss,e.s.publicKey);return this.mixKey(e.ss,this.dh(e.s.privateKey,e.re)),{ne:r,ns:s,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageC(e,t){const i=this.encryptAndHash(e.ss,e.s.publicKey);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const s=this.encryptAndHash(e.ss,t),a={ne:this.createEmptyKey(),ns:i,ciphertext:s},{cs1:l,cs2:_}=this.split(e.ss);return{h:e.ss.h,messageBuffer:a,cs1:l,cs2:_}}readMessageA(e,t){return uh(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(uh(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&uh(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:s,valid:i&&o}}readMessageC(e,t){const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);if(i&&uh(r)&&(e.rs=r),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:a,cs2:l}=this.split(e.ss);return{h:e.ss.h,plaintext:s,valid:i&&o,cs1:a,cs2:l}}initSession(e,t,r){const i=this.createEmptyKey(),s=new Uint8Array(32);let o;return o=e?this.initializeInitiator(t,r,s,i):this.initializeResponder(t,r,s,i),{hs:o,i:e,mc:0}}sendMessage(e,t,r){let i;if(0===e.mc)i=this.writeMessageA(e.hs,t,r);else if(1===e.mc)i=this.writeMessageB(e.hs,t);else if(2===e.mc){const{h:s,messageBuffer:o,cs1:a,cs2:l}=this.writeMessageC(e.hs,t);i=o,e.h=s,e.cs1=a,e.cs2=l}else{if(!(e.mc>2))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");i=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");i=this.writeMessageRegular(e.cs2,t)}}return e.mc++,i}recvMessage(e,t){let r=new Uint8Array(0),i=!1;if(0===e.mc)({plaintext:r,valid:i}=this.readMessageA(e.hs,t));else if(1===e.mc)({plaintext:r,valid:i}=this.readMessageB(e.hs,t));else if(2===e.mc){const{h:s,plaintext:o,valid:a,cs1:l,cs2:_}=this.readMessageC(e.hs,t);r=o,i=a,e.h=s,e.cs1=l,e.cs2=_}return e.mc++,{plaintext:r,valid:i}}}class H5{constructor(e,t,r,i,s,o,a,l){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=l??new V5(i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=new Uint8Array(0)}propose(){var e=this;return $(function*(){if(function N5(n){qi(`LOCAL_STATIC_PUBLIC_KEY ${Lt(n.publicKey,"hex")}`),qi(`LOCAL_STATIC_PRIVATE_KEY ${Lt(n.privateKey,"hex")}`)}(e.session.hs.s),e.isInitiator){Qr("Stage 0 - Initiator starting to send first message.");const t=e.xx.sendMessage(e.session,new Uint8Array(0));e.connection.writeLP(function xB(n){return br([n.ne,n.ciphertext],n.ne.length+n.ciphertext.length)}(t)),Qr("Stage 0 - Initiator finished sending first message."),f2(e.session.hs.e)}else{Qr("Stage 0 - Responder waiting to receive first message...");const t=function NB(n){if(n.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:n.subarray(0,32),ciphertext:n.subarray(32,n.length),ns:new Uint8Array(0)}}((yield e.connection.readLP()).subarray()),{valid:r}=e.xx.recvMessage(e.session,t);if(!r)throw new Oc("xx handshake stage 0 validation fail");Qr("Stage 0 - Responder received first message."),d2(e.session.hs.re)}})()}exchange(){var e=this;return $(function*(){if(e.isInitiator){Qr("Stage 1 - Initiator waiting to receive first message from responder...");const t=function MB(n){if(n.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:n.subarray(0,32),ns:n.subarray(32,80),ciphertext:n.subarray(80,n.length)}}((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Oc("xx handshake stage 1 validation fail");Qr("Stage 1 - Initiator received the message."),d2(e.session.hs.re),function M5(n){qi(`REMOTE_STATIC_PUBLIC_KEY ${Lt(n,"hex")}`)}(e.session.hs.rs),Qr("Initiator going to check remote's signature...");try{const s=c2(r);e.remotePeer=e.remotePeer||(yield a2(s)),yield l2(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new Hd(`Error occurred while verifying signed payload: ${s.message}`)}Qr("All good with the signature!")}else{Qr("Stage 1 - Responder sending out first message with signed payload and static key.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function RB(n){return br([n.ne,n.ns,n.ciphertext],n.ne.length+n.ns.length+n.ciphertext.length)}(t)),Qr("Stage 1 - Responder sent the second handshake message with signed payload."),f2(e.session.hs.e)}})()}finish(){var e=this;return $(function*(){if(e.isInitiator){Qr("Stage 2 - Initiator sending third handshake message.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function PB(n){return br([n.ns,n.ciphertext],n.ns.length+n.ciphertext.length)}(t)),Qr("Stage 2 - Initiator sent message with signed payload.")}else{Qr("Stage 2 - Responder waiting for third handshake message...");const t=function OB(n){if(n.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:n.subarray(0,48),ciphertext:n.subarray(48,n.length)}}((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Oc("xx handshake stage 2 validation fail");Qr("Stage 2 - Responder received the message, finished handshake.");try{const s=c2(r);e.remotePeer=e.remotePeer||(yield a2(s)),yield l2(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new Hd(`Error occurred while verifying signed payload: ${s.message}`)}}!function O5(n){n.cs1&&n.cs2?(qi(`CIPHER_STATE_1 ${n.cs1.n.getUint64()} ${Lt(n.cs1.k,"hex")}`),qi(`CIPHER_STATE_2 ${n.cs2.n.getUint64()} ${Lt(n.cs2.k,"hex")}`)):qi("Missing cipher state.")}(e.session)})()}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,new Uint8Array(0),e)}decrypt(e,t){const r=this.getCS(t,!1);return this.xx.decryptWithAd(r,new Uint8Array(0),e)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e,t=!0){if(!e.cs1||!e.cs2)throw new Oc("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteEarlyData(e){e&&(this.remoteEarlyData=e)}}class K5{constructor(e,t,r=oB,i){this.protocol="/noise",this.earlyData=t??new Uint8Array(0),this.crypto=r,this.staticKeys=e?this.crypto.generateX25519KeyPairFromSeed(e):this.crypto.generateX25519KeyPair(),this.prologue=i??new Uint8Array(0)}secureOutbound(e,t,r){var i=this;return $(function*(){const s=$C(t,{lengthEncoder:Ud,lengthDecoder:Vd,maxDataLength:pl}),o=yield i.performHandshake({connection:s,isInitiator:!0,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remoteEarlyData:o.remoteEarlyData,remotePeer:o.remotePeer}})()}secureInbound(e,t,r){var i=this;return $(function*(){const s=$C(t,{lengthEncoder:Ud,lengthDecoder:Vd,maxDataLength:pl}),o=yield i.performHandshake({connection:s,isInitiator:!1,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remoteEarlyData:o.remoteEarlyData,remotePeer:o.remotePeer}})()}performHandshake(e){var t=this;return $(function*(){const r=yield function x5(n,e,t){return Lm.apply(this,arguments)}(e.localPeer,t.staticKeys.publicKey,t.earlyData);return yield t.performXXHandshake(e,r)})()}performXXHandshake(e,t){var r=this;return $(function*(){const{isInitiator:i,remotePeer:s,connection:o}=e,a=new H5(i,t,r.prologue,r.crypto,r.staticKeys,o,s);try{yield a.propose(),yield a.exchange(),yield a.finish()}catch(l){if(l instanceof Error)throw l.message=`Error occurred during XX handshake: ${l.message}`,l}return a})()}createSecureConnection(e,t){return $(function*(){const[r,i]=function _B(){const n=jC(),e=jC();return[{source:n.source,sink:e.sink},{source:e.source,sink:n.sink}]}(),s=e.unwrap();return yield qn(r,function IB(n){return function(){var e=hn(function*(t){var s,r=!1,i=!1;try{for(var a,o=Pt(t);r=!(a=yield lt(o.next())).done;r=!1){const l=a.value;for(let _=0;_l.length&&(R=l.length),yield n.encrypt(l.subarray(_,R),n.session)}}}catch(l){i=!0,s=l}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),Os({lengthEncoder:Ud}),s,ps({lengthDecoder:Vd}),function TB(n){return function(){var e=hn(function*(t){var s,r=!1,i=!1;try{for(var a,o=Pt(t);r=!(a=yield lt(o.next())).done;r=!1){const l=a.value;for(let _=0;_l.length&&(R=l.length);const{plaintext:N,valid:B}=yield lt(n.decrypt(l.subarray(_,R),n.session));if(!B)throw new Error("Failed to validate decrypted chunk");yield N}}}catch(l){i=!0,s=l}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),r),i})()}}function fo(n){return null!=n&&"function"==typeof n.start&&"function"==typeof n.stop}function Fr(n){return null!=n&&"function"==typeof n.init}class ho{constructor(e={}){this.started=!1,null!=e.peerId&&this.setPeerId(e.peerId),null!=e.addressManager&&this.setAddressManager(e.addressManager),null!=e.peerStore&&this.setPeerStore(e.peerStore),null!=e.upgrader&&this.setUpgrader(e.upgrader),null!=e.metrics&&this.setMetrics(e.metrics),null!=e.registrar&&this.setRegistrar(e.registrar),null!=e.connectionManager&&this.setConnectionManager(e.connectionManager),null!=e.transportManager&&this.setTransportManager(e.transportManager),null!=e.connectionGater&&this.setConnectionGater(e.connectionGater),null!=e.contentRouting&&this.setContentRouting(e.contentRouting),null!=e.peerRouting&&this.setPeerRouting(e.peerRouting),null!=e.datastore&&this.setDatastore(e.datastore),null!=e.connectionProtector&&this.setConnectionProtector(e.connectionProtector),null!=e.dht&&this.setDHT(e.dht),null!=e.pubsub&&this.setPubSub(e.pubsub)}isStarted(){return this.started}beforeStart(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}()))})()}start(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){yield r.start()});return function(r){return t.apply(this,arguments)}}())),e.started=!0})()}afterStart(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}()))})()}beforeStop(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}()))})()}stop(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){yield r.stop()});return function(r){return t.apply(this,arguments)}}())),e.started=!1})()}afterStop(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}()))})()}setPeerId(e){return this.peerId=e,e}getPeerId(){if(null==this.peerId)throw ae(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this.peerId}setMetrics(e){return this.metrics=e,Fr(e)&&e.init(this),e}getMetrics(){return this.metrics}setAddressManager(e){return this.addressManager=e,Fr(e)&&e.init(this),e}getAddressManager(){if(null==this.addressManager)throw ae(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this.addressManager}setPeerStore(e){return this.peerStore=e,Fr(e)&&e.init(this),e}getPeerStore(){if(null==this.peerStore)throw ae(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this.peerStore}setUpgrader(e){return this.upgrader=e,Fr(e)&&e.init(this),e}getUpgrader(){if(null==this.upgrader)throw ae(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this.upgrader}setRegistrar(e){return this.registrar=e,Fr(e)&&e.init(this),e}getRegistrar(){if(null==this.registrar)throw ae(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this.registrar}setConnectionManager(e){return this.connectionManager=e,Fr(e)&&e.init(this),e}getConnectionManager(){if(null==this.connectionManager)throw ae(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this.connectionManager}setTransportManager(e){return this.transportManager=e,Fr(e)&&e.init(this),e}getTransportManager(){if(null==this.transportManager)throw ae(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this.transportManager}setConnectionGater(e){return this.connectionGater=e,Fr(e)&&e.init(this),e}getConnectionGater(){if(null==this.connectionGater)throw ae(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this.connectionGater}setContentRouting(e){return this.contentRouting=e,Fr(e)&&e.init(this),e}getContentRouting(){if(null==this.contentRouting)throw ae(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this.contentRouting}setPeerRouting(e){return this.peerRouting=e,Fr(e)&&e.init(this),e}getPeerRouting(){if(null==this.peerRouting)throw ae(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this.peerRouting}setDatastore(e){return this.datastore=e,Fr(e)&&e.init(this),e}getDatastore(){if(null==this.datastore)throw ae(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this.datastore}setConnectionProtector(e){return this.connectionProtector=e,Fr(e)&&e.init(this),e}getConnectionProtector(){return this.connectionProtector}setDHT(e){return this.dht=e,Fr(e)&&e.init(this),e}getDHT(){if(null==this.dht)throw ae(new Error("dht not set"),"ERR_SERVICE_MISSING");return this.dht}setPubSub(e){return this.pubsub=e,Fr(e)&&e.init(this),e}getPubSub(){if(null==this.pubsub)throw ae(new Error("pubsub not set"),"ERR_SERVICE_MISSING");return this.pubsub}setDialer(e){return this.dialer=e,Fr(e)&&e.init(this),e}getDialer(){if(null==this.dialer)throw ae(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this.dialer}}class h2 extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function vs(n,e,t){const r=t??{},i=function $5(n){if(null!=n){if("function"==typeof n[Symbol.iterator])return n[Symbol.iterator]();if("function"==typeof n[Symbol.asyncIterator])return n[Symbol.asyncIterator]();if("function"==typeof n.next)return n}throw new Error("argument is not an iterator or iterable")}(n);function o(){return(o=hn(function*(){let a;const l=()=>{a?.()};for(e.addEventListener("abort",l);;){let _;try{if(e.aborted){const{abortMessage:N,abortCode:B}=r;throw new h2(N,B)}const R=new Promise((N,B)=>{a=()=>{const{abortMessage:z,abortCode:Z}=r;B(new h2(z,Z))}});_=yield lt(Promise.race([R,i.next()])),a=null}catch(R){e.removeEventListener("abort",l);const N="aborted"===R.type&&e.aborted;if(N&&null!=r.onAbort&&(yield lt(r.onAbort(n))),"function"==typeof i.return)try{const B=i.return();B instanceof Promise&&B.catch(z=>{null!=r.onReturnError&&r.onReturnError(z)})}catch(B){null!=r.onReturnError&&r.onReturnError(B)}if(N&&!0===r.returnOnAbort)return;throw R}if(!0===_.done)break;yield _.value}e.removeEventListener("abort",l)})).apply(this,arguments)}return function s(){return o.apply(this,arguments)}()}function j5(n,e,t){return r=>n(vs(r,e,t))}function Go(n,e,t){return{sink:j5(n.sink,e,{...t,onAbort:void 0}),source:vs(n.source,e,t)}}var dr=x(1732);function p2(n){return new Uint8Array(n)}var un=(()=>(function(n){n[n.NEW_STREAM=0]="NEW_STREAM",n[n.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",n[n.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",n[n.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",n[n.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",n[n.RESET_RECEIVER=5]="RESET_RECEIVER",n[n.RESET_INITIATOR=6]="RESET_INITIATOR"}(un||(un={})),un))();const Km=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),g2=Object.freeze({NEW_STREAM:un.NEW_STREAM,MESSAGE:un.MESSAGE_INITIATOR,CLOSE:un.CLOSE_INITIATOR,RESET:un.RESET_INITIATOR}),z5=Object.freeze({MESSAGE:un.MESSAGE_RECEIVER,CLOSE:un.CLOSE_RECEIVER,RESET:un.RESET_RECEIVER}),y2=new class G5{constructor(){this._pool=p2(10240),this._poolOffset=0}write(e){const t=this._pool;let r=this._poolOffset;dr.encode(e.id<<3|e.type,t,r),r+=dr.encode.bytes,dr.encode(e.type!==un.NEW_STREAM&&e.type!==un.MESSAGE_INITIATOR&&e.type!==un.MESSAGE_RECEIVER||null==e.data?0:e.data.length,t,r),r+=dr.encode.bytes;const i=t.subarray(this._poolOffset,r);return 10240-r<100?(this._pool=p2(10240),this._poolOffset=0):this._poolOffset=r,e.type!==un.NEW_STREAM&&e.type!==un.MESSAGE_INITIATOR&&e.type!==un.MESSAGE_RECEIVER||null==e.data?[i]:[i,...e.data instanceof Uint8Array?[e.data]:e.data]}};function jm(){return jm=hn(function*(n){var r,e=!1,t=!1;try{for(var s,i=Pt(n);e=!(s=yield lt(i.next())).done;e=!1){const o=s.value;if(Array.isArray(o))for(const a of o)yield*Mr(Pt(y2.write(a)),lt);else yield*Mr(Pt(y2.write(o)),lt)}}catch(o){t=!0,r=o}finally{try{e&&null!=i.return&&(yield lt(i.return()))}finally{if(t)throw r}}}),jm.apply(this,arguments)}class q5{constructor(){this._buffer=new qr,this._headerInfo=null}write(e){if(null==e||0===e.length)return[];this._buffer.append(e);const t=[];for(;0!==this._buffer.length;){if(null==this._headerInfo)try{this._headerInfo=this._decodeHeader(this._buffer)}catch{break}const{id:r,type:i,length:s,offset:o}=this._headerInfo;if(this._buffer.length-o>3,type:o,offset:r+s,length:i}}}function v2(n,e=0){let s,t=0,r=0,i=e;const o=n.length;do{if(i>=o||r>49)throw e=0,new RangeError("Could not decode varint");s=n.get(i++),t+=r<28?(127&s)<=128);return{value:t,offset:e=i-e}}function Q5(n){return zm.apply(this,arguments)}function zm(){return zm=hn(function*(n){const e=new q5;var i,t=!1,r=!1;try{for(var o,s=Pt(n);t=!(o=yield lt(s.next())).done;t=!1){const l=e.write(o.value);l.length>0&&(yield l)}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield lt(s.return()))}finally{if(r)throw i}}}),zm.apply(this,arguments)}const E2=1<<20;var lh=x(772);const Es=zt("libp2p:mplex:stream"),Gm="ERR_STREAM_RESET";class nU extends Map{constructor(e){super();const{system:t,component:r,metric:i,metrics:s}=e;this.system=t??"libp2p",this.component=r,this.metric=i,this.metrics=s,this.updateComponentMetric()}set(e,t){return super.set(e,t),this.updateComponentMetric(),this}delete(e){const t=super.delete(e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metrics.updateComponentMetric({system:this.system,component:this.component,metric:this.metric,value:this.size})}}function kl(n){const{system:e,component:t,metric:r,metrics:i}=n;let s;return s=null!=i?new nU({system:e,component:t,metric:r,metrics:i}):new Map,s}var rU=x(7813);const bs=zt("libp2p:mplex");function b2(n){const e={...n,type:`${Km[n.type]} (${n.type})`};return n.type===un.NEW_STREAM&&(e.data=Lt(n.data instanceof Uint8Array?n.data:n.data.subarray())),(n.type===un.MESSAGE_INITIATOR||n.type===un.MESSAGE_RECEIVER)&&(e.data=Lt(n.data instanceof Uint8Array?n.data:n.data.subarray(),"base16")),e}class cU{constructor(e,t){this.protocol="/mplex/6.7.0",t=t??{},this._streamId=0,this._streams={initiators:kl({metrics:e.getMetrics(),component:"mplex",metric:"initiatorStreams"}),receivers:kl({metrics:e.getMetrics(),component:"mplex",metric:"receiverStreams"})},this._init=t,this.sink=this._createSink();const r=this._createSource();this._source=r,this.source=r,this.closeController=new AbortController,this.rateLimiter=new rU.RateLimiterMemory({points:t.disconnectThreshold??5,duration:1})}init(e){}get streams(){const e=[];for(const t of this._streams.initiators.values())e.push(t);for(const t of this._streams.receivers.values())e.push(t);return e}newStream(e){if(this.closeController.signal.aborted)throw new Error("Muxer already closed");const t=this._streamId++;return e=null==e?t.toString():e.toString(),this._newStream({id:t,name:e,type:"initiator",registry:this._streams.initiators})}close(e){this.closeController.signal.aborted||(this.streams.forEach(null!=e?t=>t.abort(e):t=>t.close()),this.closeController.abort())}_newReceiverStream(e){const{id:t,name:r}=e;return this._newStream({id:t,name:r,type:"receiver",registry:this._streams.receivers})}_newStream(e){const{id:t,name:r,type:i,registry:s}=e;if(bs("new %s stream %s %s",i,t),"initiator"===i&&this._streams.initiators.size===(this._init.maxOutboundStreams??1024))throw ae(new Error("Too many outbound streams open"),"ERR_TOO_MANY_OUTBOUND_STREAMS");if(s.has(t))throw new Error(`${i} stream ${t} already exists!`);const l=function tU(n){const{id:e,name:t,send:r,onEnd:i,type:s="initiator",maxMsgSize:o=E2}=n,a=new AbortController,l=new AbortController,_=new AbortController,R="initiator"===s?g2:z5,N="initiator"===s?`i${e}`:`r${e}`,B=`${t??e}`;let se,z=!1,Z=!1,J=!1;const he={open:Date.now()},ue=Pe=>{Z||(Z=!0,Es.trace("%s stream %s sink end - err: %o",s,B,Pe),null!=Pe&&null==se&&(se=Pe),z&&(he.close=Date.now(),i?.(se)))},Re=Mc({onEnd:Pe=>{z||(z=!0,Es.trace("%s stream %s source end - err: %o",s,B,Pe),null!=Pe&&null==se&&(se=Pe),Z&&($e.stat.timeline.close=Date.now(),i?.(se)))}}),$e={close:()=>{Es.trace("%s stream %s close",s,B),$e.closeRead(),$e.closeWrite()},closeRead:()=>{Es.trace("%s stream %s closeRead",s,B),!z&&Re.end()},closeWrite:()=>{if(Es.trace("%s stream %s closeWrite",s,B),!Z){_.abort();try{r({id:e,type:R.CLOSE})}catch(Pe){Es.trace("%s stream %s error sending close",s,t,Pe)}ue()}},abort:Pe=>{Es.trace("%s stream %s abort",s,B,Pe),Re.end(Pe),a.abort(),ue(Pe)},reset:()=>{const Pe=ae(new Error("stream reset"),Gm);l.abort(),Re.end(Pe),ue(Pe)},sink:(Pe=$(function*(bt){if(J)throw ae(new Error("sink already called on stream"),"ERR_DOUBLE_SINK");if(J=!0,Z)throw ae(new Error("stream closed for writing"),"ERR_SINK_ENDED");bt=vs(bt,(0,lh.anySignal)([a.signal,l.signal,_.signal]));try{"initiator"===s&&r({id:e,type:g2.NEW_STREAM,data:new qr(Ot(B))});const Qn=new qr;var pn,yt=!1,Xt=!1;try{for(var Di,Gn=Pt(bt);yt=!(Di=yield Gn.next()).done;yt=!1)for(Qn.append(Di.value);0!==Qn.length;){if(Qn.length<=o){r({id:e,type:R.MESSAGE,data:Qn.sublist()}),Qn.consume(Qn.length);break}r({id:e,type:R.MESSAGE,data:Qn.sublist(0,o)}),Qn.consume(o)}}catch(Do){Xt=!0,pn=Do}finally{try{yt&&null!=Gn.return&&(yield Gn.return())}finally{if(Xt)throw pn}}}catch(Qn){if("aborted"===Qn.type&&"The operation was aborted"===Qn.message){if(_.signal.aborted)return;l.signal.aborted&&(Qn.message="stream reset",Qn.code=Gm),a.signal.aborted&&(Qn.message="stream aborted",Qn.code="ERR_STREAM_ABORT")}if(Qn.code===Gm)Es.trace("%s stream %s reset",s,t);else{Es.trace("%s stream %s error",s,t,Qn);try{r({id:e,type:R.RESET})}catch(Do){Es.trace("%s stream %s error sending reset",s,t,Do)}}return Re.end(Qn),void ue(Qn)}try{r({id:e,type:R.CLOSE})}catch(Qn){Es.trace("%s stream %s error sending close",s,t,Qn)}ue()}),function(yt){return Pe.apply(this,arguments)}),source:Re,sourcePush:Pe=>{Re.push(Pe)},sourceReadableLength:()=>Re.readableLength,stat:{direction:"initiator"===s?"outbound":"inbound",timeline:he},metadata:{},id:N};var Pe;return $e}({id:t,name:r,send:_=>{bs.enabled&&bs.trace("%s stream %s send",i,t,b2(_)),this._source.push(_)},type:i,onEnd:()=>{bs("%s stream with id %s and protocol %s ended",i,t,l.stat.protocol),s.delete(t),null!=this._init.onStreamEnd&&this._init.onStreamEnd(l)},maxMsgSize:this._init.maxMsgSize});return s.set(t,l),l}_createSink(){var e=this;return function(){var r=$(function*(i){const s=[e.closeController.signal];null!=e._init.signal&&s.push(e._init.signal),i=vs(i,lh(s));try{yield qn(i,Q5,function Z5(n){const e=n??E2,t=r=>{if((r.type===un.NEW_STREAM||r.type===un.MESSAGE_INITIATOR||r.type===un.MESSAGE_RECEIVER)&&r.data.byteLength>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return r=>{return(i=hn(function*(){var l,o=!1,a=!1;try{for(var R,_=Pt(r);o=!(R=yield lt(_.next())).done;o=!1){const N=R.value;Array.isArray(N)?(N.forEach(t),yield*Mr(Pt(N),lt)):(t(N),yield N)}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield lt(_.return()))}finally{if(a)throw l}}}),function s(){return i.apply(this,arguments)})();var i}}(e._init.maxMsgSize),function(){var o=$(function*(a){var R,l=!1,_=!1;try{for(var B,N=Pt(a);l=!(B=yield N.next()).done;l=!1){const z=B.value;yield e._handleIncoming(z)}}catch(z){_=!0,R=z}finally{try{l&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()),e._source.end()}catch(o){bs("error in sink",o),e._source.end(o)}});return function(s){return r.apply(this,arguments)}}()}_createSource(){const t=function cB(n={}){return VC(t=>{let r;const i=[];for(;!t.isEmpty()&&(r=t.shift(),null!=r);){if(null!=r.error)throw r.error;!1===r.done&&i.push(r.value)}return null==r?{done:!0}:{done:!0===r.done,value:i}},n)}({objectMode:!0,onEnd:r=>{this.close(r)}});return Object.assign(function W5(n){return jm.apply(this,arguments)}(t),{push:t.push,end:t.end,return:t.return})}_handleIncoming(e){var t=this;return $(function*(){const{id:r,type:i}=e;if(bs.enabled&&bs.trace("incoming message",b2(e)),e.type===un.NEW_STREAM){if(t._streams.receivers.size===(t._init.maxInboundStreams??1024)){bs("too many inbound streams open"),t._source.push({id:r,type:un.RESET_RECEIVER});try{yield t.rateLimiter.consume("new-stream",1)}catch{return bs("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),void t._source.end(new Error("Too many open streams"))}return}const l=t._newReceiverStream({id:r,name:Lt(e.data instanceof Uint8Array?e.data:e.data.subarray())});return void(null!=t._init.onIncomingStream&&t._init.onIncomingStream(l))}const o=(1==(1&i)?t._streams.initiators:t._streams.receivers).get(r);if(null==o)return void bs("missing stream %s for message type %s",r,Km[i]);const a=t._init.maxStreamBufferSize??4194304;switch(i){case un.MESSAGE_INITIATOR:case un.MESSAGE_RECEIVER:if(o.sourceReadableLength()>a){t._source.push({id:e.id,type:i===un.MESSAGE_INITIATOR?un.RESET_RECEIVER:un.RESET_INITIATOR});const l=ae(new Error("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers"),"ERR_STREAM_INPUT_BUFFER_FULL");return void o.abort(l)}o.sourcePush(e.data);break;case un.CLOSE_INITIATOR:case un.CLOSE_RECEIVER:o.closeRead();break;case un.RESET_INITIATOR:case un.RESET_RECEIVER:o.reset();break;default:bs("unknown message type %s",i)}})()}}class uU{constructor(e={}){this.protocol="/mplex/6.7.0",this.components=new ho,this._init=e}init(e){this.components=e}createStreamMuxer(e={}){return new cU(this.components,{...e,...this._init})}}const lU=WebSocket;var fU=x(3676);function w2(n){return n instanceof ArrayBuffer||"ArrayBuffer"===n?.constructor?.name&&"number"==typeof n?.byteLength}const dU=n=>{n.binaryType="arraybuffer";const e=function(){var s=$(function*(){return yield new Promise((o,a)=>{if(r)return o();if(null!=i)return a(i);const l=N=>{n.removeEventListener("open",_),n.removeEventListener("error",R),N()},_=()=>l(o),R=N=>{l(()=>a(N.error??new Error(`connect ECONNREFUSED ${n.url}`)))};n.addEventListener("open",_),n.addEventListener("error",R)})});return function(){return s.apply(this,arguments)}}(),t=hn(function*(){const s=new fU.zN(({push:N,stop:B,fail:z})=>{const Z=se=>{let he=null;"string"==typeof se.data&&(he=Ot(se.data)),w2(se.data)&&(he=new Uint8Array(se.data)),se.data instanceof Uint8Array&&(he=se.data),null!=he&&N(he)},J=se=>z(se.error??new Error("Socket error"));return n.addEventListener("message",Z),n.addEventListener("error",J),n.addEventListener("close",B),()=>{n.removeEventListener("message",Z),n.removeEventListener("error",J),n.removeEventListener("close",B)}},{highWaterMark:1/0});yield lt(e());var l,o=!1,a=!1;try{for(var R,_=Pt(s);o=!(R=yield lt(_.next())).done;o=!1){const N=R.value;yield w2(N)?new Uint8Array(N):N}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield lt(_.return()))}finally{if(a)throw l}}})();let i,r=1===n.readyState;return n.addEventListener("open",()=>{r=!0,i=null}),n.addEventListener("close",()=>{r=!1,i=null}),n.addEventListener("error",s=>{r||(i=s.error??new Error(`connect ECONNREFUSED ${n.url}`))}),Object.assign(t,{connected:e})},hU=n=>{if(n.readyState>=2)throw new Error("socket closed");if(1!==n.readyState)return new Promise((e,t)=>{function r(){n.removeEventListener("open",i),n.removeEventListener("error",s)}function i(){r(),e()}function s(o){r(),t(o.error??new Error(`connect ECONNREFUSED ${n.url}`))}n.addEventListener("open",i),n.addEventListener("error",s)})},pU=(n,e)=>((e=e??{}).closeOnEnd=!1!==e.closeOnEnd,function(){var r=$(function*(i){var a,s=!1,o=!1;try{for(var _,l=Pt(i);s=!(_=yield l.next()).done;s=!1){const R=_.value;try{yield hU(n)}catch(N){if("socket closed"===N.message)break;throw N}n.send(R)}}catch(R){o=!0,a=R}finally{try{s&&null!=l.return&&(yield l.return())}finally{if(o)throw a}}if(null!=e.closeOnEnd&&n.readyState<=1)return yield new Promise((R,N)=>{n.addEventListener("close",B=>{if(B.wasClean||1006===B.code)R();else{const z=Object.assign(new Error("ws error"),{event:B});N(z)}}),setTimeout(()=>n.close())})});return function(s){return r.apply(this,arguments)}}()),gU=(n,e)=>{e=e??{};const t=dU(n);let r=e.remoteAddress,i=e.remotePort;if(null!=n.url)try{const o=new URL(n.url);r=o.hostname,i=parseInt(o.port,10)}catch{}if(null==r||null==i)throw new Error("Remote connection did not have address and/or port");return{sink:pU(n,e),source:t,connected:(o=$(function*(){return yield t.connected()}),function(){return o.apply(this,arguments)}),close:function(){var o=$(function*(){(n.readyState===n.CONNECTING||n.readyState===n.OPEN)&&(yield new Promise(a=>{n.addEventListener("close",()=>{a()}),n.close()}))});return function(){return o.apply(this,arguments)}}(),destroy:()=>{null!=n.terminate?n.terminate():n.close()},remoteAddress:r,remotePort:i,socket:n};var o};var yU=x(8596);const mU={http:"ws",https:"wss"};const _2="[a-fA-F\\d:]",Wo=n=>n&&n.includeBoundaries?`(?:(?<=\\s|^)(?=${_2})|(?<=${_2})(?=\\s|$))`:"",ws="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",Dr="[a-fA-F\\d]{1,4}",fh=`\n(?:\n(?:${Dr}:){7}(?:${Dr}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${Dr}:){6}(?:${ws}|:${Dr}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${Dr}:){5}(?::${ws}|(?::${Dr}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${Dr}:){4}(?:(?::${Dr}){0,1}:${ws}|(?::${Dr}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${Dr}:){3}(?:(?::${Dr}){0,2}:${ws}|(?::${Dr}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${Dr}:){2}(?:(?::${Dr}){0,3}:${ws}|(?::${Dr}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${Dr}:){1}(?:(?::${Dr}){0,4}:${ws}|(?::${Dr}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${Dr}){0,5}:${ws}|(?::${Dr}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),wU=new RegExp(`(?:^${ws}$)|(?:^${fh}$)`),_U=new RegExp(`^${ws}$`),DU=new RegExp(`^${fh}$`),Wm=n=>n&&n.exact?wU:new RegExp(`(?:${Wo(n)}${ws}${Wo(n)})|(?:${Wo(n)}${fh}${Wo(n)})`,"g");Wm.v4=n=>n&&n.exact?_U:new RegExp(`${Wo(n)}${ws}${Wo(n)}`,"g"),Wm.v6=n=>n&&n.exact?DU:new RegExp(`${Wo(n)}${fh}${Wo(n)}`,"g");const qm=Wm,{toString:IU}=Object.prototype,D2={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Ym(n,e,{}={}){try{return function SU(n){const e=(...t)=>n(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${n.name||""})`,configurable:!0}),e}(()=>function AU(n,e={}){if(!function TU(n){return"[object RegExp]"===IU.call(n)}(n))throw new TypeError("Expected a RegExp instance");const t=Object.keys(D2).map(i=>("boolean"==typeof e[i]?e[i]:n[i])?D2[i]:"").join(""),r=new RegExp(e.source||n.source,t);return r.lastIndex="number"==typeof e.lastIndex?e.lastIndex:n.lastIndex,r}(n).test(e))()}catch(r){throw r}}const Qm={timeout:400};function Zm(n){return Ym(qm({exact:!0}),n.slice(0,45),Qm)}const T2=function RU(n){return Ym(qm.v4({exact:!0}),n.slice(0,15),Qm)},PU=function I2(n){return Ym(qm.v6({exact:!0}),n.slice(0,45),Qm)},A2=function(n){let t,e=0;if(n=n.trim(),T2(n))t=new Uint8Array(e+4),n.split(/\./g).forEach(r=>{t[e++]=255&parseInt(r,10)});else if(PU(n)){const r=n.split(":",8);let i;for(i=0;i0;i--)s.push("0");r.splice.apply(r,s)}for(t=new Uint8Array(e+16),i=0;i>8&255,t[e++]=255&s}}if(null==t)throw new Error(`invalid ip address "${n}"`);return t},_s=-1,dh={},Xm={};function Sr(n){if("number"==typeof n){if(null!=Xm[n])return Xm[n];throw new Error(`no protocol with code: ${n}`)}if("string"==typeof n){if(null!=dh[n])return dh[n];throw new Error(`no protocol with name: ${n}`)}throw new Error("invalid protocol id type: "+typeof n)}function x2(n,e){switch(Sr(n).code){case 4:case 41:return function kU(n){const e=function(n,e=0,t){e=~~e,t=t??n.length-e;const r=[];let i="";const s=new DataView(n.buffer);if(4===t){for(let o=0;o65536)throw new Error("Port number is not in range(1, 65536)");const i=ev(r);return br([t,i],t.length+i.length)}(e);case 445:return function $U(n){const e=n.split(":");if(2!==e.length)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(56!==e[0].length)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);const t=co.decode(`b${e[0]}`),r=parseInt(e[1],10);if(r<1||r>65536)throw new Error("Port number is not in range(1, 65536)");const i=ev(r);return br([t,i],t.length+i.length)}(e);case 466:return function UU(n){const e=OU.decode(n),t=Uint8Array.from(dr.encode(e.length));return br([t,e],t.length+e.length)}(e);default:return Ot(e,"base16")}}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,_s,"ip6zone"],[53,_s,"dns",!0],[54,_s,"dns4",!0],[55,_s,"dns6",!0],[56,_s,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,_s,"unix",!1,!0],[421,_s,"ipfs"],[421,_s,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,_s,"garlic64"],[460,0,"quic"],[466,_s,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,_s,"memory"]].forEach(n=>{const e=function MU(n,e,t,r,i){return{code:n,size:e,name:t,resolvable:Boolean(r),path:Boolean(i)}}(...n);Xm[e.code]=e,dh[e.name]=e});const Jm=Object.values(vl).map(n=>n.decoder),OU=function(){let n=Jm[0].or(Jm[1]);return Jm.slice(2).forEach(e=>n=n.or(e)),n}();function ev(n){const e=new ArrayBuffer(2);return new DataView(e).setUint16(0,n),new Uint8Array(e)}function N2(n){return new DataView(n.buffer).getUint16(n.byteOffset)}function O2(n){return n.map(e=>{const t=ph(e);return null!=e[1]?[t.code,x2(t.code,e[1])]:[t.code]})}function k2(n){return nv(br(n.map(e=>{const t=ph(e);let r=Uint8Array.from(dr.encode(t.code));return e.length>1&&null!=e[1]&&(r=br([r,e[1]])),r})))}function L2(n,e){return n.size>0?n.size/8:0===n.size?0:dr.decode(e)+dr.decode.bytes}function hh(n){const e=[];let t=0;for(;tn.length)throw F2("Invalid address Uint8Array: "+Lt(n,"base16"));e.push([r,a])}return e}function tv(n){return function zU(n){const e=[];return n.map(t=>{const r=ph(t);return e.push(r.name),t.length>1&&null!=t[1]&&e.push(t[1]),null}),rv(e.join("/"))}(O2(hh(n)))}function nv(n){const e=function B2(n){try{hh(n)}catch(e){return e}}(n);if(null!=e)throw e;return Uint8Array.from(n)}function rv(n){return"/"+n.trim().split("/").filter(e=>e).join("/")}function F2(n){return new Error("Error parsing address: "+n)}function ph(n){return Sr(n[0])}const YU=Symbol.for("nodejs.util.inspect.custom"),U2=[Sr("dns").code,Sr("dns4").code,Sr("dns6").code,Sr("dnsaddr").code],QU=[Sr("p2p").code,Sr("ipfs").code],V2=new Map,H2=Symbol.for("@multiformats/js-multiaddr/multiaddr");let mn=(()=>{class n{constructor(t){if(null==t&&(t=""),Object.defineProperty(this,H2,{value:!0}),t instanceof Uint8Array)this.bytes=nv(t);else if("string"==typeof t){if(t.length>0&&"/"!==t.charAt(0))throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=function qU(n){return function WU(n){const e=function jU(n){const e=[],t=n.split("/").slice(1);if(1===t.length&&""===t[0])return[];for(let r=0;r=t.length)throw F2("invalid address: "+n);if(!0===s.path){e.push([i,rv(t.slice(r).join("/"))]);break}e.push([i,t[r]])}else e.push([i])}return e}(n=rv(n)),t=function GU(n){return n.map(e=>{Array.isArray(e)||(e=[e]);const t=ph(e);return e.length>1?[t.code,R2(t.code,e[1])]:[t.code]})}(e);return k2(t)}(n)}(t)}else{if(!n.isMultiaddr(t))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=nv(t.bytes)}}toString(){return tv(this.bytes)}toJSON(){return this.toString()}toOptions(){const t=this.protoCodes(),r=this.toString().split("/").slice(1);let i,s;if(r.length>2)U2.includes(t[0])&&QU.includes(t[1])?(i=Sr("tcp").name,s=443):(i=Sr(r[2]).name,s=parseInt(r[3]));else{if(!U2.includes(t[0]))throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');i=Sr("tcp").name,s=443}return{family:41===t[0]||55===t[0]?6:4,host:r[1],transport:i,port:s}}protos(){return this.protoCodes().map(t=>Object.assign({},Sr(t)))}protoCodes(){const t=[],r=this.bytes;let i=0;for(;it.name)}tuples(){return hh(this.bytes)}stringTuples(){return O2(hh(this.bytes))}encapsulate(t){return t=new n(t),new n(this.toString()+t.toString())}decapsulate(t){const r=t.toString(),i=this.toString(),s=i.lastIndexOf(r);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new n(i.slice(0,s))}decapsulateCode(t){const r=this.tuples();for(let i=r.length-1;i>=0;i--)if(r[i][0]===t)return new n(k2(r.slice(0,i)));return this}getPeerId(){try{const r=this.stringTuples().filter(i=>i[0]===dh.ipfs.code).pop();if(null!=r?.[1]){const i=r[1];return Lt("Q"===i[0]||"1"===i[0]?ui.decode(`z${i}`):wr.parse(i).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(r=>!0===Sr(r[0]).path)[0][1],null==t&&(t=null)}catch{t=null}return t}equals(t){return kr(this.bytes,t.bytes)}resolve(t){var r=this;return $(function*(){const i=r.protos().find(a=>a.resolvable);if(null==i)return[r];const s=V2.get(i.name);if(null==s)throw ae(new Error(`no available resolver for ${i.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(yield s(r,t)).map(a=>new n(a))})()}nodeAddress(){const t=this.toOptions();if("tcp"!==t.transport&&"udp"!==t.transport)throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){const r=(t??this).protos();return!(2!==r.length||4!==r[0].code&&41!==r[0].code||6!==r[1].code&&273!==r[1].code)}static fromNodeAddress(t,r){if(null==t)throw new Error("requires node address object");if(null==r)throw new Error("requires transport protocol");let i;switch(t.family){case 4:i="ip4";break;case 6:i="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new n("/"+[i,t.address,r,t.port].join("/"))}static isName(t){return!!n.isMultiaddr(t)&&t.protos().some(r=>r.resolvable)}static isMultiaddr(t){return Boolean(t?.[H2])}[YU](){return""}inspect(){return""}}return n.resolvers=V2,n})();const gh=(n,e)=>e,JU={ip4:gh,ip6:(n,e,t,r)=>1===r.length&&"ip6"===r[0].protocol?e:`[${e}]`,tcp:(n,e,t,r,i)=>r.some(s=>["http","https","ws","wss"].includes(s.protocol))?`${n}:${e}`:((n,e,t,r)=>{if(null!=r&&!1===r.assumeHttp)return`tcp://${n}:${e}`;let i="tcp",s=`:${e}`;return"tcp"===t[t.length-1].protocol&&(i="443"===e?"https":"http",s="443"===e||"80"===e?"":s),`${i}://${n}${s}`})(n,e,r,i),udp:(n,e)=>`udp://${n}:${e}`,dnsaddr:gh,dns4:gh,dns6:gh,ipfs:(n,e)=>`${n}/ipfs/${e}`,p2p:(n,e)=>`${n}/p2p/${e}`,http:n=>`http://${n}`,https:n=>`https://${n}`,ws:n=>`ws://${n}`,wss:n=>`wss://${n}`,"p2p-websocket-star":n=>`${n}/p2p-websocket-star`,"p2p-webrtc-star":n=>`${n}/p2p-webrtc-star`,"p2p-webrtc-direct":n=>`${n}/p2p-webrtc-direct`};class eu extends Error{constructor(e="The operation was aborted"){super(e),this.code=eu.code,this.type=eu.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}}var tV=x(9456);const iv="object"==typeof window&&"object"==typeof document&&9===document.nodeType,yh=tV(),mh=iv&&!yh,nV=yh&&!iv,rV=yh&&iv,iV=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&"node"===globalThis.process.release.name&&!yh,K2="function"==typeof importScripts&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,sV=(typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis,typeof navigator<"u"&&"ReactNative"===navigator.product);class lV extends Error{constructor(e){super(e),this.name="TimeoutError"}}class fV extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const z2=n=>void 0===globalThis.DOMException?new fV(n):new DOMException(n),G2=n=>{const e=void 0===n.reason?z2("This operation was aborted."):n.reason;return e instanceof Error?e:z2(e)},W2=zt("libp2p:websockets:socket");const pV=It("dns4"),gV=It("dns6"),yV=It("dnsaddr"),Ca=Zr(It("dns"),yV,pV,gV),vh=Zr(It("ip4"),It("ip6")),Ll=Zr(en(vh,It("tcp")),en(Ca,It("tcp"))),q2=en(vh,It("udp")),mV=en(q2,It("utp")),vV=en(q2,It("quic")),tu=Zr(en(Ll,It("ws")),en(Ca,It("ws"))),Ia=Zr(en(Ll,It("wss")),en(Ca,It("wss"))),sv=Zr(en(Ll,It("http")),en(vh,It("http")),en(Ca,It("http"))),ov=Zr(en(Ll,It("https")),en(vh,It("https")),en(Ca,It("https"))),Y2=Zr(en(tu,It("p2p-webrtc-star"),It("p2p")),en(Ia,It("p2p-webrtc-star"),It("p2p")),en(tu,It("p2p-webrtc-star")),en(Ia,It("p2p-webrtc-star"))),Q2=(Zr(en(tu,It("p2p-websocket-star"),It("p2p")),en(Ia,It("p2p-websocket-star"),It("p2p")),en(tu,It("p2p-websocket-star")),en(Ia,It("p2p-websocket-star"))),Zr(en(sv,It("p2p-webrtc-direct"),It("p2p")),en(ov,It("p2p-webrtc-direct"),It("p2p")),en(sv,It("p2p-webrtc-direct")),en(ov,It("p2p-webrtc-direct")))),Bl=Zr(tu,Ia,sv,ov,Y2,Q2,Ll,mV,vV,Ca),qo=(Zr(en(Bl,It("p2p-stardust"),It("p2p")),en(Bl,It("p2p-stardust"))),Zr(en(Bl,It("p2p")),Y2,Q2,It("p2p"))),Z2=Zr(en(qo,It("p2p-circuit"),qo),en(qo,It("p2p-circuit")),en(It("p2p-circuit"),qo),en(Bl,It("p2p-circuit")),en(It("p2p-circuit"),Bl),It("p2p-circuit")),X2=()=>Zr(en(Z2,X2),Z2),nu=X2();function J2(n){return function e(t){let r;try{r=new mn(t)}catch{return!1}const i=n(r.protoNames());return null!==i&&(!0===i||!1===i?i:0===i.length)}}function en(...n){function e(t){if(t.length(r="function"==typeof i?i().partialMatch(t):i.partialMatch(t),Array.isArray(r)&&(t=r),null===r)),r}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:J2(e),partialMatch:e}}function Zr(...n){function e(r){let i=null;return n.some(s=>{const o="function"==typeof s?s().partialMatch(r):s.partialMatch(r);return null!=o&&(i=o,!0)}),i}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:J2(e),partialMatch:e}}function It(n){const e=n;return{toString:function(){return e},matches:function t(i){let s;try{s=new mn(i)}catch{return!1}const o=s.protoNames();return 1===o.length&&o[0]===e},partialMatch:function r(i){return 0===i.length?null:i[0]===e?i.slice(1):null}}}function eT(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return tu.matches(t)||Ia.matches(t)})}Zr(en(nu,qo,nu),en(qo,nu),en(nu,qo),nu,qo);const av=Symbol.for("@libp2p/transport"),Yo=zt("libp2p:websockets");class bV{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[av](){return!0}dial(e,t){var r=this;return $(function*(){Yo("dialing %s",e),t=t??{};const s=function hV(n,e,t){const r={sink:i=>$(function*(){null!=t?.signal&&(i=vs(i,t.signal));try{yield n.sink(i)}catch(s){"aborted"!==s.type&&W2.error(s)}})(),source:null!=(t=t??{}).signal?vs(n.source,t.signal):n.source,remoteAddr:e,timeline:{open:Date.now()},close:()=>$(function*(){const i=Date.now();try{yield function dV(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((l,_)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if(e.signal){const{signal:R}=e;R.aborted&&_(G2(R)),R.addEventListener("abort",()=>{_(G2(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{l(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new lV("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),$(function*(){try{l(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else l(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}(n.close(),{milliseconds:2e3})}catch{const{host:o,port:a}=r.remoteAddr.toOptions();W2("timeout closing stream to %s:%s after %dms, destroying it manually",o,a,Date.now()-i),n.destroy()}finally{r.timeline.close=Date.now()}})()};return null!=n.socket.once&&n.socket.once("close",()=>{null==r.timeline.close&&(r.timeline.close=Date.now())}),r}(yield r._connect(e,t),e);Yo("new outbound connection %s",s.remoteAddr);const o=yield t.upgrader.upgradeOutbound(s);return Yo("outbound connection %s upgraded",s.remoteAddr),o})()}_connect(e,t){var r=this;return $(function*(){if(!0===t?.signal?.aborted)throw new eu;const i=e.toOptions();Yo("dialing %s:%s",i.host,i.port);const s=b0(),o=R=>{Yo.error("connection error:",R),s.reject(R)},a=function bU(n,e){e=e??{};const r=((n,e)=>(0,yU.relative)(n,e,mU,"ws"))(n,(typeof window>"u"?"":window.location).toString()),i=new lU(r,e.websocket);return gU(i,e)}(function eV(n,e){const t=new mn(n),r=n.toString().split("/").slice(1);return t.tuples().map(i=>({protocol:r.shift()??"",content:null!=i[1]?r.shift()??"":""})).reduce((i,s,o,a)=>{const l=JU[s.protocol];if(null==l)throw new Error(`Unsupported protocol ${s.protocol}`);return l(i,s.content,o,a,e)},"")}(e),r.init);if(null!=a.socket.on?a.socket.on("error",o):a.socket.onerror=o,null==t.signal)return yield Promise.race([a.connected(),s.promise]),Yo("connected %s",e),a;let l;const _=new Promise((R,N)=>{if(l=()=>{N(new eu),setTimeout(()=>{a.close().catch(B=>{Yo.error("error closing raw socket",B)})})},!0===t?.signal?.aborted)return l();t?.signal?.addEventListener("abort",l)});try{yield Promise.race([_,s.promise,a.connected()])}finally{null!=l&&t?.signal?.removeEventListener("abort",l)}return Yo("connected %s",e),a})()}createListener(e){return function oV(){throw new Error("WebSocket Servers can not be created in the browser!")}()}filter(e){return e=Array.isArray(e)?e:[e],null!=this.init?.filter?this.init?.filter(e):mh||K2?function EV(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return Ia.matches(t)&&Ca.matches(t.decapsulateCode(6).decapsulateCode(478))})}(e):eT(e)}}var po,Ta=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};class Ei extends EventTarget{constructor(){super(...arguments),po.set(this,new Map)}listenerCount(e){const t=Ta(this,po,"f").get(e);return null==t?0:t.length}addEventListener(e,t,r){super.addEventListener(e,t,r);let i=Ta(this,po,"f").get(e);null==i&&(i=[],Ta(this,po,"f").set(e,i)),i.push({callback:t,once:(!0!==r&&!1!==r&&r?.once)??!1})}removeEventListener(e,t,r){super.removeEventListener(e.toString(),t??null,r);let i=Ta(this,po,"f").get(e);null!=i&&(i=i.filter(({callback:s})=>s!==t),Ta(this,po,"f").set(e,i))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=Ta(this,po,"f").get(e.type);return null==r||(r=r.filter(({once:i})=>!i),Ta(this,po,"f").set(e.type,r)),t}}po=new WeakMap;class wV extends Event{constructor(e,t){super(e,t),this.detail=t?.detail}}const nn=globalThis.CustomEvent??wV;var Fl=x(5357);const tT=(n,e)=>hn(function*(){const t=yield lt(Fl(n));yield*Mr(Pt(t.sort(e)),lt)})();var Qo=x(7414),Ds=x(6225),nT=x(0);const go="/",rT=(new TextEncoder).encode(go),Eh=rT[0];class Ur{constructor(e,t){if("string"==typeof e)this._buf=Ot(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==Eh)throw new Error("Invalid key")}toString(e="utf8"){return Lt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Ur(e.join(go))}static random(){return new Ur(((n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""))().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||"string"==typeof e?new Ur(e):"function"==typeof e.uint8Array?new Ur(e.uint8Array()):null}clean(){if((null==this._buf||0===this._buf.byteLength)&&(this._buf=rT),this._buf[0]!==Eh){const e=new Uint8Array(this._buf.byteLength+1);e.fill(Eh,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Eh;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let i=0;io)return!1}return t.lengtht.namespaces()))])}}function AV(n){return[].concat(...n)}class RV extends class _V{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,t,r){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}putMany(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var l,a=Pt(e);i=!(l=yield lt(a.next())).done;i=!1){const{key:_,value:R}=l.value;yield lt(r.put(_,R,t)),yield{key:_,value:R}}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}getMany(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var l,a=Pt(e);i=!(l=yield lt(a.next())).done;i=!1){const _=l.value;yield r.get(_,t)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}deleteMany(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var l,a=Pt(e);i=!(l=yield lt(a.next())).done;i=!1){const _=l.value;yield lt(r.delete(_,t)),yield _}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}batch(){var e=this;let t=[],r=[];return{put(i,s){t.push({key:i,value:s})},delete(i){r.push(i)},commit:(i=$(function*(s){yield Qo(e.putMany(t,s)),t=[],yield Qo(e.deleteMany(r,s)),r=[]}),function(o){return i.apply(this,arguments)})};var i}_all(e,t){return hn(function*(){throw new Error("._all is not implemented")})()}_allKeys(e,t){return hn(function*(){throw new Error("._allKeys is not implemented")})()}query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>tT(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=nT(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>tT(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=nT(r,e.limit)),r}}{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}put(e,t){var r=this;return $(function*(){r.data[e.toString()]=t})()}get(e){var t=this;return $(function*(){if(!(yield t.has(e)))throw function xV(n){return n=n||new Error("Not Found"),ae(n,"ERR_NOT_FOUND")}();return t.data[e.toString()]})()}has(e){var t=this;return $(function*(){return void 0!==t.data[e.toString()]})()}delete(e){var t=this;return $(function*(){delete t.data[e.toString()]})()}_all(){var e=this;return hn(function*(){yield*Mr(Pt(Object.entries(e.data).map(([t,r])=>({key:new Ur(t),value:r}))),lt)})()}_allKeys(){var e=this;return hn(function*(){yield*Mr(Pt(Object.entries(e.data).map(([t])=>new Ur(t))),lt)})()}}var Dn=(()=>(function(n){n.NOT_STARTED_YET="The libp2p node is not started yet",n.DHT_DISABLED="DHT is not available",n.PUBSUB_DISABLED="PubSub is not available",n.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",n.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",n.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",n.NOT_FOUND="Not found"}(Dn||(Dn={})),Dn))(),Ce=(()=>(function(n){n.DHT_DISABLED="ERR_DHT_DISABLED",n.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",n.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",n.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",n.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",n.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",n.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",n.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",n.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",n.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",n.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",n.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",n.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",n.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",n.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",n.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",n.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",n.ERR_DIALED_SELF="ERR_DIALED_SELF",n.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",n.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",n.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",n.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",n.ERR_INVALID_KEY="ERR_INVALID_KEY",n.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",n.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",n.ERR_INVALID_PEER="ERR_INVALID_PEER",n.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",n.ERR_NOT_FOUND="ERR_NOT_FOUND",n.ERR_TIMEOUT="ERR_TIMEOUT",n.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",n.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",n.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",n.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",n.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",n.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",n.ERR_FIND_SELF="ERR_FIND_SELF",n.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",n.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",n.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",n.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",n.ERR_INVALID_CMS="ERR_INVALID_CMS",n.ERR_MISSING_KEYS="ERR_MISSING_KEYS",n.ERR_NO_KEY="ERR_NO_KEY",n.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",n.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",n.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",n.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",n.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",n.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",n.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",n.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",n.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",n.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",n.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",n.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",n.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",n.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",n.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",n.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",n.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",n.ERR_INVALID_RECORD="ERR_INVALID_RECORD",n.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",n.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",n.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",n.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS"}(Ce||(Ce={})),Ce))(),cv=x(6930);function uv(n,e){return lv.apply(this,arguments)}function lv(){return lv=hn(function*(n,e){yield*Mr(Pt(cv(n,function(){var t=$(function*(r){return yield e.addressBook.add(r.id,r.multiaddrs),r});return function(r){return t.apply(this,arguments)}}())),lt)}),lv.apply(this,arguments)}function iT(n){const e=new Set;return Ds(n,t=>!e.has(t.id.toString())&&(e.add(t.id.toString()),!0))}function sT(n){return fv.apply(this,arguments)}function fv(){return fv=hn(function*(n,e=1){let t=0;var s,r=!1,i=!1;try{for(var a,o=Pt(n);r=!(a=yield lt(o.next())).done;r=!1){const l=a.value;t++,yield l}}catch(l){i=!0,s=l}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}if(thn(function*(){try{yield yield lt(s.findPeer(e,t))}catch(o){oT.error(o)}})())),s=>Ds(s,Boolean),s=>uv(s,r.components.getPeerStore()),function(){var s=$(function*(o){return yield Aa(o)});return function(o){return s.apply(this,arguments)}}());if(null!=i)return i;throw ae(new Error(Dn.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getClosestPeers(e,t){var r=this;return hn(function*(){if(0===r.routers.length)throw ae(new Error("No peer routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield*Mr(Pt(qn(Fd(...r.routers.map(i=>i.getClosestPeers(e,t))),i=>uv(i,r.components.getPeerStore()),i=>iT(i),i=>sT(i))),lt)})()}}class NV{constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started=!0})()}stop(){var e=this;return $(function*(){e.started=!1})()}findProviders(e,t={}){var r=this;return hn(function*(){if(0===r.routers.length)throw ae(new Error("No content this.routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield*Mr(Pt(qn(Fd(...r.routers.map(i=>i.findProviders(e,t))),i=>uv(i,r.components.getPeerStore()),i=>iT(i),i=>sT(i))),lt)})()}provide(e,t={}){var r=this;return $(function*(){if(0===r.routers.length)throw ae(new Error("No content routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield Promise.all(r.routers.map(function(){var i=$(function*(s){return yield s.provide(e,t)});return function(s){return i.apply(this,arguments)}}()))})()}put(e,t,r){var i=this;return $(function*(){if(!i.isStarted())throw ae(new Error(Dn.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);const s=i.components.getDHT();null!=s&&(yield Qo(s.put(e,t,r)))})()}get(e,t){var r=this;return $(function*(){if(!r.isStarted())throw ae(new Error(Dn.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);const i=r.components.getDHT();if(null!=i){var a,s=!1,o=!1;try{for(var _,l=Pt(i.get(e,t));s=!(_=yield l.next()).done;s=!1){const R=_.value;if("VALUE"===R.name)return R.value}}catch(R){o=!0,a=R}finally{try{s&&null!=l.return&&(yield l.return())}finally{if(o)throw a}}}throw ae(new Error(Dn.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getMany(e,t,r){var i=this;return hn(function*(){if(!i.isStarted())throw ae(new Error(Dn.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);if(null==t||0===t)return;let s=0;const o=i.components.getDHT();if(null!=o){var _,a=!1,l=!1;try{for(var N,R=Pt(o.get(e,r));a=!(N=yield lt(R.next())).done;a=!1){const B=N.value;if("VALUE"===B.name&&(yield{from:B.from,val:B.value},s++,s===t))break}}catch(B){l=!0,_=B}finally{try{a&&null!=R.return&&(yield lt(R.return()))}finally{if(l)throw _}}}if(0===s)throw ae(new Error(Dn.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}}function Ul(n){if(r2(n))return{id:n,multiaddrs:[],protocols:[]};let e;return"string"==typeof n&&(n=new mn(n)),mn.isMultiaddr(n)&&(e=n,n=function MV(n){const e=n.getPeerId();if(null==e)throw ae(new Error(`${n.toString()} does not have a valid peer type`),Ce.ERR_INVALID_MULTIADDR);try{return fr(e)}catch{throw ae(new Error(`${n.toString()} is not a valid peer type`),Ce.ERR_INVALID_MULTIADDR)}}(n)),{id:n,multiaddrs:null!=e?[e]:[],protocols:[]}}const OV=n=>n;class kV extends Ei{constructor(e,t){super();const{listen:r=[],announce:i=[]}=t;this.components=e,this.listen=new Set(r.map(s=>s.toString())),this.announce=new Set(i.map(s=>s.toString())),this.observed=new Set,this.announceFilter=t.announceFilter??OV}getListenAddrs(){return Array.from(this.listen).map(e=>new mn(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>new mn(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>new mn(e))}addObservedAddr(e){let t=new mn(e);const r=t.getPeerId();null!=r&&fr(r).equals(this.components.getPeerId())&&(t=t.decapsulate(new mn(`/p2p/${this.components.getPeerId().toString()}`)));const i=t.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new nn("change:addresses")))}getAddresses(){let e=this.getAnnounceAddrs().map(r=>r.toString());0===e.length&&(e=this.components.getTransportManager().getAddrs().map(r=>r.toString())),e=e.concat(this.getObservedAddrs().map(r=>r.toString()));const t=new Set(e);return this.announceFilter(Array.from(t).map(r=>new mn(r))).map(r=>r.getPeerId()===this.components.getPeerId().toString()?r:r.encapsulate(`/p2p/${this.components.getPeerId().toString()}`))}}const Vl=x(7820),aT=zt("libp2p:connection-manager:latency-monitor:visibility-change-emitter");class BV extends Ei{constructor(){super(),this.hidden="hidden",this.visibilityChange="visibilityChange",null!=globalThis.document&&(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener())}_initializeVisibilityVarNames(){let e="hidden",t="visibilitychange";typeof globalThis.document.hidden<"u"?(e="hidden",t="visibilitychange"):typeof globalThis.document.mozHidden<"u"?(e="mozHidden",t="mozvisibilitychange"):typeof globalThis.document.msHidden<"u"?(e="msHidden",t="msvisibilitychange"):typeof globalThis.document.webkitHidden<"u"&&(e="webkitHidden",t="webkitvisibilitychange"),this.hidden=e,this.visibilityChange=t}_addVisibilityChangeListener(){typeof globalThis.document.addEventListener>"u"||typeof document[this.hidden]>"u"?aT("Checking page visibility requires a browser that supports the Page Visibility API."):globalThis.document.addEventListener(this.visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(void 0!==this.hidden&&void 0!==document[this.hidden])return null==document[this.hidden]}_handleVisibilityChange(){const e=!1===globalThis.document[this.hidden];aT(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new nn("visibilityChange",{detail:e}))}}const yo=zt("libp2p:connection-manager:latency-monitor");class FV extends Ei{constructor(e={}){super();const{latencyCheckIntervalMs:t,dataEmitIntervalMs:r,asyncTestFn:i,latencyRandomPercentage:s}=e;this.latencyCheckIntervalMs=t??500,this.latencyRandomPercentage=s??10,this.latencyCheckMultiply=this.latencyRandomPercentage/100*2*this.latencyCheckIntervalMs,this.latencyCheckSubtract=this.latencyCheckMultiply/2,this.dataEmitIntervalMs=null===r||0===r?void 0:r??5e3,yo("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),null!=this.dataEmitIntervalMs?yo("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):yo("Not emitting summaries"),this.asyncTestFn=i,null!=globalThis.process?.hrtime?(yo("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=o=>{const a=this.now(o);return 1e3*a[0]+a[1]/1e6}):typeof window<"u"&&null!=window.performance?.now?(yo("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(yo("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){(function UV(){return typeof globalThis.window<"u"})()&&(this.visibilityChangeEmitter=new BV,this.visibilityChangeEmitter.addEventListener("visibilityChange",e=>{const{detail:t}=e;t?this._startTimers():(this._emitSummary(),this._stopTimers())})),!0===this.visibilityChangeEmitter?.isVisible()&&this._startTimers()}stop(){this._stopTimers()}_startTimers(){null==this.checkLatencyID&&(this.checkLatency(),null!=this.dataEmitIntervalMs&&(this.emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),"function"==typeof this.emitIntervalID.unref&&this.emitIntervalID.unref()))}_stopTimers(){null!=this.checkLatencyID&&(clearTimeout(this.checkLatencyID),this.checkLatencyID=void 0),null!=this.emitIntervalID&&(clearInterval(this.emitIntervalID),this.emitIntervalID=void 0)}_emitSummary(){const e=this.getSummary();e.events>0&&this.dispatchEvent(new nn("data",{detail:e}))}getSummary(){const e={events:this.latencyData.events,minMs:this.latencyData.minMs,maxMs:this.latencyData.maxMs,avgMs:this.latencyData.events>0?this.latencyData.totalMs/this.latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this.latencyData.startTime)};return this.latencyData=this.initLatencyData(),yo.trace("Summary: %O",e),e}checkLatency(){const e=Math.random()*this.latencyCheckMultiply-this.latencyCheckSubtract,t={deltaOffset:Math.ceil(this.latencyCheckIntervalMs+e),startTime:this.now()},r=()=>{if(null==this.checkLatencyID)return;const i=this.getDeltaMS(t.startTime)-t.deltaOffset;this.checkLatency(),this.latencyData.events++,this.latencyData.minMs=Math.min(this.latencyData.minMs,i),this.latencyData.maxMs=Math.max(this.latencyData.maxMs,i),this.latencyData.totalMs+=i,yo.trace("MS: %s Data: %O",i,this.latencyData)};yo.trace("localData: %O",t),this.checkLatencyID=setTimeout(()=>{null!=this.asyncTestFn?(t.deltaOffset=0,t.startTime=this.now(),this.asyncTestFn(r)):(t.deltaOffset-=1,r())},t.deltaOffset),"function"==typeof this.checkLatencyID.unref&&this.checkLatencyID.unref()}initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}var Hl=x(2502);const uT="CLOSING",dv="CLOSED";var VV=x(8614);const lT=zt("libp2p:dialer:dial-request");class HV{constructor(e){const{addrs:t,dialAction:r,dialer:i}=e;this.addrs=t,this.dialer=i,this.dialAction=r}run(e={}){var t=this;return $(function*(){const r=t.dialer.getTokens(t.addrs.length);if(r.length<1)throw ae(new Error("No dial tokens available"),Ce.ERR_NO_DIAL_TOKENS);const i=new VV;for(const l of r)i.push(l).catch(_=>{lT.error(_)});const s=t.addrs.map(()=>{const l=new AbortController;try{(0,Vr.setMaxListeners)?.(1/0,l.signal)}catch{}return l});if(null!=e.signal)try{(0,Vr.setMaxListeners)?.(1/0,e.signal)}catch{}let o=0,a=!1;try{return yield Promise.any(t.addrs.map(function(){var l=$(function*(_,R){const N=yield i.shift();if(a)throw t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0]),ae(new Error("dialAction already succeeded"),Ce.ERR_ALREADY_SUCCEEDED);const B=s[R];if(null==B)throw ae(new Error("dialAction did not come with an AbortController"),Ce.ERR_INVALID_PARAMETERS);let z;try{const Z=B.signal;z=yield t.dialAction(_,{...e,signal:null!=e.signal?(0,lh.anySignal)([Z,e.signal]):Z}),s[R]=void 0}finally{o++,t.addrs.length-o>=r.length?i.push(N).catch(Z=>{lT.error(Z)}):t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0])}if(null==z)throw ae(new Error("dialAction led to empty object"),Ce.ERR_TRANSPORT_DIAL_FAILED);return a=!0,z});return function(_,R){return l.apply(this,arguments)}}()))}finally{s.forEach(l=>{void 0!==l&&l.abort()}),r.forEach(l=>t.dialer.releaseToken(l))}})()}}var fT=x(4108);function dT(n){const{address:e}=n.nodeAddress();return Boolean(fT(e))}function hv(n,e){const t=dT(n.multiaddr),r=dT(e.multiaddr);return t&&!r?1:!t&&r||n.isCertified&&!e.isCertified?-1:!n.isCertified&&e.isCertified?1:0}var pv=x(4297);const Fs=zt("libp2p:dialer"),yT="dialler";class WV{constructor(e={}){this.components=new ho,this.started=!1,this.addressSorter=e.addressSorter??hv,this.maxAddrsToDial=e.maxAddrsToDial??25,this.timeout=e.dialTimeout??3e4,this.maxDialsPerPeer=e.maxDialsPerPeer??4,this.tokens=[...new Array(e.maxParallelDials??100)].map((t,r)=>r),this.pendingDials=kl({component:yT,metric:"pending-dials",metrics:e.metrics}),this.pendingDialTargets=kl({component:yT,metric:"pending-dial-targets",metrics:e.metrics});for(const[t,r]of Object.entries(e.resolvers??{}))mn.resolvers.set(t,r)}init(e){this.components=e}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started=!0})()}stop(){var e=this;return $(function*(){e.started=!1;for(const t of e.pendingDials.values())try{t.controller.abort()}catch(r){Fs.error(r)}e.pendingDials.clear();for(const t of e.pendingDialTargets.values())t.reject(new eu("Dialer was destroyed"));e.pendingDialTargets.clear()})()}dial(e,t={}){var r=this;return $(function*(){const{id:i,multiaddrs:s}=Ul(e);if(r.components.getPeerId().equals(i))throw ae(new Error("Tried to dial self"),Ce.ERR_DIALED_SELF);if(Fs("check multiaddrs %p",i),null!=s&&s.length>0&&(Fs("storing multiaddrs %p",i,s),yield r.components.getPeerStore().addressBook.add(i,s)),yield r.components.getConnectionGater().denyDialPeer(i))throw ae(new Error("The dial request is blocked by gater.allowDialPeer"),Ce.ERR_PEER_DIAL_INTERCEPTED);Fs("creating dial target for %p",i);const o=yield r._createCancellableDialTarget(i,t);if(0===o.addrs.length)throw ae(new Error("The dial request has no valid addresses"),Ce.ERR_NO_VALID_ADDRESSES);const a=r.pendingDials.get(o.id)??r._createPendingDial(o,t);try{const l=yield a.promise;return Fs("dial succeeded to %s",o.id),l}catch(l){throw Fs("dial failed to %s",o.id,l),a.controller.signal.aborted&&(l.code=Ce.ERR_TIMEOUT),Fs.error(l),l}finally{a.destroy()}})()}_createCancellableDialTarget(e,t){var r=this;return $(function*(){const i=`${parseInt(String(1e9*Math.random()),10).toString()}${Date.now()}`,s=new Promise((o,a)=>{r.pendingDialTargets.set(i,{resolve:o,reject:a})});try{return yield Promise.race([r._createDialTarget(e,t),s])}finally{r.pendingDialTargets.delete(i)}})()}_createDialTarget(e,t){var r=this;return $(function*(){const i=yield qn(yield r.components.getPeerStore().addressBook.get(e),a=>Ds(a,function(){var l=$(function*(_){return!(yield r.components.getConnectionGater().denyDialMultiaddr(e,_.multiaddr))});return function(_){return l.apply(this,arguments)}}()),a=>pv(a,r.addressSorter),a=>cv(a,l=>{const _=l.multiaddr;return e.toString()===_.getPeerId()?_:_.encapsulate(`/p2p/${e.toString()}`)}),function(){var a=$(function*(l){return yield Fl(l)});return function(l){return a.apply(this,arguments)}}()),s=[];for(const a of i)(yield r._resolve(a,t)).forEach(_=>s.push(_));const o=s.filter(a=>r.components.getTransportManager().transportForMultiaddr(a));if(o.length>r.maxAddrsToDial)throw yield r.components.getPeerStore().delete(e),ae(new Error("dial with more addresses than allowed"),Ce.ERR_TOO_MANY_ADDRESSES);return{id:e.toString(),addrs:o}})()}_createPendingDial(e,t={}){var r=this;const i=function(){var R=$(function*(N,B={}){if(!0===B.signal?.aborted)throw ae(new Error("already aborted"),Ce.ERR_ALREADY_ABORTED);return yield r.components.getTransportManager().dial(N,B)});return function(B){return R.apply(this,arguments)}}(),s=new HV({addrs:e.addrs,dialAction:i,dialer:this}),o=new bi.TimeoutController(this.timeout),a=[o.signal];null!=t.signal&&a.push(t.signal);const l=(0,lh.anySignal)(a);try{(0,Vr.setMaxListeners)?.(1/0,l)}catch{}const _={dialRequest:s,controller:o,promise:s.run({...t,signal:l}),destroy:()=>{o.clear(),this.pendingDials.delete(e.id)}};return this.pendingDials.set(e.id,_),_}getTokens(e){const t=Math.min(e,this.maxDialsPerPeer,this.tokens.length),r=this.tokens.splice(0,t);return Fs("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.includes(e)||(Fs("token %d released",e),this.tokens.push(e))}_resolve(e,t){var r=this;return $(function*(){if(!e.protoNames().includes("dnsaddr"))return[e];const s=yield r._resolveRecord(e,t);return(yield Promise.all(s.map(function(){var l=$(function*(_){return yield r._resolve(_,t)});return function(_){return l.apply(this,arguments)}}()))).flat().reduce((l,_)=>(null==l.find(R=>R.equals(_))&&l.push(_),l),[])})()}_resolveRecord(e,t){return $(function*(){try{return e=new mn(e.toString()),yield e.resolve(t)}catch(r){return Fs.error(`multiaddr ${e.toString()} could not be resolved`,r),[]}})()}}function wh(n,e){const t={[Symbol.iterator]:()=>t,next:()=>{const r=n.next(),i=r.value;return!0===r.done||null==i?{done:!0,value:void 0}:{done:!1,value:e(i)}}};return t}class qV{constructor(e){if(this.map=new Map,null!=e)for(const[t,r]of e.entries())this.map.set(t.toString(),r)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){this.map.delete(e.toString())}entries(){return wh(this.map.entries(),e=>[fr(e[0]),e[1]])}forEach(e){this.map.forEach((t,r)=>{e(t,fr(r),this)})}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,t){this.map.set(e.toString(),t)}keys(){return wh(this.map.keys(),e=>fr(e))}values(){return this.map.values()}get size(){return this.map.size}}class YV{constructor(e){if(this.set=new Set,null!=e)for(const t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return wh(this.set.entries(),e=>{const t=fr(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{const r=fr(t);e(r,r,this)})}has(e){return this.set.has(e.toString())}values(){return wh(this.set.values(),e=>fr(e))}}Symbol;const Xr=zt("libp2p:connection-manager"),ZV={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4},yv="libp2p",mv="connection-manager";class JV extends Ei{constructor(e){if(super(),this.components=new ho,this.opts=Vl.call({ignoreUndefined:!0},ZV,e),this.opts.maxConnections{const t={inbound:0,outbound:0};for(const r of this.connections.values())for(const i of r)"inbound"===i.stat.direction?t.inbound++:t.outbound++;return t}}),this.components.getMetrics()?.updateComponentMetric({system:yv,component:mv,metric:"protocol-streams-total",label:"protocol",value:()=>{const t={};for(const r of this.connections.values())for(const i of r)for(const s of i.streams){const o=`${s.stat.direction} ${s.stat.protocol??"unnegotiated"}`;t[o]=(t[o]??0)+1}return t}}),this.components.getMetrics()?.updateComponentMetric({system:yv,component:mv,metric:"protocol-streams-per-connection-90th-percentile",label:"protocol",value:()=>{const t={};for(const i of this.connections.values())for(const s of i){const o={};for(const a of s.streams){const l=`${a.stat.direction} ${a.stat.protocol??"unnegotiated"}`;o[l]=(o[l]??0)+1}for(const[a,l]of Object.entries(o))t[a]=t[a]??[],t[a].push(l)}const r={};for(let[i,s]of Object.entries(t)){s=s.sort((a,l)=>a-l);const o=Math.floor(.9*s.length);r[i]=s[o]}return r}})}isStarted(){return this.started}start(){var e=this;return $(function*(){null!=e.components.getMetrics()&&(e.timer=e.timer??Hl(e._checkMetrics,e.opts.pollInterval)),e.latencyMonitor.start(),e._onLatencyMeasure=e._onLatencyMeasure.bind(e),e.latencyMonitor.addEventListener("data",e._onLatencyMeasure),yield e.dialer.start(),e.started=!0,Xr("started")})()}afterStart(){var e=this;return $(function*(){e.components.getUpgrader().addEventListener("connection",e.onConnect),e.components.getUpgrader().addEventListener("connectionEnd",e.onDisconnect),Promise.resolve().then($(function*(){const t=[];for(const r of yield e.components.getPeerStore().all())(yield e.components.getPeerStore().getTags(r.id)).filter(o=>"keep-alive"===o.name).length>0&&t.push(r.id);e.connectOnStartupController?.clear(),e.connectOnStartupController=new bi.TimeoutController(e.startupReconnectTimeout);try{(0,Vr.setMaxListeners)?.(1/0,e.connectOnStartupController.signal)}catch{}yield Promise.all(t.map(function(){var r=$(function*(i){yield e.openConnection(i,{signal:e.connectOnStartupController?.signal}).catch(s=>{Xr.error(s)})});return function(i){return r.apply(this,arguments)}}()))})).catch(t=>{Xr.error(t)}).finally(()=>{e.connectOnStartupController?.clear()})})()}beforeStop(){var e=this;return $(function*(){e.connectOnStartupController?.abort(),e.components.getUpgrader().removeEventListener("connection",e.onConnect),e.components.getUpgrader().removeEventListener("connectionEnd",e.onDisconnect)})()}stop(){var e=this;return $(function*(){e.timer?.clear(),e.latencyMonitor.removeEventListener("data",e._onLatencyMeasure),e.latencyMonitor.stop(),yield e.dialer.stop(),e.started=!1,yield e._close(),Xr("stopped")})()}_close(){var e=this;return $(function*(){const t=[];for(const r of e.connections.values())for(const i of r)t.push($(function*(){try{yield i.close()}catch(s){Xr.error(s)}})());Xr("closing %d connections",t.length),yield Promise.all(t),e.connections.clear()})()}_checkMetrics(){var e=this;return $(function*(){const t=e.components.getMetrics();if(null!=t)try{const r=t.getGlobal().getMovingAverages(),i=r.dataReceived[e.opts.movingAverageInterval].movingAverage;yield e._checkMaxLimit("maxReceivedData",i);const s=r.dataSent[e.opts.movingAverageInterval].movingAverage;yield e._checkMaxLimit("maxSentData",s);const o=i+s;yield e._checkMaxLimit("maxData",o),Xr.trace("metrics update",o)}finally{e.timer=Hl(e._checkMetrics,e.opts.pollInterval)}})()}onConnect(e){this._onConnect(e).catch(t=>{Xr.error(t)})}_onConnect(e){var t=this;return $(function*(){const{detail:r}=e;if(!t.started)return void(yield r.close());const i=r.remotePeer,s=i.toString(),o=t.connections.get(s);null!=o?o.push(r):t.connections.set(s,[r]),null!=i.publicKey&&(yield t.components.getPeerStore().keyBook.set(i,i.publicKey));const a=t.getConnections().length,l=a-t.opts.maxConnections;yield t._checkMaxLimit("maxConnections",a,l),t.dispatchEvent(new nn("peer:connect",{detail:r}))})()}onDisconnect(e){const{detail:t}=e;if(!this.started)return;const r=t.remotePeer.toString();let i=this.connections.get(r);null!=i&&i.length>1?(i=i.filter(s=>s.id!==t.id),this.connections.set(r,i)):null!=i&&(this.connections.delete(r),this.dispatchEvent(new nn("peer:disconnect",{detail:t})),this.components.getMetrics()?.onPeerDisconnected(t.remotePeer))}getConnections(e){if(null!=e)return this.connections.get(e.toString())??[];let t=[];for(const r of this.connections.values())t=t.concat(r);return t}openConnection(e,t={}){var r=this;return $(function*(){Xr("dial to %p",e);const i=r.getConnections(e);if(i.length>0)return Xr("had an existing connection to %p",e),i[0];let s;if(null==t?.signal){s=new bi.TimeoutController(r.dialTimeout),t.signal=s.signal;try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}}try{const o=yield r.dialer.dial(e,t);let a=r.connections.get(e.toString());null==a&&(a=[],r.connections.set(e.toString(),a));let l=!1;for(const _ of a)_.id===o.id&&(l=!0);return l||a.push(o),o}finally{s?.clear()}})()}closeConnections(e){var t=this;return $(function*(){const r=t.connections.get(e.toString())??[];yield Promise.all(r.map(function(){var i=$(function*(s){return yield s.close()});return function(s){return i.apply(this,arguments)}}()))})()}getAll(e){if(!r2(e))throw ae(new Error("peerId must be an instance of peer-id"),Ce.ERR_INVALID_PARAMETERS);const t=e.toString(),r=this.connections.get(t);return null!=r?r.filter(i=>"OPEN"===i.stat.status):[]}_onLatencyMeasure(e){const{detail:t}=e;this._checkMaxLimit("maxEventLoopDelay",t.avgMs,1).catch(r=>{Xr.error(r)})}_checkMaxLimit(e,t,r=1){var i=this;return $(function*(){const s=i.opts[e];Xr.trace("checking limit of %s. current value: %d of %d",e,t,s),t>s&&(Xr("%s: limit exceeded: %p, %d/%d, pruning %d connection(s)",i.components.getPeerId(),e,t,s,r),yield i._maybePruneConnections(r))})()}_maybePruneConnections(e){var t=this;return $(function*(){const r=t.getConnections();if(r.length<=t.opts.minConnections||e<1)return;const i=new qV;for(const a of r){const l=a.remotePeer;if(i.has(l))continue;const _=yield t.components.getPeerStore().getTags(l);i.set(l,_.reduce((R,N)=>R+N.value,0))}const s=r.sort((a,l)=>{const _=i.get(a.remotePeer)??0,R=i.get(l.remotePeer)??0;return _>R?1:_{Zo.error("could start autodial",t)}),Zo("started")):Zo("not enabled")})()}stop(){var e=this;return $(function*(){e.options.enabled?(e.running=!1,null!=e.autoDialTimeout&&e.autoDialTimeout.clear(),Zo("stopped")):Zo("not enabled")})()}_autoDial(){var e=this;return $(function*(){null!=e.autoDialTimeout&&e.autoDialTimeout.clear();const t=e.options.minConnections;if(e.components.getConnectionManager().getConnections().length>=t)return void(e.autoDialTimeout=Hl(e._autoDial,e.options.autoDialInterval));const r=yield e.components.getPeerStore().all(),i=yield qn(r.sort(()=>Math.random()>.5?1:-1),s=>Ds(s,o=>!o.id.equals(e.components.getPeerId())),s=>pv(s,(o,a)=>a.protocols.length>o.protocols.length||null!=a.id.publicKey&&null==o.id.publicKey?1:-1),function(){var s=$(function*(o){return yield Fl(o)});return function(o){return s.apply(this,arguments)}}());for(let s=0;e.running&&sFo(t)}(e=n.Status||(n.Status={})),function(a){a.HOP="HOP",a.STOP="STOP",a.STATUS="STATUS",a.CAN_HOP="CAN_HOP"}(r=n.Type||(n.Type={})),function(a){a[a.HOP=1]="HOP",a[a.STOP=2]="STOP",a[a.STATUS=3]="STATUS",a[a.CAN_HOP=4]="CAN_HOP"}(i||(i={})),function(a){a.codec=()=>Fo(i)}(r=n.Type||(n.Type={})),function(a){let l;a.codec=()=>(null==l&&(l=Yt((_,R,N={})=>{if(!1!==N.lengthDelimited&&R.fork(),null==_.id)throw new Error('Protocol error: required field "id" was not found in object');if(R.uint32(10),R.bytes(_.id),null==_.addrs)throw new Error('Protocol error: required field "addrs" was not found in object');for(const B of _.addrs)R.uint32(18),R.bytes(B);!1!==N.lengthDelimited&&R.ldelim()},(_,R)=>{const N={},B=null==R?_.len:_.pos+R;for(;_.pos>>3){case 1:N.id=_.bytes();break;case 2:N.addrs=N.addrs??[],N.addrs.push(_.bytes());break;default:_.skipType(7&z)}}if(N.addrs=N.addrs??[],null==N.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');if(null==N.addrs)throw new Error('Protocol error: value for required field "addrs" was not found in protobuf');return N})),l),a.encode=_=>qt(_,a.codec()),a.decode=_=>Wt(_,a.codec())}(s=n.Peer||(n.Peer={})),n.codec=()=>(null==o&&(o=Yt((a,l,_={})=>{!1!==_.lengthDelimited&&l.fork(),null!=a.type&&(l.uint32(8),n.Type.codec().encode(a.type,l)),null!=a.srcPeer&&(l.uint32(18),n.Peer.codec().encode(a.srcPeer,l)),null!=a.dstPeer&&(l.uint32(26),n.Peer.codec().encode(a.dstPeer,l)),null!=a.code&&(l.uint32(32),n.Status.codec().encode(a.code,l)),!1!==_.lengthDelimited&&l.ldelim()},(a,l)=>{const _={},R=null==l?a.len:a.pos+l;for(;a.pos>>3){case 1:_.type=n.Type.codec().decode(a);break;case 2:_.srcPeer=n.Peer.codec().decode(a,a.uint32());break;case 3:_.dstPeer=n.Peer.codec().decode(a,a.uint32());break;case 4:_.code=n.Status.codec().decode(a);break;default:a.skipType(7&N)}}return _})),o),n.encode=a=>qt(a,n.codec()),n.decode=a=>Wt(a,n.codec())}(rn||(rn={}));const n7=zt("libp2p:stream:converter");function mT(n,e={}){const{stream:t,remoteAddr:r}=n,{sink:i,source:s}=t,o=hn(function*(){var B,R=!1,N=!1;try{for(var Z,z=Pt(s);R=!(Z=yield lt(z.next())).done;R=!1){const J=Z.value;yield*Mr(Pt(J),lt)}}catch(J){N=!0,B=J}finally{try{R&&null!=z.return&&(yield lt(z.return()))}finally{if(N)throw B}}})(),a={sink:R=>$(function*(){null!=e.signal&&(R=vs(R,e.signal));try{yield i(R),yield l()}catch(N){"aborted"!==N.type&&n7(N)}})(),source:null!=e.signal?vs(o,e.signal):o,remoteAddr:r,timeline:{open:Date.now(),close:void 0},close:()=>$(function*(){yield i(hn(function*(){yield new Uint8Array(0)})()),yield l()})()};function l(){return _.apply(this,arguments)}function _(){return(_=$(function*(){return null==a.timeline.close&&(a.timeline.close=Date.now()),yield Promise.resolve()})).apply(this,arguments)}return a}const Kl="/libp2p/circuit/relay/0.1.0";function vT(n,e){n.write({type:rn.Type.STATUS,code:e})}function ET(n,e){try{null!=n.dstPeer?.addrs&&n.dstPeer.addrs.forEach(t=>new mn(t))}catch(t){throw vT(e,n.type===rn.Type.HOP?rn.Status.HOP_DST_MULTIADDR_INVALID:rn.Status.STOP_DST_MULTIADDR_INVALID),t}try{null!=n.srcPeer?.addrs&&n.srcPeer.addrs.forEach(t=>new mn(t))}catch(t){throw vT(e,n.type===rn.Type.HOP?rn.Status.HOP_SRC_MULTIADDR_INVALID:rn.Status.STOP_SRC_MULTIADDR_INVALID),t}}const $l=zt("libp2p:circuit:stream-handler");class _h{constructor(e){const{stream:t,maxLength:r=4096}=e;this.stream=t,this.shake=Ld(this.stream),this.decoder=ps.fromReader(this.shake.reader,{maxDataLength:r})}read(){var e=this;return $(function*(){const t=yield e.decoder.next();if(null!=t.value){const r=rn.decode(t.value);return $l("read message type",r.type),r}$l("read received no value, closing stream"),e.close()})()}write(e){$l("write message type %s",e.type),this.shake.write(Os.single(rn.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){$l("closing the stream"),this.rest().sink([]).catch(e=>{$l.error(e)})}}const jl=zt("libp2p:circuit:stop");function s7(n){return vv.apply(this,arguments)}function vv(){return vv=$(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream(Kl,{signal:r});jl("starting stop request to %p",e.remotePeer);const s=new _h({stream:i});s.write(t);const o=yield s.read();if(null!=o)return o.code===rn.Status.SUCCESS?(jl("stop request to %p was successful",e.remotePeer),s.rest()):(jl("stop request failed with code %d",o.code),void s.close());s.close()}),vv.apply(this,arguments)}const Yi=zt("libp2p:circuit:hop");function Ev(){return Ev=$(function*(n){const{connection:e,request:t,streamHandler:r,circuit:i,connectionManager:s}=n;if(!i.hopEnabled())return Yi("HOP request received but we are not acting as a relay"),r.end({type:rn.Type.STATUS,code:rn.Status.HOP_CANT_SPEAK_RELAY});try{ET(t,r)}catch(N){return void Yi.error("invalid hop request via peer %p %o",e.remotePeer,N)}if(null==t.dstPeer)return void Yi("HOP request received but we do not receive a dstPeer");const o=Jc(t.dstPeer.id),a=s.getConnections(o);if(0===a.length&&!i.hopActive())return Yi("HOP request received but we are not connected to the destination peer"),r.end({type:rn.Type.STATUS,code:rn.Status.HOP_NO_CONN_TO_DST});if(0===a.length)return Yi("did not have connection to remote peer"),r.end({type:rn.Type.STATUS,code:rn.Status.HOP_NO_CONN_TO_DST});const l={type:rn.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer};let _;try{Yi("performing STOP request");const N=yield s7({connection:a[0],request:l});if(null==N)throw new Error("Could not stop");_=N}catch(N){return void Yi.error(N)}Yi("hop request from %p is valid",e.remotePeer),r.write({type:rn.Type.STATUS,code:rn.Status.SUCCESS});const R=r.rest();return Yi("creating related connections"),yield qn(R,_,R)}),Ev.apply(this,arguments)}function bv(){return bv=$(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream(Kl,{signal:r}),s=new _h({stream:i});s.write(t);const o=yield s.read();if(null==o)throw ae(new Error("HOP request had no response"),Ce.ERR_HOP_REQUEST_FAILED);if(o.code===rn.Status.SUCCESS)return Yi("hop request was successful"),s.rest();throw Yi("hop request failed with code %d, closing stream",o.code),s.close(),ae(new Error(`HOP request failed with code "${o.code??"unknown"}"`),Ce.ERR_HOP_REQUEST_FAILED)}),bv.apply(this,arguments)}function wv(){return wv=$(function*(n){const{connection:e,signal:t}=n,r=yield e.newStream(Kl,{signal:t}),i=new _h({stream:r});i.write({type:rn.Type.CAN_HOP});const s=yield i.read();return yield i.close(),!(null==s||s.code!==rn.Status.SUCCESS)}),wv.apply(this,arguments)}const Qi=zt("libp2p:circuit");class l7{constructor(e){this.components=new ho,this._init=e}init(e){this.components=e,this.components.getRegistrar().handle(Kl,t=>{this._onProtocol(t).catch(r=>{Qi.error(r)})}).catch(t=>{Qi.error(t)})}hopEnabled(){return!0}hopActive(){return!0}get[av](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}_onProtocol(e){var t=this;return $(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t._init.hop.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=Go(i,s.signal),a=new _h({stream:{...i,...o}}),l=yield a.read();if(null==l)return Qi("request was invalid, could not read from stream"),a.write({type:rn.Type.STATUS,code:rn.Status.MALFORMED_MESSAGE}),void a.close();let _;switch(l.type){case rn.Type.CAN_HOP:Qi("received CAN_HOP request from %p",r.remotePeer),yield function u7(n){const{connection:e,streamHandler:t,circuit:r}=n,i=r.hopEnabled();Yi("can hop (%s) request from %p",i,e.remotePeer),t.end({type:rn.Type.STATUS,code:i?rn.Status.SUCCESS:rn.Status.HOP_CANT_SPEAK_RELAY})}({circuit:t,connection:r,streamHandler:a});break;case rn.Type.HOP:Qi("received HOP request from %p",r.remotePeer),yield function o7(n){return Ev.apply(this,arguments)}({connection:r,request:l,streamHandler:a,circuit:t,connectionManager:t.components.getConnectionManager()});break;case rn.Type.STOP:Qi("received STOP request from %p",r.remotePeer),_=yield function i7(n){const{connection:e,request:t,streamHandler:r}=n;try{ET(t,r)}catch(i){return void jl.error("invalid stop request via peer %p %o",e.remotePeer,i)}return jl("stop request is valid"),r.write({type:rn.Type.STATUS,code:rn.Status.SUCCESS}),r.rest()}({connection:r,request:l,streamHandler:a});break;default:return Qi("Request of type %s not supported",l.type),a.write({type:rn.Type.STATUS,code:rn.Status.MALFORMED_MESSAGE}),void a.close()}if(null!=_){const B=mT({stream:_,remoteAddr:r.remoteAddr.encapsulate("/p2p-circuit").encapsulate(new mn(l.dstPeer?.addrs[0])),localAddr:new mn(l.srcPeer?.addrs[0])}),z=l.type===rn.Type.HOP?"relay":"inbound";Qi("new %s connection %s",z,B.remoteAddr);const Z=yield t.components.getUpgrader().upgradeInbound(B);Qi("%s connection %s upgraded",z,B.remoteAddr),null!=t.handler&&t.handler(Z)}}finally{s.clear()}})()}dial(e,t={}){var r=this;return $(function*(){const i=e.toString().split("/p2p-circuit"),s=new mn(i[0]),o=new mn(i[i.length-1]),a=s.getPeerId(),l=o.getPeerId();if(null==a||null==l){const Z="Circuit relay dial failed as addresses did not have peer id";throw Qi.error(Z),ae(new Error(Z),Ce.ERR_RELAYED_DIAL)}const _=fr(a),R=fr(l);let N=!1,z=r.components.getConnectionManager().getConnections(_)[0];null==z&&(yield r.components.getPeerStore().addressBook.add(_,[s]),z=yield r.components.getConnectionManager().openConnection(_,t),N=!0);try{const Z=yield function a7(n){return bv.apply(this,arguments)}({...t,connection:z,request:{type:rn.Type.HOP,srcPeer:{id:r.components.getPeerId().toBytes(),addrs:r.components.getAddressManager().getAddresses().map(he=>he.bytes)},dstPeer:{id:R.toBytes(),addrs:[new mn(o).bytes]}}}),J=s.encapsulate(`/p2p-circuit/p2p/${r.components.getPeerId().toString()}`),se=mT({stream:Z,remoteAddr:e,localAddr:J});return Qi("new outbound connection %s",se.remoteAddr),yield r.components.getUpgrader().upgradeOutbound(se)}catch(Z){throw Qi.error("Circuit relay dial failed",Z),N&&(yield z.close()),Z}})()}createListener(e){return this.handler=e.handler,function r7(n){const e=new Map;function r(){return(r=$(function*(o){const a=o.toString().split("/p2p-circuit").find(z=>""!==z),l=new mn(a),_=l.getPeerId();if(null==_)throw new Error("Could not determine relay peer from multiaddr");const R=fr(_);yield n.peerStore.addressBook.add(R,[l]);const N=yield n.connectionManager.openConnection(R),B=N.remoteAddr.encapsulate("/p2p-circuit");e.set(N.remotePeer.toString(),B),s.dispatchEvent(new nn("listening"))})).apply(this,arguments)}const s=Object.assign(new Ei,{close:(o=$(function*(){return yield Promise.resolve()}),function(){return o.apply(this,arguments)}),listen:function t(o){return r.apply(this,arguments)},getAddrs:function i(){const o=[];for(const a of e.values())o.push(a);return o}});var o;return n.connectionManager.addEventListener("peer:disconnect",o=>{const{detail:a}=o;e.delete(a.remotePeer.toString())&&s.dispatchEvent(new nn("close"))}),s}({connectionManager:this.components.getConnectionManager(),peerStore:this.components.getPeerStore()})}filter(e){return(e=Array.isArray(e)?e:[e]).filter(t=>nu.matches(t))}}function bT(n){return _v.apply(this,arguments)}function _v(){return _v=$(function*(n){const e=(new TextEncoder).encode(n),t=yield mi.digest(e);return wr.createV0(t)}),_v.apply(this,arguments)}const _T="hop_relay",ST="/libp2p/relay",zl=zt("libp2p:auto-relay"),p7=()=>{};class g7{constructor(e,t){this.components=e,this.addressSorter=t.addressSorter??hv,this.maxListeners=t.maxListeners??1,this.listenRelays=new Set,this.onError=t.onError??p7,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this.components.getPeerStore().addEventListener("change:protocols",r=>{this._onProtocolChange(r).catch(i=>{zl.error(i)})}),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onPeerDisconnected)}_onProtocolChange(e){var t=this;return $(function*(){const{peerId:r,protocols:i}=e.detail,s=r.toString();if(null!=i.find(a=>a===Kl)){if(!t.listenRelays.has(s))try{const a=t.components.getConnectionManager().getConnections(r);if(0===a.length)return;const l=a[0];if(l.remoteAddr.protoCodes().includes(290))return void zl(`relayed connection to ${s} will not be used to hop on`);(yield function c7(n){return wv.apply(this,arguments)}({connection:l}))&&(yield t.components.getPeerStore().metadataBook.setValue(r,_T,Ot("true")),yield t._addListenRelay(l,s))}catch(a){t.onError(a)}}else t.listenRelays.has(s)&&(yield t._removeListenRelay(s))})()}_onPeerDisconnected(e){const i=e.detail.remotePeer.toString();!this.listenRelays.has(i)||this._removeListenRelay(i).catch(s=>{zl.error(s)})}_addListenRelay(e,t){var r=this;return $(function*(){try{if(r.listenRelays.size>=r.maxListeners)return;const i=yield qn(yield r.components.getPeerStore().addressBook.get(e.remotePeer),o=>pv(o,r.addressSorter),function(){var o=$(function*(a){return yield Fl(a)});return function(a){return o.apply(this,arguments)}}());(yield Promise.all(i.map(function(){var o=$(function*(a){try{let l=a.multiaddr;return null==l.getPeerId()&&(l=l.encapsulate(`/p2p/${e.remotePeer.toString()}`)),l=l.encapsulate("/p2p-circuit"),yield r.components.getTransportManager().listen([l]),!0}catch(l){zl.error("error listening on circuit address",l),r.onError(l)}return!1});return function(a){return o.apply(this,arguments)}}()))).includes(!0)&&r.listenRelays.add(t)}catch(i){r.onError(i),r.listenRelays.delete(t)}})()}_removeListenRelay(e){var t=this;return $(function*(){t.listenRelays.delete(e)&&(yield t._listenOnAvailableHopRelays([e]))})()}_listenOnAvailableHopRelays(e=[]){var t=this;return $(function*(){if(t.listenRelays.size>=t.maxListeners)return;const r=[],i=yield t.components.getPeerStore().all();for(const{id:R,metadata:N}of i){const B=R.toString();if(t.listenRelays.has(B)||e.includes(B))continue;const z=N.get(_T);if(null==z||"true"!==Lt(z))continue;const Z=t.components.getConnectionManager().getConnections(R);if(0!==Z.length){if(yield t._addListenRelay(Z[0],B),t.listenRelays.size>=t.maxListeners)return}else r.push(R)}for(const R of r)if(yield t._tryToListenOnRelay(R),t.listenRelays.size>=t.maxListeners)return;try{const R=yield bT(ST);var a,s=!1,o=!1;try{for(var _,l=Pt(t.components.getContentRouting().findProviders(R));s=!(_=yield l.next()).done;s=!1){const N=_.value;if(0===N.multiaddrs.length)continue;const B=N.id;if(yield t.components.getPeerStore().addressBook.add(B,N.multiaddrs),yield t._tryToListenOnRelay(B),t.listenRelays.size>=t.maxListeners)return}}catch(N){o=!0,a=N}finally{try{s&&null!=l.return&&(yield l.return())}finally{if(o)throw a}}}catch(R){t.onError(R)}})()}_tryToListenOnRelay(e){var t=this;return $(function*(){try{const r=yield t.components.getConnectionManager().openConnection(e);yield t._addListenRelay(r,e.toString())}catch(r){zl.error("Could not use %p as relay",e,r),t.onError(r,`could not connect and listen on known hop relay ${e.toString()}`)}})()}}const CT=zt("libp2p:relay");class y7{constructor(e,t){this.components=e,this.autoRelay=!1!==t.autoRelay?.enabled?new g7(e,{addressSorter:t.addressSorter,...t.autoRelay}):void 0,this.started=!1,this.init=t,this._advertiseService=this._advertiseService.bind(this)}isStarted(){return this.started}start(){var e=this;return $(function*(){!1!==e.init.hop.enabled&&!1!==e.init.advertise.enabled&&(e.timeout=(0,bh.setDelayedInterval)(e._advertiseService,e.init.advertise.ttl,e.init.advertise.bootDelay)),e.started=!0})()}stop(){var e=this;return $(function*(){null!=e.timeout&&(0,bh.clearDelayedInterval)(e.timeout),e.started=!1})()}_advertiseService(){var e=this;return $(function*(){try{const t=yield bT(ST);yield e.components.getContentRouting().provide(t)}catch(t){t.code===Ce.ERR_NO_ROUTERS_AVAILABLE?(CT.error("a content router, such as a DHT, must be provided in order to advertise the relay service",t),yield e.stop()):CT.error(t)}})()}}var m7=x(9014);x(422),x(5911);const IT=Un.pki;function Dv(){return Dv=$(function*(n,e){const t=n.map(e);return n[(yield Promise.all(t)).findIndex(s=>s)]}),Dv.apply(this,arguments)}const b7=zt("libp2p:keychain:cms"),Sv=new WeakMap;class w7{constructor(e,t){if(null==e)throw ae(new Error("keychain is required"),Ce.ERR_KEYCHAIN_REQUIRED);this.keychain=e,Sv.set(this,{dek:t})}encrypt(e,t){var r=this;return $(function*(){if(!(t instanceof Uint8Array))throw ae(new Error("Plain data must be a Uint8Array"),Ce.ERR_INVALID_PARAMETERS);const i=yield r.keychain.findKeyByName(e),s=yield r.keychain.getPrivateKey(e),o=Sv.get(r);if(null==o)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const l=Un.pki.decryptRsaPrivateKey(s,o.dek),_=yield((n,e)=>{const t=IT.rsa.setPublicKey(e.n,e.e),r=IT.createCertificate();r.publicKey=t,r.serialNumber="01",r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+10);const i=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:n.id}];return r.setSubject(i),r.setIssuer(i),r.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),r.sign(e),r})(i,l),R=Un.pkcs7.createEnvelopedData();return R.addRecipient(_),R.content=Un.util.createBuffer(t),R.encrypt(),Ot(Un.asn1.toDer(R.toAsn1()).getBytes(),"ascii")})()}decrypt(e){var t=this;return $(function*(){if(!(e instanceof Uint8Array))throw ae(new Error("CMS data is required"),Ce.ERR_INVALID_PARAMETERS);let r;try{const N=Un.util.createBuffer(Lt(e,"ascii")),B=Un.asn1.fromDer(N);r=Un.pkcs7.messageFromAsn1(B)}catch(N){throw b7.error(N),ae(new Error("Invalid CMS"),Ce.ERR_INVALID_CMS)}const i=r.recipients.filter(N=>N.issuer.find(B=>"O"===B.shortName&&"ipfs"===B.value)).filter(N=>N.issuer.find(B=>"CN"===B.shortName)).map(N=>({recipient:N,keyId:N.issuer.find(B=>"CN"===B.shortName).value})),s=yield function E7(n,e){return Dv.apply(this,arguments)}(i,function(){var N=$(function*(B){try{if(null!=(yield t.keychain.findKeyById(B.keyId)))return!0}catch{return!1}return!1});return function(B){return N.apply(this,arguments)}}());if(null==s){const N=i.map(B=>B.keyId);throw ae(new Error(`Decryption needs one of the key(s): ${N.join(", ")}`),Ce.ERR_MISSING_KEYS,{missingKeys:N})}const o=yield t.keychain.findKeyById(s.keyId);if(null==o)throw ae(new Error("No key available to decrypto"),Ce.ERR_NO_KEY);const a=yield t.keychain.getPrivateKey(o.name),l=Sv.get(t);if(null==l)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const R=Un.pki.decryptRsaPrivateKey(a,l.dek);return r.decrypt(s.recipient,R),Ot(r.content.getBytes(),"ascii")})()}}x(1298);var _7=x(7949);const AT={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function xT(n,e,t,r,i){if("sha1"!==i&&"sha2-256"!==i&&"sha2-512"!==i){const a=Object.keys(AT).join(" / ");throw ae(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}const o=_7(n,e,t,r,AT[i]);return aF.encode64(o,null)}const Dh=zt("libp2p:keychain"),Xo=new WeakMap,Iv={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function mo(n){return null!=n&&"string"==typeof n&&n===m7(n.trim())&&n.length>0}function Ln(){return Tv.apply(this,arguments)}function Tv(){return(Tv=$(function*(){const t=800*Math.random()+200;yield new Promise(r=>setTimeout(r,t))})).apply(this,arguments)}function Us(n){return new Ur("/pkcs8/"+n)}function Jo(n){return new Ur("/info/"+n)}class PT{constructor(e,t){if(this.components=e,this.init=Vl(Iv,t),null!=this.init.pass&&this.init.pass?.length<20)throw new Error("pass must be least 20 characters");if(null!=this.init.dek?.keyLength&&this.init.dek.keyLength<14)throw new Error("dek.keyLength must be least 14 bytes");if(null!=this.init.dek?.salt?.length&&this.init.dek.salt.length<16)throw new Error("dek.saltLength must be least 16 bytes");if(null!=this.init.dek?.iterationCount&&this.init.dek.iterationCount<1e3)throw new Error("dek.iterationCount must be least 1000");const r=null!=this.init.pass&&null!=this.init.dek?.salt?xT(this.init.pass,this.init.dek?.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";Xo.set(this,{dek:r})}get cms(){const e=Xo.get(this);if(null==e)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);return new w7(this,e.dek)}static generateOptions(){const e=Object.assign({},Iv),t=3*Math.ceil(16/3);return e.dek.salt=Lt(nh(t),"base64"),e}static get options(){return Iv}createKey(e,t,r=2048){var i=this;return $(function*(){if(!mo(e)||"self"===e)throw yield Ln(),ae(new Error("Invalid key name"),Ce.ERR_INVALID_KEY_NAME);if("string"!=typeof t)throw yield Ln(),ae(new Error("Invalid key type"),Ce.ERR_INVALID_KEY_TYPE);const s=Us(e);if(yield i.components.getDatastore().has(s))throw yield Ln(),ae(new Error("Key name already exists"),Ce.ERR_KEY_ALREADY_EXISTS);if("rsa"===t.toLowerCase()&&(!Number.isSafeInteger(r)||r<2048))throw yield Ln(),ae(new Error("Invalid RSA key size"),Ce.ERR_INVALID_KEY_SIZE);let a;try{const l=yield e2(t,r),_=yield l.id(),R=Xo.get(i);if(null==R)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const N=R.dek,B=yield l.export(N);a={name:e,id:_};const z=i.components.getDatastore().batch();z.put(s,Ot(B)),z.put(Jo(e),Ot(JSON.stringify(a))),yield z.commit()}catch(l){throw yield Ln(),l}return a})()}listKeys(){var e=this;return $(function*(){const t={prefix:"/info/"},r=[];var o,i=!1,s=!1;try{for(var l,a=Pt(e.components.getDatastore().query(t));i=!(l=yield a.next()).done;i=!1)r.push(JSON.parse(Lt(l.value.value)))}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}return r})()}findKeyById(e){var t=this;return $(function*(){try{return(yield t.listKeys()).find(i=>i.id===e)}catch(r){throw yield Ln(),r}})()}findKeyByName(e){var t=this;return $(function*(){if(!mo(e))throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);const r=Jo(e);try{const i=yield t.components.getDatastore().get(r);return JSON.parse(Lt(i))}catch(i){throw yield Ln(),Dh.error(i),ae(new Error(`Key '${e}' does not exist.`),Ce.ERR_KEY_NOT_FOUND)}})()}removeKey(e){var t=this;return $(function*(){if(!mo(e)||"self"===e)throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);const r=Us(e),i=yield t.findKeyByName(e),s=t.components.getDatastore().batch();return s.delete(r),s.delete(Jo(e)),yield s.commit(),i})()}renameKey(e,t){var r=this;return $(function*(){if(!mo(e)||"self"===e)throw yield Ln(),ae(new Error(`Invalid old key name '${e}'`),Ce.ERR_OLD_KEY_NAME_INVALID);if(!mo(t)||"self"===t)throw yield Ln(),ae(new Error(`Invalid new key name '${t}'`),Ce.ERR_NEW_KEY_NAME_INVALID);const i=Us(e),s=Us(t),o=Jo(e),a=Jo(t);if(yield r.components.getDatastore().has(s))throw yield Ln(),ae(new Error(`Key '${t}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);try{const _=yield r.components.getDatastore().get(i),R=yield r.components.getDatastore().get(o),N=JSON.parse(Lt(R));N.name=t;const B=r.components.getDatastore().batch();return B.put(s,_),B.put(a,Ot(JSON.stringify(N))),B.delete(i),B.delete(o),yield B.commit(),N}catch(_){throw yield Ln(),_}})()}exportKey(e,t){var r=this;return $(function*(){if(!mo(e))throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t)throw yield Ln(),ae(new Error("Password is required"),Ce.ERR_PASSWORD_REQUIRED);const i=Us(e);try{const o=Lt(yield r.components.getDatastore().get(i)),a=Xo.get(r);if(null==a)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const l=a.dek;return yield(yield Rm(o,l)).export(t)}catch(s){throw yield Ln(),s}})()}importKey(e,t,r){var i=this;return $(function*(){if(!mo(e)||"self"===e)throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t)throw yield Ln(),ae(new Error("PEM encoded key is required"),Ce.ERR_PEM_REQUIRED);const s=Us(e);if(yield i.components.getDatastore().has(s))throw yield Ln(),ae(new Error(`Key '${e}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);let a,l;try{a=yield Rm(t,r)}catch{throw yield Ln(),ae(new Error("Cannot read the key, most likely the password is wrong"),Ce.ERR_CANNOT_READ_KEY)}try{l=yield a.id();const N=Xo.get(i);if(null==N)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const B=N.dek;t=yield a.export(B)}catch(N){throw yield Ln(),N}const _={name:e,id:l},R=i.components.getDatastore().batch();return R.put(s,Ot(t)),R.put(Jo(e),Ot(JSON.stringify(_))),yield R.commit(),_})()}importPeer(e,t){var r=this;return $(function*(){try{if(!mo(e))throw ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t||null==t.privateKey)throw ae(new Error("Peer.privKey is required"),Ce.ERR_MISSING_PRIVATE_KEY);const i=yield Rl(t.privateKey),s=Us(e);if(yield r.components.getDatastore().has(s))throw yield Ln(),ae(new Error(`Key '${e}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);const a=Xo.get(r);if(null==a)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const l=a.dek,_=yield i.export(l),R={name:e,id:t.toString()},N=r.components.getDatastore().batch();return N.put(s,Ot(_)),N.put(Jo(e),Ot(JSON.stringify(R))),yield N.commit(),R}catch(i){throw yield Ln(),i}})()}getPrivateKey(e){var t=this;return $(function*(){if(!mo(e))throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);try{const r=Us(e);return Lt(yield t.components.getDatastore().get(r))}catch(r){throw yield Ln(),Dh.error(r),ae(new Error(`Key '${e}' does not exist.`),Ce.ERR_KEY_NOT_FOUND)}})()}rotateKeychainPass(e,t){var r=this;return $(function*(){if("string"!=typeof e)throw yield Ln(),ae(new Error(`Invalid old pass type '${typeof e}'`),Ce.ERR_INVALID_OLD_PASS_TYPE);if("string"!=typeof t)throw yield Ln(),ae(new Error(`Invalid new pass type '${typeof t}'`),Ce.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw yield Ln(),ae(new Error(`Invalid pass length ${t.length}`),Ce.ERR_INVALID_PASS_LENGTH);Dh("recreating keychain");const i=Xo.get(r);if(null==i)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const s=i.dek;r.init.pass=t;const o=null!=t&&null!=r.init.dek?.salt?xT(t,r.init.dek.salt,r.init.dek?.iterationCount,r.init.dek?.keyLength,r.init.dek?.hash):"";Xo.set(r,{dek:o});const a=yield r.listKeys();for(const l of a){const R=Lt(yield r.components.getDatastore().get(Us(l.name))),N=yield Rm(R,s),B=o.toString(),z=yield N.export(B),Z=r.components.getDatastore().batch(),J={name:l.name,id:l.id};Z.put(Us(l.name),Ot(z)),Z.put(Jo(l.name),Ot(JSON.stringify(J))),yield Z.commit()}Dh("keychain reconstructed")})()}}var Av=x(1349),S7=x(5550);class C7{constructor(e){if("number"!=typeof e)throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");this.timespan=e,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(e,t){return 1-Math.exp(-(e-t)/this.timespan)}push(e,t){if(null!=this.previousTime){const r=this.alpha(e,this.previousTime),i=t-this.movingAverage,s=r*i;this.movingAverage=r*t+(1-r)*this.movingAverage,this.variance=(1-r)*(this.variance+i*s),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+r*i}else this.movingAverage=t;this.previousTime=e}}function NT(n){return new C7(n)}class xv extends Ei{constructor(e){super(),this.enabled=e.enabled,this.queue=[],this.stats={dataReceived:0n,dataSent:0n},this.frequencyLastTime=Date.now(),this.frequencyAccumulators={},this.movingAverages={dataReceived:[],dataSent:[]},this.computeThrottleMaxQueueSize=e.computeThrottleMaxQueueSize,this.computeThrottleTimeout=e.computeThrottleTimeout,this._update=this._update.bind(this),this.movingAverageIntervals=e.movingAverageIntervals;for(let t=0;t0&&this._resetComputeTimeout()}stop(){null!=this.timeout&&(this.timeout.clear(),this.timeout=null)}getSnapshot(){return Object.assign({},this.stats)}getMovingAverages(){return Object.assign({},this.movingAverages)}push(e,t){this.queue.push([e,t,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this.timeout=Hl(this._update,this._nextTimeout())}_nextTimeout(){return Math.max(this.computeThrottleTimeout*(1-this.queue.length/this.computeThrottleMaxQueueSize),0)}_update(){if(this.timeout=null,this.queue.length>0){let e=["",0,0];for(e of this.queue)this._applyOp(e);this.queue=[],e.length>2&&""!==e[0]&&this._updateFrequency(e[2]),this.dispatchEvent(new nn("update",{detail:this.stats}))}}_updateFrequency(e){const t=e-this.frequencyLastTime;this._updateFrequencyFor("dataReceived",t,e),this._updateFrequencyFor("dataSent",t,e),this.frequencyLastTime=e}_updateFrequencyFor(e,t,r){const i=this.frequencyAccumulators[e]??0;this.frequencyAccumulators[e]=0;const o=i/(t??1)*1e3;let a=this.movingAverages[e];null==a&&(a=this.movingAverages[e]=[]);const l=this.movingAverageIntervals;for(let _=0;_s:s})}forPeer(e){const t=e.toString();return this.peerStats.get(t)??this.oldPeers.get(t)}getProtocols(){return Array.from(this.protocolStats.keys())}forProtocol(e){return this.protocolStats.get(e)}onPeerDisconnected(e){const t=e.toString(),r=this.peerStats.get(t);null!=r&&(r.stop(),this.peerStats.delete(t),this.oldPeers.set(t,r))}_onMessage(e){if(!this.running)return;const{remotePeer:t,protocol:r,direction:i,dataLength:s}=e,o=T7[i];let a=this.forPeer(t);if(null==a){const l=new xv(this.statsInit);this.peerStats.set(t.toString(),l),a=l}if(a.push(o,s),this.globalStats.push(o,s),null!=r){let l=this.forProtocol(r);if(null==l){const _=new xv(this.statsInit);this.protocolStats.set(r,_),l=_}l.push(o,s)}}updatePlaceholder(e,t){if(!this.running)return;const r=e.toString(),i=this.peerStats.get(r)??this.oldPeers.get(r),s=t.toString(),o=this.peerStats.get(s)??this.oldPeers.get(s);let a=i;null!=o&&(a=function x7(n,e){return n.stop(),e.stop(),n.queue=[...n.queue,...e.queue],n}(o,a),this.oldPeers.remove(s)),this.peerStats.delete(e.toString()),this.peerStats.set(s,a),a.start()}trackStream(e){var t=this;const{stream:r,remotePeer:i,protocol:s}=e;if(!this.running)return;r.source=Av(r.source,l=>this._onMessage({remotePeer:i,protocol:s,direction:"in",dataLength:l.byteLength}));const a=r.sink;r.sink=function(){var l=$(function*(_){return yield qn(_,R=>Av(R,N=>{t._onMessage({remotePeer:i,protocol:s,direction:"out",dataLength:N.byteLength})}),a)});return function(_){return l.apply(this,arguments)}}()}}function Rv(n){return Pv.apply(this,arguments)}function Pv(){return Pv=$(function*(n){try{return{status:"fulfilled",value:yield n,isFulfilled:!0,isRejected:!1}}catch(e){return{status:"rejected",reason:e,isFulfilled:!1,isRejected:!0}}}),Pv.apply(this,arguments)}class R7{constructor(e){rb(this,"value"),rb(this,"next"),this.value=e}}class P7{constructor(){dp(this,js,void 0),dp(this,Va,void 0),dp(this,Ha,void 0),this.clear()}enqueue(e){const t=new R7(e);aa(this,js)?(aa(this,Va).next=t,So(this,Va,t)):(So(this,js,t),So(this,Va,t)),ib(this,Ha)._++}dequeue(){const e=aa(this,js);if(e)return So(this,js,aa(this,js).next),ib(this,Ha)._--,e.value}clear(){So(this,js,void 0),So(this,Va,void 0),So(this,Ha,0)}get size(){return aa(this,Ha)}*[Symbol.iterator](){let e=aa(this,js);for(;e;)yield e.value,e=e.next}}function N7(n){if(!Number.isInteger(n)&&n!==Number.POSITIVE_INFINITY||!(n>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const e=new P7;let t=0;const i=function(){var a=$(function*(l,_,R){t++;const N=$(function*(){return l(...R)})();_(N);try{yield N}catch{}t--,e.size>0&&e.dequeue()()});return function(_,R,N){return a.apply(this,arguments)}}(),o=(a,...l)=>new Promise(_=>{((a,l,_)=>{e.enqueue(i.bind(void 0,a,l,_)),$(function*(){yield Promise.resolve(),t0&&e.dequeue()()})()})(a,_,l)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}function M7(n){return Nv.apply(this,arguments)}function Nv(){return Nv=$(function*(n,e={}){const{concurrency:t=Number.POSITIVE_INFINITY}=e,r=N7(t);return Promise.all(n.map(i=>Rv(i&&"function"==typeof i.then?i:"function"==typeof i?r(()=>i()):Promise.resolve(i))))}),Nv.apply(this,arguments)}js=new WeakMap,Va=new WeakMap,Ha=new WeakMap;const Ra=zt("libp2p:transports");class O7 extends Ei{constructor(e,t={}){super(),this.components=e,this.started=!1,this.transports=new Map,this.listeners=kl({component:"transport-manager",metric:"listeners",metrics:this.components.getMetrics()}),this.faultTolerance=t.faultTolerance??Pa.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw ae(new Error("Transport must have a valid tag"),Ce.ERR_INVALID_KEY);if(this.transports.has(t))throw ae(new Error("There is already a transport with this tag"),Ce.ERR_DUPLICATE_TRANSPORT);Ra("adding transport %s",t),this.transports.set(t,e),this.listeners.has(t)||this.listeners.set(t,[])}isStarted(){return this.started}start(){var e=this;return $(function*(){const t=e.components.getAddressManager().getListenAddrs();yield e.listen(t),e.started=!0})()}stop(){var e=this;return $(function*(){const t=[];for(const[r,i]of e.listeners)for(Ra("closing listeners for %s",r);i.length>0;){const s=i.pop();null!=s&&t.push(s.close())}yield Promise.all(t),Ra("all listeners closed");for(const r of e.listeners.keys())e.listeners.set(r,[]);e.started=!1})()}dial(e,t){var r=this;return $(function*(){const i=r.transportForMultiaddr(e);if(null==i)throw ae(new Error(`No transport available for address ${String(e)}`),Ce.ERR_TRANSPORT_UNAVAILABLE);try{return yield i.dial(e,{...t,upgrader:r.components.getUpgrader()})}catch(s){throw null==s.code&&(s.code=Ce.ERR_TRANSPORT_DIAL_FAILED),s}})()}getAddrs(){let e=[];for(const t of this.listeners.values())for(const r of t)e=[...e,...r.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}transportForMultiaddr(e){for(const t of this.transports.values())if(t.filter([e]).length>0)return t}listen(e){var t=this;return $(function*(){if(null==e||0===e.length)return void Ra("no addresses were provided for listening, this node is dial only");const r=[];for(const[i,s]of t.transports.entries()){const o=s.filter(e),a=[];for(const R of o){Ra("creating listener for %s on %s",i,R);const N=s.createListener({upgrader:t.components.getUpgrader()});let B=t.listeners.get(i);null==B&&(B=[],t.listeners.set(i,B)),B.push(N),N.addEventListener("listening",()=>{t.dispatchEvent(new nn("listener:listening",{detail:N}))}),N.addEventListener("close",()=>{t.dispatchEvent(new nn("listener:close",{detail:N}))}),a.push(N.listen(R))}if(0!==a.length){if(null==(yield M7(a)).find(R=>R.isFulfilled)&&t.faultTolerance!==Pa.NO_FATAL)throw ae(new Error(`Transport (${i}) could not listen on any available address`),Ce.ERR_NO_VALID_ADDRESSES)}else r.push(i)}if(r.length===t.transports.size){const i=`no valid addresses were provided for transports [${r.join(", ")}]`;if(t.faultTolerance===Pa.FATAL_ALL)throw ae(new Error(i),Ce.ERR_NO_VALID_ADDRESSES);Ra(`libp2p in dial mode only: ${i}`)}})()}remove(e){var t=this;return $(function*(){Ra("removing %s",e);for(const r of t.listeners.get(e)??[])yield r.close();t.transports.delete(e),t.listeners.delete(e)})()}removeAll(){var e=this;return $(function*(){const t=[];for(const r of e.transports.keys())t.push(e.remove(r));yield Promise.all(t)})()}}var Pa=(()=>(function(n){n[n.FATAL_ALL=0]="FATAL_ALL",n[n.NO_FATAL=1]="NO_FATAL"}(Pa||(Pa={})),Pa))();const ru="/multistream/1.0.0",MT=Ot("\n");function Mv(n){const e=new qr(n,MT);return Os.single(e)}function Gl(n,e,t={}){const r=Mv(e);n.push(!0===t.writeBytes?r.subarray():r)}function k7(n,e,t={}){const r=new qr;for(const i of e)r.append(Mv(i));n.push(!0===t.writeBytes?r.subarray():r)}function L7(n,e){return Ov.apply(this,arguments)}function Ov(){return Ov=$(function*(n,e){let t=1;const r={[Symbol.asyncIterator]:()=>r,next:(a=$(function*(){return yield n.next(t)}),function(){return a.apply(this,arguments)})};var a;let i=r;null!=e?.signal&&(i=vs(r,e.signal));const o=yield qn(i,ps({onLength:a=>{t=a}}),function(){var a=$(function*(l){return yield Aa(l)});return function(l){return a.apply(this,arguments)}}());if(null==o)throw ae(new Error("no buffer returned"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(o.get(o.byteLength-1)!==MT[0])throw ae(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.sublist(0,-1)}),Ov.apply(this,arguments)}function Sh(n,e){return kv.apply(this,arguments)}function kv(){return kv=$(function*(n,e){return Lt((yield L7(n,e)).subarray())}),kv.apply(this,arguments)}const Wl=zt("libp2p:mss:select");function Lv(n,e){return Bv.apply(this,arguments)}function Bv(){return Bv=$(function*(n,e,t={}){e=Array.isArray(e)?[...e]:[e];const{reader:r,writer:i,rest:s,stream:o}=Ld(n),a=e.shift();if(null==a)throw new Error("At least one protocol must be specified");Wl('select: write ["%s", "%s"]',ru,a),k7(i,[Ot(ru),Ot(a)],t);let R=yield Sh(r,t);if(Wl('select: read "%s"',R),R===ru&&(R=yield Sh(r,t),Wl('select: read "%s"',R)),R===a)return s(),{stream:o,protocol:a};for(const N of e){Wl('select: write "%s"',N),Gl(i,Ot(N),t);const B=yield Sh(r,t);if(Wl('select: read "%s" for "%s"',B,N),B===N)return s(),{stream:o,protocol:N}}throw s(),ae(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}),Bv.apply(this,arguments)}const ql=zt("libp2p:mss:handle");function Fv(n,e,t){return Uv.apply(this,arguments)}function Uv(){return Uv=$(function*(n,e,t){e=Array.isArray(e)?e:[e];const{writer:r,reader:i,rest:s,stream:o}=Ld(n);for(;;){const a=yield Sh(i,t);if(ql('read "%s"',a),a!==ru){if(e.includes(a))return Gl(r,Ot(a),t),ql('respond with "%s" for "%s"',a,a),s(),{stream:o,protocol:a};"ls"!==a?(Gl(r,Ot("na"),t),ql('respond with "na" for "%s"',a)):(Gl(r,new qr(...e.map(l=>Mv(Ot(l)))),t),ql('respond with "%s" for %s',e,a))}else ql('respond with "%s" for "%s"',ru,a),Gl(r,Ot(ru),t)}}),Uv.apply(this,arguments)}var OT=x(344);const kT=Symbol.for("@libp2p/connection"),B7=zt("libp2p:connection");class F7{constructor(e){const{remoteAddr:t,remotePeer:r,newStream:i,close:s,getStreams:o,stat:a}=e;this.id=`${parseInt(String(1e9*Math.random())).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=r,this.stat={...a,status:"OPEN"},this._newStream=i,this._close=s,this._getStreams=o,this.tags=[],this._closing=!1}get[Symbol.toStringTag](){return"Connection"}get[kT](){return!0}get streams(){return this._getStreams()}newStream(e,t){var r=this;return $(function*(){if(r.stat.status===uT)throw ae(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(r.stat.status===dv)throw ae(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);const i=yield r._newStream(e,t);return i.stat.direction="outbound",i})()}addStream(e){e.stat.direction="inbound"}removeStream(e){}close(){var e=this;return $(function*(){if(e.stat.status!==dv&&!e._closing){e.stat.status=uT;try{e.streams.forEach(t=>t.close())}catch(t){B7.error(t)}e._closing=!0,yield e._close(),e._closing=!1,e.stat.timeline.close=Date.now(),e.stat.status=dv}})()}}const Vv=Symbol.for("@libp2p/topology"),LT=zt("libp2p:registrar");class H7{constructor(e){this.topologies=new Map,this.handlers=new Map,this.components=e,this._onDisconnect=this._onDisconnect.bind(this),this._onProtocolChange=this._onProtocolChange.bind(this),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onDisconnect),this.components.getPeerStore().addEventListener("change:protocols",this._onProtocolChange)}getProtocols(){return Array.from(new Set([...this.topologies.keys(),...this.handlers.keys()])).sort()}getHandler(e){const t=this.handlers.get(e);if(null==t)throw ae(new Error(`No handler registered for protocol ${e}`),Ce.ERR_NO_HANDLER_FOR_PROTOCOL);return t}getTopologies(e){const t=this.topologies.get(e);return null==t?[]:[...t.values()]}handle(e,t,r){var i=this;return $(function*(){if(i.handlers.has(e))throw ae(new Error(`Handler already registered for protocol ${e}`),Ce.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const s=Vl.bind({ignoreUndefined:!0})({maxInboundStreams:32,maxOutboundStreams:64},r);i.handlers.set(e,{handler:t,options:s}),yield i.components.getPeerStore().protoBook.add(i.components.getPeerId(),[e])})()}unhandle(e){var t=this;return $(function*(){const r=Array.isArray(e)?e:[e];r.forEach(i=>{t.handlers.delete(i)}),yield t.components.getPeerStore().protoBook.remove(t.components.getPeerId(),r)})()}register(e,t){var r=this;return $(function*(){if(!function V7(n){return null!=n&&Boolean(n[Vv])}(t))throw LT.error("topology must be an instance of interfaces/topology"),ae(new Error("topology must be an instance of interfaces/topology"),Ce.ERR_INVALID_PARAMETERS);const i=`${(1e9*Math.random()).toString(36)}${Date.now()}`;let s=r.topologies.get(e);return null==s&&(s=new Map,r.topologies.set(e,s)),s.set(i,t),yield t.setRegistrar(r),i})()}unregister(e){for(const[t,r]of this.topologies.entries())r.has(e)&&(r.delete(e),0===r.size&&this.topologies.delete(t))}_onDisconnect(e){const t=e.detail;this.components.getPeerStore().protoBook.get(t.remotePeer).then(r=>{for(const i of r){const s=this.topologies.get(i);if(null!=s)for(const o of s.values())o.onDisconnect(t.remotePeer)}}).catch(r=>{LT.error(r)})}_onProtocolChange(e){const{peerId:t,protocols:r,oldProtocols:i}=e.detail,s=i.filter(a=>!r.includes(a)),o=r.filter(a=>!i.includes(a));for(const a of s){const l=this.topologies.get(a);if(null!=l)for(const _ of l.values())_.onDisconnect(t)}for(const a of o){const l=this.topologies.get(a);if(null!=l)for(const _ of l.values()){const R=this.components.getConnectionManager().getConnections(t)[0];null!=R&&_.onConnect(t,R)}}}}const zn=zt("libp2p:upgrader");function UT(n,e,t){let r=0;return t.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===n&&r++}),r}class j7 extends Ei{constructor(e,t){super(),this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(r=>{this.connectionEncryption.set(r.protocol,r)}),this.muxers=new Map,t.muxers.forEach(r=>{this.muxers.set(r.protocol,r)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout}upgradeInbound(e){var t=this;return $(function*(){let r,i,s,o,a,l,_;const R=t.components.getMetrics(),N=new bi.TimeoutController(t.inboundUpgradeTimeout);try{(0,Vr.setMaxListeners)?.(1/0,N.signal)}catch{}try{const B=Go(e,N.signal);if(e.source=B.source,e.sink=B.sink,yield t.components.getConnectionGater().denyInboundConnection(e))throw ae(new Error("The multiaddr connection is blocked by gater.acceptConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(null!=R){({setTarget:l,proxy:_}=OT());const J=`${(1e9*Math.random()).toString(36)}${Date.now()}`;l({toString:()=>J}),R.trackStream({stream:e,remotePeer:_})}zn("starting the inbound connection upgrade");let z=e;const Z=t.components.getConnectionProtector();null!=Z&&(zn("protecting the inbound connection"),z=yield Z.protect(e));try{if(({conn:r,remotePeer:i,protocol:a}=yield t._encryptInbound(z)),yield t.components.getConnectionGater().denyInboundEncryptedConnection(i,{...z,...r}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const J=yield t._multiplexInbound({...z,...r},t.muxers);o=J.muxerFactory,s=J.stream}else s=r}catch(J){throw zn.error("Failed to upgrade inbound connection",J),yield e.close(J),J}if(yield t.components.getConnectionGater().denyInboundUpgradedConnection(i,{...z,...r}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);return null!=R&&(R.updatePlaceholder(_,i),l(i)),zn("Successfully upgraded inbound connection"),t._createConnection({cryptoProtocol:a,direction:"inbound",maConn:e,upgradedConn:s,muxerFactory:o,remotePeer:i})}finally{N.clear()}})()}upgradeOutbound(e){var t=this;return $(function*(){const r=e.remoteAddr.getPeerId();if(null==r)throw ae(new Error("outbound connection must have a peer id"),Ce.ERR_INVALID_MULTIADDR);const i=fr(r);if(yield t.components.getConnectionGater().denyOutboundConnection(i,e))throw ae(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),Ce.ERR_CONNECTION_INTERCEPTED);let s,o,a,l,_,R,N;const B=t.components.getMetrics();if(null!=B){({setTarget:R,proxy:N}=OT());const J=`${(1e9*Math.random()).toString(36)}${Date.now()}`;R({toB58String:()=>J}),B.trackStream({stream:e,remotePeer:N})}zn("Starting the outbound connection upgrade");let z=e;const Z=t.components.getConnectionProtector();null!=Z&&(z=yield Z.protect(e));try{if(({conn:s,remotePeer:o,protocol:l}=yield t._encryptOutbound(z,i)),yield t.components.getConnectionGater().denyOutboundEncryptedConnection(o,{...z,...s}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const J=yield t._multiplexOutbound({...z,...s},t.muxers);_=J.muxerFactory,a=J.stream}else a=s}catch(J){throw zn.error("Failed to upgrade outbound connection",J),yield e.close(J),J}if(yield t.components.getConnectionGater().denyOutboundUpgradedConnection(o,{...z,...s}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);return null!=B&&(B.updatePlaceholder(N,o),R(o)),zn("Successfully upgraded outbound connection"),t._createConnection({cryptoProtocol:l,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:_,remotePeer:o})})()}_createConnection(e){var t=this;const{cryptoProtocol:r,direction:i,maConn:s,upgradedConn:o,remotePeer:a,muxerFactory:l}=e;let _,R,N;null!=l&&(_=l.createStreamMuxer({direction:i,onIncomingStream:Z=>{null!=N&&Promise.resolve().then($(function*(){const J=t.components.getRegistrar().getProtocols(),{stream:se,protocol:he}=yield Fv(Z,J);if(zn("%s: incoming stream opened on %s",i,he),t.components.getMetrics()?.trackStream({stream:se,remotePeer:a,protocol:he}),null==N)return;const ue=function K7(n,e){try{const{options:t}=e.getHandler(n);return t.maxInboundStreams}catch(t){if(t.code!==Ce.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 32}(he,t.components.getRegistrar());UT(he,"inbound",N)!==ue?(Z.stat.protocol=he,t.components.getPeerStore().protoBook.add(a,[he]).catch($e=>zn.error($e)),N.addStream(Z),t._onStream({connection:N,stream:{...Z,...se},protocol:he})):Z.abort(ae(new Error(`Too many inbound protocol streams for protocol "${he}" - limit ${ue}`),Ce.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS))})).catch(J=>{zn.error(J),null==Z.stat.timeline.close&&Z.close()})},onStreamEnd:Z=>{N?.removeStream(Z.id)}}),Fr(_)&&_.init(this.components),R=function(){var Z=$(function*(J,se={}){if(null==_)throw ae(new Error("Stream is not multiplexed"),Ce.ERR_MUXER_UNAVAILABLE);zn("%s: starting new stream on %s",i,J);const he=_.newStream(),Te=t.components.getMetrics();let ue;try{if(null==se.signal){zn("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",J),ue=new bi.TimeoutController(3e4),se.signal=ue.signal;try{(0,Vr.setMaxListeners)?.(1/0,ue.signal)}catch{}}const{stream:Re,protocol:$e}=yield Lv(he,J,se);Te?.trackStream({stream:Re,remotePeer:a,protocol:$e});const Pe=function $7(n,e){try{const{options:t}=e.getHandler(n);return t.maxOutboundStreams}catch(t){if(t.code!==Ce.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 64}($e,t.components.getRegistrar());if(UT($e,"outbound",N)===Pe){const yt=ae(new Error(`Too many outbound protocol streams for protocol "${$e}" - limit ${Pe}`),Ce.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw he.abort(yt),yt}return he.stat.protocol=$e,t.components.getPeerStore().protoBook.add(a,[$e]).catch(yt=>zn.error(yt)),{...he,...Re,stat:{...he.stat,protocol:$e}}}catch(Re){throw zn.error("could not create new stream",Re),null==he.stat.timeline.close&&he.close(),null!=Re.code?Re:ae(Re,Ce.ERR_UNSUPPORTED_PROTOCOL)}finally{ue?.clear()}});return function(se){return Z.apply(this,arguments)}}(),qn(o,_,o).catch(zn.error));const B=s.timeline;s.timeline=new Proxy(B,{set:(...Z)=>(null!=N&&"close"===Z[1]&&null!=Z[2]&&null==B.close&&$(function*(){try{"OPEN"===N.stat.status&&(yield N.close())}catch(J){zn.error(J)}finally{t.dispatchEvent(new nn("connectionEnd",{detail:N}))}})().catch(J=>{zn.error(J)}),Reflect.set(...Z))}),s.timeline.upgraded=Date.now();const z=()=>{throw ae(new Error("connection is not multiplexed"),Ce.ERR_CONNECTION_NOT_MULTIPLEXED)};return N=function U7(n){return new F7(n)}({remoteAddr:s.remoteAddr,remotePeer:a,stat:{status:"OPEN",direction:i,timeline:s.timeline,multiplexer:_?.protocol,encryption:r},newStream:R??z,getStreams:()=>null!=_?_.streams:z(),close:(Z=$(function*(){yield s.close(),_?.close()}),function(){return Z.apply(this,arguments)})}),this.dispatchEvent(new nn("connection",{detail:N})),N;var Z}_onStream(e){const{connection:t,stream:r,protocol:i}=e,{handler:s}=this.components.getRegistrar().getHandler(i);s({connection:t,stream:r})}_encryptInbound(e){var t=this;return $(function*(){const r=Array.from(t.connectionEncryption.keys());zn("handling inbound crypto protocol selection",r);try{const{stream:i,protocol:s}=yield Fv(e,r,{writeBytes:!0}),o=t.connectionEncryption.get(s);if(null==o)throw new Error(`no crypto module found for ${s}`);return zn("encrypting inbound connection..."),{...yield o.secureInbound(t.components.getPeerId(),i),protocol:s}}catch(i){throw ae(i,Ce.ERR_ENCRYPTION_FAILED)}})()}_encryptOutbound(e,t){var r=this;return $(function*(){const i=Array.from(r.connectionEncryption.keys());zn("selecting outbound crypto protocol",i);try{const{stream:s,protocol:o}=yield Lv(e,i,{writeBytes:!0}),a=r.connectionEncryption.get(o);if(null==a)throw new Error(`no crypto module found for ${o}`);return zn("encrypting outbound connection to %p",t),{...yield a.secureOutbound(r.components.getPeerId(),s,t),protocol:o}}catch(s){throw ae(s,Ce.ERR_ENCRYPTION_FAILED)}})()}_multiplexOutbound(e,t){return $(function*(){const r=Array.from(t.keys());zn("outbound selecting muxer %s",r);try{const{stream:i,protocol:s}=yield Lv(e,r,{writeBytes:!0});return zn("%s selected as muxer protocol",s),{stream:i,muxerFactory:t.get(s)}}catch(i){throw zn.error("error multiplexing outbound stream",i),ae(i,Ce.ERR_MUXER_UNAVAILABLE)}})()}_multiplexInbound(e,t){return $(function*(){const r=Array.from(t.keys());zn("inbound handling muxers %s",r);try{const{stream:i,protocol:s}=yield Fv(e,r,{writeBytes:!0});return{stream:i,muxerFactory:t.get(s)}}catch(i){throw zn.error("error multiplexing inbound stream",i),ae(i,Ce.ERR_MUXER_UNAVAILABLE)}})()}}var Na;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.protocolVersion&&(r.uint32(42),r.string(t.protocolVersion)),null!=t.agentVersion&&(r.uint32(50),r.string(t.agentVersion)),null!=t.publicKey&&(r.uint32(10),r.bytes(t.publicKey)),null==t.listenAddrs)throw new Error('Protocol error: required field "listenAddrs" was not found in object');for(const s of t.listenAddrs)r.uint32(18),r.bytes(s);if(null!=t.observedAddr&&(r.uint32(34),r.bytes(t.observedAddr)),null==t.protocols)throw new Error('Protocol error: required field "protocols" was not found in object');for(const s of t.protocols)r.uint32(26),r.string(s);null!=t.signedPeerRecord&&(r.uint32(66),r.bytes(t.signedPeerRecord)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 5:i.protocolVersion=t.string();break;case 6:i.agentVersion=t.string();break;case 1:i.publicKey=t.bytes();break;case 2:i.listenAddrs=i.listenAddrs??[],i.listenAddrs.push(t.bytes());break;case 4:i.observedAddr=t.bytes();break;case 3:i.protocols=i.protocols??[],i.protocols.push(t.string());break;case 8:i.signedPeerRecord=t.bytes();break;default:t.skipType(7&o)}}if(i.listenAddrs=i.listenAddrs??[],i.protocols=i.protocols??[],null==i.listenAddrs)throw new Error('Protocol error: value for required field "listenAddrs" was not found in protobuf');if(null==i.protocols)throw new Error('Protocol error: value for required field "protocols" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Na||(Na={}));var Ch;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.publicKey)throw new Error('Protocol error: required field "publicKey" was not found in object');if(r.uint32(10),r.bytes(t.publicKey),null==t.payloadType)throw new Error('Protocol error: required field "payloadType" was not found in object');if(r.uint32(18),r.bytes(t.payloadType),null==t.payload)throw new Error('Protocol error: required field "payload" was not found in object');if(r.uint32(26),r.bytes(t.payload),null==t.signature)throw new Error('Protocol error: required field "signature" was not found in object');r.uint32(42),r.bytes(t.signature),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.publicKey=t.bytes();break;case 2:i.payloadType=t.bytes();break;case 3:i.payload=t.bytes();break;case 5:i.signature=t.bytes();break;default:t.skipType(7&o)}}if(null==i.publicKey)throw new Error('Protocol error: value for required field "publicKey" was not found in protobuf');if(null==i.payloadType)throw new Error('Protocol error: value for required field "payloadType" was not found in protobuf');if(null==i.payload)throw new Error('Protocol error: value for required field "payload" was not found in protobuf');if(null==i.signature)throw new Error('Protocol error: value for required field "signature" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Ch||(Ch={}));class wi{constructor(e){const{peerId:t,payloadType:r,payload:i,signature:s}=e;this.peerId=t,this.payloadType=r,this.payload=i,this.signature=s}marshal(){if(null==this.peerId.publicKey)throw new Error("Missing public key");return null==this.marshaled&&(this.marshaled=Ch.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return kr(this.marshal(),e.marshal())}validate(e){var t=this;return $(function*(){const r=VT(e,t.payloadType,t.payload);if(null==t.peerId.publicKey)throw new Error("Missing public key");return yield xl(t.peerId.publicKey).verify(r.subarray(),t.signature)})()}}wi.createFromProtobuf=function(){var n=$(function*(e){const t=Ch.decode(e),r=yield Ol(t.publicKey);return new wi({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})});return function(e){return n.apply(this,arguments)}}(),wi.seal=function(){var n=$(function*(e,t){if(null==t.privateKey)throw new Error("Missing private key");const r=e.domain,i=e.codec,s=e.marshal(),o=VT(r,i,s),l=yield(yield Rl(t.privateKey)).sign(o.subarray());return new wi({peerId:t,payloadType:i,payload:s,signature:l})});return function(e,t){return n.apply(this,arguments)}}(),wi.openAndCertify=function(){var n=$(function*(e,t){const r=yield wi.createFromProtobuf(e);if(!(yield r.validate(t)))throw ae(new Error("envelope signature is not valid for the given domain"),"ERR_SIGNATURE_NOT_VALID");return r});return function(e,t){return n.apply(this,arguments)}}();const VT=(n,e,t)=>{const r=Ot(n),i=Ni.encode(r.byteLength),s=Ni.encode(e.length),o=Ni.encode(t.length);return new qr(i,r,s,e,o,t)};var Ih;!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Yt((s,o,a={})=>{if(!1!==a.lengthDelimited&&o.fork(),null==s.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');o.uint32(10),o.bytes(s.multiaddr),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={multiaddr:new Uint8Array(0)},l=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.multiaddr=s.bytes():s.skipType(7&_)}if(null==a.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return a})),i),r.encode=s=>qt(s,r.codec()),r.decode=s=>Wt(s,r.codec())}(e=n.AddressInfo||(n.AddressInfo={})),n.codec=()=>(null==t&&(t=Yt((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null==r.peerId)throw new Error('Protocol error: required field "peerId" was not found in object');if(i.uint32(10),i.bytes(r.peerId),null==r.seq)throw new Error('Protocol error: required field "seq" was not found in object');if(i.uint32(16),i.uint64(r.seq),null==r.addresses)throw new Error('Protocol error: required field "addresses" was not found in object');for(const o of r.addresses)i.uint32(26),n.AddressInfo.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={peerId:new Uint8Array(0),seq:0n,addresses:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.peerId=r.bytes();break;case 2:s.seq=r.uint64();break;case 3:s.addresses.push(n.AddressInfo.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}if(null==s.peerId)throw new Error('Protocol error: value for required field "peerId" was not found in protobuf');if(null==s.seq)throw new Error('Protocol error: value for required field "seq" was not found in protobuf');return s})),t),n.encode=r=>qt(r,n.codec()),n.decode=r=>Wt(r,n.codec())}(Ih||(Ih={}));const Y7=Uint8Array.from([3,1]);let iu=(()=>{class n{constructor(t){this.domain=n.DOMAIN,this.codec=n.CODEC;const{peerId:r,multiaddrs:i,seqNumber:s}=t;this.peerId=r,this.multiaddrs=i??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=Ih.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!!(t instanceof n&&this.peerId.equals(t.peerId)&&this.seqNumber===t.seqNumber&&function W7(n,e){const t=(r,i)=>r.toString().localeCompare(i.toString());return n.length===e.length&&e.sort(t)&&n.sort(t).every((r,i)=>e[i].equals(r))}(this.multiaddrs,t.multiaddrs))}}return n.createFromProtobuf=e=>{const t=Ih.decode(e),r=Jc(t.peerId),i=(t.addresses??[]).map(o=>new mn(o.multiaddr));return new n({peerId:r,multiaddrs:i,seqNumber:t.seq})},n.DOMAIN="libp2p-peer-record",n.CODEC=Y7,n})();const KT="js-libp2p/0.0.0",Hn=zt("libp2p:identify");class Hv{constructor(e,t){this.components=e,this.started=!1,this.init=t,this.identifyProtocolStr=`/${t.protocolPrefix}/id/1.0.0`,this.identifyPushProtocolStr=`/${t.protocolPrefix}/id/push/1.0.0`,this.host={protocolVersion:`${t.protocolPrefix}/0.1.0`,...t.host},this.components.getConnectionManager().addEventListener("peer:connect",r=>{this.identify(r.detail).catch(Hn.error)}),this.components.getPeerStore().addEventListener("change:multiaddrs",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Hn.error(s))}),this.components.getPeerStore().addEventListener("change:protocols",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Hn.error(s))})}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started||(yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"AgentVersion",Ot(e.host.agentVersion)),yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"ProtocolVersion",Ot(e.host.protocolVersion)),yield e.components.getRegistrar().handle(e.identifyProtocolStr,t=>{e._handleIdentify(t).catch(r=>{Hn.error(r)})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),yield e.components.getRegistrar().handle(e.identifyPushProtocolStr,t=>{e._handlePush(t).catch(r=>{Hn.error(r)})},{maxInboundStreams:e.init.maxPushIncomingStreams,maxOutboundStreams:e.init.maxPushOutgoingStreams}),e.started=!0)})()}stop(){var e=this;return $(function*(){yield e.components.getRegistrar().unhandle(e.identifyProtocolStr),yield e.components.getRegistrar().unhandle(e.identifyPushProtocolStr),e.started=!1})()}push(e){var t=this;return $(function*(){const r=yield t.components.getPeerStore().addressBook.getRawEnvelope(t.components.getPeerId()),i=t.components.getAddressManager().getAddresses().map(a=>a.bytes),s=yield t.components.getPeerStore().protoBook.get(t.components.getPeerId()),o=e.map(function(){var a=$(function*(l){let _;const R=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,R.signal)}catch{}try{_=yield l.newStream([t.identifyPushProtocolStr],{signal:R.signal});const N=Go(_,R.signal);yield qn([Na.encode({listenAddrs:i,signedPeerRecord:r,protocols:s})],Os(),N,Qo)}catch(N){Hn.error("could not push identify update to peer",N)}finally{_?.close(),R.clear()}});return function(l){return a.apply(this,arguments)}}());yield Promise.all(o)})()}pushToPeerStore(){var e=this;return $(function*(){if(!e.isStarted())return;const t=[];for(const r of e.components.getConnectionManager().getConnections()){const i=r.remotePeer;!(yield e.components.getPeerStore().get(i)).protocols.includes(e.identifyPushProtocolStr)||t.push(r)}yield e.push(t)})()}_identify(e,t={}){var r=this;return $(function*(){let i,o,s=t.signal;if(null==s){i=new bi.TimeoutController(r.init.timeout),s=i.signal;try{(0,Vr.setMaxListeners)?.(1/0,i.signal)}catch{}}try{o=yield e.newStream([r.identifyProtocolStr],{signal:s});const a=Go(o,s),l=yield qn([],a,ps({maxDataLength:r.init.maxIdentifyMessageSize??8192}),function(){var _=$(function*(R){return yield Aa(R)});return function(R){return _.apply(this,arguments)}}());if(null==l)throw ae(new Error("No data could be retrieved"),Ce.ERR_CONNECTION_ENDED);try{return Na.decode(l)}catch(_){throw ae(_,Ce.ERR_INVALID_MESSAGE)}}finally{i?.clear(),o?.close()}})()}identify(e,t={}){var r=this;return $(function*(){const i=yield r._identify(e,t),{publicKey:s,listenAddrs:o,protocols:a,observedAddr:l,signedPeerRecord:_,agentVersion:R,protocolVersion:N}=i;if(null==s)throw ae(new Error("public key was missing from identify message"),Ce.ERR_MISSING_PUBLIC_KEY);const B=yield Ol(s);if(!e.remotePeer.equals(B))throw ae(new Error("identified peer does not match the expected peer"),Ce.ERR_INVALID_PEER);if(r.components.getPeerId().equals(B))throw ae(new Error("identified peer is our own peer id?"),Ce.ERR_INVALID_PEER);const z=Hv.getCleanMultiaddr(l);if(null!=_){Hn("received signed peer record from %p",B);try{const Z=yield wi.openAndCertify(_,iu.DOMAIN);if(!Z.peerId.equals(B))throw ae(new Error("identified peer does not match the expected peer"),Ce.ERR_INVALID_PEER);if(yield r.components.getPeerStore().addressBook.consumePeerRecord(Z))return yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",Ot(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",Ot(N))),void Hn("identify completed for peer %p and protocols %o",B,a)}catch(Z){Hn("received invalid envelope, discard it and fallback to listenAddrs is available",Z)}}else Hn("no signed peer record received from %p",B);Hn("falling back to legacy addresses from %p",B);try{yield r.components.getPeerStore().addressBook.set(B,o.map(Z=>new mn(Z)))}catch(Z){Hn.error("received invalid addrs",Z)}yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",Ot(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",Ot(N))),Hn("identify completed for peer %p and protocols %o",B,a),Hn("received observed address of %s",z?.toString())})()}_handleIdentify(e){var t=this;return $(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=t.components.getPeerId().publicKey??new Uint8Array(0),a=yield t.components.getPeerStore().get(t.components.getPeerId()),l=t.components.getAddressManager().getAddresses().map(B=>B.decapsulateCode(Sr("p2p").code));let _=a.peerRecordEnvelope;if(l.length>0&&null==_){const B=new iu({peerId:t.components.getPeerId(),multiaddrs:l}),z=yield wi.seal(B,t.components.getPeerId());yield t.components.getPeerStore().addressBook.consumePeerRecord(z),_=z.marshal().subarray()}const R=Na.encode({protocolVersion:t.host.protocolVersion,agentVersion:t.host.agentVersion,publicKey:o,listenAddrs:l.map(B=>B.bytes),signedPeerRecord:_,observedAddr:r.remoteAddr.bytes,protocols:a.protocols}),N=Go(i,s.signal);yield qn([R],Os(),N,Qo)}catch(o){Hn.error("could not respond to identify request",o)}finally{i.close(),s.clear()}})()}_handlePush(e){var t=this;return $(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}let o;try{const l=Go(i,s.signal),_=yield qn([],l,ps({maxDataLength:t.init.maxIdentifyMessageSize??8192}),function(){var R=$(function*(N){return yield Aa(N)});return function(N){return R.apply(this,arguments)}}());null!=_&&(o=Na.decode(_))}catch(l){return Hn.error("received invalid message",l)}finally{i.close(),s.clear()}if(null==o)return Hn.error("received invalid message");const a=r.remotePeer;if(t.components.getPeerId().equals(a))Hn("received push from ourselves?");else{if(Hn("received push from %p",a),null!=o.signedPeerRecord){Hn("received signedPeerRecord in push");try{const l=yield wi.openAndCertify(o.signedPeerRecord,iu.DOMAIN);if(yield t.components.getPeerStore().addressBook.consumePeerRecord(l))return Hn("consumed signedPeerRecord sent in push"),void(yield t.components.getPeerStore().protoBook.set(a,o.protocols));Hn("failed to consume signedPeerRecord sent in push")}catch(l){Hn("received invalid envelope, discard it and fallback to listenAddrs is available",l)}}else Hn("did not receive signedPeerRecord in push");try{yield t.components.getPeerStore().addressBook.set(a,o.listenAddrs.map(l=>new mn(l)))}catch(l){Hn.error("received invalid addrs",l)}try{yield t.components.getPeerStore().protoBook.set(a,o.protocols)}catch(l){Hn.error("received invalid protocols",l)}Hn("handled push from %p",a)}})()}static getCleanMultiaddr(e){if(null!=e&&e.length>0)try{return new mn(e)}catch{}}}var Th,Vs;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.identifier)throw new Error('Protocol error: required field "identifier" was not found in object');r.uint32(10),r.string(t.identifier),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.identifier=t.string():t.skipType(7&o)}if(null==i.identifier)throw new Error('Protocol error: value for required field "identifier" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Th||(Th={})),function(n){let e;var i;let t,r;(i=e=n.StatusCode||(n.StatusCode={})).OK="OK",i.NOT_FOUND="NOT_FOUND",i.ERROR="ERROR",function(i){i[i.OK=0]="OK",i[i.NOT_FOUND=1]="NOT_FOUND",i[i.ERROR=2]="ERROR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.StatusCode||(n.StatusCode={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.status)throw new Error('Protocol error: required field "status" was not found in object');if(s.uint32(8),n.StatusCode.codec().encode(i.status,s),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(18),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.status=n.StatusCode.codec().decode(i);break;case 2:o.data=i.bytes();break;default:i.skipType(7&l)}}if(null==o.status)throw new Error('Protocol error: value for required field "status" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(Vs||(Vs={}));const jT=zt("libp2p:fetch");class o9{constructor(e,t){this.started=!1,this.components=e,this.protocol=`/${t.protocolPrefix??"libp2p"}/fetch/0.0.1`,this.lookupFunctions=new Map,this.handleMessage=this.handleMessage.bind(this),this.init=t}start(){var e=this;return $(function*(){yield e.components.getRegistrar().handle(e.protocol,t=>{e.handleMessage(t).catch(r=>{jT.error(r)}).finally(()=>{t.stream.close()})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return $(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}fetch(e,t,r={}){var i=this;return $(function*(){jT("dialing %s to %p",i.protocol,e);const s=yield i.components.getConnectionManager().openConnection(e,r);let o,l,a=r.signal;if(null==a){o=new bi.TimeoutController(i.init.timeout),a=o.signal;try{(0,Vr.setMaxListeners)?.(1/0,o.signal)}catch{}}try{l=yield s.newStream([i.protocol],{signal:a});const _=Go(l,a);return(yield qn([Th.encode({identifier:t})],Os(),_,ps(),function(){var N=$(function*(B){const z=yield Aa(B);if(null==z)throw ae(new Error("No data received"),Ce.ERR_INVALID_MESSAGE);const Z=Vs.decode(z);switch(Z.status){case Vs.StatusCode.OK:return Z.data;case Vs.StatusCode.NOT_FOUND:return null;case Vs.StatusCode.ERROR:{const J=(new TextDecoder).decode(Z.data);throw ae(new Error("Error in fetch protocol response: "+J),Ce.ERR_INVALID_PARAMETERS)}default:throw ae(new Error("Unknown response status"),Ce.ERR_INVALID_MESSAGE)}});return function(B){return N.apply(this,arguments)}}()))??null}finally{o?.clear(),l?.close()}})()}handleMessage(e){var t=this;return $(function*(){const{stream:r}=e,i=t;yield qn(r,ps(),function(){var s=hn(function*(o){const a=yield lt(Aa(o));if(null==a)throw ae(new Error("No data received"),Ce.ERR_INVALID_MESSAGE);const l=Th.decode(a);let _;const R=i._getLookupFunction(l.identifier);if(null!=R){const N=yield lt(R(l.identifier));_=null!=N?{status:Vs.StatusCode.OK,data:N}:{status:Vs.StatusCode.NOT_FOUND,data:new Uint8Array(0)}}else{const N=(new TextEncoder).encode("No lookup function registered for key: "+l.identifier);_={status:Vs.StatusCode.ERROR,data:N}}yield Vs.encode(_)});return function(o){return s.apply(this,arguments)}}(),Os(),r)})()}_getLookupFunction(e){for(const t of this.lookupFunctions.keys())if(e.startsWith(t))return this.lookupFunctions.get(t)}registerLookupFunction(e,t){if(this.lookupFunctions.has(e))throw ae(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),Ce.ERR_KEY_ALREADY_EXISTS);this.lookupFunctions.set(e,t)}unregisterLookupFunction(e,t){null!=t&&this.lookupFunctions.get(e)!==t||this.lookupFunctions.delete(e)}}const zT=zt("libp2p:ping");class l9{constructor(e,t){this.components=e,this.started=!1,this.protocol=`/${t.protocolPrefix}/ping/1.0.0`,this.init=t}start(){var e=this;return $(function*(){yield e.components.getRegistrar().handle(e.protocol,e.handleMessage,{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return $(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}handleMessage(e){const{stream:t}=e;qn(t,t).catch(r=>{zT.error(r)})}ping(e,t={}){var r=this;return $(function*(){zT("dialing %s to %p",r.protocol,e);const i=Date.now(),s=nh(32),o=yield r.components.getConnectionManager().openConnection(e,t);let a,_,l=t.signal;if(null==l){a=new bi.TimeoutController(r.init.timeout),l=a.signal;try{(0,Vr.setMaxListeners)?.(1/0,a.signal)}catch{}}try{_=yield o.newStream([r.protocol],{signal:l});const R=Go(_,l),N=yield qn([s],R,function(){var z=$(function*(Z){return yield Aa(Z)});return function(Z){return z.apply(this,arguments)}}()),B=Date.now();if(null==N||!kr(s,N.subarray()))throw ae(new Error("Received wrong ping ack"),Ce.ERR_WRONG_PING_ACK);return B-i}finally{a?.clear(),_?.close()}})()}}function Kv(){return(Kv=$(function*(){throw new Error("Not supported in browsers")})).apply(this,arguments)}function h9(n){const{address:e}=n.nodeAddress();return function d9(n){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(n)||/^::1$/.test(n)}(e)}const jv=zt("libp2p:nat");function p9(n=1024,e=65535){return Math.floor(Math.random()*(e-n+1)+n)}class g9{constructor(e,t){if(this.components=e,this.started=!1,this.enabled=t.enabled,this.externalAddress=t.externalAddress,this.localAddress=t.localAddress,this.description=t.description??`libp2p@0.0.0 ${this.components.getPeerId().toString()}`,this.ttl=t.ttl??7200,this.keepAlive=t.keepAlive??!0,this.gateway=t.gateway,this.ttl<7200)throw ae(new Error("NatManager ttl should be at least 7200 seconds"),Ce.ERR_INVALID_PARAMETERS)}isStarted(){return this.started}start(){}afterStart(){mh||!this.enabled||this.started||(this.started=!0,this._start().catch(e=>{jv.error(e)}))}_start(){var e=this;return $(function*(){const t=e.components.getTransportManager().getAddrs();for(const r of t){const{family:i,host:s,port:o,transport:a}=r.toOptions();if(!r.isThinWaistAddress()||"tcp"!==a||h9(r)||4!==i)continue;const l=yield e._getClient(),_=e.externalAddress??(yield l.externalIp());if(fT(_))throw new Error(`${_} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);const R=p9();jv(`opening uPnP connection from ${_}:${R} to ${s}:${o}`),yield l.map({publicPort:R,localPort:o,localAddress:e.localAddress,protocol:"TCP"===a.toUpperCase()?"TCP":"UDP"}),e.components.getAddressManager().addObservedAddr(mn.fromNodeAddress({family:4,address:_,port:R},a))}})()}_getClient(){var e=this;return $(function*(){return null!=e.client||(e.client=yield function f9(){return Kv.apply(this,arguments)}({description:e.description,ttl:e.ttl,keepAlive:e.keepAlive,gateway:e.gateway})),e.client})()}stop(){var e=this;return $(function*(){if(!mh&&null!=e.client)try{yield e.client.close(),e.client=void 0}catch(t){jv.error(t)}})()}}const y9=zt("libp2p:peer-record-updater");class m9{constructor(e){this.components=e,this.started=!1,this.update=this.update.bind(this)}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started=!0,e.components.getTransportManager().addEventListener("listener:listening",e.update),e.components.getTransportManager().addEventListener("listener:close",e.update),e.components.getAddressManager().addEventListener("change:addresses",e.update)})()}stop(){var e=this;return $(function*(){e.started=!1,e.components.getTransportManager().removeEventListener("listener:listening",e.update),e.components.getTransportManager().removeEventListener("listener:close",e.update),e.components.getAddressManager().removeEventListener("change:addresses",e.update)})()}update(){var e=this;Promise.resolve().then($(function*(){const t=new iu({peerId:e.components.getPeerId(),multiaddrs:e.components.getAddressManager().getAddresses().map(i=>i.decapsulateCode(Sr("p2p").code))}),r=yield wi.seal(t,e.components.getPeerId());yield e.components.getPeerStore().addressBook.consumePeerRecord(r)})).catch(t=>{y9.error("Could not update self peer record: %o",t)})}}class v9{constructor(e){this.dht=e}findPeer(e,t={}){var r=this;return $(function*(){var o,i=!1,s=!1;try{for(var l,a=Pt(r.dht.findPeer(e,t));i=!(l=yield a.next()).done;i=!1){const _=l.value;if("FINAL_PEER"===_.name)return _.peer}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw ae(new Error(Dn.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getClosestPeers(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var l,a=Pt(r.dht.getClosestPeers(e,t));i=!(l=yield lt(a.next())).done;i=!1){const _=l.value;"PEER_RESPONSE"===_.name&&(yield*Mr(Pt(_.closer),lt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}}const Bn=zt("libp2p:peer-store:address-book"),Ah="change:multiaddrs";function E9(){return Gv.apply(this,arguments)}function Gv(){return(Gv=$(function*(){return!0})).apply(this,arguments)}class b9{constructor(e,t,r){this.dispatchEvent=e,this.store=t,this.addressFilter=r??E9}consumePeerRecord(e){var t=this;return $(function*(){Bn.trace("consumePeerRecord await write lock");const r=yield t.store.lock.writeLock();let i,s,o;Bn.trace("consumePeerRecord got write lock");try{let a;try{a=iu.createFromProtobuf(e.payload)}catch{return Bn.error("invalid peer record received"),!1}i=a.peerId;const l=a.multiaddrs;if(!i.equals(e.peerId))return Bn("signing key does not match PeerId in the PeerRecord"),!1;if(null==l||0===l.length)return!1;if((yield t.store.has(i))&&(s=yield t.store.load(i),null!=s.peerRecordEnvelope)){const R=yield wi.createFromProtobuf(s.peerRecordEnvelope),N=iu.createFromProtobuf(R.payload);if(N.seqNumber>=a.seqNumber)return Bn("sequence number was lower or equal to existing sequence number - stored: %d received: %d",N.seqNumber,a.seqNumber),!1}const _=yield Wv(i,l,t.addressFilter,!0);o=yield t.store.patchOrCreate(i,{addresses:_,peerRecordEnvelope:e.marshal().subarray()}),Bn("stored provided peer record for %p",a.peerId)}finally{Bn.trace("consumePeerRecord release write lock"),r()}return t.dispatchEvent(new nn(Ah,{detail:{peerId:i,multiaddrs:o.addresses.map(({multiaddr:a})=>a),oldMultiaddrs:null==s?[]:s.addresses.map(({multiaddr:a})=>a)}})),!0})()}getRawEnvelope(e){var t=this;return $(function*(){Bn.trace("getRawEnvelope await read lock");const r=yield t.store.lock.readLock();Bn.trace("getRawEnvelope got read lock");try{return(yield t.store.load(e)).peerRecordEnvelope}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Bn.trace("getRawEnvelope release read lock"),r()}})()}getPeerRecord(e){var t=this;return $(function*(){const r=yield t.getRawEnvelope(e);if(null!=r)return yield wi.createFromProtobuf(r)})()}get(e){var t=this;return $(function*(){e=Br(e),Bn.trace("get wait for read lock");const r=yield t.store.lock.readLock();Bn.trace("get got read lock");try{return(yield t.store.load(e)).addresses}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Bn.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Bn.error("multiaddrs must be an array of Multiaddrs"),ae(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Bn.trace("set await write lock");const i=yield r.store.lock.writeLock();Bn.trace("set got write lock");let o,a,s=!1;try{const l=yield Wv(e,t,r.addressFilter);if(0===l.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...l.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length&&l.length===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.patchOrCreate(e,{addresses:l}),Bn("set multiaddrs for %p",e)}finally{Bn.trace("set multiaddrs for %p",e),Bn("set release write lock"),i()}r.dispatchEvent(new nn(Ah,{detail:{peerId:e,multiaddrs:a.addresses.map(l=>l.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:l})=>l)}})),s||r.dispatchEvent(new nn("peer",{detail:{id:e,multiaddrs:a.addresses.map(l=>l.multiaddr),protocols:a.protocols}}))})()}add(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Bn.error("multiaddrs must be an array of Multiaddrs"),ae(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Bn.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o,a;Bn.trace("add got write lock");try{const l=yield Wv(e,t,r.addressFilter);if(0===l.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...l.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.mergeOrCreate(e,{addresses:l}),Bn("added multiaddrs for %p",e)}finally{Bn.trace("set release write lock"),i()}r.dispatchEvent(new nn(Ah,{detail:{peerId:e,multiaddrs:a.addresses.map(l=>l.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:l})=>l)}})),!0===s&&r.dispatchEvent(new nn("peer",{detail:{id:e,multiaddrs:a.addresses.map(l=>l.multiaddr),protocols:a.protocols}}))})()}delete(e){var t=this;return $(function*(){e=Br(e),Bn.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Bn.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{addresses:[]})}finally{Bn.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new nn(Ah,{detail:{peerId:e,multiaddrs:[],oldMultiaddrs:null==i?[]:i.addresses.map(({multiaddr:s})=>s)}}))})()}}function Wv(n,e,t){return qv.apply(this,arguments)}function qv(){return qv=$(function*(n,e,t,r=!1){return yield qn(e,i=>Av(i,s=>{if(!mn.isMultiaddr(s))throw Bn.error("multiaddr must be an instance of Multiaddr"),ae(new Error("multiaddr must be an instance of Multiaddr"),"ERR_INVALID_PARAMETERS")}),i=>Ds(i,function(){var s=$(function*(o){return yield t(n,o)});return function(o){return s.apply(this,arguments)}}()),i=>cv(i,s=>({multiaddr:new mn(s.toString()),isCertified:r})),function(){var i=$(function*(s){return yield Fl(s)});return function(s){return i.apply(this,arguments)}}())}),qv.apply(this,arguments)}const Hs=zt("libp2p:peer-store:key-book"),GT="change:pubkey";class w9{constructor(e,t){this.dispatchEvent=e,this.store=t}set(e,t){var r=this;return $(function*(){if(e=Br(e),!(t instanceof Uint8Array))throw Hs.error("publicKey must be an instance of Uint8Array to store data"),ae(new Error("publicKey must be an instance of PublicKey"),"ERR_INVALID_PARAMETERS");Hs.trace("set await write lock");const i=yield r.store.lock.writeLock();Hs.trace("set got write lock");let o,s=!1;try{try{if(o=yield r.store.load(e),null!=o.pubKey&&kr(o.pubKey,t))return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}yield r.store.patchOrCreate(e,{pubKey:t}),s=!0}finally{Hs.trace("set release write lock"),i()}s&&r.dispatchEvent(new nn(GT,{detail:{peerId:e,publicKey:t,oldPublicKey:o?.pubKey}}))})()}get(e){var t=this;return $(function*(){e=Br(e),Hs.trace("get await write lock");const r=yield t.store.lock.readLock();Hs.trace("get got write lock");try{return(yield t.store.load(e)).pubKey}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Hs("get release write lock"),r()}})()}delete(e){var t=this;return $(function*(){e=Br(e),Hs.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Hs.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{pubKey:void 0})}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}finally{Hs.trace("delete release write lock"),r()}t.dispatchEvent(new nn(GT,{detail:{peerId:e,publicKey:void 0,oldPublicKey:i?.pubKey}}))})()}}const Cr=zt("libp2p:peer-store:metadata-book"),xh="change:metadata";class _9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return $(function*(){e=Br(e),Cr.trace("get await read lock");const r=yield t.store.lock.readLock();Cr.trace("get got read lock");try{return(yield t.store.load(e)).metadata}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Cr.trace("get release read lock"),r()}return new Map})()}getValue(e,t){var r=this;return $(function*(){e=Br(e),Cr.trace("getValue await read lock");const i=yield r.store.lock.readLock();Cr.trace("getValue got read lock");try{return(yield r.store.load(e)).metadata.get(t)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}finally{Cr.trace("getValue release write lock"),i()}})()}set(e,t){var r=this;return $(function*(){if(e=Br(e),!(t instanceof Map))throw Cr.error("valid metadata must be provided to store data"),ae(new Error("valid metadata must be provided"),"ERR_INVALID_PARAMETERS");Cr.trace("set await write lock");const i=yield r.store.lock.writeLock();let s;Cr.trace("set got write lock");try{try{s=yield r.store.load(e)}catch(o){if("ERR_NOT_FOUND"!==o.code)throw o}yield r.store.mergeOrCreate(e,{metadata:t})}finally{Cr.trace("set release write lock"),i()}r.dispatchEvent(new nn(xh,{detail:{peerId:e,metadata:t,oldMetadata:null==s?new Map:s.metadata}}))})()}setValue(e,t,r){var i=this;return $(function*(){if(e=Br(e),"string"!=typeof t||!(r instanceof Uint8Array))throw Cr.error("valid key and value must be provided to store data"),ae(new Error("valid key and value must be provided"),"ERR_INVALID_PARAMETERS");Cr.trace("setValue await write lock");const s=yield i.store.lock.writeLock();let o,a;Cr.trace("setValue got write lock");try{try{o=yield i.store.load(e);const l=o.metadata.get(t);if(null!=l&&kr(r,l))return}catch(l){if("ERR_NOT_FOUND"!==l.code)throw l}a=yield i.store.mergeOrCreate(e,{metadata:new Map([[t,r]])})}finally{Cr.trace("setValue release write lock"),s()}i.dispatchEvent(new nn(xh,{detail:{peerId:e,metadata:a.metadata,oldMetadata:null==o?new Map:o.metadata}}))})()}delete(e){var t=this;return $(function*(){e=Br(e),Cr.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Cr.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}null!=i&&(yield t.store.patch(e,{metadata:new Map}))}finally{Cr.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new nn(xh,{detail:{peerId:e,metadata:new Map,oldMetadata:i.metadata}}))})()}deleteValue(e,t){var r=this;return $(function*(){e=Br(e),Cr.trace("deleteValue await write lock");const i=yield r.store.lock.writeLock();let s,o;Cr.trace("deleteValue got write lock");try{o=yield r.store.load(e),s=o.metadata,s.delete(t),yield r.store.patch(e,{metadata:s})}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}finally{Cr.trace("deleteValue release write lock"),i()}null!=s&&r.dispatchEvent(new nn(xh,{detail:{peerId:e,metadata:s,oldMetadata:null==o?new Map:o.metadata}}))})()}}const Ir=zt("libp2p:peer-store:proto-book"),Rh="change:protocols";class D9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return $(function*(){Ir.trace("get wait for read lock");const r=yield t.store.lock.readLock();Ir.trace("get got read lock");try{return(yield t.store.load(e)).protocols}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Ir.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("set await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("set got write lock");try{try{if(s=yield r.store.load(e),new Set([...t]).size===s.protocols.length)return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.patchOrCreate(e,{protocols:t}),Ir("stored provided protocols for %p",e)}finally{Ir.trace("set release write lock"),i()}r.dispatchEvent(new nn(Rh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}add(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("add got write lock");try{try{if(s=yield r.store.load(e),new Set([...s.protocols,...t]).size===s.protocols.length)return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.mergeOrCreate(e,{protocols:t}),Ir("added provided protocols for %p",e)}finally{Ir.trace("add release write lock"),i()}r.dispatchEvent(new nn(Rh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}remove(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("remove await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("remove got write lock");try{try{s=yield r.store.load(e);const a=new Set(s.protocols);for(const l of t)a.delete(l);if(s.protocols.length===a.size)return;t=Array.from(a)}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.patchOrCreate(e,{protocols:t})}finally{Ir.trace("remove release write lock"),i()}r.dispatchEvent(new nn(Rh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}delete(e){var t=this;return $(function*(){e=Br(e),Ir.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Ir.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{protocols:[]})}finally{Ir.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new nn(Rh,{detail:{peerId:e,protocols:[],oldProtocols:i.protocols}}))})()}}var Ph,Nh,Mh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.addresses)throw new Error('Protocol error: required field "addresses" was not found in object');for(const s of t.addresses)r.uint32(10),Nh.codec().encode(s,r);if(null==t.protocols)throw new Error('Protocol error: required field "protocols" was not found in object');for(const s of t.protocols)r.uint32(18),r.string(s);if(null==t.metadata)throw new Error('Protocol error: required field "metadata" was not found in object');for(const s of t.metadata)r.uint32(26),Mh.codec().encode(s,r);null!=t.pubKey&&(r.uint32(34),r.bytes(t.pubKey)),null!=t.peerRecordEnvelope&&(r.uint32(42),r.bytes(t.peerRecordEnvelope)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={addresses:[],protocols:[],metadata:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.addresses.push(Nh.codec().decode(t,t.uint32()));break;case 2:i.protocols.push(t.string());break;case 3:i.metadata.push(Mh.codec().decode(t,t.uint32()));break;case 4:i.pubKey=t.bytes();break;case 5:i.peerRecordEnvelope=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Ph||(Ph={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');r.uint32(10),r.bytes(t.multiaddr),null!=t.isCertified&&(r.uint32(16),r.bool(t.isCertified)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={multiaddr:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.multiaddr=t.bytes();break;case 2:i.isCertified=t.bool();break;default:t.skipType(7&o)}}if(null==i.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Nh||(Nh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.key)throw new Error('Protocol error: required field "key" was not found in object');if(r.uint32(10),r.string(t.key),null==t.value)throw new Error('Protocol error: required field "value" was not found in object');r.uint32(18),r.bytes(t.value),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={key:"",value:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.key=t.string();break;case 2:i.value=t.bytes();break;default:t.skipType(7&o)}}if(null==i.key)throw new Error('Protocol error: value for required field "key" was not found in protobuf');if(null==i.value)throw new Error('Protocol error: value for required field "value" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Mh||(Mh={}));var S9=x(2005);class WT extends Error{constructor(e){super(e),this.name="TimeoutError"}}class C9 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const qT=n=>void 0===globalThis.DOMException?new C9(n):new DOMException(n),YT=n=>{const e=void 0===n.reason?qT("This operation was aborted."):n.reason;return e instanceof Error?e:qT(e)};function QT(n,e,t,r){let i;const s=new Promise((o,a)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:l}=r;l.aborted&&a(YT(l)),l.addEventListener("abort",()=>{a(YT(l))})}i=r.customTimers.setTimeout.call(void 0,()=>{if("function"==typeof t){try{o(t())}catch(R){a(R)}return}const _=t instanceof Error?t:new WT("string"==typeof t?t:`Promise timed out after ${e} milliseconds`);"function"==typeof n.cancel&&n.cancel(),a(_)},e),$(function*(){try{o(yield n)}catch(l){a(l)}finally{r.customTimers.clearTimeout.call(void 0,i)}})()}else o(n)});return s.clear=()=>{clearTimeout(i),i=void 0},s}var vo,Ma=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};class T9{constructor(){vo.set(this,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&Ma(this,vo,"f")[this.size-1].priority>=t.priority)return void Ma(this,vo,"f").push(r);const i=function I9(n,e,t){let r=0,i=n.length;for(;i>0;){const s=Math.trunc(i/2);let o=r+s;t(n[o],e)<=0?(r=++o,i-=s+1):i=s}return r}(Ma(this,vo,"f"),r,(s,o)=>o.priority-s.priority);Ma(this,vo,"f").splice(i,0,r)}dequeue(){return Ma(this,vo,"f").shift()?.run}filter(e){return Ma(this,vo,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Ma(this,vo,"f").length}}vo=new WeakMap;var hr,Yl,Ql,ea,Oh,Zl,kh,Ss,Xl,Oi,Lh,ki,Jl,ta,Bh,ZT,XT,JT,eA,tA,nA,Fh,Yv,Qv,Uh,Vh,ir=function(n,e,t,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?n!==e||!i:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(n,t):i?i.value=t:e.set(n,t),t},gt=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};const A9=new WT;class x9 extends Error{}class rA extends S9{constructor(e){var t,r,i,s;if(super(),hr.add(this),Yl.set(this,void 0),Ql.set(this,void 0),ea.set(this,0),Oh.set(this,void 0),Zl.set(this,void 0),kh.set(this,0),Ss.set(this,void 0),Xl.set(this,void 0),Oi.set(this,void 0),Lh.set(this,void 0),ki.set(this,0),Jl.set(this,void 0),ta.set(this,void 0),Bh.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:T9,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(s=null===(i=e.interval)||void 0===i?void 0:i.toString())&&void 0!==s?s:""}\` (${typeof e.interval})`);ir(this,Yl,e.carryoverConcurrencyCount,"f"),ir(this,Ql,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,"f"),ir(this,Oh,e.intervalCap,"f"),ir(this,Zl,e.interval,"f"),ir(this,Oi,new e.queueClass,"f"),ir(this,Lh,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,ir(this,Bh,!0===e.throwOnTimeout,"f"),ir(this,ta,!1===e.autoStart,"f")}get concurrency(){return gt(this,Jl,"f")}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);ir(this,Jl,e,"f"),gt(this,hr,"m",Uh).call(this)}add(e,t={}){var r=this;return $(function*(){return new Promise((i,s)=>{const o=function(){var a=$(function*(){var l,_,R;ir(r,ki,(_=gt(r,ki,"f"),++_),"f"),ir(r,ea,(R=gt(r,ea,"f"),++R),"f");try{if(null!==(l=t.signal)&&void 0!==l&&l.aborted)return void s(new x9("The task was aborted."));const B=yield void 0===r.timeout&&void 0===t.timeout?e({signal:t.signal}):QT(Promise.resolve(e({signal:t.signal})),void 0===t.timeout?r.timeout:t.timeout,()=>{(void 0===t.throwOnTimeout?gt(r,Bh,"f"):t.throwOnTimeout)&&s(A9)});i(B),r.emit("completed",B)}catch(N){s(N),r.emit("error",N)}gt(r,hr,"m",JT).call(r)});return function(){return a.apply(this,arguments)}}();gt(r,Oi,"f").enqueue(o,t),gt(r,hr,"m",Fh).call(r),r.emit("add")})})()}addAll(e,t){var r=this;return $(function*(){return Promise.all(e.map(function(){var i=$(function*(s){return r.add(s,t)});return function(s){return i.apply(this,arguments)}}()))})()}start(){return gt(this,ta,"f")?(ir(this,ta,!1,"f"),gt(this,hr,"m",Uh).call(this),this):this}pause(){ir(this,ta,!0,"f")}clear(){ir(this,Oi,new(gt(this,Lh,"f")),"f")}onEmpty(){var e=this;return $(function*(){0!==gt(e,Oi,"f").size&&(yield gt(e,hr,"m",Vh).call(e,"empty"))})()}onSizeLessThan(e){var t=this;return $(function*(){gt(t,Oi,"f").sizegt(t,Oi,"f").size{gt(this,hr,"m",tA).call(this)},t),"f"),!0;ir(this,ea,gt(this,Yl,"f")?gt(this,ki,"f"):0,"f")}return!1},Fh=function(){if(0===gt(this,Oi,"f").size)return gt(this,Ss,"f")&&clearInterval(gt(this,Ss,"f")),ir(this,Ss,void 0,"f"),gt(this,hr,"m",eA).call(this),!1;if(!gt(this,ta,"f")){const e=!gt(this,hr,"a",nA);if(gt(this,hr,"a",ZT)&>(this,hr,"a",XT)){const t=gt(this,Oi,"f").dequeue();return!!t&&(this.emit("active"),t(),e&>(this,hr,"m",Yv).call(this),!0)}}return!1},Yv=function(){gt(this,Ql,"f")||void 0!==gt(this,Ss,"f")||(ir(this,Ss,setInterval(()=>{gt(this,hr,"m",Qv).call(this)},gt(this,Zl,"f")),"f"),ir(this,kh,Date.now()+gt(this,Zl,"f"),"f"))},Qv=function(){0===gt(this,ea,"f")&&0===gt(this,ki,"f")&>(this,Ss,"f")&&(clearInterval(gt(this,Ss,"f")),ir(this,Ss,void 0,"f")),ir(this,ea,gt(this,Yl,"f")?gt(this,ki,"f"):0,"f"),gt(this,hr,"m",Uh).call(this)},Uh=function(){for(;gt(this,hr,"m",Fh).call(this););},Vh=function(){var n=$(function*(t,r){return new Promise(i=>{const s=()=>{r&&!r()||(this.off(t,s),i())};this.on(t,s)})});return function e(t,r){return n.apply(this,arguments)}}();class R9 extends Error{constructor(e){super(e),this.name="TimeoutError"}}class P9 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const iA=n=>void 0===globalThis.DOMException?new P9(n):new DOMException(n),sA=n=>{const e=void 0===n.reason?iA("This operation was aborted."):n.reason;return e instanceof Error?e:iA(e)};function N9(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((l,_)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if(e.signal){const{signal:R}=e;R.aborted&&_(sA(R)),R.addEventListener("abort",()=>{_(sA(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{l(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new R9("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),$(function*(){try{l(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else l(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}const oA="lock:worker:request-read",aA="lock:worker:release-read",cA="lock:master:grant-read",uA="lock:worker:request-write",lA="lock:worker:release-write",fA="lock:master:grant-write",na={},su=n=>{n.addEventListener("message",e=>{su.dispatchEvent("message",n,e)}),null!=n.port&&n.port.addEventListener("message",e=>{su.dispatchEvent("message",n,e)})};su.addEventListener=(n,e)=>{null==na[n]&&(na[n]=[]),na[n].push(e)},su.removeEventListener=(n,e)=>{null!=na[n]&&(na[n]=na[n].filter(t=>t===e))},su.dispatchEvent=function(n,e,t){null!=na[n]&&na[n].forEach(r=>r(e,t))};const dA=su,hA=(n,e,t,r,i)=>(s,o)=>{if(o.data.type!==t)return;const a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};var l;n.dispatchEvent(new MessageEvent(e,{data:{name:a.name,handler:(l=$(function*(){return s.postMessage({type:i,name:a.name,identifier:a.identifier}),yield new Promise(_=>{const R=N=>{null!=N&&null!=N.data&&N.data.type===r&&N.data.identifier===a.identifier&&(s.removeEventListener("message",R),_())};s.addEventListener("message",R)})}),function(){return l.apply(this,arguments)})}}))},pA=(n,e,t,r)=>$(function*(){const i=((n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""))();return globalThis.postMessage({type:e,identifier:i,name:n}),yield new Promise(s=>{const o=a=>{null!=a&&null!=a.data&&a.data.type===t&&a.data.identifier===i&&(globalThis.removeEventListener("message",o),s(()=>{globalThis.postMessage({type:r,identifier:i,name:n})}))};globalThis.addEventListener("message",o)})}),L9={singleProcess:!1},Oa={};let ra;function Zv(n,e){return Xv.apply(this,arguments)}function Xv(){return Xv=$(function*(n,e){let t;const r=new Promise(i=>{t=i});return n.add($(function*(){return yield N9($(function*(){return yield new Promise(i=>{t(()=>{i()})})})(),{milliseconds:e.timeout})})),yield r}),Xv.apply(this,arguments)}const U9={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};const gA=zt("libp2p:peer-store:store"),yA="/peers/";class H9{constructor(){this.components=new ho,this.lock=function V9(n){const e=Object.assign({},U9,n);return null==ra&&(ra=(n=>{if(n=Object.assign({},L9,n),Boolean(globalThis.document)||n.singleProcess){const t=new EventTarget;return dA.addEventListener("message",hA(t,"requestReadLock",oA,aA,cA)),dA.addEventListener("message",hA(t,"requestWriteLock",uA,lA,fA)),t}return{isWorker:!0,readLock:t=>pA(t,oA,cA,aA),writeLock:t=>pA(t,uA,fA,lA)}})(e),!0!==ra.isWorker&&(ra.addEventListener("requestReadLock",t=>{null!=Oa[t.data.name]&&Oa[t.data.name].readLock().then(function(){var r=$(function*(i){return yield t.data.handler().finally(()=>i())});return function(i){return r.apply(this,arguments)}}())}),ra.addEventListener("requestWriteLock",function(){var t=$(function*(r){null!=Oa[r.data.name]&&Oa[r.data.name].writeLock().then(function(){var i=$(function*(s){return yield r.data.handler().finally(()=>s())});return function(s){return i.apply(this,arguments)}}())});return function(r){return t.apply(this,arguments)}}()))),null==Oa[e.name]&&(Oa[e.name]=((n,e)=>{if(!0===ra.isWorker)return{readLock:ra.readLock(n,e),writeLock:ra.writeLock(n,e)};const t=new rA({concurrency:1});let r;return{readLock:()=>$(function*(){if(null!=r)return yield Zv(r,e);r=new rA({concurrency:e.concurrency,autoStart:!1});const i=r,s=Zv(r,e);return t.add($(function*(){return i.start(),yield i.onIdle().then(()=>{r===i&&(r=null)})})),yield s})(),writeLock:()=>$(function*(){return r=null,yield Zv(t,e)})()}})(e.name,e)),Oa[e.name]}({name:"peer-store",singleProcess:!0})}init(e){this.components=e}_peerIdToDatastoreKey(e){if(null==e.type)throw gA.error("peerId must be an instance of peer-id to store data"),ae(new Error("peerId must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");const t=e.toCID().toString();return new Ur(`${yA}${t}`)}has(e){var t=this;return $(function*(){return yield t.components.getDatastore().has(t._peerIdToDatastoreKey(e))})()}delete(e){var t=this;return $(function*(){yield t.components.getDatastore().delete(t._peerIdToDatastoreKey(e))})()}load(e){var t=this;return $(function*(){const r=yield t.components.getDatastore().get(t._peerIdToDatastoreKey(e)),i=Ph.decode(r),s=new Map;for(const o of i.metadata)s.set(o.key,o.value);return{...i,id:e,addresses:i.addresses.map(({multiaddr:o,isCertified:a})=>({multiaddr:new mn(o),isCertified:a??!1})),metadata:s,pubKey:i.pubKey??void 0,peerRecordEnvelope:i.peerRecordEnvelope??void 0}})()}save(e){var t=this;return $(function*(){if(null!=e.pubKey&&null!=e.id.publicKey&&!kr(e.pubKey,e.id.publicKey))throw gA.error("peer publicKey bytes do not match peer id publicKey bytes"),ae(new Error("publicKey bytes do not match peer id publicKey bytes"),"ERR_INVALID_PARAMETERS");const r=new Set,i=e.addresses.filter(a=>!r.has(a.multiaddr.toString())&&(r.add(a.multiaddr.toString()),!0)).sort((a,l)=>a.multiaddr.toString().localeCompare(l.multiaddr.toString())).map(({multiaddr:a,isCertified:l})=>({multiaddr:a.bytes,isCertified:l})),s=[];[...e.metadata.keys()].sort().forEach(a=>{const l=e.metadata.get(a);null!=l&&s.push({key:a,value:l})});const o=Ph.encode({addresses:i,protocols:e.protocols.sort(),pubKey:e.pubKey,metadata:s,peerRecordEnvelope:e.peerRecordEnvelope});return yield t.components.getDatastore().put(t._peerIdToDatastoreKey(e.id),o.subarray()),yield t.load(e.id)})()}patch(e,t){var r=this;return $(function*(){const i=yield r.load(e);return yield r._patch(e,t,i)})()}patchOrCreate(e,t){var r=this;return $(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._patch(e,t,i)})()}_patch(e,t,r){var i=this;return $(function*(){return yield i.save({...r,...t,id:e})})()}merge(e,t){var r=this;return $(function*(){const i=yield r.load(e);return yield r._merge(e,t,i)})()}mergeOrCreate(e,t){var r=this;return $(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._merge(e,t,i)})()}_merge(e,t,r){var i=this;return $(function*(){const s=new Map;return r.addresses.forEach(o=>{s.set(o.multiaddr.toString(),o.isCertified)}),(t.addresses??[]).forEach(o=>{const a=o.multiaddr.toString(),_=Boolean(s.get(a))||o.isCertified;s.set(a,_)}),yield i.save({id:e,addresses:Array.from(s.entries()).map(([o,a])=>({multiaddr:new mn(o),isCertified:a})),protocols:Array.from(new Set([...r.protocols??[],...t.protocols??[]])),metadata:new Map([...r.metadata?.entries()??[],...t.metadata?.entries()??[]]),pubKey:t.pubKey??r?.pubKey,peerRecordEnvelope:t.peerRecordEnvelope??r?.peerRecordEnvelope})})()}all(){var e=this;return hn(function*(){var i,t=!1,r=!1;try{for(var o,s=Pt(e.components.getDatastore().queryKeys({prefix:yA}));t=!(o=yield lt(s.next())).done;t=!1){const l=o.value.toString().split("/")[2],_=co.decode(l);yield e.load(Jc(_))}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield lt(s.return()))}finally{if(r)throw i}}})()}}var ia,Hh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.tags)throw new Error('Protocol error: required field "tags" was not found in object');for(const s of t.tags)r.uint32(10),Hh.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={tags:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.tags.push(Hh.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ia||(ia={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.name)throw new Error('Protocol error: required field "name" was not found in object');r.uint32(10),r.string(t.name),null!=t.value&&(r.uint32(16),r.uint32(t.value)),null!=t.expiry&&(r.uint32(24),r.uint64(t.expiry)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={name:""},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.name=t.string();break;case 2:i.value=t.uint32();break;case 3:i.expiry=t.uint64();break;default:t.skipType(7&o)}}if(null==i.name)throw new Error('Protocol error: value for required field "name" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Hh||(Hh={}));const Zi=zt("libp2p:peer-store");class K9 extends Ei{constructor(e={}){super(),this.components=new ho,this.store=new H9,this.addressBook=new b9(this.dispatchEvent.bind(this),this.store,e.addressFilter),this.keyBook=new w9(this.dispatchEvent.bind(this),this.store),this.metadataBook=new _9(this.dispatchEvent.bind(this),this.store),this.protoBook=new D9(this.dispatchEvent.bind(this),this.store)}init(e){this.components=e,this.store.init(e)}forEach(e){var t=this;return $(function*(){Zi.trace("getPeers await read lock");const r=yield t.store.lock.readLock();Zi.trace("getPeers got read lock");try{var o,i=!1,s=!1;try{for(var l,a=Pt(t.store.all());i=!(l=yield a.next()).done;i=!1){const _=l.value;_.id.equals(t.components.getPeerId())||e(_)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}}finally{Zi.trace("getPeers release read lock"),r()}})()}all(){var e=this;return $(function*(){const t=[];return yield e.forEach(r=>{t.push(r)}),t})()}delete(e){var t=this;return $(function*(){Zi.trace("delete await write lock");const r=yield t.store.lock.writeLock();Zi.trace("delete got write lock");try{yield t.store.delete(e)}finally{Zi.trace("delete release write lock"),r()}})()}get(e){var t=this;return $(function*(){Zi.trace("get await read lock");const r=yield t.store.lock.readLock();Zi.trace("get got read lock");try{return yield t.store.load(e)}finally{Zi.trace("get release read lock"),r()}})()}has(e){var t=this;return $(function*(){Zi.trace("has await read lock");const r=yield t.store.lock.readLock();Zi.trace("has got read lock");try{return yield t.store.has(e)}finally{Zi.trace("has release read lock"),r()}})()}tagPeer(e,t,r={}){var i=this;return $(function*(){const s=r.value??0,o=Math.round(s),a=r.ttl??void 0;if(o!==s||o<0||o>100)throw ae(new Error("Tag value must be between 0-100"),"ERR_TAG_VALUE_OUT_OF_BOUNDS");const l=yield i.metadataBook.getValue(e,"tags");let _=[];null!=l&&(_=ia.decode(l).tags);for(const R of _)if(R.name===t)throw ae(new Error("Peer already tagged"),"ERR_DUPLICATE_TAG");_.push({name:t,value:o,expiry:null==a?void 0:BigInt(Date.now()+a)}),yield i.metadataBook.setValue(e,"tags",ia.encode({tags:_}).subarray())})()}unTagPeer(e,t){var r=this;return $(function*(){const i=yield r.metadataBook.getValue(e,"tags");let s=[];null!=i&&(s=ia.decode(i).tags),s=s.filter(o=>o.name!==t),yield r.metadataBook.setValue(e,"tags",ia.encode({tags:s}).subarray())})()}getTags(e){var t=this;return $(function*(){const r=yield t.metadataBook.getValue(e,"tags");let i=[];null!=r&&(i=ia.decode(r).tags);const s=BigInt(Date.now()),o=i.filter(a=>null==a.expiry||a.expiry>s);return o.length!==i.length&&(yield t.metadataBook.setValue(e,"tags",ia.encode({tags:o}).subarray())),o.map(a=>({name:a.name,value:a.value??0}))})()}}class $9{constructor(e){this.dht=e}provide(e){var t=this;return $(function*(){yield Qo(t.dht.provide(e))})()}findProviders(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var l,a=Pt(r.dht.findProviders(e,t));i=!(l=yield lt(a.next())).done;i=!1){const _=l.value;"PROVIDER"===_.name&&(yield*Mr(Pt(_.providers),lt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}put(e,t,r){var i=this;return $(function*(){yield Qo(i.dht.put(e,t,r))})()}get(e,t){var r=this;return $(function*(){var o,i=!1,s=!1;try{for(var l,a=Pt(r.dht.get(e,t));i=!(l=yield a.next()).done;i=!1){const _=l.value;if("VALUE"===_.name)return _.value}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw ae(new Error("Not found"),"ERR_NOT_FOUND")})()}}const mA=zt("libp2p:dialer:auto-dialer");class j9{constructor(e,t){this.components=e,this.enabled=t.enabled,this.minConnections=t.minConnections,this.dialTimeout=t.dialTimeout}handle(e){const{detail:t}=e;if(this.enabled&&0===this.components.getConnectionManager().getConnections(t.id).length&&(this.minConnections??0)>this.components.getConnectionManager().getConnections().length){mA("auto-dialing discovered peer %p with timeout %d",t.id,this.dialTimeout);const o=new bi.TimeoutController(this.dialTimeout);try{(0,Vr.setMaxListeners)?.(1/0,o.signal)}catch{}this.components.getConnectionManager().openConnection(t.id,{signal:o.signal}).catch(a=>{mA.error("could not connect to discovered peer %p with %o",t.id,a)}).finally(()=>{o.clear()})}}}var vA=x(4033);const z9=globalThis.fetch,G9=globalThis.Headers;function Jv(n,e,t){return`${n}?name=${e}&type=${t}`}function W9(n,e){return eE.apply(this,arguments)}function eE(){return eE=$(function*(n,e){return yield(yield z9(n,{headers:new G9({accept:"application/dns-json"}),signal:e})).json()}),eE.apply(this,arguments)}function ou(n,e){return`${e}_${n}`}globalThis,globalThis;const tE=Object.assign(_r("dns-over-http-resolver"),{error:_r("dns-over-http-resolver:error")}),Y9=class q9{constructor(e={}){this._cache=new vA({max:e?.maxCache??100}),this._TXTcache=new vA({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??W9,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>e.abort())}getServers(){return this._servers}_getShuffledServers(){const e=[...this._servers];for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),i=e[t];e[t]=e[r],e[r]=i}return e}setServers(e){this._servers=e}resolve(e,t="A"){var r=this;return $(function*(){switch(t){case"A":return yield r.resolve4(e);case"AAAA":return yield r.resolve6(e);case"TXT":return yield r.resolveTxt(e);default:throw new Error(`${t} is not supported`)}})()}resolve4(e){var t=this;return $(function*(){const i=t._cache.get(ou(e,"A"));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const l=yield t._request(Jv(o,e,"A"),a.signal),_=l.Answer.map(N=>N.data),R=Math.min(...l.Answer.map(N=>N.TTL));return t._cache.set(ou(e,"A"),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),tE.error(`${o} could not resolve ${e} record A`)}finally{t._abortControllers=t._abortControllers.filter(l=>l!==a)}}throw s?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record A`)})()}resolve6(e){var t=this;return $(function*(){const r="AAAA",i=t._cache.get(ou(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const l=yield t._request(Jv(o,e,r),a.signal),_=l.Answer.map(N=>N.data),R=Math.min(...l.Answer.map(N=>N.TTL));return t._cache.set(ou(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),tE.error(`${o} could not resolve ${e} record AAAA`)}finally{t._abortControllers=t._abortControllers.filter(l=>l!==a)}}throw s?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record AAAA`)})()}resolveTxt(e){var t=this;return $(function*(){const r="TXT",i=t._TXTcache.get(ou(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const l=yield t._request(Jv(o,e,r),a.signal),_=l.Answer.map(N=>[N.data.replace(/['"]+/g,"")]),R=Math.min(...l.Answer.map(N=>N.TTL));return t._TXTcache.set(ou(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),tE.error(`${o} could not resolve ${e} record TXT`)}finally{t._abortControllers=t._abortControllers.filter(l=>l!==a)}}throw s?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record TXT`)})()}clearCache(){this._cache.clear(),this._TXTcache.clear()}},{code:Q9}=Sr("dnsaddr");function nE(){return nE=$(function*(n,e={}){const t=new Y9;null!=e.signal&&e.signal.addEventListener("abort",()=>{t.cancel()});const r=n.getPeerId(),[,i]=n.stringTuples().find(([a])=>a===Q9)??[];if(null==i)throw new Error("No hostname found in multiaddr");let o=(yield t.resolveTxt(`_dnsaddr.${i}`)).flat().map(a=>a.split("=")[1]);return null!=r&&(o=o.filter(a=>a.includes(r))),o}),nE.apply(this,arguments)}const X9={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:n=>n},connectionManager:{maxConnections:300,minConnections:50,autoDial:!0,autoDialInterval:1e4,maxParallelDials:100,maxDialsPerPeer:4,dialTimeout:3e4,inboundUpgradeTimeout:3e4,resolvers:{dnsaddr:function Z9(n){return nE.apply(this,arguments)}},addressSorter:hv},connectionGater:{},transportManager:{faultTolerance:Pa.FATAL_ALL},metrics:{enabled:!1,computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},nat:{enabled:!0,ttl:7200,keepAlive:!0},relay:{enabled:!0,advertise:{bootDelay:9e5,enabled:!1,ttl:18e5},hop:{enabled:!1,active:!1,timeout:3e4},autoRelay:{enabled:!1,maxListeners:2}},identify:{protocolPrefix:"ipfs",host:{agentVersion:KT},timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1},ping:{protocolPrefix:"ipfs",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4},fetch:{protocolPrefix:"libp2p",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4}};function J9(n){const e=Vl(X9,n);if(null==e.transports||e.transports.length<1)throw ae(new Error(Dn.ERR_TRANSPORTS_REQUIRED),Ce.ERR_TRANSPORTS_REQUIRED);if(null==e.connectionEncryption||0===e.connectionEncryption.length)throw ae(new Error(Dn.CONN_ENCRYPTION_REQUIRED),Ce.CONN_ENCRYPTION_REQUIRED);if(null===e.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw ae(new Error(Dn.ERR_PROTECTOR_REQUIRED),Ce.ERR_PROTECTOR_REQUIRED);return e.identify.host.agentVersion===KT&&(iV||nV?e.identify.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(mh||K2||rV||sV)&&(e.identify.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`)),e}var EA;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.id)throw new Error('Protocol error: required field "id" was not found in object');r.uint32(10),r.bytes(t.id),null!=t.pubKey&&(r.uint32(18),r.bytes(t.pubKey)),null!=t.privKey&&(r.uint32(26),r.bytes(t.privKey)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={id:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.id=t.bytes();break;case 2:i.pubKey=t.bytes();break;case 3:i.privKey=t.bytes();break;default:t.skipType(7&o)}}if(null==i.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(EA||(EA={}));const eH=function(){var n=$(function*(){const e=yield e2("Ed25519"),t=yield function bA(n){return iE.apply(this,arguments)}(e);if("Ed25519"===t.type)return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)});return function(){return n.apply(this,arguments)}}();function iE(){return iE=$(function*(n){return yield Ol(t2(n.public),T5(n))}),iE.apply(this,arguments)}const cE=Symbol.for("@libp2p/peer-discovery");class nH extends Ei{get[cE](){return!0}get[Symbol.toStringTag](){return"@libp2p/dummy-dht"}get wan(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}get lan(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}get(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}findProviders(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}findPeer(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}getClosestPeers(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}provide(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}put(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}getMode(){return $(function*(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)})()}setMode(){return $(function*(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)})()}refreshRoutingTable(){return $(function*(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)})()}}class rH extends Ei{isStarted(){return!1}start(){}stop(){}get globalSignaturePolicy(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}get multicodecs(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getPeers(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getTopics(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}subscribe(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}unsubscribe(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getSubscribers(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}publish(){return $(function*(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)})()}}const Eo=zt("libp2p");class iH extends Ei{constructor(e){var o;super(),this.initializables=[],this.started=!1,this.peerId=e.peerId,this.components=new ho({peerId:e.peerId,datastore:e.datastore??new RV,connectionGater:{denyDialPeer:(o=$(function*(){return yield Promise.resolve(!1)}),function(){return o.apply(this,arguments)}),denyDialMultiaddr:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundEncryptedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundEncryptedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundUpgradedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundUpgradedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),filterMultiaddrForPeer:function(){var o=$(function*(){return yield Promise.resolve(!0)});return function(){return o.apply(this,arguments)}}(),...e.connectionGater}}),this.components.setPeerStore(new K9({addressFilter:this.components.getConnectionGater().filterMultiaddrForPeer,...e.peerStore})),this.services=[this.components],e.metrics.enabled&&(this.metrics=this.components.setMetrics(new A7(e.metrics))),this.peerStore=this.components.getPeerStore(),this.peerStore.addEventListener("peer",o=>{const{detail:a}=o;this.dispatchEvent(new nn("peer:discovery",{detail:a}))}),null!=e.connectionProtector&&this.components.setConnectionProtector(e.connectionProtector),this.components.setUpgrader(new j7(this.components,{connectionEncryption:(e.connectionEncryption??[]).map(o=>this.configureComponent(o)),muxers:(e.streamMuxers??[]).map(o=>this.configureComponent(o)),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout})),this.connectionManager=this.components.setConnectionManager(new JV(e.connectionManager)),this.registrar=this.components.setRegistrar(new H7(this.components)),this.components.setTransportManager(new O7(this.components,e.transportManager)),this.components.setAddressManager(new kV(this.components,e.addresses)),this.configureComponent(new m9(this.components)),this.configureComponent(new t7(this.components,{enabled:e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,autoDialInterval:e.connectionManager.autoDialInterval}));const t=PT.generateOptions();this.keychain=this.configureComponent(new PT(this.components,{...t,...e.keychain})),this.services.push(new g9(this.components,e.nat)),e.transports.forEach(o=>{this.components.getTransportManager().add(this.configureComponent(o))}),null!=e.streamMuxers&&e.streamMuxers.length>0&&(this.identifyService=new Hv(this.components,{...e.identify}),this.configureComponent(this.identifyService)),this.dht=null!=e.dht?this.components.setDHT(e.dht):new nH,this.pubsub=null!=e.pubsub?this.components.setPubSub(e.pubsub):new rH;const r=(e.peerRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&(r.push(this.configureComponent(new v9(this.dht))),this.dht.addEventListener("peer",o=>{this.onDiscoveryPeer(o)})),this.peerRouting=this.components.setPeerRouting(this.configureComponent(new PV(this.components,{...e.peerRouting,routers:r})));const i=(e.contentRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&i.push(this.configureComponent(new $9(this.dht))),this.contentRouting=this.components.setContentRouting(this.configureComponent(new NV(this.components,{routers:i}))),e.relay.enabled&&(this.components.getTransportManager().add(this.configureComponent(new l7(e.relay))),this.configureComponent(new y7(this.components,{addressSorter:e.connectionManager.addressSorter,...e.relay}))),this.fetchService=this.configureComponent(new o9(this.components,{...e.fetch})),this.pingService=this.configureComponent(new l9(this.components,{...e.ping}));const s=this.configureComponent(new j9(this.components,{enabled:!1!==e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,dialTimeout:e.connectionManager.dialTimeout??3e4}));this.addEventListener("peer:discovery",o=>{!this.isStarted()||s.handle(o)});for(const o of e.peerDiscovery??[])this.configureComponent(o),o.addEventListener("peer",a=>{this.onDiscoveryPeer(a)})}configureComponent(e){return fo(e)&&this.services.push(e),Fr(e)&&this.initializables.push(e),e}start(){var e=this;return $(function*(){if(!e.started){e.started=!0,Eo("libp2p is starting");try{e.initializables.forEach(t=>{t.init(e.components)}),yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.start())),yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has started")}catch(t){throw Eo.error("An error occurred starting libp2p",t),yield e.stop(),t}}})()}stop(){var e=this;return $(function*(){!e.started||(Eo("libp2p is stopping"),e.started=!1,yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.stop())),yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has stopped"))})()}loadKeychain(){var e=this;return $(function*(){if(null!=e.keychain)try{yield e.keychain.findKeyByName("self")}catch{yield e.keychain.importPeer("self",e.peerId)}})()}isStarted(){return this.started}getConnections(e){return this.components.getConnectionManager().getConnections(e)}getPeers(){const e=new YV;for(const t of this.components.getConnectionManager().getConnections())e.add(t.remotePeer);return Array.from(e)}dial(e,t={}){var r=this;return $(function*(){const{id:i,multiaddrs:s}=Ul(e);return yield r.components.getPeerStore().addressBook.add(i,s),yield r.components.getConnectionManager().openConnection(i,t)})()}dialProtocol(e,t,r={}){var i=this;return $(function*(){if(null==t)throw ae(new Error("no protocols were provided to open a stream"),Ce.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw ae(new Error("no protocols were provided to open a stream"),Ce.ERR_INVALID_PROTOCOLS_FOR_STREAM);return yield(yield i.dial(e,r)).newStream(t,r)})()}getMultiaddrs(){return this.components.getAddressManager().getAddresses()}hangUp(e){var t=this;return $(function*(){const{id:r}=Ul(e);yield t.components.getConnectionManager().closeConnections(r)})()}getPublicKey(e,t={}){var r=this;return $(function*(){if(Eo("getPublicKey %p",e),null!=e.publicKey)return e.publicKey;const i=yield r.peerStore.get(e);if(null!=i.pubKey)return i.pubKey;if(null==r.dht)throw ae(new Error("Public key was not in the peer store and the DHT is not enabled"),Ce.ERR_NO_ROUTERS_AVAILABLE);const s=br([Ot("/pk/"),e.multihash.digest]);var l,o=!1,a=!1;try{for(var R,_=Pt(r.dht.get(s,t));o=!(R=yield _.next()).done;o=!1){const N=R.value;if("VALUE"===N.name){const B=xl(N.value);return yield r.peerStore.keyBook.set(e,N.value),B.bytes}}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw l}}throw ae(new Error(`Node not responding with its public key: ${e.toString()}`),Ce.ERR_INVALID_RECORD)})()}fetch(e,t,r={}){var i=this;return $(function*(){const{id:s,multiaddrs:o}=Ul(e);return null!=o&&(yield i.components.getPeerStore().addressBook.add(s,o)),yield i.fetchService.fetch(s,t,r)})()}ping(e,t={}){var r=this;return $(function*(){const{id:i,multiaddrs:s}=Ul(e);return s.length>0&&(yield r.components.getPeerStore().addressBook.add(i,s)),yield r.pingService.ping(i,t)})()}handle(e,t,r){var i=this;return $(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var s=$(function*(o){yield i.components.getRegistrar().handle(o,t,r)});return function(o){return s.apply(this,arguments)}}()))})()}unhandle(e){var t=this;return $(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var r=$(function*(i){yield t.components.getRegistrar().unhandle(i)});return function(i){return r.apply(this,arguments)}}()))})()}onDiscoveryPeer(e){const{detail:t}=e;t.id.toString()!==this.peerId.toString()?(t.multiaddrs.length>0&&this.components.getPeerStore().addressBook.add(t.id,t.multiaddrs).catch(r=>Eo.error(r)),t.protocols.length>0&&this.components.getPeerStore().protoBook.set(t.id,t.protocols).catch(r=>Eo.error(r)),this.dispatchEvent(new nn("peer:discovery",{detail:t}))):Eo.error(new Error(Ce.ERR_DISCOVERED_SELF))}}function sH(n){return uE.apply(this,arguments)}function uE(){return uE=$(function*(n){return null==n.peerId&&(n.peerId=yield eH()),new iH(J9(n))}),uE.apply(this,arguments)}function oH(n){return lE.apply(this,arguments)}function lE(){return lE=$(function*(n){return yield sH(n)}),lE.apply(this,arguments)}function _A(n,e){return n.length<=e||n.length<=1?n:function cH(n){if(n.length<=1)return n;for(let t=0;t{class n extends Ei{constructor(t,r){super(),this.interval=r?.interval??n.DefaultInterval;const i=r?.maxPeers??t?.length,s=t.map(o=>"string"==typeof o?new mn(o):o);this.peers=function aH(n){return n.map(e=>{const t=e.getPeerId();return{id:t?fr(t):null,multiaddrs:[e.decapsulateCode(421)],protocols:[]}}).filter(e=>null!==e.id)}(_A(s,i)),DA("Use provided list of peers (reduced to maxPeers)",this.peers.map(o=>o.toString()))}start(){this._startTimer()}_startTimer(){if(this.peers){if(DA("Starting to emit static peers."),null!=this.timer)return;this.timer=setInterval(()=>this._returnPeers(),this.interval),this._returnPeers()}}_returnPeers(){null!=this.timer&&this.peers.forEach(t=>{this.dispatchEvent(new nn("peer",{detail:t}))})}stop(){null!=this.timer&&clearInterval(this.timer),this.timer=void 0}get[cE](){return!0}get[Symbol.toStringTag](){return"@waku/peer-discovery-static-list"}}return n.DefaultInterval=200,n})();var au=(()=>(function(n){n.Prod="prod",n.Test="test"}(au||(au={})),au))();const fE_fleets={"wakuv2.prod":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.prod":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD","node-01.do-ams3.wakuv2.prod":"/dns4/node-01.do-ams3.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmL5okWopX7NqZWBUKVqW8iUxCEmd5GMHLVPwCgzYzQv3e","node-01.gc-us-central1-a.wakuv2.prod":"/dns4/node-01.gc-us-central1-a.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA"}},"wakuv2.test":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.test":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm","node-01.do-ams3.wakuv2.test":"/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ","node-01.gc-us-central1-a.wakuv2.test":"/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS"}}};function cu(n){return"string"==typeof n?Ot(n.replace(/^0x/i,"").toLowerCase(),"base16"):n}function Cs(n,e){const t=e??n.reduce((s,o)=>s+o.length,0),r=new Uint8Array(t);let i=0;for(const s of n)r.set(s,i),i+=s.length;return r}var Kh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Kh||(Kh={}));var pH=x(6577),gH=x(4237);const uu_algorithm={name:"AES-GCM",length:128},$h={node:pH,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0};function Xi(){if($h.web)return $h.web.subtle;if($h.node)return $h.node.webcrypto.subtle;throw new Error("The environment doesn't have Crypto Subtle API (if in the browser, be sure to use to be in a secure context, ie, https)")}const lu=Yr.randomBytes,dE=Yr.sha256;function yH(n,e){return hE.apply(this,arguments)}function hE(){return hE=$(function*(n,e){const[t,r]=yield xI(n,e,{recovered:!0,der:!1});return Cs([t,new Uint8Array([r])],t.length+1)}),hE.apply(this,arguments)}function pE(n){return new Uint8Array(gH.keccak256.arrayBuffer(n))}function SA(n,e){let t=1,r=0,i=Promise.resolve(new Uint8Array);for(;r>24,t>>16,t>>8,t]),o=Cs([s,n],s.length+n.length),a=dE(o);i=i.then(l=>a.then(_=>{const R=new Uint8Array(_);return Cs([l,R],l.length+R.length)})),r+=32,t+=1}return i}function mH(n,e,t){return Xi().importKey("raw",e,"AES-CTR",!1,["encrypt"]).then(r=>Xi().encrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function vH(n,e,t){return Xi().importKey("raw",e,"AES-CTR",!1,["decrypt"]).then(r=>Xi().decrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function EH(n,e){const t={name:"HMAC",hash:{name:"SHA-256"}};return Xi().importKey("raw",n,t,!1,["sign"]).then(r=>Xi().sign(t,r,e)).then(r=>new Uint8Array(r))}function bH(n,e,t){const r={name:"HMAC",hash:{name:"SHA-256"}};return Xi().importKey("raw",n,r,!1,["verify"]).then(s=>Xi().verify(r,s,t,e))}function CA(n,e){if(32!==n.length)throw new Error(`Bad private key, it should be 32 bytes but it's actually ${n.length} bytes long`);if(65!==e.length)throw new Error(`Bad public key, it should be 65 bytes but it's actually ${e.length} bytes long`);if(4!==e[0])throw new Error("Bad public key, a valid public key would begin with 4");{const t=function _F(n,e,t=!1){if(SI(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!SI(e))throw new TypeError("getSharedSecret: second arg must be public key");const r=F0(e);return r.assertValidity(),r.multiply(_a(n)).toRawBytes(t)}(n,e,!0);return new Uint8Array(cu(t).slice(1))}}function wH(n,e){return gE.apply(this,arguments)}function gE(){return gE=$(function*(n,e){const t=lu(32),r=yield CA(t,n),i=yield SA(r,32),s=lu(16),o=i.slice(0,16),a=yield mH(s,o,e),l=Cs([s,a],s.length+a.length),_=yield dE(i.slice(16)),R=yield EH(_,l),N=_l(t,!1);return Cs([N,l,R],N.length+l.length+R.length)}),gE.apply(this,arguments)}function _H(n,e){return mE.apply(this,arguments)}function mE(){return mE=$(function*(n,e){if(e.length<=113)throw new Error("Invalid Ciphertext. Data is too small. It should ba at least 113 bytes");if(4!==e[0])throw new Error(`Not a valid ciphertext. It should begin with 4 but actually begin with ${e[0]}`);{const t=e.slice(0,65),r=e.length-113,i=e.slice(65,81),s=e.slice(65,81+r),o=s.slice(16),a=e.slice(81+r),l=CA(n,t),_=yield SA(l,32),[R,N]=yield dE(_.slice(16)).then(B=>[_.slice(0,16),B]);if(!(yield bH(N,s,a)))throw new Error("Incorrect MAC");return vH(i,R,o)}}),mE.apply(this,arguments)}function DH(n,e,t){return vE.apply(this,arguments)}function vE(){return vE=$(function*(n,e,t){return Xi().importKey("raw",e,uu_algorithm,!1,["encrypt"]).then(r=>Xi().encrypt({iv:n,...uu_algorithm},r,t)).then(r=>new Uint8Array(r))}),vE.apply(this,arguments)}function SH(n,e,t){return EE.apply(this,arguments)}function EE(){return EE=$(function*(n,e,t){return Xi().importKey("raw",e,uu_algorithm,!1,["decrypt"]).then(r=>Xi().decrypt({iv:n,...uu_algorithm},r,t)).then(r=>new Uint8Array(r))}),EE.apply(this,arguments)}function CH(){return lu(12)}function TA(n,e){return _E.apply(this,arguments)}function _E(){return _E=$(function*(n,e){let t=new Uint8Array([0]);t=OH(t,n),t=Cs([t,n]);let r=1+RA(n)+n.length;e&&(r+=65);const s=256-r%256,o=lu(s);if(!kH(o,s))throw new Error("failed to generate random padding of size "+s);let a;if(t=Cs([t,o]),e){t[0]|=4;const l=pE(t),_=yield yH(l,e);t=Cs([t,_]),a={signature:_,publicKey:_l(e,!1)}}return{payload:t,sig:a}}),_E.apply(this,arguments)}function DE(){return DE=$(function*(n,e){return wH(cu(e),n)}),DE.apply(this,arguments)}function AA(n,e){return SE.apply(this,arguments)}function SE(){return SE=$(function*(n,e){return _H(e,n)}),SE.apply(this,arguments)}function CE(){return CE=$(function*(n,e){const t=CH();return Cs([yield DH(t,cu(e),n),t])}),CE.apply(this,arguments)}function xA(n,e){return IE.apply(this,arguments)}function IE(){return IE=$(function*(n,e){const t=n.length-12,r=n.slice(0,t);return SH(n.slice(t),cu(e),r)}),IE.apply(this,arguments)}function OH(n,e){const t=RA(e);let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e.length,!0),r=r.slice(0,t),(n=Cs([n,r]))[0]|=t,n}function RA(n){let e=1;for(let t=n.length;t>=256;t/=256)e++;return e}function kH(n,e){return n.length===e&&(e<=3||-1!==n.findIndex(t=>0!==t))}const sa=_r("waku:message"),PA=BigInt(1e6);var jh,zh,NA,Gh,ef=(()=>(function(n){n.Asymmetric="asymmetric",n.Symmetric="symmetric"}(ef||(ef={})),ef))();class oa{constructor(e,t,r){this.proto=e,this._signaturePublicKey=t,this._signature=r}static fromUtf8String(e,t,r){return $(function*(){const i=(n=>Ot(n,"utf8"))(e);return oa.fromBytes(i,t,r)})()}static fromBytes(e,t,r){return $(function*(){const{timestamp:i,encPublicKey:s,symKey:o,sigPrivKey:a}=Object.assign({timestamp:new Date},r||{});let R,l=e,_=0;if(s&&o)throw"Pass either `encPublicKey` or `symKey`, not both.";if(s){const N=yield TA(l,a);l=yield function NH(n,e){return DE.apply(this,arguments)}(N.payload,s),R=N.sig,_=1}else if(o){const N=yield TA(l,a);l=yield function MH(n,e){return CE.apply(this,arguments)}(N.payload,o),R=N.sig,_=1}return new oa({payload:l,timestampDeprecated:i.valueOf()/1e3,timestamp:BigInt(i.valueOf())*PA,version:_,contentTopic:t},R?.publicKey,R?.signature)})()}static decode(e,t){return $(function*(){const r=Kh.decode(e);return oa.decodeProto(r,t)})()}static decodeProto(e,t){return $(function*(){const r=e.payload;let i,s;if(1===e.version&&r){if(void 0===t)return void sa("Payload is encrypted but no private keys have been provided.");const o=yield Promise.all(t.map(function(){var N=$(function*({key:B,method:z,contentTopics:Z}){if(!Z||e.contentTopic&&Z.includes(e.contentTopic))switch(z){case ef.Asymmetric:try{return yield AA(r,B)}catch(J){return void sa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",J)}case ef.Symmetric:try{return yield xA(r,B)}catch(J){return void sa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",J)}default:try{return yield xA(r,B)}catch(J){sa("Failed to decrypt message using symmetric encryption",J);try{return yield AA(r,B)}catch(se){return void sa("Failed to decrypt message using asymmetric encryption",se)}}}});return function(B){return N.apply(this,arguments)}}())),l=o.filter(N=>!!N);if(0===l.length)return void sa("Failed to decrypt payload.");const _=l[0],R=yield function AH(n){const e=function xH(n){return 3&new DataView(n.buffer).getUint8(0)}(n);if(0===e)return;const t=function RH(n,e){let t=n.slice(1,1+e);return e<4&&(t=Cs([t,new Uint8Array(4-e)],4)),new DataView(t.buffer).getInt32(0,!0)}(n,e),r=1+e,i=n.slice(r,r+t),s=function PH(n){return 4==(4&new DataView(n.buffer).getUint8(0))}(n);let o;if(s){const a=function LH(n){return n.slice(n.length-65,n.length)}(n),l=function BH(n,e){return pE(e?n.slice(0,n.length-65):n)}(n,s),_=function FH(n,e){const r=new DataView(e.slice(64).buffer).getUint8(0);return function wF(n,e,t,r=!1){return Tn.fromSignature(n,e,t).toRawBytes(r)}(n,uo.fromCompact(e.slice(0,64)),r,!1)}(l,a);o={signature:a,publicKey:_}}return{payload:i,sig:o}}(_);if(!R)return void sa("Failed to decode payload.");Object.assign(e,{payload:R.payload}),i=R.sig?.publicKey,s=R.sig?.signature}return new oa(e,i,s)})()}encode(){return Kh.encode(this.proto)}get payloadAsUtf8(){if(!this.payload)return"";try{return(n=>Lt(this.payload,"utf8"))()}catch(e){return sa("Could not decode byte as UTF-8",e),""}}get payload(){if(this.proto.payload)return new Uint8Array(this.proto.payload)}get contentTopic(){return this.proto.contentTopic}get version(){return this.proto.version??0}get timestamp(){try{if(this.proto.timestamp)return new Date(Number(this.proto.timestamp/PA));if(this.proto.timestampDeprecated)return new Date(1e3*this.proto.timestampDeprecated)}catch{return}}get signaturePublicKey(){return this._signaturePublicKey}get signature(){return this._signature}}!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Yt((s,o,a={})=>{!1!==a.lengthDelimited&&o.fork(),null!=s.contentTopic&&(o.uint32(10),o.string(s.contentTopic)),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={},l=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.contentTopic=s.string():s.skipType(7&_)}return a})),i),r.encode=s=>qt(s,r.codec()),r.decode=s=>Wt(s,r.codec())}(e=n.ContentFilter||(n.ContentFilter={})),n.codec=()=>(null==t&&(t=Yt((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null!=r.subscribe&&(i.uint32(8),i.bool(r.subscribe)),null!=r.topic&&(i.uint32(18),i.string(r.topic)),null==r.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const o of r.contentFilters)i.uint32(26),n.ContentFilter.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={contentFilters:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.subscribe=r.bool();break;case 2:s.topic=r.string();break;case 3:s.contentFilters.push(n.ContentFilter.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}return s})),t),n.encode=r=>qt(r,n.codec()),n.decode=r=>Wt(r,n.codec())}(jh||(jh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const s of t.messages)r.uint32(10),Gh.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={messages:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.messages.push(Gh.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(zh||(zh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),jh.codec().encode(t.request,r)),null!=t.push&&(r.uint32(26),zh.codec().encode(t.push,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=jh.codec().decode(t,t.uint32());break;case 3:i.push=zh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(NA||(NA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Gh||(Gh={}));const tf="/vac/waku/filter/2.0.0-beta1";var Wh,qh,MA,Yh;_r("waku:filter"),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(10),r.string(t.pubSubTopic)),null!=t.message&&(r.uint32(18),Yh.codec().encode(t.message,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.pubSubTopic=t.string();break;case 2:i.message=Yh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Wh||(Wh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.isSuccess&&(r.uint32(8),r.bool(t.isSuccess)),null!=t.info&&(r.uint32(18),r.string(t.info)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.isSuccess=t.bool();break;case 2:i.info=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(qh||(qh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),Wh.codec().encode(t.request,r)),null!=t.response&&(r.uint32(26),qh.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=Wh.codec().decode(t,t.uint32());break;case 3:i.response=qh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(MA||(MA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Yh||(Yh={})),_r("waku:light-push");const nf="/vac/waku/lightpush/2.0.0-beta1",ka=["/vac/waku/relay/2.0.0-beta2","/vac/waku/relay/2.0.0"];var Qh,fu,Zh,Xh,rf,OA,Jh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(16),r.sint64(t.receivedTime)),null!=t.senderTime&&(r.uint32(24),r.sint64(t.senderTime)),null!=t.pubsubTopic&&(r.uint32(34),r.string(t.pubsubTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.sint64();break;case 3:i.senderTime=t.sint64();break;case 4:i.pubsubTopic=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Qh||(Qh={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),Qh.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=Qh.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&l)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(fu||(fu={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Zh||(Zh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),Zh.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),fu.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(40),r.sint64(t.startTime)),null!=t.endTime&&(r.uint32(48),r.sint64(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(Zh.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=fu.codec().decode(t,t.uint32());break;case 5:i.startTime=t.sint64();break;case 6:i.endTime=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Xh||(Xh={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),Jh.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),fu.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(Jh.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=fu.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&l)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(rf||(rf={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),Xh.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),rf.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=Xh.codec().decode(t,t.uint32());break;case 3:i.response=rf.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(OA||(OA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Jh||(Jh={}));var ep,du,tp,np,rp,kA,ip,sf=(()=>(function(n){n.V2Beta3="/vac/waku/store/2.0.0-beta3",n.V2Beta4="/vac/waku/store/2.0.0-beta4"}(sf||(sf={})),sf))();!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(17),r.double(t.receivedTime)),null!=t.senderTime&&(r.uint32(25),r.double(t.senderTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.double();break;case 3:i.senderTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ep||(ep={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),ep.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=ep.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&l)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(du||(du={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(tp||(tp={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),tp.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),du.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(41),r.double(t.startTime)),null!=t.endTime&&(r.uint32(49),r.double(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(tp.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=du.codec().decode(t,t.uint32());break;case 5:i.startTime=t.double();break;case 6:i.endTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(np||(np={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),ip.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),du.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(ip.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=du.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&l)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(rp||(rp={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),np.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),rp.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=np.codec().decode(t,t.uint32());break;case 3:i.response=rp.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(kA||(kA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ip||(ip={})),BigInt(1e6),_r("waku:store");const FA=_r("waku:waku");var Jr=(()=>(function(n){n.Relay="relay",n.Store="store",n.LightPush="lightpush",n.Filter="filter"}(Jr||(Jr={})),Jr))();class WH{constructor(e,t,r,i,s){this.libp2p=t,this.store=r,this.filter=s,this.lightPush=i,function qH(n){if(n)try{return n.multicodecs.includes(ka[ka.length-1])}catch{}return!1}(t.pubsub)&&(this.relay=t.pubsub),this.pingKeepAliveTimers={},this.relayKeepAliveTimers={};const o=e.pingKeepAlive||0,a=this.relay?e.relayKeepAlive||300:0;t.connectionManager.addEventListener("peer:connect",l=>{this.startKeepAlive(l.detail.remotePeer,o,a)}),t.connectionManager.addEventListener("peer:disconnect",l=>{this.stopKeepAlive(l.detail.remotePeer)}),e?.decryptionKeys?.forEach(l=>{this.addDecryptionKey(l)})}dial(e,t){var r=this;return $(function*(){const i=t??[Jr.Relay],s=[];if(i.includes(Jr.Relay)&&ka.forEach(o=>s.push(o)),i.includes(Jr.Store))for(const o of Object.values(sf))s.push(o);return i.includes(Jr.LightPush)&&s.push(nf),i.includes(Jr.Filter)&&s.push(tf),r.libp2p.dialProtocol(e,s)})()}addPeerToAddressBook(e,t){var r=this;return $(function*(){let i;i="string"==typeof e?fr(e):e;const s=t.map(o=>"string"==typeof o?function ZU(n){return new mn(n)}(o):o);yield r.libp2p.peerStore.addressBook.set(i,s)})()}start(){var e=this;return $(function*(){yield e.libp2p.start()})()}stop(){var e=this;return $(function*(){e.stopAllKeepAlives(),yield e.libp2p.stop()})()}isStarted(){return this.libp2p.isStarted()}addDecryptionKey(e,t){this.relay&&this.relay.addDecryptionKey(e,t),this.store&&this.store.addDecryptionKey(e,t),this.filter&&this.filter.addDecryptionKey(e,t)}deleteDecryptionKey(e){this.relay&&this.relay.deleteDecryptionKey(e),this.store&&this.store.deleteDecryptionKey(e),this.filter&&this.filter.deleteDecryptionKey(e)}getLocalMultiaddrWithID(){const e=this.libp2p.getMultiaddrs().find(t=>t.toString().match(/127\.0\.0\.1/));if(!e||""===e.toString())throw"Not listening on localhost";return e+"/p2p/"+this.libp2p.peerId.toString()}startKeepAlive(e,t,r){this.stopKeepAlive(e);const i=e.toString();0!==t&&(this.pingKeepAliveTimers[i]=setInterval(()=>{this.libp2p.ping(e).catch(o=>{FA(`Ping failed (${i})`,o)})},1e3*t));const s=this.relay;s&&0!==r&&(this.relayKeepAliveTimers[i]=setInterval(()=>{FA("Sending Waku Relay ping message"),oa.fromBytes(new Uint8Array,"/relay-ping/1/ping/null").then(o=>s.send(o))},1e3*r))}stopKeepAlive(e){const t=e.toString();this.pingKeepAliveTimers[t]&&(clearInterval(this.pingKeepAliveTimers[t]),delete this.pingKeepAliveTimers[t]),this.relayKeepAliveTimers[t]&&(clearInterval(this.relayKeepAliveTimers[t]),delete this.relayKeepAliveTimers[t])}stopAllKeepAlives(){for(const e of[...Object.values(this.pingKeepAliveTimers),...Object.values(this.relayKeepAliveTimers)])clearInterval(e);this.pingKeepAliveTimers={},this.relayKeepAliveTimers={}}}const UA=()=>{};class YH{constructor(e){this.min=e.min??0,this.max=e.max??1/0,this.peers=new Set,this.onConnect=e.onConnect??UA,this.onDisconnect=e.onDisconnect??UA}get[Symbol.toStringTag](){return Vv.toString()}get[Vv](){return!0}setRegistrar(e){var t=this;return $(function*(){t.registrar=e})()}disconnect(e){this.onDisconnect(e)}}class ZH{constructor(e,t,r){this.gossip=e,this.msgs=new Map,this.history=[],this.msgIdToStrFn=r;for(let i=0;i{const s=this.msgs.get(i.msgIdStr);if(s&&s.validated&&e.has(i.topic)){let o=t.get(i.topic);o||(o=[],t.set(i.topic,o)),o.push(i.msgId)}});return t}validate(e){const t=this.msgs.get(e);if(!t)return null;const{message:r,originatingPeers:i}=t;return t.validated=!0,t.originatingPeers=new Set,{message:r,originatingPeers:i}}shift(){this.history[this.history.length-1].forEach(t=>{this.msgs.delete(t.msgIdStr)}),this.history.pop(),this.history.unshift([])}remove(e){const t=this.msgs.get(e);return t?(this.msgs.delete(e),t):null}}var XH=x(8479);const{RPC:op}=XH,VA="/floodsub/1.0.0",HA="/meshsub/1.0.0",PE="/meshsub/1.1.0",pu=5e3;function bo(n=[],e){return{subscriptions:[],messages:n,control:e?{graft:e.graft||[],prune:e.prune||[],ihave:e.ihave||[],iwant:e.iwant||[]}:void 0}}function wo(n){if(n.length<=1)return n;for(let t=0;t(function(n){n.StrictSign="StrictSign",n.StrictNoSign="StrictNoSign"}(cp||(cp={})),cp))(),Ba=(()=>(function(n){n[n.Signing=0]="Signing",n[n.Anonymous=1]="Anonymous"}(Ba||(Ba={})),Ba))(),$s=(()=>(function(n){n.Accept="accept",n.Ignore="ignore",n.Reject="reject"}($s||($s={})),$s))(),Ji=(()=>(function(n){n.Error="error",n.Ignore="ignore",n.Reject="reject",n.Blacklisted="blacklisted"}(Ji||(Ji={})),Ji))(),li=(()=>(function(n){n.InvalidSignature="invalid_signature",n.InvalidSeqno="invalid_seqno",n.InvalidPeerId="invalid_peerid",n.SignaturePresent="signature_present",n.SeqnoPresent="seqno_present",n.FromPresent="from_present",n.TransformFailed="transform_failed"}(li||(li={})),li))(),es=(()=>(function(n){n.duplicate="duplicate",n.invalid="invalid",n.valid="valid"}(es||(es={})),es))();function $A(n){switch(n){case $s.Ignore:return Ji.Ignore;case $s.Reject:return Ji.Reject}}function ME(){return ME=$(function*(n,e){switch(n){case ap:{if(!e)throw Error("Must provide PeerId");if(null==e.privateKey)throw Error("Cannot sign message, no private key present");if(null==e.publicKey)throw Error("Cannot sign message, no public key present");const t=yield Rl(e.privateKey);return{type:Ba.Signing,author:e,key:e.publicKey,privateKey:t}}case NE:return{type:Ba.Anonymous};default:throw new Error(`Unknown signature policy "${n}"`)}}),ME.apply(this,arguments)}const Kn="ERR_INVALID_PEER_SCORE_PARAMS",PK={topics:{},topicScoreCap:10,appSpecificScore:()=>0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyThreshold:0,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},NK={topicWeight:.5,timeInMeshWeight:1,timeInMeshQuantum:1,timeInMeshCap:3600,firstMessageDeliveriesWeight:1,firstMessageDeliveriesDecay:.5,firstMessageDeliveriesCap:2e3,meshMessageDeliveriesWeight:-1,meshMessageDeliveriesDecay:.5,meshMessageDeliveriesCap:100,meshMessageDeliveriesThreshold:20,meshMessageDeliveriesWindow:10,meshMessageDeliveriesActivation:5e3,meshFailurePenaltyWeight:-1,meshFailurePenaltyDecay:.5,invalidMessageDeliveriesWeight:-1,invalidMessageDeliveriesDecay:.3};function MK(n={}){return{...PK,...n,topics:n.topics?Object.entries(n.topics).reduce((e,[t,r])=>(e[t]=function OK(n={}){return{...NK,...n}}(r),e),{}):{}}}function LK(n){if(n.topicWeight<0)throw ae(new Error("invalid topic weight; must be >= 0"),Kn);if(0===n.timeInMeshQuantum)throw ae(new Error("invalid TimeInMeshQuantum; must be non zero"),Kn);if(n.timeInMeshWeight<0)throw ae(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),Kn);if(0!==n.timeInMeshWeight&&n.timeInMeshQuantum<=0)throw ae(new Error("invalid TimeInMeshQuantum; must be positive"),Kn);if(0!==n.timeInMeshWeight&&n.timeInMeshCap<=0)throw ae(new Error("invalid TimeInMeshCap; must be positive"),Kn);if(n.firstMessageDeliveriesWeight<0)throw ae(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),Kn);if(0!==n.firstMessageDeliveriesWeight&&(n.firstMessageDeliveriesDecay<=0||n.firstMessageDeliveriesDecay>=1))throw ae(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),Kn);if(0!==n.firstMessageDeliveriesWeight&&n.firstMessageDeliveriesCap<=0)throw ae(new Error("invalid FirstMessageDeliveriesCap; must be positive"),Kn);if(n.meshMessageDeliveriesWeight>0)throw ae(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.meshMessageDeliveriesWeight&&(n.meshMessageDeliveriesDecay<=0||n.meshMessageDeliveriesDecay>=1))throw ae(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesCap<=0)throw ae(new Error("invalid MeshMessageDeliveriesCap; must be positive"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesThreshold<=0)throw ae(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),Kn);if(n.meshMessageDeliveriesWindow<0)throw ae(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesActivation<1e3)throw ae(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),Kn);if(n.meshFailurePenaltyWeight>0)throw ae(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.meshFailurePenaltyWeight&&(n.meshFailurePenaltyDecay<=0||n.meshFailurePenaltyDecay>=1))throw ae(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),Kn);if(n.invalidMessageDeliveriesWeight>0)throw ae(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),Kn);if(n.invalidMessageDeliveriesDecay<=0||n.invalidMessageDeliveriesDecay>=1)throw ae(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),Kn)}const BK={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function FK(n={}){return{...BK,...n}}function UK(n,e,t,r){let i=0;if(Object.entries(e.topics).forEach(([o,a])=>{const l=t.topics[o];if(void 0===l)return;let _=0;if(a.inMesh){let z=a.meshTime/l.timeInMeshQuantum;z>l.timeInMeshCap&&(z=l.timeInMeshCap),_+=z*l.timeInMeshWeight}let R=a.firstMessageDeliveries;if(R>l.firstMessageDeliveriesCap&&(R=l.firstMessageDeliveriesCap),_+=R*l.firstMessageDeliveriesWeight,a.meshMessageDeliveriesActive&&a.meshMessageDeliveries0&&i>t.topicScoreCap&&(i=t.topicScoreCap),i+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(o=>{if(t.IPColocationFactorWhitelist.has(o))return;const a=r.get(o),l=a?a.size:0;if(l>t.IPColocationFactorThreshold){const _=l-t.IPColocationFactorThreshold;i+=_*_*t.IPColocationFactorWeight}}),e.behaviourPenalty>t.behaviourPenaltyThreshold){const o=e.behaviourPenalty-t.behaviourPenaltyThreshold;i+=o*o*t.behaviourPenaltyWeight}return i}var VK=x(1807),fi=(()=>(function(n){n[n.unknown=0]="unknown",n[n.valid=1]="valid",n[n.invalid=2]="invalid",n[n.ignored=3]="ignored"}(fi||(fi={})),fi))();class HK{constructor(){this.records=new Map,this.queue=new VK}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:fi.unknown,firstSeen:Date.now(),validated:0,peers:new Set},this.records.set(e,t);const r={msgId:e,expire:Date.now()+12e4};return this.queue.push(r),t}gc(){const e=Date.now();let t=this.queue.peekFront();for(;t&&t.expire0)throw ae(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.IPColocationFactorWeight&&n.IPColocationFactorThreshold<1)throw ae(new Error("invalid IPColocationFactorThreshold; must be at least 1"),Kn);if(n.behaviourPenaltyWeight>0)throw ae(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.behaviourPenaltyWeight&&(n.behaviourPenaltyDecay<=0||n.behaviourPenaltyDecay>=1))throw ae(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),Kn);if(n.decayInterval<1e3)throw ae(new Error("invalid DecayInterval; must be at least 1s"),Kn);if(n.decayToZero<=0||n.decayToZero>=1)throw ae(new Error("invalid DecayToZero; must be between 0 and 1"),Kn)}(e),this.scoreCacheValidityMs=r.scoreCacheValidityMs,this.computeScore=r.computeScore??UK}init(e){this.components=e}get size(){return this.peerStats.size}start(){this._backgroundInterval?gu("Peer score already running"):(this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),gu("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),gu("stopped")):gu("Peer score already stopped")}background(){this.refreshScores(),this.updateIPs(),this.deliveryRecords.gc()}dumpPeerScoreStats(){return Object.fromEntries(Array.from(this.peerStats.entries()).map(([e,t])=>[e,t]))}refreshScores(){const e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach((r,i)=>{r.connected?(Object.entries(r.topics).forEach(([s,o])=>{const a=this.params.topics[s];void 0!==a&&(o.firstMessageDeliveries*=a.firstMessageDeliveriesDecay,o.firstMessageDeliveriesa.meshMessageDeliveriesActivation&&(o.meshMessageDeliveriesActive=!0)))}),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenaltyr.expire&&(this.removeIPs(i,r.ips),this.peerStats.delete(i),this.scoreCache.delete(i))})}score(e){this.metrics?.scoreFnCalls.inc();const t=this.peerStats.get(e);if(!t)return 0;const r=Date.now(),i=this.scoreCache.get(e);if(i&&i.cacheUntil>r)return i.score;this.metrics?.scoreFnRuns.inc();const s=this.computeScore(e,t,this.params,this.peerIPs),o=r+this.scoreCacheValidityMs;return i?(this.metrics?.scoreCachedDelta.observe(Math.abs(s-i.score)),i.score=s,i.cacheUntil=o):this.scoreCache.set(e,{score:s,cacheUntil:o}),s}addPenalty(e,t,r){const i=this.peerStats.get(e);i&&(i.behaviourPenalty+=t,this.metrics?.onScorePenalty(r))}addPeer(e){const t={connected:!0,expire:0,topics:{},ips:[],behaviourPenalty:0};this.peerStats.set(e,t);const r=this.getIPs(e);this.setIPs(e,r,t.ips),t.ips=r}removePeer(e){const t=this.peerStats.get(e);if(t){if(this.score(e)>0)return this.removeIPs(e,t.ips),void this.peerStats.delete(e);Object.entries(t.topics).forEach(([r,i])=>{i.firstMessageDeliveries=0;const s=this.params.topics[r].meshMessageDeliveriesThreshold;if(i.inMesh&&i.meshMessageDeliveriesActive&&i.meshMessageDeliveries{o!==e.toString()&&this.markDuplicateMessageDelivery(o,r)})):gu("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,s-i.firstSeen,fi[i.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,i){switch(i){case Ji.Error:return void this.markInvalidMessageDelivery(e,r);case Ji.Blacklisted:return}const s=this.deliveryRecords.ensureRecord(t);if(s.status===fi.unknown)return i===Ji.Ignore?(s.status=fi.ignored,void s.peers.clear()):(s.status=fi.invalid,this.markInvalidMessageDelivery(e,r),s.peers.forEach(o=>{this.markInvalidMessageDelivery(o,r)}),void s.peers.clear());gu("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-s.firstSeen,fi[s.status])}duplicateMessage(e,t,r){const i=this.deliveryRecords.ensureRecord(t);if(!i.peers.has(e))switch(i.status){case fi.unknown:i.peers.add(e);break;case fi.valid:i.peers.add(e),this.markDuplicateMessageDelivery(e,r,i.validated);break;case fi.invalid:this.markInvalidMessageDelivery(e,r)}}markInvalidMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);i&&(i.invalidMessageDeliveries+=1)}}markFirstMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);if(i){let s=this.params.topics[t].firstMessageDeliveriesCap;i.firstMessageDeliveries=Math.min(s,i.firstMessageDeliveries+1),i.inMesh&&(s=this.params.topics[t].meshMessageDeliveriesCap,i.meshMessageDeliveries=Math.min(s,i.meshMessageDeliveries+1))}}}markDuplicateMessageDelivery(e,t,r){const i=this.peerStats.get(e);if(i){const s=void 0!==r?Date.now():0,o=this.getPtopicStats(i,t);if(o&&o.inMesh){const a=this.params.topics[t];if(void 0!==r){const _=s-r,R=_>a.meshMessageDeliveriesWindow;if(this.metrics?.onDuplicateMsgDelivery(t,_,R),R)return}o.meshMessageDeliveries=Math.min(a.meshMessageDeliveriesCap,o.meshMessageDeliveries+1)}}}getIPs(e){return this.components.getConnectionManager().getConnections(fr(e)).map(t=>t.remoteAddr.toOptions().host)}setIPs(e,t,r){e:for(const i of t){for(const o of r)if(i===o)continue e;let s=this.peerIPs.get(i);s||(s=new Set,this.peerIPs.set(i,s)),s.add(e)}e:for(const i of r){for(const o of t)if(i===o)continue e;const s=this.peerIPs.get(i);!s||(s.delete(e),s.size||this.peerIPs.delete(i))}}removeIPs(e,t){t.forEach(r=>{const i=this.peerIPs.get(r);!i||(i.delete(e),i.size||this.peerIPs.delete(r))})}updateIPs(){this.peerStats.forEach((e,t)=>{const r=this.getIPs(t);this.setIPs(t,r,e.ips),e.ips=r})}getPtopicStats(e,t){let r=e.topics[t];return void 0!==r?r:void 0!==this.params.topics[t]?(r={inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e.topics[t]=r,r):null}}class $K{constructor(e,t,r){this.gossipsubIWantFollowupMs=e,this.msgIdToStrFn=t,this.metrics=r,this.promises=new Map,this.requestMsByMsg=new Map,this.requestMsByMsgExpire=10*e}get size(){return this.promises.size}get requestMsByMsgSize(){return this.requestMsByMsg.size}addPromise(e,t){const r=Math.floor(Math.random()*t.length),s=this.msgIdToStrFn(t[r]);let o=this.promises.get(s);o||(o=new Map,this.promises.set(s,o));const a=Date.now();o.has(e)||(o.set(e,a+this.gossipsubIWantFollowupMs),this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(s)||this.requestMsByMsg.set(s,a)))}getBrokenPromises(){const e=Date.now(),t=new Map;let r=0;return this.promises.forEach((i,s)=>{i.forEach((o,a)=>{o=Date.now()?t.value:void 0}clear(){this.entries.clear()}}var _o=(()=>(function(n){n.Fanout="fanout",n.Random="random",n.Subscribed="subscribed",n.Outbound="outbound",n.NotEnough="not_enough",n.Opportunistic="opportunistic"}(_o||(_o={})),_o))(),Fa=(()=>(function(n){n.Dc="disconnected",n.BadScore="bad_score",n.Prune="prune",n.Unsub="unsubscribed",n.Excess="excess"}(Fa||(Fa={})),Fa))(),yu=(()=>(function(n){n.GraftBackoff="graft_backoff",n.BrokenPromise="broken_promise",n.MessageDeficit="message_deficit",n.IPColocation="IP_colocation"}(yu||(yu={})),yu))(),mu=(()=>(function(n){n.LowScore="low_score",n.MaxIhave="max_ihave",n.MaxIasked="max_iasked"}(mu||(mu={})),mu))(),Ua=(()=>(function(n){n.graylist="graylist",n.publish="publish",n.gossip="gossip",n.mesh="mesh"}(Ua||(Ua={})),Ua))();const jA=Ot("libp2p-pubsub:");function kE(){return kE=$(function*(n,e,t,r){switch(n.type){case Ba.Signing:{const i={from:n.author.toBytes(),data:r,seqno:nh(8),topic:e,signature:void 0,key:void 0},s=br([jA,op.Message.encode(i).finish()]);return i.signature=yield n.privateKey.sign(s),i.key=n.key,{raw:i,msg:{type:"signed",from:n.author,data:t,sequenceNumber:BigInt(`0x${Lt(i.seqno,"base16")}`),topic:e,signature:i.signature,key:i.key}}}case Ba.Anonymous:return{raw:{from:void 0,data:r,seqno:void 0,topic:e,signature:void 0,key:void 0},msg:{type:"unsigned",data:t,topic:e}}}}),kE.apply(this,arguments)}function LE(){return LE=$(function*(n,e){switch(n){case NE:return null!=e.signature?{valid:!1,error:li.SignaturePresent}:null!=e.seqno?{valid:!1,error:li.SeqnoPresent}:null!=e.key?{valid:!1,error:li.FromPresent}:{valid:!0,message:{type:"unsigned",topic:e.topic,data:e.data??new Uint8Array(0)}};case ap:{if(null==e.seqno)return{valid:!1,error:li.InvalidSeqno};if(8!==e.seqno.length)return{valid:!1,error:li.InvalidSeqno};if(null==e.signature)return{valid:!1,error:li.InvalidSignature};if(null==e.from)return{valid:!1,error:li.InvalidPeerId};let t,r;try{t=Jc(e.from)}catch{return{valid:!1,error:li.InvalidPeerId}}if(e.key){if(r=xl(e.key),void 0!==t.publicKey&&!kr(r.bytes,t.publicKey))return{valid:!1,error:li.InvalidPeerId}}else{if(null==t.publicKey)return{valid:!1,error:li.InvalidPeerId};r=xl(t.publicKey)}const s=br([jA,op.Message.encode({from:e.from,data:e.data,seqno:e.seqno,topic:e.topic,signature:void 0,key:void 0}).finish()]);return(yield r.verify(s,e.signature))?{valid:!0,message:{type:"signed",from:t,data:e.data??new Uint8Array(0),sequenceNumber:BigInt(`0x${Lt(e.seqno,"base16")}`),topic:e.topic,signature:e.signature,key:e.key??t2(r)}}:{valid:!1,error:li.InvalidSignature}}}}),LE.apply(this,arguments)}function QK(n){if("signed"!==n.type)throw new Error("expected signed message type");if(null==n.sequenceNumber)throw Error("missing seqno field");return((n,e)=>{const t=Ot(e.toString(16).padStart(16,"0"),"base16"),r=new Uint8Array(n.length+t.length);return r.set(n,0),r.set(t,n.length),r})(n.from.toBytes(),n.sequenceNumber)}function ZK(n){return BE.apply(this,arguments)}function BE(){return BE=$(function*(n){return yield mi.encode(n.data)}),BE.apply(this,arguments)}function XK(n,e,t,r,i){let s=0;const o=new Map;if(Object.entries(e.topics).forEach(([B,z])=>{const Z=i.get(B)??"unknown",J=t.topics[B];if(void 0===J)return;let se=o.get(Z);se||(se={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},o.set(Z,se));let he=0,Te=0,ue=0,Re=0,$e=0;z.inMesh&&(he+=Math.max(z.meshTime/J.timeInMeshQuantum,J.timeInMeshCap)*J.timeInMeshWeight);let Pe=z.firstMessageDeliveries;if(Pe>J.firstMessageDeliveriesCap&&(Pe=J.firstMessageDeliveriesCap),Te+=Pe*J.firstMessageDeliveriesWeight,z.meshMessageDeliveriesActive&&z.meshMessageDeliveries0&&s>t.topicScoreCap){s=t.topicScoreCap;const B=t.topicScoreCap/s;for(const z of o.values())z.p1w*=B,z.p2w*=B,z.p3w*=B,z.p3bw*=B,z.p4w*=B}let a=0,l=0,_=0;return a+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(B=>{if(t.IPColocationFactorWhitelist.has(B))return;const z=r.get(B),Z=z?z.size:0;if(Z>t.IPColocationFactorThreshold){const J=Z-t.IPColocationFactorThreshold;l+=J*J*t.IPColocationFactorWeight}}),_+=e.behaviourPenalty*e.behaviourPenalty*t.behaviourPenaltyWeight,s+=a+l+_,{byTopic:o,p5w:a,p6w:l,p7w:_,score:s}}function FE(n,e,t=(()=>!0)){const r=new Set;if(e<=0)return r;for(const i of n){if(r.size>=e)break;t(i)&&(r.add(i),n.delete(i))}return r}class t${constructor(e,t,r){this.rawStream=e,this.pushable=Mc({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=r.maxBufferSize??1/0,qn(vs(this.pushable,this.closeController.signal,{returnOnAbort:!0}),Os(),this.rawStream).catch(t)}get protocol(){return this.rawStream.stat.protocol}push(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);this.pushable.push(e)}close(){this.closeController.abort(),this.pushable.return(),this.rawStream.close()}}class n${constructor(e){this.rawStream=e,this.closeController=new AbortController,this.source=vs(qn(this.rawStream,ps()),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}}var _i=(()=>(function(n){n[n.started=0]="started",n[n.stopped=1]="stopped"}(_i||(_i={})),_i))();class zA extends Ei{constructor(e={}){super(),this.multicodecs=[PE,HA],this.peers=new Set,this.streamsInbound=new Map,this.streamsOutbound=new Map,this.outboundInflightQueue=Mc({objectMode:!0}),this.direct=new Set,this.floodsubPeers=new Set,this.acceptFromWhitelist=new Map,this.topics=new Map,this.subscriptions=new Set,this.mesh=new Map,this.fanout=new Map,this.fanoutLastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.topicValidators=new Map,this.heartbeatTicks=0,this.components=new ho,this.directPeerInitial=null,this.status={code:_i.stopped},this.heartbeatTimer=null,this.runHeartbeat=()=>{const r=this.metrics?.heartbeatDuration.startTimer();this.heartbeat().catch(i=>{this.log("Error running heartbeat",i)}).finally(()=>{if(r?.(),this.status.code===_i.started){clearTimeout(this.status.heartbeatTimeout);let i=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;i<.25*this.opts.heartbeatInterval&&(i+=this.opts.heartbeatInterval,this.metrics?.heartbeatSkipped.inc()),this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,i)}})};const t={fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:6,Dlo:4,Dhi:12,Dscore:4,Dout:2,Dlazy:6,heartbeatInterval:1e3,fanoutTTL:6e4,mcacheLength:5,mcacheGossip:3,seenTTL:12e4,gossipsubIWantFollowupMs:3e3,prunePeers:16,pruneBackoff:6e4,graftFloodThreshold:1e4,opportunisticGraftPeers:2,opportunisticGraftTicks:60,directConnectTicks:300,...e,scoreParams:MK(e.scoreParams),scoreThresholds:FK(e.scoreThresholds)};if(this.globalSignaturePolicy=t.globalSignaturePolicy??ap,t.fallbackToFloodsub&&this.multicodecs.push(VA),this.log=zt(t.debugName??"libp2p:gossipsub"),this.opts=t,this.direct=new Set(t.directPeers.map(r=>r.id.toString())),this.seenCache=new OE({validityMs:t.seenTTL}),this.publishedMessageIds=new OE({validityMs:t.seenTTL}),e.msgIdFn)this.msgIdFn=e.msgIdFn;else switch(this.globalSignaturePolicy){case ap:this.msgIdFn=QK;break;case NE:this.msgIdFn=ZK}if(e.fastMsgIdFn&&(this.fastMsgIdFn=e.fastMsgIdFn,this.fastMsgIdCache=new OE({validityMs:t.seenTTL})),this.msgIdToStrFn=e.msgIdToStrFn??xK,this.mcache=e.messageCache||new ZH(t.mcacheGossip,t.mcacheLength,this.msgIdToStrFn),e.dataTransform&&(this.dataTransform=e.dataTransform),e.metricsRegister){if(!e.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");const r=Math.max(...Object.values(t.scoreParams.topics).map(s=>s.meshMessageDeliveriesWindow),1e3),i=function jK(n,e,t){return{protocolsEnabled:n.gauge({name:"gossipsub_protocol",help:"Status of enabled protocols",labelNames:["protocol"]}),topicSubscriptionStatus:n.gauge({name:"gossipsub_topic_subscription_status",help:"Status of our subscription to this topic",labelNames:["topicStr"]}),topicPeersCount:n.gauge({name:"gossipsub_topic_peer_count",help:"Number of peers subscribed to each topic",labelNames:["topicStr"]}),meshPeerCounts:n.gauge({name:"gossipsub_mesh_peer_count",help:"Number of peers in our mesh",labelNames:["topicStr"]}),meshPeerInclusionEvents:n.gauge({name:"gossipsub_mesh_peer_inclusion_events_total",help:"Number of times we include peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),meshPeerChurnEvents:n.gauge({name:"gossipsub_peer_churn_events_total",help:"Number of times we remove peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),peersPerProtocol:n.gauge({name:"gossipsub_peers_per_protocol_count",help:"Peers connected for each topic",labelNames:["protocol"]}),heartbeatDuration:n.histogram({name:"gossipsub_heartbeat_duration_seconds",help:"The time it takes to complete one iteration of the heartbeat",buckets:[.01,.1,1]}),heartbeatSkipped:n.gauge({name:"gossipsub_heartbeat_skipped",help:"Heartbeat run took longer than heartbeat interval so next is skipped"}),asyncValidationResult:n.gauge({name:"gossipsub_async_validation_result_total",help:"Message validation result for each topic",labelNames:["topic","acceptance"]}),asyncValidationMcacheHit:n.gauge({name:"gossipsub_async_validation_mcache_hit_total",help:"Async validation result reported by the user layer",labelNames:["hit"]}),rpcRecvBytes:n.gauge({name:"gossipsub_rpc_recv_bytes_total",help:"RPC recv"}),rpcRecvCount:n.gauge({name:"gossipsub_rpc_recv_count_total",help:"RPC recv"}),rpcRecvSubscription:n.gauge({name:"gossipsub_rpc_recv_subscription_total",help:"RPC recv"}),rpcRecvMessage:n.gauge({name:"gossipsub_rpc_recv_message_total",help:"RPC recv"}),rpcRecvControl:n.gauge({name:"gossipsub_rpc_recv_control_total",help:"RPC recv"}),rpcRecvIHave:n.gauge({name:"gossipsub_rpc_recv_ihave_total",help:"RPC recv"}),rpcRecvIWant:n.gauge({name:"gossipsub_rpc_recv_iwant_total",help:"RPC recv"}),rpcRecvGraft:n.gauge({name:"gossipsub_rpc_recv_graft_total",help:"RPC recv"}),rpcRecvPrune:n.gauge({name:"gossipsub_rpc_recv_prune_total",help:"RPC recv"}),rpcRecvNotAccepted:n.gauge({name:"gossipsub_rpc_rcv_not_accepted_total",help:"Total count of RPC dropped because acceptFrom() == false"}),rpcSentBytes:n.gauge({name:"gossipsub_rpc_sent_bytes_total",help:"RPC sent"}),rpcSentCount:n.gauge({name:"gossipsub_rpc_sent_count_total",help:"RPC sent"}),rpcSentSubscription:n.gauge({name:"gossipsub_rpc_sent_subscription_total",help:"RPC sent"}),rpcSentMessage:n.gauge({name:"gossipsub_rpc_sent_message_total",help:"RPC sent"}),rpcSentControl:n.gauge({name:"gossipsub_rpc_sent_control_total",help:"RPC sent"}),rpcSentIHave:n.gauge({name:"gossipsub_rpc_sent_ihave_total",help:"RPC sent"}),rpcSentIWant:n.gauge({name:"gossipsub_rpc_sent_iwant_total",help:"RPC sent"}),rpcSentGraft:n.gauge({name:"gossipsub_rpc_sent_graft_total",help:"RPC sent"}),rpcSentPrune:n.gauge({name:"gossipsub_rpc_sent_prune_total",help:"RPC sent"}),msgPublishCount:n.gauge({name:"gossipsub_msg_publish_count_total",help:"Total count of msg published by topic",labelNames:["topic"]}),msgPublishPeers:n.gauge({name:"gossipsub_msg_publish_peers_total",help:"Total count of peers that we publish a msg to",labelNames:["topic"]}),msgPublishPeersByGroup:n.gauge({name:"gossipsub_msg_publish_peers_by_group",help:"Total count of peers (by group) that we publish a msg to",labelNames:["topic","peerGroup"]}),msgPublishBytes:n.gauge({name:"gossipsub_msg_publish_bytes_total",help:"Total count of msg publish data.length bytes",labelNames:["topic"]}),msgForwardCount:n.gauge({name:"gossipsub_msg_forward_count_total",help:"Total count of msg forwarded by topic",labelNames:["topic"]}),msgForwardPeers:n.gauge({name:"gossipsub_msg_forward_peers_total",help:"Total count of peers that we forward a msg to",labelNames:["topic"]}),msgReceivedPreValidation:n.gauge({name:"gossipsub_msg_received_prevalidation_total",help:"Total count of recv msgs before any validation",labelNames:["topic"]}),msgReceivedStatus:n.gauge({name:"gossipsub_msg_received_status_total",help:"Tracks distribution of recv msgs by duplicate, invalid, valid",labelNames:["topic","status"]}),msgReceivedInvalid:n.gauge({name:"gossipsub_msg_received_invalid_total",help:"Tracks specific reason of invalid",labelNames:["topic","error"]}),duplicateMsgDeliveryDelay:n.histogram({name:"gossisub_duplicate_msg_delivery_delay_seconds",help:"Time since the 1st duplicated message validated",labelNames:["topic"],buckets:[.25*t.maxMeshMessageDeliveriesWindowSec,.5*t.maxMeshMessageDeliveriesWindowSec,1*t.maxMeshMessageDeliveriesWindowSec,2*t.maxMeshMessageDeliveriesWindowSec,4*t.maxMeshMessageDeliveriesWindowSec]}),duplicateMsgLateDelivery:n.gauge({name:"gossisub_duplicate_msg_late_delivery_total",help:"Total count of late duplicate message delivery by topic, which triggers P3 penalty",labelNames:["topic"]}),scoreFnCalls:n.gauge({name:"gossipsub_score_fn_calls_total",help:"Total times score() is called"}),scoreFnRuns:n.gauge({name:"gossipsub_score_fn_runs_total",help:"Total times score() call actually computed computeScore(), no cache"}),scoreCachedDelta:n.histogram({name:"gossipsub_score_cache_delta",help:"Delta of score between cached values that expired",buckets:[10,100,1e3]}),peersByScoreThreshold:n.gauge({name:"gossipsub_peers_by_score_threshold_count",help:"Current count of peers by score threshold",labelNames:["threshold"]}),score:n.avgMinMax({name:"gossipsub_score",help:"Avg min max of gossip scores",labelNames:["topic","p"]}),scoreWeights:n.avgMinMax({name:"gossipsub_score_weights",help:"Separate score weights",labelNames:["topic","p"]}),scorePerMesh:n.avgMinMax({name:"gossipsub_score_per_mesh",help:"Histogram of the scores for each mesh topic",labelNames:["topic"]}),scoringPenalties:n.gauge({name:"gossipsub_scoring_penalties_total",help:"A counter of the kind of penalties being applied to peers",labelNames:["penalty"]}),behaviourPenalty:n.histogram({name:"gossipsub_peer_stat_behaviour_penalty",help:"Current peer stat behaviour_penalty at each scrape",buckets:[.25*t.behaviourPenaltyThreshold,.5*t.behaviourPenaltyThreshold,1*t.behaviourPenaltyThreshold,2*t.behaviourPenaltyThreshold,4*t.behaviourPenaltyThreshold]}),ihaveRcvIgnored:n.gauge({name:"gossipsub_ihave_rcv_ignored_total",help:"Total received IHAVE messages that we ignore for some reason",labelNames:["reason"]}),ihaveRcvMsgids:n.gauge({name:"gossipsub_ihave_rcv_msgids_total",help:"Total received IHAVE messages by topic",labelNames:["topic"]}),ihaveRcvNotSeenMsgids:n.gauge({name:"gossipsub_ihave_rcv_not_seen_msgids_total",help:"Total messages per topic we do not have, not actual requests",labelNames:["topic"]}),iwantRcvMsgids:n.gauge({name:"gossipsub_iwant_rcv_msgids_total",help:"Total received IWANT messages by topic",labelNames:["topic"]}),iwantRcvDonthaveMsgids:n.gauge({name:"gossipsub_iwant_rcv_dont_have_msgids_total",help:"Total requested messageIDs that we do not have"}),iwantPromiseStarted:n.gauge({name:"gossipsub_iwant_promise_sent_total",help:"Total count of started IWANT promises"}),iwantPromiseResolved:n.gauge({name:"gossipsub_iwant_promise_resolved_total",help:"Total count of resolved IWANT promises"}),iwantPromiseResolvedPeers:n.gauge({name:"gossipsub_iwant_promise_resolved_peers",help:"Total count of peers we have asked IWANT promises that are resolved"}),iwantPromiseBroken:n.gauge({name:"gossipsub_iwant_promise_broken",help:"Total count of broken IWANT promises"}),iwantPromiseDeliveryTime:n.histogram({name:"gossipsub_iwant_promise_delivery_seconds",help:"Histogram of delivery time of resolved IWANT promises",buckets:[.5*t.gossipPromiseExpireSec,1*t.gossipPromiseExpireSec,2*t.gossipPromiseExpireSec,4*t.gossipPromiseExpireSec]}),cacheSize:n.gauge({name:"gossipsub_cache_size",help:"Unbounded cache sizes",labelNames:["cache"]}),mcacheSize:n.gauge({name:"gossipsub_mcache_size",help:"Current mcache msg count"}),topicStrToLabel:e,toTopic(r){return this.topicStrToLabel.get(r)??r},onJoin(r){this.topicSubscriptionStatus.set({topicStr:r},1),this.meshPeerCounts.set({topicStr:r},0)},onLeave(r){this.topicSubscriptionStatus.set({topicStr:r},0),this.meshPeerCounts.set({topicStr:r},0)},onAddToMesh(r,i,s){const o=this.toTopic(r);this.meshPeerInclusionEvents.inc({topic:o,reason:i},s)},onRemoveFromMesh(r,i,s){const o=this.toTopic(r);this.meshPeerChurnEvents.inc({topic:o,reason:i},s)},onReportValidationMcacheHit(r){this.asyncValidationMcacheHit.inc({hit:r?"hit":"miss"})},onReportValidation(r,i){const s=this.toTopic(r);this.asyncValidationResult.inc({topic:s,acceptance:i})},onScorePenalty(r){this.scoringPenalties.inc({penalty:r},1)},onIhaveRcv(r,i,s){const o=this.toTopic(r);this.ihaveRcvMsgids.inc({topic:o},i),this.ihaveRcvNotSeenMsgids.inc({topic:o},s)},onIwantRcv(r,i){for(const[s,o]of r){const a=this.toTopic(s);this.iwantRcvMsgids.inc({topic:a},o)}this.iwantRcvDonthaveMsgids.inc(i)},onForwardMsg(r,i){const s=this.toTopic(r);this.msgForwardCount.inc({topic:s},1),this.msgForwardPeers.inc({topic:s},i)},onPublishMsg(r,i,s,o){const a=this.toTopic(r);this.msgPublishCount.inc({topic:a},1),this.msgPublishBytes.inc({topic:a},s*o),this.msgPublishPeers.inc({topic:a},s),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"direct"},i.direct),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"floodsub"},i.floodsub),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"mesh"},i.mesh),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"fanout"},i.fanout)},onMsgRecvPreValidation(r){const i=this.toTopic(r);this.msgReceivedPreValidation.inc({topic:i},1)},onMsgRecvResult(r,i){const s=this.toTopic(r);this.msgReceivedStatus.inc({topic:s,status:i})},onMsgRecvInvalid(r,i){const s=this.toTopic(r);this.msgReceivedInvalid.inc({topic:s,error:i.reason===Ji.Error?i.error:i.reason},1)},onDuplicateMsgDelivery(r,i,s){if(this.duplicateMsgDeliveryDelay.observe(i/1e3),s){const o=this.toTopic(r);this.duplicateMsgLateDelivery.inc({topic:o},1)}},onRpcRecv(r,i){this.rpcRecvBytes.inc(i),this.rpcRecvCount.inc(1),r.subscriptions&&this.rpcRecvSubscription.inc(r.subscriptions.length),r.messages&&this.rpcRecvMessage.inc(r.messages.length),r.control&&(this.rpcRecvControl.inc(1),r.control.ihave&&this.rpcRecvIHave.inc(r.control.ihave.length),r.control.iwant&&this.rpcRecvIWant.inc(r.control.iwant.length),r.control.graft&&this.rpcRecvGraft.inc(r.control.graft.length),r.control.prune&&this.rpcRecvPrune.inc(r.control.prune.length))},onRpcSent(r,i){if(this.rpcSentBytes.inc(i),this.rpcSentCount.inc(1),r.subscriptions&&this.rpcSentSubscription.inc(r.subscriptions.length),r.messages&&this.rpcSentMessage.inc(r.messages.length),r.control){const s=r.control.ihave?.length??0,o=r.control.iwant?.length??0,a=r.control.graft?.length??0,l=r.control.prune?.length??0;s>0&&this.rpcSentIHave.inc(s),o>0&&this.rpcSentIWant.inc(o),a>0&&this.rpcSentGraft.inc(a),l>0&&this.rpcSentPrune.inc(l),(s>0||o>0||a>0||l>0)&&this.rpcSentControl.inc(1)}},registerScores(r,i){let s=0,o=0,a=0,l=0;for(const _ of r)_>=i.graylistThreshold&&s++,_>=i.publishThreshold&&o++,_>=i.gossipThreshold&&a++,_>=0&&l++;this.peersByScoreThreshold.set({threshold:Ua.graylist},s),this.peersByScoreThreshold.set({threshold:Ua.publish},o),this.peersByScoreThreshold.set({threshold:Ua.gossip},a),this.peersByScoreThreshold.set({threshold:Ua.mesh},l),this.score.set(r)},registerScoreWeights(r){for(const[i,s]of r.byTopic)this.scoreWeights.set({topic:i,p:"p1"},s.p1w),this.scoreWeights.set({topic:i,p:"p2"},s.p2w),this.scoreWeights.set({topic:i,p:"p3"},s.p3w),this.scoreWeights.set({topic:i,p:"p3b"},s.p3bw),this.scoreWeights.set({topic:i,p:"p4"},s.p4w);this.scoreWeights.set({p:"p5"},r.p5w),this.scoreWeights.set({p:"p6"},r.p6w),this.scoreWeights.set({p:"p7"},r.p7w)},registerScorePerMesh(r,i){const s=new Map;r.forEach((o,a)=>{const l=this.topicStrToLabel.get(a)??"unknown";let _=s.get(l);_||(_=new Set,s.set(l,_)),o.forEach(R=>_?.add(R))});for(const[o,a]of s){const l=[];a.forEach(_=>{l.push(i.get(_)??0)}),this.scorePerMesh.set({topic:o},l)}}}}(e.metricsRegister,e.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:t.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:r/1e3});i.mcacheSize.addCollect(()=>this.onScrapeMetrics(i));for(const s of this.multicodecs)i.protocolsEnabled.set({protocol:s},1);this.metrics=i}else this.metrics=null;this.gossipTracer=new $K(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new KK(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:t.heartbeatInterval}),this.maxInboundStreams=e.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams}getPeers(){return[...this.peers.keys()].map(e=>fr(e))}isStarted(){return this.status.code===_i.started}init(e){var t=this;return $(function*(){t.components=e,t.score.init(e)})()}start(){var e=this;return $(function*(){if(e.isStarted())return;e.log("starting"),e.publishConfig=yield function RK(n,e){return ME.apply(this,arguments)}(e.globalSignaturePolicy,e.components.getPeerId()),e.outboundInflightQueue=Mc({objectMode:!0}),qn(e.outboundInflightQueue,function(){var o=$(function*(a){var R,l=!1,_=!1;try{for(var B,N=Pt(a);l=!(B=yield N.next()).done;l=!1){const{peerId:z,connection:Z}=B.value;yield e.createOutboundStream(z,Z)}}catch(z){_=!0,R=z}finally{try{l&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()).catch(o=>e.log.error("outbound inflight queue error",o)),yield Promise.all(e.opts.directPeers.map(function(){var o=$(function*(a){yield e.components.getPeerStore().addressBook.add(a.id,a.addrs)});return function(a){return o.apply(this,arguments)}}()));const t=e.components.getRegistrar();yield Promise.all(e.multicodecs.map(o=>t.handle(o,e.onIncomingStream.bind(e),{maxInboundStreams:e.maxInboundStreams,maxOutboundStreams:e.maxOutboundStreams})));const r=function QH(n){return new YH(n)}({onConnect:e.onPeerConnected.bind(e),onDisconnect:e.onPeerDisconnected.bind(e)}),i=yield Promise.all(e.multicodecs.map(o=>t.register(o,r))),s=setTimeout(e.runHeartbeat,100);e.status={code:_i.started,registrarTopologyIds:i,heartbeatTimeout:s,hearbeatStartMs:Date.now()+100},e.score.start(),e.directPeerInitial=setTimeout(()=>{Promise.resolve().then($(function*(){yield Promise.all(Array.from(e.direct).map(function(){var o=$(function*(a){return yield e.connect(a)});return function(a){return o.apply(this,arguments)}}()))})).catch(o=>{e.log(o)})},1e3),e.log("started")})()}stop(){var e=this;return $(function*(){if(e.log("stopping"),e.status.code!==_i.started)return;const{registrarTopologyIds:t}=e.status;e.status={code:_i.stopped};const r=e.components.getRegistrar();t.forEach(i=>r.unregister(i)),e.outboundInflightQueue.end();for(const i of e.streamsOutbound.values())i.close();e.streamsOutbound.clear();for(const i of e.streamsInbound.values())i.close();e.streamsInbound.clear(),e.peers.clear(),e.subscriptions.clear(),e.heartbeatTimer&&(e.heartbeatTimer.cancel(),e.heartbeatTimer=null),e.score.stop(),e.mesh.clear(),e.fanout.clear(),e.fanoutLastpub.clear(),e.gossip.clear(),e.control.clear(),e.peerhave.clear(),e.iasked.clear(),e.backoff.clear(),e.outbound.clear(),e.gossipTracer.clear(),e.seenCache.clear(),e.fastMsgIdCache&&e.fastMsgIdCache.clear(),e.directPeerInitial&&clearTimeout(e.directPeerInitial),e.log("stopped")})()}dumpPeerScoreStats(){return this.score.dumpPeerScoreStats()}onIncomingStream({stream:e,connection:t}){if(!this.isStarted())return;const r=t.remotePeer;this.addPeer(r,t.stat.direction),this.createInboundStream(r,e),this.outboundInflightQueue.push({peerId:r,connection:t})}onPeerConnected(e,t){!this.isStarted()||(this.addPeer(e,t.stat.direction),this.outboundInflightQueue.push({peerId:e,connection:t}))}onPeerDisconnected(e){this.log("connection ended %p",e),this.removePeer(e)}createOutboundStream(e,t){var r=this;return $(function*(){if(!r.isStarted())return;const i=e.toString();if(r.peers.has(i)&&!r.streamsOutbound.has(i))try{const s=new t$(yield t.newStream(r.multicodecs),a=>r.log.error("outbound pipe error",a),{maxBufferSize:r.opts.maxOutboundBufferSize});r.log("create outbound stream %p",e),r.streamsOutbound.set(i,s);const o=s.protocol;o===VA&&r.floodsubPeers.add(i),r.metrics?.peersPerProtocol.inc({protocol:o},1),r.subscriptions.size>0&&(r.log("send subscriptions to",i),r.sendSubscriptions(i,Array.from(r.subscriptions),!0))}catch(s){r.log.error("createOutboundStream error",s)}})()}createInboundStream(e,t){var r=this;return $(function*(){if(!r.isStarted())return;const i=e.toString();if(!r.peers.has(i))return;const s=r.streamsInbound.get(i);void 0!==s&&(r.log("replacing existing inbound steam %s",i),s.close()),r.log("create inbound stream %s",i);const o=new n$(t);r.streamsInbound.set(i,o),r.pipePeerReadStream(e,o.source).catch(a=>r.log(a))})()}addPeer(e,t){const r=e.toString();this.peers.has(r)||(this.log("new peer %p",e),this.peers.add(r),this.score.addPeer(r),this.outbound.has(r)||this.outbound.set(r,"outbound"===t))}removePeer(e){const t=e.toString();if(!this.peers.has(t))return;this.log("delete peer %p",e),this.peers.delete(t);const r=this.streamsOutbound.get(t),i=this.streamsInbound.get(t);r&&this.metrics?.peersPerProtocol.inc({protocol:r.protocol},-1),r?.close(),i?.close(),this.streamsOutbound.delete(t),this.streamsInbound.delete(t);for(const s of this.topics.values())s.delete(t);for(const[s,o]of this.mesh)!0===o.delete(t)&&this.metrics?.onRemoveFromMesh(s,Fa.Dc,1);for(const s of this.fanout.values())s.delete(t);this.floodsubPeers.delete(t),this.gossip.delete(t),this.control.delete(t),this.outbound.delete(t),this.score.removePeer(t),this.acceptFromWhitelist.delete(t)}get started(){return this.status.code===_i.started}getMeshPeers(e){const t=this.mesh.get(e);return t?Array.from(t):[]}getSubscribers(e){const t=this.topics.get(e);return(t?Array.from(t):[]).map(r=>fr(r))}getTopics(){return Array.from(this.subscriptions)}pipePeerReadStream(e,t){var r=this;return $(function*(){try{yield qn(t,function(){var i=$(function*(s){var l,o=!1,a=!1;try{for(var R,_=Pt(s);o=!(R=yield _.next()).done;o=!1){const N=R.value;try{const B=N.subarray(),z=op.decode(B);r.metrics?.onRpcRecv(z,B.length),r.opts.awaitRpcHandler?yield r.handleReceivedRpc(e,z):r.handleReceivedRpc(e,z).catch(Z=>r.log(Z))}catch(B){r.log(B)}}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw l}}});return function(s){return i.apply(this,arguments)}}())}catch(i){r.log.error(i),r.onPeerDisconnected(e)}})()}handleReceivedRpc(e,t){var r=this;return $(function*(){if(!r.acceptFrom(e.toString()))return r.log("received message from unacceptable peer %p",e),void r.metrics?.rpcRecvNotAccepted.inc();if(r.log("rpc from %p",e),t.subscriptions&&t.subscriptions.length>0&&(t.subscriptions.forEach(i=>{r.handleReceivedSubscription(e,i)}),r.dispatchEvent(new nn("subscription-change",{detail:{peerId:e,subscriptions:t.subscriptions.filter(i=>null!==i.topic).map(i=>({topic:i.topic??"",subscribe:Boolean(i.subscribe)}))}}))),t.messages)for(const i of t.messages){const s=r.handleReceivedMessage(e,i).catch(o=>r.log(o));r.opts.awaitRpcMessageHandler&&(yield s)}t.control&&(yield r.handleControlMessage(e.toString(),t.control))})()}handleReceivedSubscription(e,t){if(null==t.topic)return;this.log("subscription update from %p topic %s",e,t.topic);let r=this.topics.get(t.topic);null==r&&(r=new Set,this.topics.set(t.topic,r)),t.subscribe?r.add(e.toString()):r.delete(e.toString())}handleReceivedMessage(e,t){var r=()=>super.dispatchEvent,i=this;return $(function*(){i.metrics?.onMsgRecvPreValidation(t.topic);const s=yield i.validateReceivedMessage(e,t);switch(i.metrics?.onMsgRecvResult(t.topic,s.code),s.code){case es.duplicate:return i.score.duplicateMessage(e.toString(),s.msgIdStr,t.topic),void i.mcache.observeDuplicate(s.msgIdStr,e.toString());case es.invalid:if(s.msgIdStr){const o=s.msgIdStr;i.score.rejectMessage(e.toString(),o,t.topic,s.reason),i.gossipTracer.rejectMessage(o,s.reason)}else i.score.rejectInvalidMessage(e.toString(),t.topic);return void i.metrics?.onMsgRecvInvalid(t.topic,s);case es.valid:i.score.validateMessage(s.messageId.msgIdStr),i.gossipTracer.deliverMessage(s.messageId.msgIdStr),i.mcache.put(s.messageId,t,!i.opts.asyncValidation),i.subscriptions.has(t.topic)&&(!i.components.getPeerId().equals(e)||i.opts.emitSelf)&&(r().call(i,new nn("gossipsub:message",{detail:{propagationSource:e,msgId:s.messageId.msgIdStr,msg:s.msg}})),r().call(i,new nn("message",{detail:s.msg}))),i.opts.asyncValidation||i.forwardMessage(s.messageId.msgIdStr,t,e.toString())}})()}validateReceivedMessage(e,t){var r=this;return $(function*(){const i=r.fastMsgIdFn?.(t),s=i?r.fastMsgIdCache?.get(i):void 0;if(s)return{code:es.duplicate,msgIdStr:s};const o=yield function GK(n,e){return LE.apply(this,arguments)}(r.globalSignaturePolicy,t);if(!o.valid)return{code:es.invalid,reason:Ji.Error,error:o.error};const a=o.message;try{r.dataTransform&&(a.data=r.dataTransform.inboundTransform(t.topic,a.data))}catch(B){return r.log("Invalid message, transform failed",B),{code:es.invalid,reason:Ji.Error,error:li.TransformFailed}}const l=yield r.msgIdFn(a),_=r.msgIdToStrFn(l),R={msgId:l,msgIdStr:_};if(i&&r.fastMsgIdCache?.put(i,_),r.seenCache.has(_))return{code:es.duplicate,msgIdStr:_};r.seenCache.put(_);const N=r.topicValidators.get(t.topic);if(null!=N){let B;try{B=yield N(a.topic,a,e)}catch(z){const Z=z.code;"ERR_TOPIC_VALIDATOR_IGNORE"===Z&&(B=$s.Ignore),B="ERR_TOPIC_VALIDATOR_REJECT"===Z?$s.Reject:$s.Ignore}if(B!==$s.Accept)return{code:es.invalid,reason:$A(B),msgIdStr:_}}return{code:es.valid,messageId:R,msg:a}})()}getScore(e){return this.score.score(e)}sendSubscriptions(e,t,r){this.sendRpc(e,{subscriptions:t.map(i=>({topic:i,subscribe:r})),messages:[]})}handleControlMessage(e,t){var r=this;return $(function*(){if(void 0===t)return;const i=t.ihave?r.handleIHave(e,t.ihave):[],s=t.iwant?r.handleIWant(e,t.iwant):[],o=t.graft?yield r.handleGraft(e,t.graft):[];t.prune&&(yield r.handlePrune(e,t.prune)),(i.length||s.length||o.length)&&r.sendRpc(e,bo(s,{iwant:i,prune:o}))})()}acceptFrom(e){if(this.direct.has(e))return!0;const t=Date.now(),r=this.acceptFromWhitelist.get(e);if(r&&r.messagesAccepted<128&&r.acceptUntil>=t)return r.messagesAccepted+=1,!0;const i=this.score.score(e);return i>=0?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+1e3}):this.acceptFromWhitelist.delete(e),i>=this.opts.scoreThresholds.graylistThreshold}handleIHave(e,t){if(!t.length)return[];const r=this.score.score(e);if(r10)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,i),this.metrics?.ihaveRcvIgnored.inc({reason:mu.MaxIhave}),[];const s=this.iasked.get(e)??0;if(s>=pu)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,s),this.metrics?.ihaveRcvIgnored.inc({reason:mu.MaxIasked}),[];const o=new Map;if(t.forEach(({topicID:_,messageIDs:R})=>{if(!_||!R||!this.mesh.has(_))return;let N=0;R.forEach(B=>{const z=this.msgIdToStrFn(B);this.seenCache.has(z)||(o.set(z,B),N++)}),this.metrics?.onIhaveRcv(_,R.length,N)}),!o.size)return[];let a=o.size;a+s>pu&&(a=pu-s),this.log("IHAVE: Asking for %d out of %d messages from %s",a,o.size,e);let l=Array.from(o.values());return wo(l),l=l.slice(0,a),this.iasked.set(e,s+a),this.gossipTracer.addPromise(e,l),[{messageIDs:l}]}handleIWant(e,t){if(!t.length)return[];const r=this.score.score(e);if(r{a&&a.forEach(l=>{const _=this.msgIdToStrFn(l),R=this.mcache.getWithIWantCount(_,e);null!=R?(s.set(R.msg.topic,1+(s.get(R.msg.topic)??0)),R.count>3?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,l):i.set(_,R.msg)):o++})}),this.metrics?.onIwantRcv(s,o),i.size?(this.log("IWANT: Sending %d messages to %s",i.size,e),Array.from(i.values())):(this.log("IWANT: Could not provide any wanted messages to %s",e),[])}handleGraft(e,t){var r=this;return $(function*(){const i=[],s=r.score.score(e),o=Date.now();let a=r.opts.doPX;return t.forEach(({topicID:l})=>{if(!l)return;const _=r.mesh.get(l);if(!_)return void(a=!1);if(_.has(e))return;if(r.direct.has(e))return r.log("GRAFT: ignoring request from direct peer %s",e),i.push(l),void(a=!1);const R=r.backoff.get(l)?.get(e);return"number"==typeof R&&o=r.opts.Dhi&&!r.outbound.get(e)?(i.push(l),void r.addBackoff(e,l)):(r.log("GRAFT: Add mesh link from %s in %s",e,l),r.score.graft(e,l),_.add(e),void r.metrics?.onAddToMesh(l,_o.Subscribed,1))}),i.length?yield Promise.all(i.map(l=>r.makePrune(e,l,a))):[]})()}handlePrune(e,t){var r=this;return $(function*(){const i=r.score.score(e);for(const{topicID:s,backoff:o,peers:a}of t){if(null==s)continue;const l=r.mesh.get(s);if(!l)return;if(r.log("PRUNE: Remove mesh link to %s in %s",e,s),r.score.prune(e,s),l.has(e)&&(l.delete(e),r.metrics?.onRemoveFromMesh(s,Fa.Unsub,1)),"number"==typeof o&&o>0?r.doAddBackoff(e,s,1e3*o):r.addBackoff(e,s),a&&a.length){if(i{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",t,e),this.score.addPenalty(t,e,yu.BrokenPromise)})}clearBackoff(){if(this.heartbeatTicks%15!=0)return;const e=Date.now();this.backoff.forEach((t,r)=>{t.forEach((i,s)=>{i{e.streamsOutbound.has(r)||t.push(r)}),yield Promise.all(t.map(function(){var r=$(function*(i){return yield e.connect(i)});return function(i){return r.apply(this,arguments)}}()))})()}pxConnect(e){var t=this;return $(function*(){e.length>t.opts.prunePeers&&(wo(e),e=e.slice(0,t.opts.prunePeers));const r=[];yield Promise.all(e.map(function(){var i=$(function*(s){if(!s.peerID)return;const o=Jc(s.peerID).toString();if(!t.peers.has(o)){if(!s.signedPeerRecord)return void r.push(o);try{const a=yield wi.openAndCertify(s.signedPeerRecord,"libp2p-peer-record"),l=a.peerId;if(!a.peerId.equals(o))return void t.log("bogus peer record obtained through px: peer ID %p doesn't match expected peer %p",l,o);if(!(yield t.components.getPeerStore().addressBook.consumePeerRecord(a)))return void t.log("bogus peer record obtained through px: could not add peer record to address book");r.push(o)}catch{t.log("bogus peer record obtained through px: invalid signature or not a peer record")}}});return function(s){return i.apply(this,arguments)}}())),r.length&&(yield Promise.all(r.map(function(){var i=$(function*(s){return yield t.connect(s)});return function(s){return i.apply(this,arguments)}}())))})()}connect(e){var t=this;return $(function*(){t.log("Initiating connection with %s",e);const r=fr(e),i=yield t.components.getConnectionManager().openConnection(r);for(const s of t.multicodecs)for(const o of t.components.getRegistrar().getTopologies(s))o.onConnect(r,i)})()}subscribe(e){if(this.status.code!==_i.started)throw new Error("Pubsub has not started");if(!this.subscriptions.has(e)){this.subscriptions.add(e);for(const t of this.peers.keys())this.sendSubscriptions(t,[e],!0)}this.join(e)}unsubscribe(e){if(this.status.code!==_i.started)throw new Error("Pubsub is not started");const t=this.subscriptions.delete(e);if(this.log("unsubscribe from %s - am subscribed %s",e,t),t)for(const r of this.peers.keys())this.sendSubscriptions(r,[e],!1);this.leave(e).catch(r=>{this.log(r)})}join(e){if(this.status.code!==_i.started)throw new Error("Gossipsub has not started");if(this.mesh.has(e))return;this.log("JOIN %s",e),this.metrics?.onJoin(e);const t=new Set,r=this.fanout.get(e);if(r&&(this.fanout.delete(e),this.fanoutLastpub.delete(e),r.forEach(i=>{!this.direct.has(i)&&this.score.score(i)>=0&&t.add(i)}),this.metrics?.onAddToMesh(e,_o.Fanout,t.size)),t.size!t.has(o)&&!this.direct.has(o)&&this.score.score(o)>=0).forEach(o=>{t.add(o)}),this.metrics?.onAddToMesh(e,_o.Random,t.size-i)}this.mesh.set(e,t),t.forEach(i=>{this.log("JOIN: Add mesh link to %s in %s",i,e),this.sendGraft(i,e)})}leave(e){var t=this;return $(function*(){if(t.status.code!==_i.started)throw new Error("Gossipsub has not started");t.log("LEAVE %s",e),t.metrics?.onLeave(e);const r=t.mesh.get(e);r&&(yield Promise.all(Array.from(r).map(function(){var i=$(function*(s){return t.log("LEAVE: Remove mesh link to %s in %s",s,e),yield t.sendPrune(s,e)});return function(s){return i.apply(this,arguments)}}())),t.mesh.delete(e))})()}selectPeersToForward(e,t,r){const i=new Set,s=this.topics.get(e);s&&(this.direct.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&i.add(a)}),this.floodsubPeers.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&this.score.score(a)>=this.opts.scoreThresholds.publishThreshold&&i.add(a)}));const o=this.mesh.get(e);return o&&o.size>0&&o.forEach(a=>{t!==a&&!r?.has(a)&&i.add(a)}),i}selectPeersToPublish(e){const t=new Set,r={direct:0,floodsub:0,mesh:0,fanout:0},i=this.topics.get(e);if(i)if(this.opts.floodPublish)i.forEach(s=>{this.direct.has(s)?(t.add(s),r.direct++):this.score.score(s)>=this.opts.scoreThresholds.publishThreshold&&(t.add(s),r.floodsub++)});else{this.direct.forEach(o=>{i.has(o)&&(t.add(o),r.direct++)}),this.floodsubPeers.forEach(o=>{i.has(o)&&this.score.score(o)>=this.opts.scoreThresholds.publishThreshold&&(t.add(o),r.floodsub++)});const s=this.mesh.get(e);if(s&&s.size>0)s.forEach(o=>{t.add(o),r.mesh++});else{const o=this.fanout.get(e);if(o&&o.size>0)o.forEach(a=>{t.add(a),r.fanout++});else{const a=this.getRandomGossipPeers(e,this.opts.D,l=>this.score.score(l)>=this.opts.scoreThresholds.publishThreshold);a.size>0&&(this.fanout.set(e,a),a.forEach(l=>{t.add(l),r.fanout++}))}this.fanoutLastpub.set(e,Date.now())}}return{tosend:t,tosendCount:r}}forwardMessage(e,t,r,i){r&&this.score.deliverMessage(r,e,t.topic);const s=this.selectPeersToForward(t.topic,r,i),o=bo([t]);s.forEach(a=>{this.sendRpc(a,o)}),this.metrics?.onForwardMsg(t.topic,s.size)}publish(e,t){var r=()=>super.dispatchEvent,i=this;return $(function*(){const s=i.dataTransform?i.dataTransform.outboundTransform(e,t):t;if(null==i.publishConfig)throw Error("PublishError.Uninitialized");const{raw:o,msg:a}=yield function zK(n,e,t,r){return kE.apply(this,arguments)}(i.publishConfig,e,t,s),l=yield i.msgIdFn(a),_=i.msgIdToStrFn(l);if(i.seenCache.has(_))throw Error("PublishError.Duplicate");const{tosend:R,tosendCount:N}=i.selectPeersToPublish(e),B=!0===i.opts.emitSelf&&i.subscriptions.has(e);if(0===R.size&&!i.opts.allowPublishToZeroPeers&&!B)throw Error("PublishError.InsufficientPeers");i.seenCache.put(_),i.mcache.put({msgId:l,msgIdStr:_},o,!0),i.publishedMessageIds.put(_);const z=bo([o]);for(const Z of R)i.sendRpc(Z,z)||R.delete(Z);return i.metrics?.onPublishMsg(e,N,R.size,null!=o.data?o.data.length:0),B&&(R.add(i.components.getPeerId().toString()),r().call(i,new nn("gossipsub:message",{detail:{propagationSource:i.components.getPeerId(),msgId:_,msg:a}})),r().call(i,new nn("message",{detail:a}))),{recipients:Array.from(R.values()).map(Z=>fr(Z))}})()}reportMessageValidationResult(e,t,r){if(r===$s.Accept){const i=this.mcache.validate(e);if(this.metrics?.onReportValidationMcacheHit(null!==i),null!=i){const{message:s,originatingPeers:o}=i;this.score.deliverMessage(t.toString(),e,s.topic),this.forwardMessage(e,i.message,t.toString(),o),this.metrics?.onReportValidation(s.topic,r)}}else{const i=this.mcache.remove(e);if(this.metrics?.onReportValidationMcacheHit(null!==i),i){const s=$A(r),{message:o,originatingPeers:a}=i;this.score.rejectMessage(t.toString(),e,o.topic,s);for(const l of a)this.score.rejectMessage(l,e,o.topic,s);this.metrics?.onReportValidation(o.topic,r)}}}sendGraft(e,t){const i=bo([],{graft:[{topicID:t}]});this.sendRpc(e,i)}sendPrune(e,t){var r=this;return $(function*(){const s=bo([],{prune:[yield r.makePrune(e,t,r.opts.doPX)]});r.sendRpc(e,s)})()}sendRpc(e,t){const r=this.streamsOutbound.get(e);if(!r)return this.log(`Cannot send RPC to ${e} as there is no open stream to it available`),!1;const i=this.control.get(e);i&&(this.piggybackControl(e,t,i),this.control.delete(e));const s=this.gossip.get(e);s&&(this.piggybackGossip(e,t,s),this.gossip.delete(e));const o=op.encode(t).finish();try{r.push(o)}catch(a){return this.log.error(`Cannot send rpc to ${e}`,a),i&&this.control.set(e,i),s&&this.gossip.set(e,s),!1}return this.metrics?.onRpcSent(t,o.length),!0}piggybackControl(e,t,r){const i=(r.graft||[]).filter(({topicID:o})=>(o&&this.mesh.get(o)||new Set).has(e)),s=(r.prune||[]).filter(({topicID:o})=>!(o&&this.mesh.get(o)||new Set).has(e));!i.length&&!s.length||(t.control?(t.control.graft=t.control.graft&&t.control.graft.concat(i),t.control.prune=t.control.prune&&t.control.prune.concat(s)):t.control={graft:i,prune:s,ihave:[],iwant:[]})}piggybackGossip(e,t,r){t.control||(t.control={ihave:[],iwant:[],graft:[],prune:[]}),t.control.ihave=r}sendGraftPrune(e,t,r){var i=this;return $(function*(){const s=i.opts.doPX;for(const[o,a]of e){const l=a.map(B=>({topicID:B}));let _=[];const R=t.get(o);R&&(_=yield Promise.all(R.map(function(){var B=$(function*(z){return yield i.makePrune(o,z,s&&!r.get(o))});return function(z){return B.apply(this,arguments)}}())),t.delete(o));const N=bo([],{graft:l,prune:_});i.sendRpc(o,N)}for(const[o,a]of t){const l=yield Promise.all(a.map(function(){var R=$(function*(N){return yield i.makePrune(o,N,s&&!r.get(o))});return function(N){return R.apply(this,arguments)}}())),_=bo([],{prune:l});i.sendRpc(o,_)}})()}emitGossip(e){const t=this.mcache.getGossipIDs(new Set(e.keys()));for(const[r,i]of e)this.doEmitGossip(r,i,t.get(r)??[])}doEmitGossip(e,t,r){if(!r.length||(wo(r),r.length>pu&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length),!t.size))return;let i=this.opts.Dlazy;const s=.25*t.size;let o=t;s>i&&(i=s),i>o.size?i=o.size:o=wo(Array.from(o)).slice(0,i),o.forEach(a=>{let l=r;r.length>pu&&(l=wo(l.slice()).slice(0,pu)),this.pushGossip(a,{topicID:e,messageIDs:l})})}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,bo([],{ihave:t}));for(const[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,bo([],{graft:t.graft,prune:t.prune}))}pushGossip(e,t){this.log("Add gossip to %s",e);const r=this.gossip.get(e)||[];this.gossip.set(e,r.concat(t))}makePrune(e,t,r){var i=this;return $(function*(){if(i.score.prune(e,t),i.streamsOutbound.get(e).protocol===HA)return{topicID:t,peers:[]};const s=i.opts.pruneBackoff/1e3;if(!r)return{topicID:t,peers:[],backoff:s};const o=i.getRandomGossipPeers(t,i.opts.prunePeers,l=>l!==e&&i.score.score(l)>=0),a=yield Promise.all(Array.from(o).map(function(){var l=$(function*(_){const R=fr(_);return{peerID:R.toBytes(),signedPeerRecord:yield i.components.getPeerStore().addressBook.getRawEnvelope(R)}});return function(_){return l.apply(this,arguments)}}()));return{topicID:t,peers:a,backoff:s}})()}heartbeat(){var e=this;return $(function*(){const{D:t,Dlo:r,Dhi:i,Dscore:s,Dout:o,fanoutTTL:a}=e.opts;e.heartbeatTicks++;const l=new Map,_=J=>{let se=l.get(J);return void 0===se&&(se=e.score.score(J),l.set(J,se)),se},R=new Map,N=new Map,B=new Map;e.clearBackoff(),e.peerhave.clear(),e.metrics?.cacheSize.set({cache:"iasked"},e.iasked.size),e.iasked.clear(),e.applyIwantPenalties(),e.heartbeatTicks%e.opts.directConnectTicks==0&&(yield e.directConnect()),e.fastMsgIdCache?.prune(),e.seenCache.prune(),e.gossipTracer.prune(),e.publishedMessageIds.prune();const z=new Map;e.mesh.forEach((J,se)=>{const he=e.topics.get(se),Te=new Set,ue=new Set;if(z.set(se,ue),he){const Pe=wo(Array.from(he)),bt=e.backoff.get(se);for(const yt of Pe){const Xt=e.streamsOutbound.get(yt);if(Xt&&e.multicodecs.includes(Xt.protocol)&&!J.has(yt)&&!e.direct.has(yt)){const pn=_(yt);(!bt||!bt.has(yt))&&pn>=0&&Te.add(yt),pn>=e.opts.scoreThresholds.gossipThreshold&&ue.add(yt)}}}const Re=(Pe,bt)=>{e.log("HEARTBEAT: Remove mesh link to %s in %s",Pe,se),e.addBackoff(Pe,se),J.delete(Pe),_(Pe)>=e.opts.scoreThresholds.gossipThreshold&&ue.add(Pe),e.metrics?.onRemoveFromMesh(se,bt,1);const yt=N.get(Pe);yt?yt.push(se):N.set(Pe,[se])},$e=(Pe,bt)=>{e.log("HEARTBEAT: Add mesh link to %s in %s",Pe,se),e.score.graft(Pe,se),J.add(Pe),ue.delete(Pe),e.metrics?.onAddToMesh(se,bt,1);const yt=R.get(Pe);yt?yt.push(se):R.set(Pe,[se])};if(J.forEach(Pe=>{const bt=_(Pe);bt<0&&(e.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",Pe,bt,se),Re(Pe,Fa.BadScore),B.set(Pe,!0))}),J.size!0)}(Te,t-J.size).forEach(yt=>{$e(yt,_o.NotEnough)}),J.size>i){let Pe=Array.from(J);Pe.sort((yt,Xt)=>_(Xt)-_(yt)),Pe=Pe.slice(0,s).concat(wo(Pe.slice(s)));let bt=0;if(Pe.slice(0,t).forEach(yt=>{e.outbound.get(yt)&&bt++}),bt{const Gn=Pe[pn];for(let Di=pn;Di>0;Di--)Pe[Di]=Pe[Di-1];Pe[0]=Gn};if(bt>0){let pn=bt;for(let Gn=1;Gn0;Gn++)e.outbound.get(Pe[Gn])&&(yt(Gn),pn--)}let Xt=t-bt;for(let pn=t;pn0;pn++)e.outbound.get(Pe[pn])&&(yt(pn),Xt--)}Pe.slice(t).forEach(yt=>{Re(yt,Fa.Excess)})}if(J.size>=r){let Pe=0;J.forEach(bt=>{e.outbound.get(bt)&&Pe++}),Pe!0===e.outbound.get(Xt)).forEach(Xt=>{$e(Xt,_o.Outbound)})}if(e.heartbeatTicks%e.opts.opportunisticGraftTicks==0&&J.size>1){const Pe=Array.from(J).sort((Xt,pn)=>_(Xt)-_(pn)),bt=Math.floor(J.size/2),yt=_(Pe[bt]);if(yt_(Gn)>yt);for(const Gn of pn)e.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",Gn,se),$e(Gn,_o.Opportunistic)}}});const Z=Date.now();e.fanoutLastpub.forEach((J,se)=>{J+a{const he=e.topics.get(se);J.forEach($e=>{(!he.has($e)||_($e)=e.opts.scoreThresholds.publishThreshold&&ue.push(Pe),yt>=e.opts.scoreThresholds.gossipThreshold&&Re.add(Pe)}}}J.size{J.add(Pe),Re?.delete(Pe)})}),e.emitGossip(z),yield e.sendGraftPrune(R,N,B),e.flush(),e.mcache.shift(),e.dispatchEvent(new nn("gossipsub:heartbeat"))})()}getRandomGossipPeers(e,t,r=(()=>!0)){const i=this.topics.get(e);if(!i)return new Set;let s=[];return i.forEach(o=>{const a=this.streamsOutbound.get(o);!a||this.multicodecs.includes(a.protocol)&&r(o)&&s.push(o)}),s=wo(s),t>0&&s.length>t&&(s=s.slice(0,t)),new Set(s)}onScrapeMetrics(e){e.mcacheSize.set(this.mcache.size),e.cacheSize.set({cache:"direct"},this.direct.size),e.cacheSize.set({cache:"seenCache"},this.seenCache.size),e.cacheSize.set({cache:"fastMsgIdCache"},this.fastMsgIdCache?.size??0),e.cacheSize.set({cache:"publishedMessageIds"},this.publishedMessageIds.size),e.cacheSize.set({cache:"mcache"},this.mcache.size),e.cacheSize.set({cache:"score"},this.score.size),e.cacheSize.set({cache:"gossipTracer.promises"},this.gossipTracer.size),e.cacheSize.set({cache:"gossipTracer.requests"},this.gossipTracer.requestMsByMsgSize),e.cacheSize.set({cache:"topics"},this.topics.size),e.cacheSize.set({cache:"subscriptions"},this.subscriptions.size),e.cacheSize.set({cache:"mesh"},this.mesh.size),e.cacheSize.set({cache:"fanout"},this.fanout.size),e.cacheSize.set({cache:"peers"},this.peers.size),e.cacheSize.set({cache:"streamsOutbound"},this.streamsOutbound.size),e.cacheSize.set({cache:"streamsInbound"},this.streamsInbound.size),e.cacheSize.set({cache:"acceptFromWhitelist"},this.acceptFromWhitelist.size),e.cacheSize.set({cache:"gossip"},this.gossip.size),e.cacheSize.set({cache:"control"},this.control.size),e.cacheSize.set({cache:"peerhave"},this.peerhave.size),e.cacheSize.set({cache:"outbound"},this.outbound.size);let t=0;for(const o of this.backoff.values())t+=o.size;e.cacheSize.set({cache:"backoff"},t);for(const[o,a]of this.topics)e.topicPeersCount.set({topicStr:o},a.size);for(const[o,a]of this.mesh)e.meshPeerCounts.set({topicStr:o},a.size);const r=[],i=new Map;e.behaviourPenalty.reset();for(const o of this.peers.keys()){const a=this.score.score(o);r.push(a),i.set(o,a),e.behaviourPenalty.observe(this.score.peerStats.get(o)?.behaviourPenalty??0)}e.registerScores(r,this.opts.scoreThresholds),e.registerScorePerMesh(this.mesh,i);const s=function JK(n,e,t,r,i){const s={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]};for(const o of n){const a=e.get(o);if(a){const l=XK(o,a,t,r,i);for(const[_,R]of l.byTopic){let N=s.byTopic.get(_);N||(N={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},s.byTopic.set(_,N)),N.p1w.push(R.p1w),N.p2w.push(R.p2w),N.p3w.push(R.p3w),N.p3bw.push(R.p3bw),N.p4w.push(R.p4w)}s.p5w.push(l.p5w),s.p6w.push(l.p6w),s.p7w.push(l.p7w),s.score.push(l.score)}else s.p5w.push(0),s.p6w.push(0),s.p7w.push(0),s.score.push(0)}return s}(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(s)}}zA.multicodec=PE;const UE=_r("waku:relay");class VE extends zA{constructor(e){super(e=Object.assign(e??{},{globalSignaturePolicy:cp.StrictNoSign,fallbackToFloodsub:!1})),this.multicodecs=ka,this.observers={},this.decryptionKeys=new Map,this.pubSubTopic=e?.pubSubTopic??"/waku/2/default-waku/proto",e?.decryptionKeys?.forEach(t=>{this.addDecryptionKey(t)})}start(){var e=()=>super.start,t=this;return $(function*(){yield e().call(t),t.subscribe(t.pubSubTopic)})()}send(e){var t=this;return $(function*(){const r=e.encode();yield t.publish(t.pubSubTopic,r)})()}addDecryptionKey(e,t){this.decryptionKeys.set(cu(e),t??{})}deleteDecryptionKey(e){this.decryptionKeys.delete(cu(e))}addObserver(e,t=[]){0===t.length?(this.observers[""]||(this.observers[""]=new Set),this.observers[""].add(e)):t.forEach(r=>{this.observers[r]||(this.observers[r]=new Set),this.observers[r].add(e)})}deleteObserver(e,t=[]){0===t.length?this.observers[""]&&this.observers[""].delete(e):t.forEach(r=>{this.observers[r]&&this.observers[r].delete(e)})}subscribe(e){this.addEventListener("gossipsub:message",t=>{if(t.detail.msg.topic===e){const r=Array.from(this.decryptionKeys).map(([i,{method:s,contentTopics:o}])=>({key:i,method:s,contentTopics:o}));UE(`Message received on ${e}`),oa.decode(t.detail.msg.data,r).then(i=>{i?(this.observers[""]&&this.observers[""].forEach(s=>{s(i)}),i.contentTopic&&this.observers[i.contentTopic]&&this.observers[i.contentTopic].forEach(s=>{s(i)})):UE("Failed to decode Waku Message")}).catch(i=>{UE("Failed to decode Waku Message",i)})}}),super.subscribe(e)}getMeshPeers(e){return super.getMeshPeers(e??this.pubSubTopic)}}function KE(){return KE=$(function*(n){const e=n?.libp2p??{},t=e.peerDiscovery??[];n?.defaultBootstrap&&(t.push(up()),Object.assign(e,{peerDiscovery:t}));const r=yield fp(new VE(n),e);return new WH(n??{},r)}),KE.apply(this,arguments)}function up(){return new uH(function fH(n=au.Prod,e=1){if(e<=0)return[];let t;switch(n){case au.Prod:t=fE_fleets["wakuv2.prod"]["waku-websocket"];break;case au.Test:t=fE_fleets["wakuv2.test"]["waku-websocket"];break;default:t=fE_fleets["wakuv2.prod"]["waku-websocket"]}return t=Object.values(t),t=t.map(r=>new mn(r)),_A(t,e)}())}function fp(n,e){return zE.apply(this,arguments)}function zE(){return zE=$(function*(n,e){return oH(Object.assign({transports:[new bV({filter:eT})],streamMuxers:[new uU],connectionEncryption:[new K5]},n?{pubsub:n}:{},e??{}))}),zE.apply(this,arguments)}VE.multicodec=ka[0],VE.multicodec=ka[ka.length-1];function s$(n,e,t){"function"==typeof t&&(t={filter:t});const r=function i$(n,e,t){let r;const i=new Promise((s,o)=>{if(!((t={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...t}).count>=0)||t.count!==Number.POSITIVE_INFINITY&&!Number.isInteger(t.count))throw new TypeError("The `count` option should be at least 0 or more");const a=[e].flat(),l=[],{addListener:_,removeListener:R}=(n=>{const e=n.on||n.addListener||n.addEventListener,t=n.off||n.removeListener||n.removeEventListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(n),removeListener:t.bind(n)}})(n),N=(...z)=>{const Z=t.multiArgs?z:z[0];t.filter&&!t.filter(Z)||(l.push(Z),t.count===l.length&&(r(),s(l)))},B=z=>{r(),o(z)};r=()=>{for(const z of a)R(z,N);for(const z of t.rejectionEvents)R(z,B)};for(const z of a)_(z,N);for(const z of t.rejectionEvents)_(z,B);t.resolveImmediately&&s(l)});if(i.cancel=r,"number"==typeof t.timeout){const s=QT(i,t.timeout);return s.cancel=r,s}return i}(n,e,t={...t,count:1,resolveImmediately:!1}),i=r.then(s=>s[0]);return i.cancel=r.cancel,i}const WA=_r("waku:wait-for-remote-peer");function GE(){return GE=$(function*(n,e,t){if(e=e??l$(n),!n.isStarted())return Promise.reject("Waku node is not started");const r=[];if(e.includes(Jr.Relay)){if(!n.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");r.push(a$(n.relay))}if(e.includes(Jr.Store)){if(!n.store)throw new Error("Cannot wait for Store peer: protocol not mounted");r.push(WE(n.store,Object.values(sf)))}if(e.includes(Jr.LightPush)){if(!n.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");r.push(WE(n.lightPush,[nf]))}if(e.includes(Jr.Filter)){if(!n.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");r.push(WE(n.filter,[tf]))}t?yield u$(Promise.all(r),t,"Timed out waiting for a remote peer."):yield Promise.all(r)}),GE.apply(this,arguments)}function WE(n,e){return qE.apply(this,arguments)}function qE(){return qE=$(function*(n,e){const t=yield n.peers();t.length?WA(`${e} peer found: `,t[0].id.toString()):yield new Promise(r=>{const i=s=>{for(const o of e)if(s.detail.protocols.includes(o)){WA("Resolving for",o,s.detail.protocols),n.libp2p.peerStore.removeEventListener("change:protocols",i),r();break}};n.libp2p.peerStore.addEventListener("change:protocols",i)})}),qE.apply(this,arguments)}function a$(n){return YE.apply(this,arguments)}function YE(){return YE=$(function*(n){let e=n.getMeshPeers();for(;0==e.length;)yield s$(n,"gossipsub:heartbeat"),e=n.getMeshPeers()}),YE.apply(this,arguments)}const c$=(n,e)=>new Promise((t,r)=>setTimeout(()=>r(e),n));function u$(n,e,t){return QE.apply(this,arguments)}function QE(){return QE=$(function*(n,e,t){yield Promise.race([n,c$(e,t)])}),QE.apply(this,arguments)}function l$(n){const e=[];return n.relay&&e.push(Jr.Relay),n.filter&&e.push(Jr.Filter),n.store&&e.push(Jr.Store),n.lightPush&&e.push(Jr.LightPush),e}let qA=(()=>{class n{constructor(){this.wakuSubject=new pr,this.waku=this.wakuSubject.asObservable(),this.wakuStatusSubject=new iB(""),this.wakuStatus=this.wakuStatusSubject.asObservable()}init(){(function r$(n){return KE.apply(this,arguments)})({defaultBootstrap:!0}).then(t=>{t.start().then(()=>{this.wakuSubject.next(t),this.wakuStatusSubject.next("Connecting..."),function o$(n,e,t){return GE.apply(this,arguments)}(t).then(()=>{this.wakuStatusSubject.next("Connected")})})})}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function d$(n,e){if(1&n&&(eo(0,"li")(1,"span"),Ic(2),to()()),2&n){const t=e.$implicit;zu(2),hy("",t.timestamp," ",t.text,"")}}_r("waku:enr");const eb=new(S0().Type)("ChatMessage").add(new(S0().Field)("timestamp",1,"uint32")).add(new(S0().Field)("text",2,"string"));let h$=(()=>{class n{constructor(t){this.wakuService=t,this.contentTopic="/relay-angular-chat/1/chat/proto",this.messages=[],this.messageCount=0,this.processIncomingMessages=r=>{if(!r.payload)return;const{text:i,timestamp:s}=eb.decode(r.payload),o=new Date;o.setTime(Number(s)),this.messages.push({text:i,timestamp:o})}}ngOnInit(){this.wakuService.wakuStatus.subscribe(t=>{this.wakuStatus=t}),this.wakuService.waku.subscribe(t=>{this.waku=t,this.waku.relay.addObserver(this.processIncomingMessages,[this.contentTopic])}),window.onbeforeunload=()=>this.ngOnDestroy()}ngOnDestroy(){this.waku.relay.deleteObserver(this.processIncomingMessages,[this.contentTopic])}sendMessage(){const t=(new Date).getTime(),r=eb.create({timestamp:t,text:`Here is a message #${this.messageCount}`}),i=eb.encode(r).finish();oa.fromBytes(i,this.contentTopic).then(s=>{this.waku.relay.send(s).then(()=>{console.log(`Message #${this.messageCount} sent`),this.messageCount+=1})})}}return n.\u0275fac=function(t){return new(t||n)(Zt(qA))},n.\u0275cmp=df({type:n,selectors:[["app-messages"]],decls:6,vars:2,consts:[[3,"disabled","click"],[1,"messages"],[4,"ngFor","ngForOf"]],template:function(t,r){1&t&&(eo(0,"button",0),uy("click",function(){return r.sendMessage()}),Ic(1,"Send Message"),to(),eo(2,"h2"),Ic(3,"Messages"),to(),eo(4,"ul",1),function f1(n,e,t,r,i,s,o,a){const l=Ue(),_=dn(),R=n+22,N=_.firstCreatePass?function $M(n,e,t,r,i,s,o,a,l){const _=e.consts,R=pc(e,n,4,o||null,Ao(_,a));Yg(e,t,R,Ao(_,l)),wf(e,R);const N=R.tViews=qg(2,R,r,i,s,e.directiveRegistry,e.pipeRegistry,null,e.schemas,_);return null!==e.queries&&(e.queries.template(e,R),N.queries=e.queries.embeddedTView(R)),R}(R,_,l,e,t,r,i,s,o):_.data[R];Ts(N,!1);const B=l[11].createComment("");jf(_,l,B,N),jr(B,l),Xf(l,l[R]=W_(B,l,B,N)),mf(N)&&Gg(_,l,N),null!=o&&Wg(l,N,a)}(5,d$,3,2,"li",2),to()),2&t&&(id("disabled","Connected"!==r.wakuStatus),zu(5),id("ngForOf",r.messages))},dependencies:[oC]}),n})(),p$=(()=>{class n{constructor(t){this.wakuService=t,this.title="relay-angular-chat"}ngOnInit(){this.wakuService.init(),this.wakuService.wakuStatus.subscribe(t=>{this.wakuStatus=t})}}return n.\u0275fac=function(t){return new(t||n)(Zt(qA))},n.\u0275cmp=df({type:n,selectors:[["app-root"]],decls:5,vars:2,template:function(t,r){1&t&&(eo(0,"h1"),Ic(1),to(),eo(2,"p"),Ic(3),to(),sy(4,"app-messages")),2&t&&(zu(1),dy(r.title),zu(2),od("Waku node's status: ",r.wakuStatus,""))},dependencies:[h$],styles:["h1[_ngcontent-%COMP%]{color:#369;font-family:Arial,Helvetica,sans-serif;font-size:250%}h2[_ngcontent-%COMP%], h3[_ngcontent-%COMP%]{color:#444;font-family:Arial,Helvetica,sans-serif;font-weight:lighter}body[_ngcontent-%COMP%]{margin:2em}body[_ngcontent-%COMP%], input[type=text][_ngcontent-%COMP%], button[_ngcontent-%COMP%]{color:#333;font-family:Cambria,Georgia,serif}*[_ngcontent-%COMP%]{font-family:Arial,Helvetica,sans-serif}"]}),n})(),g$=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=bu({type:n,bootstrap:[p$]}),n.\u0275inj=Ka({imports:[q4]}),n})();x(8583),function vL(){FS=!1}(),W4().bootstrapModule(g$).catch(n=>console.error(n))},1280:Y=>{"use strict";Y.exports=function U(x,y){for(var u=new Array(arguments.length-1),g=0,w=2,m=!0;w{"use strict";var x=U;x.length=function(h){var c=h.length;if(!c)return 0;for(var f=0;--c%4>1&&"="===h.charAt(c);)++f;return Math.ceil(3*h.length)/4-f};for(var y=new Array(64),u=new Array(123),g=0;g<64;)u[y[g]=g<26?g+65:g<52?g+71:g<62?g-4:g-59|43]=g++;x.encode=function(h,c,f){for(var v,d=null,b=[],S=0,E=0;c>2],v=(3&p)<<4,E=1;break;case 1:b[S++]=y[v|p>>4],v=(15&p)<<2,E=2;break;case 2:b[S++]=y[v|p>>6],b[S++]=y[63&p],E=0}S>8191&&((d||(d=[])).push(String.fromCharCode.apply(String,b)),S=0)}return E&&(b[S++]=y[v],b[S++]=61,1===E&&(b[S++]=61)),d?(S&&d.push(String.fromCharCode.apply(String,b.slice(0,S))),d.join("")):String.fromCharCode.apply(String,b.slice(0,S))};var w="invalid encoding";x.decode=function(h,c,f){for(var S,d=f,b=0,E=0;E1)break;if(void 0===(v=u[v]))throw Error(w);switch(b){case 0:S=v,b=1;break;case 1:c[f++]=S<<2|(48&v)>>4,S=v,b=2;break;case 2:c[f++]=(15&S)<<4|(60&v)>>2,S=v,b=3;break;case 3:c[f++]=(3&S)<<6|v,b=0}}if(1===b)throw Error(w);return f-d},x.test=function(h){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(h)}},9749:Y=>{"use strict";function U(x,y){"string"==typeof x&&(y=x,x=void 0);var u=[];function g(m){if("string"!=typeof m){var h=w();if(U.verbose&&console.log("codegen: "+h),h="return "+h,m){for(var c=Object.keys(m),f=new Array(c.length+1),d=new Array(c.length),b=0;b{"use strict";function U(){this._listeners={}}Y.exports=U,U.prototype.on=function(y,u,g){return(this._listeners[y]||(this._listeners[y]=[])).push({fn:u,ctx:g||this}),this},U.prototype.off=function(y,u){if(void 0===y)this._listeners={};else if(void 0===u)this._listeners[y]=[];else for(var g=this._listeners[y],w=0;w{"use strict";Y.exports=w;var y=x(1280),g=x(716)("fs");function w(m,h,c){return"function"==typeof h?(c=h,h={}):h||(h={}),c?!h.xhr&&g&&g.readFile?g.readFile(m,function(d,b){return d&&typeof XMLHttpRequest<"u"?w.xhr(m,h,c):d?c(d):c(null,h.binary?b:b.toString("utf8"))}):w.xhr(m,h,c):y(w,this,m,h)}w.xhr=function(h,c,f){var d=new XMLHttpRequest;d.onreadystatechange=function(){if(4===d.readyState){if(0!==d.status&&200!==d.status)return f(Error("status "+d.status));if(c.binary){var S=d.response;if(!S){S=[];for(var E=0;E{"use strict";function U(w){return typeof Float32Array<"u"?function(){var m=new Float32Array([-0]),h=new Uint8Array(m.buffer),c=128===h[3];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3]}function d(E,v,p){m[0]=E,v[p]=h[3],v[p+1]=h[2],v[p+2]=h[1],v[p+3]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],m[0]}function S(E,v){return h[3]=E[v],h[2]=E[v+1],h[1]=E[v+2],h[0]=E[v+3],m[0]}w.writeFloatLE=c?f:d,w.writeFloatBE=c?d:f,w.readFloatLE=c?b:S,w.readFloatBE=c?S:b}():function(){function m(c,f,d,b){var S=f<0?1:0;if(S&&(f=-f),0===f)c(1/f>0?0:2147483648,d,b);else if(isNaN(f))c(2143289344,d,b);else if(f>34028234663852886e22)c((S<<31|2139095040)>>>0,d,b);else if(f<11754943508222875e-54)c((S<<31|Math.round(f/1401298464324817e-60))>>>0,d,b);else{var E=Math.floor(Math.log(f)/Math.LN2);c((S<<31|E+127<<23|8388607&Math.round(f*Math.pow(2,-E)*8388608))>>>0,d,b)}}function h(c,f,d){var b=c(f,d),S=2*(b>>31)+1,E=b>>>23&255,v=8388607&b;return 255===E?v?NaN:S*(1/0):0===E?1401298464324817e-60*S*v:S*Math.pow(2,E-150)*(v+8388608)}w.writeFloatLE=m.bind(null,x),w.writeFloatBE=m.bind(null,y),w.readFloatLE=h.bind(null,u),w.readFloatBE=h.bind(null,g)}(),typeof Float64Array<"u"?function(){var m=new Float64Array([-0]),h=new Uint8Array(m.buffer),c=128===h[7];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3],v[p+4]=h[4],v[p+5]=h[5],v[p+6]=h[6],v[p+7]=h[7]}function d(E,v,p){m[0]=E,v[p]=h[7],v[p+1]=h[6],v[p+2]=h[5],v[p+3]=h[4],v[p+4]=h[3],v[p+5]=h[2],v[p+6]=h[1],v[p+7]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],h[4]=E[v+4],h[5]=E[v+5],h[6]=E[v+6],h[7]=E[v+7],m[0]}function S(E,v){return h[7]=E[v],h[6]=E[v+1],h[5]=E[v+2],h[4]=E[v+3],h[3]=E[v+4],h[2]=E[v+5],h[1]=E[v+6],h[0]=E[v+7],m[0]}w.writeDoubleLE=c?f:d,w.writeDoubleBE=c?d:f,w.readDoubleLE=c?b:S,w.readDoubleBE=c?S:b}():function(){function m(c,f,d,b,S,E){var v=b<0?1:0;if(v&&(b=-b),0===b)c(0,S,E+f),c(1/b>0?0:2147483648,S,E+d);else if(isNaN(b))c(0,S,E+f),c(2146959360,S,E+d);else if(b>17976931348623157e292)c(0,S,E+f),c((v<<31|2146435072)>>>0,S,E+d);else{var p;if(b<22250738585072014e-324)c((p=b/5e-324)>>>0,S,E+f),c((v<<31|p/4294967296)>>>0,S,E+d);else{var I=Math.floor(Math.log(b)/Math.LN2);1024===I&&(I=1023),c(4503599627370496*(p=b*Math.pow(2,-I))>>>0,S,E+f),c((v<<31|I+1023<<20|1048576*p&1048575)>>>0,S,E+d)}}}function h(c,f,d,b,S){var E=c(b,S+f),v=c(b,S+d),p=2*(v>>31)+1,I=v>>>20&2047,A=4294967296*(1048575&v)+E;return 2047===I?A?NaN:p*(1/0):0===I?5e-324*p*A:p*Math.pow(2,I-1075)*(A+4503599627370496)}w.writeDoubleLE=m.bind(null,x,0,4),w.writeDoubleBE=m.bind(null,y,4,0),w.readDoubleLE=h.bind(null,u,0,4),w.readDoubleBE=h.bind(null,g,4,0)}(),w}function x(w,m,h){m[h]=255&w,m[h+1]=w>>>8&255,m[h+2]=w>>>16&255,m[h+3]=w>>>24}function y(w,m,h){m[h]=w>>>24,m[h+1]=w>>>16&255,m[h+2]=w>>>8&255,m[h+3]=255&w}function u(w,m){return(w[m]|w[m+1]<<8|w[m+2]<<16|w[m+3]<<24)>>>0}function g(w,m){return(w[m]<<24|w[m+1]<<16|w[m+2]<<8|w[m+3])>>>0}Y.exports=U(U)},716:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(Y){}return null}module.exports=inquire},1311:(Y,U)=>{"use strict";var x=U,y=x.isAbsolute=function(w){return/^(?:\/|\w+:)/.test(w)},u=x.normalize=function(w){var m=(w=w.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),h=y(w),c="";h&&(c=m.shift()+"/");for(var f=0;f0&&".."!==m[f-1]?m.splice(--f,2):h?m.splice(f,1):++f:"."===m[f]?m.splice(f,1):++f;return c+m.join("/")};x.resolve=function(w,m,h){return h||(m=u(m)),y(m)?m:(h||(w=u(w)),(w=w.replace(/(?:\/|^)[^/]+$/,"")).length?u(w+"/"+m):m)}},4479:Y=>{"use strict";Y.exports=function U(x,y,u){var g=u||8192,w=g>>>1,m=null,h=g;return function(f){if(f<1||f>w)return x(f);h+f>g&&(m=x(g),h=0);var d=y.call(m,h,h+=f);return 7&h&&(h=1+(7|h)),d}}},7768:(Y,U)=>{"use strict";var x=U;x.length=function(u){for(var g=0,w=0,m=0;m191&&d<224?c[f++]=(31&d)<<6|63&u[g++]:d>239&&d<365?(d=((7&d)<<18|(63&u[g++])<<12|(63&u[g++])<<6|63&u[g++])-65536,c[f++]=55296+(d>>10),c[f++]=56320+(1023&d)):c[f++]=(15&d)<<12|(63&u[g++])<<6|63&u[g++],f>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,c)),f=0);return h?(f&&h.push(String.fromCharCode.apply(String,c.slice(0,f))),h.join("")):String.fromCharCode.apply(String,c.slice(0,f))},x.write=function(u,g,w){for(var h,c,m=w,f=0;f>6|192,g[w++]=63&h|128):55296==(64512&h)&&56320==(64512&(c=u.charCodeAt(f+1)))?(++f,g[w++]=(h=65536+((1023&h)<<10)+(1023&c))>>18|240,g[w++]=h>>12&63|128,g[w++]=h>>6&63|128,g[w++]=63&h|128):(g[w++]=h>>12|224,g[w++]=h>>6&63|128,g[w++]=63&h|128);return w-m}},4502:(Y,U,x)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(8046);function h(X,q,ne){return void 0===q&&(q=new Uint8Array(2)),void 0===ne&&(ne=0),q[ne+0]=X>>>8,q[ne+1]=X>>>0,q}function c(X,q,ne){return void 0===q&&(q=new Uint8Array(2)),void 0===ne&&(ne=0),q[ne+0]=X>>>0,q[ne+1]=X>>>8,q}function f(X,q){return void 0===q&&(q=0),X[q]<<24|X[q+1]<<16|X[q+2]<<8|X[q+3]}function d(X,q){return void 0===q&&(q=0),(X[q]<<24|X[q+1]<<16|X[q+2]<<8|X[q+3])>>>0}function b(X,q){return void 0===q&&(q=0),X[q+3]<<24|X[q+2]<<16|X[q+1]<<8|X[q]}function S(X,q){return void 0===q&&(q=0),(X[q+3]<<24|X[q+2]<<16|X[q+1]<<8|X[q])>>>0}function E(X,q,ne){return void 0===q&&(q=new Uint8Array(4)),void 0===ne&&(ne=0),q[ne+0]=X>>>24,q[ne+1]=X>>>16,q[ne+2]=X>>>8,q[ne+3]=X>>>0,q}function v(X,q,ne){return void 0===q&&(q=new Uint8Array(4)),void 0===ne&&(ne=0),q[ne+0]=X>>>0,q[ne+1]=X>>>8,q[ne+2]=X>>>16,q[ne+3]=X>>>24,q}function D(X,q,ne){return void 0===q&&(q=new Uint8Array(8)),void 0===ne&&(ne=0),E(X/4294967296>>>0,q,ne),E(X>>>0,q,ne+4),q}function T(X,q,ne){return void 0===q&&(q=new Uint8Array(8)),void 0===ne&&(ne=0),v(X>>>0,q,ne),v(X/4294967296>>>0,q,ne+4),q}U.readInt16BE=function u(X,q){return void 0===q&&(q=0),(X[q+0]<<8|X[q+1])<<16>>16},U.readUint16BE=function g(X,q){return void 0===q&&(q=0),(X[q+0]<<8|X[q+1])>>>0},U.readInt16LE=function w(X,q){return void 0===q&&(q=0),(X[q+1]<<8|X[q])<<16>>16},U.readUint16LE=function m(X,q){return void 0===q&&(q=0),(X[q+1]<<8|X[q])>>>0},U.writeUint16BE=h,U.writeInt16BE=h,U.writeUint16LE=c,U.writeInt16LE=c,U.readInt32BE=f,U.readUint32BE=d,U.readInt32LE=b,U.readUint32LE=S,U.writeUint32BE=E,U.writeInt32BE=E,U.writeUint32LE=v,U.writeInt32LE=v,U.readInt64BE=function p(X,q){void 0===q&&(q=0);var ne=f(X,q),oe=f(X,q+4);return 4294967296*ne+oe-4294967296*(oe>>31)},U.readUint64BE=function I(X,q){return void 0===q&&(q=0),4294967296*d(X,q)+d(X,q+4)},U.readInt64LE=function A(X,q){void 0===q&&(q=0);var ne=b(X,q);return 4294967296*b(X,q+4)+ne-4294967296*(ne>>31)},U.readUint64LE=function P(X,q){void 0===q&&(q=0);var ne=S(X,q);return 4294967296*S(X,q+4)+ne},U.writeUint64BE=D,U.writeInt64BE=D,U.writeUint64LE=T,U.writeInt64LE=T,U.readUintBE=function M(X,q,ne){if(void 0===ne&&(ne=0),X%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(X/8>q.length-ne)throw new Error("readUintBE: array is too short for the given bitLength");for(var oe=0,de=1,pe=X/8+ne-1;pe>=ne;pe--)oe+=q[pe]*de,de*=256;return oe},U.readUintLE=function k(X,q,ne){if(void 0===ne&&(ne=0),X%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(X/8>q.length-ne)throw new Error("readUintLE: array is too short for the given bitLength");for(var oe=0,de=1,pe=ne;pe=oe;pe--)ne[pe]=q/de&255,de*=256;return ne},U.writeUintLE=function j(X,q,ne,oe){if(void 0===ne&&(ne=new Uint8Array(X/8)),void 0===oe&&(oe=0),X%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!y.isSafeInteger(q))throw new Error("writeUintLE value must be an integer");for(var de=1,pe=oe;pe{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(4502),u=x(9815);function w(f,d,b){for(var S=1634760805,E=857760878,v=2036477234,p=1797285236,I=b[3]<<24|b[2]<<16|b[1]<<8|b[0],A=b[7]<<24|b[6]<<16|b[5]<<8|b[4],P=b[11]<<24|b[10]<<16|b[9]<<8|b[8],D=b[15]<<24|b[14]<<16|b[13]<<8|b[12],T=b[19]<<24|b[18]<<16|b[17]<<8|b[16],M=b[23]<<24|b[22]<<16|b[21]<<8|b[20],k=b[27]<<24|b[26]<<16|b[25]<<8|b[24],F=b[31]<<24|b[30]<<16|b[29]<<8|b[28],j=d[3]<<24|d[2]<<16|d[1]<<8|d[0],C=d[7]<<24|d[6]<<16|d[5]<<8|d[4],O=d[11]<<24|d[10]<<16|d[9]<<8|d[8],V=d[15]<<24|d[14]<<16|d[13]<<8|d[12],L=S,K=E,re=v,G=p,te=I,X=A,q=P,ne=D,oe=T,de=M,pe=k,Le=F,Se=j,Ne=C,be=O,je=V,H=0;H<20;H+=2)te=(te^=oe=oe+(Se=(Se^=L=L+te|0)>>>16|Se<<16)|0)>>>20|te<<12,X=(X^=de=de+(Ne=(Ne^=K=K+X|0)>>>16|Ne<<16)|0)>>>20|X<<12,q=(q^=pe=pe+(be=(be^=re=re+q|0)>>>16|be<<16)|0)>>>20|q<<12,ne=(ne^=Le=Le+(je=(je^=G=G+ne|0)>>>16|je<<16)|0)>>>20|ne<<12,q=(q^=pe=pe+(be=(be^=re=re+q|0)>>>24|be<<8)|0)>>>25|q<<7,ne=(ne^=Le=Le+(je=(je^=G=G+ne|0)>>>24|je<<8)|0)>>>25|ne<<7,X=(X^=de=de+(Ne=(Ne^=K=K+X|0)>>>24|Ne<<8)|0)>>>25|X<<7,te=(te^=oe=oe+(Se=(Se^=L=L+te|0)>>>24|Se<<8)|0)>>>25|te<<7,X=(X^=pe=pe+(je=(je^=L=L+X|0)>>>16|je<<16)|0)>>>20|X<<12,q=(q^=Le=Le+(Se=(Se^=K=K+q|0)>>>16|Se<<16)|0)>>>20|q<<12,ne=(ne^=oe=oe+(Ne=(Ne^=re=re+ne|0)>>>16|Ne<<16)|0)>>>20|ne<<12,te=(te^=de=de+(be=(be^=G=G+te|0)>>>16|be<<16)|0)>>>20|te<<12,ne=(ne^=oe=oe+(Ne=(Ne^=re=re+ne|0)>>>24|Ne<<8)|0)>>>25|ne<<7,te=(te^=de=de+(be=(be^=G=G+te|0)>>>24|be<<8)|0)>>>25|te<<7,q=(q^=Le=Le+(Se=(Se^=K=K+q|0)>>>24|Se<<8)|0)>>>25|q<<7,X=(X^=pe=pe+(je=(je^=L=L+X|0)>>>24|je<<8)|0)>>>25|X<<7;y.writeUint32LE(L+S|0,f,0),y.writeUint32LE(K+E|0,f,4),y.writeUint32LE(re+v|0,f,8),y.writeUint32LE(G+p|0,f,12),y.writeUint32LE(te+I|0,f,16),y.writeUint32LE(X+A|0,f,20),y.writeUint32LE(q+P|0,f,24),y.writeUint32LE(ne+D|0,f,28),y.writeUint32LE(oe+T|0,f,32),y.writeUint32LE(de+M|0,f,36),y.writeUint32LE(pe+k|0,f,40),y.writeUint32LE(Le+F|0,f,44),y.writeUint32LE(Se+j|0,f,48),y.writeUint32LE(Ne+C|0,f,52),y.writeUint32LE(be+O|0,f,56),y.writeUint32LE(je+V|0,f,60)}function m(f,d,b,S,E){if(void 0===E&&(E=0),32!==f.length)throw new Error("ChaCha: key size must be 32 bytes");if(S.length>>=8,d++;if(S>0)throw new Error("ChaCha: counter overflow")}U.streamXOR=m,U.stream=function h(f,d,b,S){return void 0===S&&(S=0),u.wipe(b),m(f,d,b,b,S)}},5876:(Y,U,x)=>{"use strict";var u=x(4484),g=x(314),w=x(9815),m=x(4502),h=x(9976);U.Cv=32,U.WH=12,U.pg=16;var c=new Uint8Array(16),f=function(){function d(b){if(this.nonceLength=U.WH,this.tagLength=U.pg,b.length!==U.Cv)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(b)}return d.prototype.seal=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var p=new Uint8Array(16);p.set(b,p.length-b.length);var I=new Uint8Array(32);u.stream(this._key,p,I,4);var P,A=S.length+this.tagLength;if(v){if(v.length!==A)throw new Error("ChaCha20Poly1305: incorrect destination length");P=v}else P=new Uint8Array(A);return u.streamXOR(this._key,p,S,P,4),this._authenticate(P.subarray(P.length-this.tagLength,P.length),I,P.subarray(0,P.length-this.tagLength),E),w.wipe(p),P},d.prototype.open=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(S.length0&&p.update(c.subarray(v.length%16))),p.update(E),E.length%16>0&&p.update(c.subarray(E.length%16));var I=new Uint8Array(8);v&&m.writeUint64LE(v.length,I),p.update(I),m.writeUint64LE(E.length,I),p.update(I);for(var A=p.digest(),P=0;P{"use strict";function u(w,m){if(w.length!==m.length)return 0;for(var h=0,c=0;c>>8}Object.defineProperty(U,"__esModule",{value:!0}),U.select=function x(w,m,h){return~(w-1)&m|w-1&h},U.lessOrEqual=function y(w,m){return(0|w)-(0|m)-1>>>31&1},U.compare=u,U.equal=function g(w,m){return 0!==w.length&&0!==m.length&&0!==u(w,m)}},5571:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.isSerializableHash=function x(y){return typeof y.saveState<"u"&&typeof y.restoreState<"u"&&typeof y.cleanSavedState<"u"}},5705:(Y,U,x)=>{"use strict";var u=x(4193),g=x(9815),w=function(){function m(h,c,f,d){void 0===f&&(f=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=h,this._info=d;var b=u.hmac(this._hash,f,c);this._hmac=new u.HMAC(h,b),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return m.prototype._fillBuffer=function(){this._counter[0]++;var h=this._counter[0];if(0===h)throw new Error("hkdf: cannot expand more");this._hmac.reset(),h>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},m.prototype.expand=function(h){for(var c=new Uint8Array(h),f=0;f{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(5571),u=x(9976),g=x(9815),w=function(){function h(c,f){this._finished=!1,this._inner=new c,this._outer=new c,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var d=new Uint8Array(this.blockSize);f.length>this.blockSize?this._inner.update(f).finish(d).clean():d.set(f);for(var b=0;b{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.mul=Math.imul||function x(h,c){var d=65535&h,S=65535&c;return d*S+((h>>>16&65535)*S+d*(c>>>16&65535)<<16>>>0)|0},U.add=function y(h,c){return h+c|0},U.sub=function u(h,c){return h-c|0},U.rotl=function g(h,c){return h<>>32-c},U.rotr=function w(h,c){return h<<32-c|h>>>c},U.isInteger=Number.isInteger||function m(h){return"number"==typeof h&&isFinite(h)&&Math.floor(h)===h},U.MAX_SAFE_INTEGER=9007199254740991,U.isSafeInteger=function(h){return U.isInteger(h)&&h>=-U.MAX_SAFE_INTEGER&&h<=U.MAX_SAFE_INTEGER}},314:(Y,U,x)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(9976),u=x(9815);U.DIGEST_LENGTH=16;var g=function(){function h(c){this.digestLength=U.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var f=c[0]|c[1]<<8;this._r[0]=8191&f;var d=c[2]|c[3]<<8;this._r[1]=8191&(f>>>13|d<<3);var b=c[4]|c[5]<<8;this._r[2]=7939&(d>>>10|b<<6);var S=c[6]|c[7]<<8;this._r[3]=8191&(b>>>7|S<<9);var E=c[8]|c[9]<<8;this._r[4]=255&(S>>>4|E<<12),this._r[5]=E>>>1&8190;var v=c[10]|c[11]<<8;this._r[6]=8191&(E>>>14|v<<2);var p=c[12]|c[13]<<8;this._r[7]=8065&(v>>>11|p<<5);var I=c[14]|c[15]<<8;this._r[8]=8191&(p>>>8|I<<8),this._r[9]=I>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return h.prototype._blocks=function(c,f,d){for(var b=this._fin?0:2048,S=this._h[0],E=this._h[1],v=this._h[2],p=this._h[3],I=this._h[4],A=this._h[5],P=this._h[6],D=this._h[7],T=this._h[8],M=this._h[9],k=this._r[0],F=this._r[1],j=this._r[2],C=this._r[3],O=this._r[4],V=this._r[5],L=this._r[6],K=this._r[7],re=this._r[8],G=this._r[9];d>=16;){var te=c[f+0]|c[f+1]<<8,X=c[f+2]|c[f+3]<<8,q=c[f+4]|c[f+5]<<8,ne=c[f+6]|c[f+7]<<8,oe=c[f+8]|c[f+9]<<8,de=c[f+10]|c[f+11]<<8,pe=c[f+12]|c[f+13]<<8,Le=c[f+14]|c[f+15]<<8,Se=0,Ne=Se;Ne+=(S+=8191&te)*k,Ne+=(E+=8191&(te>>>13|X<<3))*(5*G),Ne+=(v+=8191&(X>>>10|q<<6))*(5*re),Ne+=(p+=8191&(q>>>7|ne<<9))*(5*K),Se=(Ne+=(I+=8191&(ne>>>4|oe<<12))*(5*L))>>>13,Ne&=8191,Ne+=(A+=oe>>>1&8191)*(5*V),Ne+=(P+=8191&(oe>>>14|de<<2))*(5*O),Ne+=(D+=8191&(de>>>11|pe<<5))*(5*C),Ne+=(T+=8191&(pe>>>8|Le<<8))*(5*j);var be=Se+=(Ne+=(M+=Le>>>5|b)*(5*F))>>>13;be+=S*F,be+=E*k,be+=v*(5*G),be+=p*(5*re),Se=(be+=I*(5*K))>>>13,be&=8191,be+=A*(5*L),be+=P*(5*V),be+=D*(5*O),be+=T*(5*C),Se+=(be+=M*(5*j))>>>13,be&=8191;var je=Se;je+=S*j,je+=E*F,je+=v*k,je+=p*(5*G),Se=(je+=I*(5*re))>>>13,je&=8191,je+=A*(5*K),je+=P*(5*L),je+=D*(5*V),je+=T*(5*O);var H=Se+=(je+=M*(5*C))>>>13;H+=S*C,H+=E*j,H+=v*F,H+=p*k,Se=(H+=I*(5*G))>>>13,H&=8191,H+=A*(5*re),H+=P*(5*K),H+=D*(5*L),H+=T*(5*V);var Ee=Se+=(H+=M*(5*O))>>>13;Ee+=S*O,Ee+=E*C,Ee+=v*j,Ee+=p*F,Se=(Ee+=I*k)>>>13,Ee&=8191,Ee+=A*(5*G),Ee+=P*(5*re),Ee+=D*(5*K),Ee+=T*(5*L);var Ie=Se+=(Ee+=M*(5*V))>>>13;Ie+=S*V,Ie+=E*O,Ie+=v*C,Ie+=p*j,Se=(Ie+=I*F)>>>13,Ie&=8191,Ie+=A*k,Ie+=P*(5*G),Ie+=D*(5*re),Ie+=T*(5*K);var xe=Se+=(Ie+=M*(5*L))>>>13;xe+=S*L,xe+=E*V,xe+=v*O,xe+=p*C,Se=(xe+=I*j)>>>13,xe&=8191,xe+=A*F,xe+=P*k,xe+=D*(5*G),xe+=T*(5*re);var He=Se+=(xe+=M*(5*K))>>>13;He+=S*K,He+=E*L,He+=v*V,He+=p*O,Se=(He+=I*C)>>>13,He&=8191,He+=A*j,He+=P*F,He+=D*k,He+=T*(5*G);var We=Se+=(He+=M*(5*re))>>>13;We+=S*re,We+=E*K,We+=v*L,We+=p*V,Se=(We+=I*O)>>>13,We&=8191,We+=A*C,We+=P*j,We+=D*F,We+=T*k;var Je=Se+=(We+=M*(5*G))>>>13;Je+=S*G,Je+=E*re,Je+=v*K,Je+=p*L,Se=(Je+=I*V)>>>13,Je&=8191,Je+=A*O,Je+=P*C,Je+=D*j,Je+=T*F,S=Ne=8191&(Se=(Se=((Se+=(Je+=M*k)>>>13)<<2)+Se|0)+(Ne&=8191)|0),E=be+=Se>>>=13,v=je&=8191,p=H&=8191,I=Ee&=8191,A=Ie&=8191,P=xe&=8191,D=He&=8191,T=We&=8191,M=Je&=8191,f+=16,d-=16}this._h[0]=S,this._h[1]=E,this._h[2]=v,this._h[3]=p,this._h[4]=I,this._h[5]=A,this._h[6]=P,this._h[7]=D,this._h[8]=T,this._h[9]=M},h.prototype.finish=function(c,f){void 0===f&&(f=0);var b,S,E,v,d=new Uint16Array(10);if(this._leftover){for(v=this._leftover,this._buffer[v++]=1;v<16;v++)this._buffer[v]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(b=this._h[1]>>>13,this._h[1]&=8191,v=2;v<10;v++)this._h[v]+=b,b=this._h[v]>>>13,this._h[v]&=8191;for(this._h[0]+=5*b,b=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=b,b=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=b,d[0]=this._h[0]+5,b=d[0]>>>13,d[0]&=8191,v=1;v<10;v++)d[v]=this._h[v]+b,b=d[v]>>>13,d[v]&=8191;for(d[9]-=8192,S=(1^b)-1,v=0;v<10;v++)d[v]&=S;for(S=~S,v=0;v<10;v++)this._h[v]=this._h[v]&S|d[v];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),this._h[0]=65535&(E=this._h[0]+this._pad[0]),v=1;v<8;v++)this._h[v]=65535&(E=(this._h[v]+this._pad[v]|0)+(E>>>16)|0);return c[f+0]=this._h[0]>>>0,c[f+1]=this._h[0]>>>8,c[f+2]=this._h[1]>>>0,c[f+3]=this._h[1]>>>8,c[f+4]=this._h[2]>>>0,c[f+5]=this._h[2]>>>8,c[f+6]=this._h[3]>>>0,c[f+7]=this._h[3]>>>8,c[f+8]=this._h[4]>>>0,c[f+9]=this._h[4]>>>8,c[f+10]=this._h[5]>>>0,c[f+11]=this._h[5]>>>8,c[f+12]=this._h[6]>>>0,c[f+13]=this._h[6]>>>8,c[f+14]=this._h[7]>>>0,c[f+15]=this._h[7]>>>8,this._finished=!0,this},h.prototype.update=function(c){var b,f=0,d=c.length;if(this._leftover){(b=16-this._leftover)>d&&(b=d);for(var S=0;S=16&&(this._blocks(c,f,b=d-d%16),f+=b,d-=b),d){for(S=0;S{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.randomStringForEntropy=U.randomString=U.randomUint32=U.randomBytes=U.defaultRandomSource=void 0;const y=x(9753),u=x(4502),g=x(9815);function w(d,b=U.defaultRandomSource){return b.randomBytes(d)}U.defaultRandomSource=new y.SystemRandomSource,U.randomBytes=w,U.randomUint32=function m(d=U.defaultRandomSource){const b=w(4,d),S=(0,u.readUint32LE)(b);return(0,g.wipe)(b),S};const h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(d,b=h,S=U.defaultRandomSource){if(b.length<2)throw new Error("randomString charset is too short");if(b.length>256)throw new Error("randomString charset is too long");let E="";const v=b.length,p=256-256%v;for(;d>0;){const I=w(Math.ceil(256*d/p),S);for(let A=0;A0;A++){const P=I[A];P{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.BrowserRandomSource=void 0,U.BrowserRandomSource=class y{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const g=typeof self<"u"?self.crypto||self.msCrypto:null;g&&void 0!==g.getRandomValues&&(this._crypto=g,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(g){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const w=new Uint8Array(g);for(let m=0;m{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.NodeRandomSource=void 0;const y=x(9815);U.NodeRandomSource=class u{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const w=x(5883);w&&w.randomBytes&&(this._crypto=w,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(w){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let m=this._crypto.randomBytes(w);if(m.length!==w)throw new Error("NodeRandomSource: got fewer bytes than requested");const h=new Uint8Array(w);for(let c=0;c{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.SystemRandomSource=void 0;const y=x(7170),u=x(1382);U.SystemRandomSource=class g{constructor(){return this.isAvailable=!1,this.name="",this._source=new y.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new u.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(m){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(m)}}},893:(Y,U,x)=>{"use strict";var u=x(4502),g=x(9815);U.k=32,U.cn=64;var w=function(){function f(){this.digestLength=U.k,this.blockSize=U.cn,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){g.wipe(this._buffer),g.wipe(this._temp),this.reset()},f.prototype.update=function(d,b){if(void 0===b&&(b=d.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var S=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=d[S++],b--;this._bufferLength===this.blockSize&&(h(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(S=h(this._temp,this._state,d,S,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=d[S++],b--;return this},f.prototype.finish=function(d){if(!this._finished){var b=this._bytesHashed,S=this._bufferLength,E=b/536870912|0,v=b<<3,p=b%64<56?64:128;this._buffer[S]=128;for(var I=S+1;I0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(d){return this._state.set(d.state),this._bufferLength=d.bufferLength,d.buffer&&this._buffer.set(d.buffer),this._bytesHashed=d.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(d){g.wipe(d.state),d.buffer&&g.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},f}();U.mE=w;var m=new Int32Array([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 h(f,d,b,S,E){for(;E>=64;){for(var v=d[0],p=d[1],I=d[2],A=d[3],P=d[4],D=d[5],T=d[6],M=d[7],k=0;k<16;k++)f[k]=u.readUint32BE(b,S+4*k);for(k=16;k<64;k++){var j=f[k-2];f[k]=((C=(j>>>17|j<<15)^(j>>>19|j<<13)^j>>>10)+f[k-7]|0)+((O=((j=f[k-15])>>>7|j<<25)^(j>>>18|j<<14)^j>>>3)+f[k-16]|0)}for(k=0;k<64;k++){var C=(((P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7))+(P&D^~P&T)|0)+(M+(m[k]+f[k]|0)|0)|0,O=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&p^v&I^p&I)|0;M=T,T=D,D=P,P=A+C|0,A=I,I=p,p=v,v=C+O|0}d[0]+=v,d[1]+=p,d[2]+=I,d[3]+=A,d[4]+=P,d[5]+=D,d[6]+=T,d[7]+=M,S+=64,E-=64}return S}U.vp=function c(f){var d=new w;d.update(f);var b=d.digest();return d.clean(),b}},9815:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.wipe=function x(y){for(var u=0;u{"use strict";U.gi=U.Au=U._w=U.KS=U.kz=void 0;const u=x(5784),g=x(9815);function w(k){const F=new Float64Array(16);if(k)for(let j=0;j=0;--ne){const oe=j[ne>>>3]>>>(7&ne)&1;f(O,V,oe),f(L,K,oe),S(re,O,L),E(O,O,L),S(L,V,K),E(V,V,K),p(K,re),p(G,O),v(O,L,O),v(L,V,re),S(re,O,L),E(O,O,L),p(V,O),E(L,K,G),v(O,L,h),S(O,O,K),v(L,L,O),v(O,K,G),v(K,V,C),p(V,re),f(O,V,oe),f(L,K,oe)}for(let ne=0;ne<16;ne++)C[ne+16]=O[ne],C[ne+32]=L[ne],C[ne+48]=V[ne],C[ne+64]=K[ne];const te=C.subarray(32),X=C.subarray(16);(function I(k,F){const j=w();for(let C=0;C<16;C++)j[C]=F[C];for(let C=253;C>=0;C--)p(j,j),2!==C&&4!==C&&v(j,j,F);for(let C=0;C<16;C++)k[C]=j[C]})(te,te),v(X,X,te);const q=new Uint8Array(32);return function d(k,F){const j=w(),C=w();for(let O=0;O<16;O++)C[O]=F[O];c(C),c(C),c(C);for(let O=0;O<2;O++){j[0]=C[0]-65517;for(let L=1;L<15;L++)j[L]=C[L]-65535-(j[L-1]>>16&1),j[L-1]&=65535;j[15]=C[15]-32767-(j[14]>>16&1);const V=j[15]>>16&1;j[14]&=65535,f(C,j,1-V)}for(let O=0;O<16;O++)k[2*O]=255&C[O],k[2*O+1]=C[O]>>8}(q,X),q}function P(k){return A(k,m)}function D(k){if(k.length!==U.KS)throw new Error(`x25519: seed must be ${U.KS} bytes`);const F=new Uint8Array(k);return{publicKey:P(F),secretKey:F}}U._w=D,U.Au=function T(k){const F=(0,u.randomBytes)(32,k),j=D(F);return(0,g.wipe)(F),j},U.gi=function M(k,F,j=!1){if(k.length!==U.kz)throw new Error("X25519: incorrect secret key length");if(F.length!==U.kz)throw new Error("X25519: incorrect public key length");const C=A(k,F);if(j){let O=0;for(let V=0;V{function U(x){const y=new globalThis.AbortController;function u(){y.abort();for(const g of x)!g||!g.removeEventListener||g.removeEventListener("abort",u)}for(const g of x)if(g&&g.addEventListener){if(g.aborted){u();break}g.addEventListener("abort",u)}return y.signal}Y.exports=U,Y.exports.anySignal=U},3210:Y=>{var U=1e3,x=60*U,y=60*x,u=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Y.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*u;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*U;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=u?f(d,b,u,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=U?f(d,b,U,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=u?Math.round(d/u)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=U?Math.round(d/U)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},1455:(Y,U,x)=>{U.formatArgs=function u(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+Y.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;c.splice(1,0,f,"color: inherit");let d=0,b=0;c[0].replace(/%[a-zA-Z%]/g,S=>{"%%"!==S&&(d++,"%c"===S&&(b=d))}),c.splice(b,0,f)},U.save=function g(c){try{c?U.storage.setItem("debug",c):U.storage.removeItem("debug")}catch{}},U.load=function w(){let c;try{c=U.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c},U.useColors=function y(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},U.storage=function m(){try{return localStorage}catch{}}(),U.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),U.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],U.log=console.debug||console.log||(()=>{}),Y.exports=x(3283)(U);const{formatters:h}=Y.exports;h.j=function(c){try{return JSON.stringify(c)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}},3283:(Y,U,x)=>{Y.exports=function y(u){function w(E){let v,I,A,p=null;function P(...D){if(!P.enabled)return;const T=P,M=Number(new Date);T.diff=M-(v||M),T.prev=v,T.curr=M,v=M,D[0]=w.coerce(D[0]),"string"!=typeof D[0]&&D.unshift("%O");let F=0;D[0]=D[0].replace(/%([a-zA-Z%])/g,(C,O)=>{if("%%"===C)return"%";F++;const V=w.formatters[O];return"function"==typeof V&&(C=V.call(T,D[F]),D.splice(F,1),F--),C}),w.formatArgs.call(T,D),(T.log||w.log).apply(T,D)}return P.namespace=E,P.useColors=w.useColors(),P.color=w.selectColor(E),P.extend=m,P.destroy=w.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==p?p:(I!==w.namespaces&&(I=w.namespaces,A=w.enabled(E)),A),set:D=>{p=D}}),"function"==typeof w.init&&w.init(P),P}function m(E,v){const p=w(this.namespace+(typeof v>"u"?":":v)+E);return p.log=this.log,p}function d(E){return E.toString().substring(2,E.toString().length-2).replace(/\.\*\?$/,"*")}return w.debug=w,w.default=w,w.coerce=function b(E){return E instanceof Error?E.stack||E.message:E},w.disable=function c(){const E=[...w.names.map(d),...w.skips.map(d).map(v=>"-"+v)].join(",");return w.enable(""),E},w.enable=function h(E){let v;w.save(E),w.namespaces=E,w.names=[],w.skips=[];const p=("string"==typeof E?E:"").split(/[\s,]+/),I=p.length;for(v=0;v{w[E]=u[E]}),w.names=[],w.skips=[],w.formatters={},w.selectColor=function g(E){let v=0;for(let p=0;p{"use strict";function U(x,u){u=u||{},this._head=0,this._tail=0,this._capacity=u.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(x)&&this._fromArray(x)}U.prototype.peekAt=function(y){var u=y;if(u===(0|u)){var g=this.size();if(!(u>=g||u<-g))return u<0&&(u+=g),this._list[u=this._head+u&this._capacityMask]}},U.prototype.get=function(y){return this.peekAt(y)},U.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},U.prototype.peekFront=function(){return this.peek()},U.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(U.prototype,"length",{get:function(){return this.size()}}),U.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),u}},U.prototype.push=function(y){if(void 0===y)return this.size();var u=this._tail;return this._list[u]=y,this._tail=u+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&y<=u>>>2&&this._shrinkArray(),g}},U.prototype.removeOne=function(y){var u=y;if(u===(0|u)&&this._head!==this._tail){var g=this.size(),w=this._list.length;if(!(u>=g||u<-g)){u<0&&(u+=g);var h,m=this._list[u=this._head+u&this._capacityMask];if(y0;h--)this._list[u]=this._list[u=u-1+w&this._capacityMask];this._list[u]=void 0,this._head=this._head+1+w&this._capacityMask}else{for(h=g-1-y;h>0;h--)this._list[u]=this._list[u=u+1+w&this._capacityMask];this._list[u]=void 0,this._tail=this._tail-1+w&this._capacityMask}return m}}},U.prototype.remove=function(y,u){var w,g=y,m=u;if(g===(0|g)&&this._head!==this._tail){var h=this.size(),c=this._list.length;if(!(g>=h||g<-h||u<1)){if(g<0&&(g+=h),1===u||!u)return(w=new Array(1))[0]=this.removeOne(g),w;if(0===g&&g+u>=h)return w=this.toArray(),this.clear(),w;var f;for(g+u>h&&(u=h-g),w=new Array(u),f=0;f0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(0===y){for(this._head=this._head+u+c&this._capacityMask,f=u-1;f>0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(g0;f--)this.unshift(this._list[g=g-1+c&this._capacityMask]);for(g=this._head-1+c&this._capacityMask;m>0;)this._list[g=g-1+c&this._capacityMask]=void 0,m--;y<0&&(this._tail=g)}else{for(this._tail=g,g=g+u+c&this._capacityMask,f=h-(u+y);f>0;f--)this.push(this._list[g++]);for(g=this._tail;m>0;)this._list[g=g+1+c&this._capacityMask]=void 0,m--}return this._head<2&&this._tail>1e4&&this._tail<=c>>>2&&this._shrinkArray(),w}}},U.prototype.splice=function(y,u){var g=y;if(g===(0|g)){var w=this.size();if(g<0&&(g+=w),!(g>w)){if(arguments.length>2){var m,h,c,f=arguments.length,d=this._list.length,b=2;if(!w||g0&&(this._head=this._head+g+d&this._capacityMask)):(c=this.remove(g,u),this._head=this._head+g+d&this._capacityMask);f>b;)this.unshift(arguments[--f]);for(m=g;m>0;m--)this.unshift(h[m-1])}else{var S=(h=new Array(w-(g+u))).length;for(m=0;mthis._tail){for(m=this._head;m>>=1,this._capacityMask>>>=1},Y.exports=U},2535:Y=>{"use strict";function U(y,u){for(const g in u)Object.defineProperty(y,g,{value:u[g],enumerable:!0,configurable:!0});return y}Y.exports=function x(y,u,g){if(!y||"string"==typeof y)throw new TypeError("Please pass an Error to err-code");g||(g={}),"object"==typeof u&&(g=u,u=""),u&&(g.code=u);try{return U(y,g)}catch{g.message=y.message,g.stack=y.stack;const m=function(){};return m.prototype=Object.create(Object.getPrototypeOf(y)),U(new m,g)}}},3676:(Y,U,x)=>{"use strict";const u=x(649);U.zN=u.EventIterator},649:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});class x{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(g){if(this.isStopped)return;const w={value:g,done:!1};if(this.pullQueue.length){const m=this.pullQueue.shift();m&&m.resolve(w)}else this.pushQueue.push(Promise.resolve(w)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const g of this.pullQueue)g.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(g){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const w of this.pullQueue)w.reject(g);this.pullQueue.length=0}else{const w=Promise.reject(g);w.catch(()=>{}),this.pushQueue.push(w)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:g=>{const w=this.pushQueue.shift();return w?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),w):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((m,h)=>{this.pullQueue.push({resolve:m,reject:h})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class y{constructor(g,{highWaterMark:w=100,lowWaterMark:m=1}={}){const h=new x;h.highWaterMark=w,h.lowWaterMark=m,h.removeCallback=g({push:c=>h.push(c),stop:()=>h.stop(),fail:c=>h.fail(c),on:(c,f)=>{h.eventHandlers[c]=f}})||(()=>{}),this[Symbol.asyncIterator]=()=>h[Symbol.asyncIterator](),Object.freeze(this)}}U.EventIterator=y,U.default=y},2005:Y=>{"use strict";var U=Object.prototype.hasOwnProperty,x="~";function y(){}function u(h,c,f){this.fn=h,this.context=c,this.once=f||!1}function g(h,c,f,d,b){if("function"!=typeof f)throw new TypeError("The listener must be a function");var S=new u(f,d||h,b),E=x?x+c:c;return h._events[E]?h._events[E].fn?h._events[E]=[h._events[E],S]:h._events[E].push(S):(h._events[E]=S,h._eventsCount++),h}function w(h,c){0==--h._eventsCount?h._events=new y:delete h._events[c]}function m(){this._events=new y,this._eventsCount=0}Object.create&&(y.prototype=Object.create(null),(new y).__proto__||(x=!1)),m.prototype.eventNames=function(){var f,d,c=[];if(0===this._eventsCount)return c;for(d in f=this._events)U.call(f,d)&&c.push(x?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(f)):c},m.prototype.listeners=function(c){var d=this._events[x?x+c:c];if(!d)return[];if(d.fn)return[d.fn];for(var b=0,S=d.length,E=new Array(S);b{"use strict";var y,U="object"==typeof Reflect?Reflect:null,x=U&&"function"==typeof U.apply?U.apply:function(M,k,F){return Function.prototype.apply.call(M,k,F)};y=U&&"function"==typeof U.ownKeys?U.ownKeys:Object.getOwnPropertySymbols?function(M){return Object.getOwnPropertyNames(M).concat(Object.getOwnPropertySymbols(M))}:function(M){return Object.getOwnPropertyNames(M)};var g=Number.isNaN||function(M){return M!=M};function w(){w.init.call(this)}Y.exports=w,Y.exports.once=function A(T,M){return new Promise(function(k,F){function j(O){T.removeListener(M,C),F(O)}function C(){"function"==typeof T.removeListener&&T.removeListener("error",j),k([].slice.call(arguments))}D(T,M,C,{once:!0}),"error"!==M&&function P(T,M,k){"function"==typeof T.on&&D(T,"error",M,k)}(T,j,{once:!0})})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var m=10;function h(T){if("function"!=typeof T)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof T)}function c(T){return void 0===T._maxListeners?w.defaultMaxListeners:T._maxListeners}function f(T,M,k,F){var j,C,O;if(h(k),void 0===(C=T._events)?(C=T._events=Object.create(null),T._eventsCount=0):(void 0!==C.newListener&&(T.emit("newListener",M,k.listener?k.listener:k),C=T._events),O=C[M]),void 0===O)O=C[M]=k,++T._eventsCount;else if("function"==typeof O?O=C[M]=F?[k,O]:[O,k]:F?O.unshift(k):O.push(k),(j=c(T))>0&&O.length>j&&!O.warned){O.warned=!0;var V=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(M)+" listeners added. Use emitter.setMaxListeners() to increase limit");V.name="MaxListenersExceededWarning",V.emitter=T,V.type=M,V.count=O.length,function u(T){console&&console.warn&&console.warn(T)}(V)}return T}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function b(T,M,k){var F={fired:!1,wrapFn:void 0,target:T,type:M,listener:k},j=d.bind(F);return j.listener=k,F.wrapFn=j,j}function S(T,M,k){var F=T._events;if(void 0===F)return[];var j=F[M];return void 0===j?[]:"function"==typeof j?k?[j.listener||j]:[j]:k?function I(T){for(var M=new Array(T.length),k=0;k0&&(O=k[0]),O instanceof Error)throw O;var V=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw V.context=O,V}var L=C[M];if(void 0===L)return!1;if("function"==typeof L)x(L,this,k);else{var K=L.length,re=v(L,K);for(F=0;F=0;O--)if(F[O]===k||F[O].listener===k){V=F[O].listener,C=O;break}if(C<0)return this;0===C?F.shift():function p(T,M){for(;M+1=0;j--)this.removeListener(M,k[j]);return this},w.prototype.listeners=function(M){return S(this,M,!0)},w.prototype.rawListeners=function(M){return S(this,M,!1)},w.listenerCount=function(T,M){return"function"==typeof T.listenerCount?T.listenerCount(M):E.call(T,M)},w.prototype.listenerCount=E,w.prototype.eventNames=function(){return this._eventsCount>0?y(this._events):[]}},3111:Y=>{Y.exports=class{constructor(x){if(!(x>0)||0!=(x-1&x))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(x),this.mask=x-1,this.top=0,this.btm=0,this.next=null}push(x){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=x,this.top=this.top+1&this.mask,!0)}shift(){const x=this.buffer[this.btm];if(void 0!==x)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,x}peek(){return this.buffer[this.btm]}isEmpty(){return void 0===this.buffer[this.btm]}}},1159:(Y,U,x)=>{const y=x(3111);Y.exports=class{constructor(g){this.hwm=g||16,this.head=new y(this.hwm),this.tail=this.head}push(g){this.head.push(g)||(this.head=this.head.next=new y(2*this.head.buffer.length),this.head.push(g))}shift(){const g=this.tail.shift();if(void 0===g&&this.tail.next){const w=this.tail.next;return this.tail.next=null,this.tail=w,this.tail.shift()}return g}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}},5550:Y=>{Y.exports=function(U){if(!U)throw Error("hashlru must have a max value, of type number, greater than 0");var x=0,y=Object.create(null),u=Object.create(null);function g(w,m){y[w]=m,++x>=U&&(x=0,u=y,y=Object.create(null))}return{has:function(w){return void 0!==y[w]||void 0!==u[w]},remove:function(w){void 0!==y[w]&&(y[w]=void 0),void 0!==u[w]&&(u[w]=void 0)},get:function(w){var m=y[w];return void 0!==m?m:void 0!==(m=u[w])?(g(w,m),m):void 0},set:function(w,m){void 0!==y[w]?y[w]=m:g(w,m)},clear:function(){y=Object.create(null),u=Object.create(null)}}}},4066:Y=>{"use strict";const U="[a-fA-F\\d:]",x=f=>f&&f.includeBoundaries?`(?:(?<=\\s|^)(?=${U})|(?<=${U})(?=\\s|$))`:"",y="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",u="[a-fA-F\\d]{1,4}",g=`\n(?:\n(?:${u}:){7}(?:${u}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${u}:){6}(?:${y}|:${u}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${u}:){5}(?::${y}|(?::${u}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${u}:){4}(?:(?::${u}){0,1}:${y}|(?::${u}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${u}:){3}(?:(?::${u}){0,2}:${y}|(?::${u}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${u}:){2}(?:(?::${u}){0,3}:${y}|(?::${u}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${u}:){1}(?:(?::${u}){0,4}:${y}|(?::${u}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${u}){0,5}:${y}|(?::${u}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),w=new RegExp(`(?:^${y}$)|(?:^${g}$)`),m=new RegExp(`^${y}$`),h=new RegExp(`^${g}$`),c=f=>f&&f.exact?w:new RegExp(`(?:${x(f)}${y}${x(f)})|(?:${x(f)}${g}${x(f)})`,"g");c.v4=f=>f&&f.exact?m:new RegExp(`${x(f)}${y}${x(f)}`,"g"),c.v6=f=>f&&f.exact?h:new RegExp(`${x(f)}${g}${x(f)}`,"g"),Y.exports=c},1396:function(Y){!function(U){"use strict";const x="(0?\\d+|0x[a-f0-9]+)",y={fourOctet:new RegExp(`^${x}\\.${x}\\.${x}\\.${x}$`,"i"),threeOctet:new RegExp(`^${x}\\.${x}\\.${x}$`,"i"),twoOctet:new RegExp(`^${x}\\.${x}$`,"i"),longValue:new RegExp(`^${x}$`,"i")},u=new RegExp("^0[0-7]+$","i"),g=new RegExp("^0x[a-f0-9]+$","i"),w="%[0-9a-z]{1,}",m="(?:[0-9a-f]+::?)+",h={zoneIndex:new RegExp(w,"i"),native:new RegExp(`^(::)?(${m})?([0-9a-f]+)?(::)?(${w})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${x}\\.${x}\\.${x}\\.${x}(${w})?)$`,"i"),transitional:new RegExp(`^((?:${m})|(?:::)(?:${m})?)${x}\\.${x}\\.${x}\\.${x}(${w})?$`,"i")};function c(E,v){if(E.indexOf("::")!==E.lastIndexOf("::"))return null;let P,D,p=0,I=-1,A=(E.match(h.zoneIndex)||[])[0];for(A&&(A=A.substring(1),E=E.replace(/%.+$/,""));(I=E.indexOf(":",I+1))>=0;)p++;if("::"===E.substr(0,2)&&p--,"::"===E.substr(-2,2)&&p--,p>v)return null;for(D=v-p,P=":";D--;)P+="0:";return":"===(E=E.replace("::",P))[0]&&(E=E.slice(1)),":"===E[E.length-1]&&(E=E.slice(0,-1)),{parts:v=function(){const T=E.split(":"),M=[];for(let k=0;k0;){if(P=p-I,P<0&&(P=0),E[A]>>P!=v[A]>>P)return!1;I-=p,A+=1}return!0}function d(E){if(g.test(E))return parseInt(E,16);if("0"===E[0]&&!isNaN(parseInt(E[1],10))){if(u.test(E))return parseInt(E,8);throw new Error(`ipaddr: cannot parse ${E} as octal`)}return parseInt(E,10)}function b(E,v){for(;E.length=0;A-=1){if(P=this.octets[A],!(P in I))return null;if(D=I[P],p&&0!==D)return null;8!==D&&(p=!0),v+=D}return 32-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){return this.octets.slice(0)},E.prototype.toIPv4MappedAddress=function(){return S.IPv6.parse(`::ffff:${this.toString()}`)},E.prototype.toNormalizedString=function(){return this.toString()},E.prototype.toString=function(){return this.octets.join(".")},E}(),S.IPv4.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<4;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.isIPv4=function(E){return null!==this.parser(E)},S.IPv4.isValid=function(E){try{return new this(this.parser(E)),!0}catch{return!1}},S.IPv4.isValidFourPartDecimal=function(E){return!(!S.IPv4.isValid(E)||!E.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},S.IPv4.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<4;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.parse=function(E){const v=this.parser(E);if(null===v)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(v)},S.IPv4.parseCIDR=function(E){let v;if(v=E.match(/^(.+)\/(\d+)$/)){const p=parseInt(v[2]);if(p>=0&&p<=32){const I=[this.parse(v[1]),p];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},S.IPv4.parser=function(E){let v,p,I;if(v=E.match(y.fourOctet))return function(){const A=v.slice(1,6),P=[];for(let D=0;D4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const A=[];let P;for(P=0;P<=24;P+=8)A.push(I>>P&255);return A}().reverse()}return(v=E.match(y.twoOctet))?function(){const A=v.slice(1,4),P=[];if(I=d(A[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(I>>16&255),P.push(I>>8&255),P.push(255&I),P}():(v=E.match(y.threeOctet))?function(){const A=v.slice(1,5),P=[];if(I=d(A[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(d(A[1])),P.push(I>>8&255),P.push(255&I),P}():null},S.IPv4.subnetMaskFromPrefixLength=function(E){if((E=parseInt(E))<0||E>32)throw new Error("ipaddr: invalid IPv4 prefix length");const v=[0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p=0;D-=1){if(A=this.parts[D],!(A in I))return null;if(P=I[A],p&&0!==P)return null;16!==P&&(p=!0),v+=P}return 128-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){let v;const p=[],I=this.parts;for(let A=0;A>8),p.push(255&v);return p},E.prototype.toFixedLengthString=function(){const v=function(){const I=[];for(let A=0;A>8,255&p,I>>8,255&I])},E.prototype.toNormalizedString=function(){const v=function(){const I=[];for(let A=0;AA&&(I=P.index,A=P[0].length);return A<0?p:`${p.substring(0,I)}::${p.substring(I+A)}`},E.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},E}(),S.IPv6.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<16;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch(v){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${v})`)}},S.IPv6.isIPv6=function(E){return null!==this.parser(E)},S.IPv6.isValid=function(E){if("string"==typeof E&&-1===E.indexOf(":"))return!1;try{const v=this.parser(E);return new this(v.parts,v.zoneId),!0}catch{return!1}},S.IPv6.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<16;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch(D){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${D})`)}},S.IPv6.parse=function(E){const v=this.parser(E);if(null===v.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(v.parts,v.zoneId)},S.IPv6.parseCIDR=function(E){let v,p,I;if((p=E.match(/^(.+)\/(\d+)$/))&&(v=parseInt(p[2]),v>=0&&v<=128))return I=[this.parse(p[1]),v],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},S.IPv6.parser=function(E){let v,p,I,A,P,D;if(I=E.match(h.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(h.native.test(E))return c(E,8);if((I=E.match(h.transitional))&&(D=I[6]||"",v=c(I[1].slice(0,-1)+D,6),v.parts)){for(P=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],p=0;p128)throw new Error("ipaddr: invalid IPv6 prefix length");const v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p{Y.exports=function U(){return typeof window<"u"&&"object"==typeof window.process&&"renderer"===window.process.type||typeof process<"u"&&"object"==typeof process.versions&&!!process.versions.electron||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0}},7494:Y=>{"use strict";Y.exports=U=>{if("[object Object]"!==Object.prototype.toString.call(U))return!1;const x=Object.getPrototypeOf(U);return null===x||x===Object.prototype}},8596:(Y,U,x)=>{"use strict";const{URLWithLegacySupport:y,format:u,URLSearchParams:g,defaultBase:w}=x(5695),m=x(340);Y.exports={URL:y,URLSearchParams:g,format:u,relative:m,defaultBase:w}},340:(Y,U,x)=>{"use strict";const{URLWithLegacySupport:y,format:u}=x(5695);Y.exports=(g,w={},m={},h)=>{let f,c=w.protocol?w.protocol.replace(":",""):"http";c=(m[c]||h||c)+":";try{f=new y(g)}catch{f={}}const d=Object.assign({},w,{protocol:c||f.protocol,host:w.host||f.host});return new y(g,u(d)).toString()}},5695:Y=>{"use strict";const U=typeof navigator<"u"&&"ReactNative"===navigator.product,y=self.URL,u=function x(){return U?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}();Y.exports={URLWithLegacySupport:class g{constructor(h="",c=u){this.super=new y(h,c),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(h){this.super.hash=h}set host(h){this.super.host=h}set hostname(h){this.super.hostname=h}set href(h){this.super.href=h}set password(h){this.super.password=h}set pathname(h){this.super.pathname=h}set port(h){this.super.port=h}set protocol(h){this.super.protocol=h}set search(h){this.super.search=h}set username(h){this.super.username=h}static createObjectURL(h){return y.createObjectURL(h)}static revokeObjectURL(h){y.revokeObjectURL(h)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:u,format:function w(m){if("string"==typeof m)return new y(m).toString();if(!(m instanceof y)){const c=m.auth?m.auth+"@":"",f=m.port?":"+m.port:"",S=m.hostname||"",E=m.search||(m.query?"?"+m.query:""),p=m.pathname||"";return`${m.protocol?m.protocol+"//":""}${(m.username&&m.password?`${m.username}:${m.password}@`:"")||c}${m.host||S+f}${m.path||p+E}${m.hash||""}`}}}},5357:(Y,U,x)=>{"use strict";var y=x(7156).default,u=x(8237).default;Y.exports=function(){var w=y(function*(m){const h=[];var d,c=!1,f=!1;try{for(var S,b=u(m);c=!(S=yield b.next()).done;c=!1)h.push(S.value)}catch(E){f=!0,d=E}finally{try{c&&null!=b.return&&(yield b.return())}finally{if(f)throw d}}return h});return function(h){return w.apply(this,arguments)}}()},7414:(Y,U,x)=>{"use strict";var y=x(7156).default,u=x(8237).default;Y.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var d=u(m);h=!(yield d.next()).done;h=!1);}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},6225:(Y,U,x)=>{"use strict";var y=x(6737).default,u=x(8186).default,g=x(8237).default;Y.exports=function(){var m=u(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;(yield y(c(v)))&&(yield v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},4943:(Y,U,x)=>{"use strict";var y=x(7156).default,u=x(8237).default;Y.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var b,d=u(m);h=!(b=yield d.next()).done;h=!1)return b.value}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},1349:(Y,U,x)=>{"use strict";var y=x(6737).default,u=x(8186).default,g=x(8237).default;Y.exports=function(){var m=u(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield y(c(v)),yield v}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},6930:(Y,U,x)=>{"use strict";var y=x(6737).default,u=x(8186).default,g=x(8237).default;Y.exports=function(){var m=u(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield c(v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},5061:(Y,U,x)=>{"use strict";var y=x(7156).default,u=x(8186).default,g=x(6737).default,w=x(8237).default,m=x(8131).default;const h=x(6343);Y.exports=function(){var f=u(function*(...d){const b=h();setTimeout(y(function*(){try{yield Promise.all(d.map(function(){var S=y(function*(E){var I,v=!1,p=!1;try{for(var P,A=w(E);v=!(P=yield A.next()).done;v=!1)b.push(P.value)}catch(D){p=!0,I=D}finally{try{v&&null!=A.return&&(yield A.return())}finally{if(p)throw I}}});return function(E){return S.apply(this,arguments)}}())),b.end()}catch(S){b.end(S)}}),0),yield*m(w(b),g)});return function(){return f.apply(this,arguments)}}()},6343:(Y,U,x)=>{const y=x(1159);Y.exports=u=>{let g;"function"==typeof(u=u||{})?(g=u,u={}):g=u.onEnd;let m,h,c,w=new y;const d=A=>h?h(A):(w.push(A),m),S=A=>c?m:d({done:!1,value:A}),E=A=>c?m:(c=!0,A?(A=>(w=new y,h?h({error:A}):(w.push({error:A}),m)))(A):d({done:!0}));if(m={[Symbol.asyncIterator](){return this},next:()=>{if(!w.isEmpty()){if(u.writev){let P;const D=[];for(;!w.isEmpty();){if(P=w.shift(),P.error)throw P.error;D.push(P.value)}return{done:P.done,value:D}}const A=w.shift();if(A.error)throw A.error;return A}return c?{done:!0}:new Promise((A,P)=>{h=D=>(h=null,D.error?P(D.error):A(u.writev&&!D.done?{done:D.done,value:[D.value]}:D),m)})},return:()=>(w=new y,E(),{done:!0}),throw:A=>(E(A),{done:!0}),push:S,end:E},!g)return m;const I=m;return m={[Symbol.asyncIterator](){return this},next:()=>I.next(),throw:A=>(I.throw(A),g&&(g(A),g=null),{done:!0}),return:()=>(I.return(),g&&(g(),g=null),{done:!0}),push:S,end:A=>(I.end(A),g&&(g(A),g=null),m)},m}},4297:(Y,U,x)=>{"use strict";var y=x(8186).default,u=x(6737).default,g=x(8237).default,w=x(8131).default;const m=x(5357);Y.exports=function(){var c=y(function*(f,d){const b=yield u(m(f));yield*w(g(b.sort(d)),u)});return function(d,b){return c.apply(this,arguments)}}()},0:(Y,U,x)=>{"use strict";var y=x(6737).default,u=x(8186).default,g=x(8237).default;Y.exports=function(){var m=u(function*(h,c){let f=0;if(!(c<1)){var S,d=!1,b=!1;try{for(var v,E=g(h);d=!(v=yield y(E.next())).done;d=!1)if(yield v.value,f++,f===c)return}catch(p){b=!0,S=p}finally{try{d&&null!=E.return&&(yield y(E.return()))}finally{if(b)throw S}}}});return function(c,f){return m.apply(this,arguments)}}()},4237:(Y,U,x)=>{var y;!function(){"use strict";var u="input is invalid type",w="object"==typeof window,m=w?window:{};m.JS_SHA3_NO_WINDOW&&(w=!1);var h=!w&&"object"==typeof self;!m.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?m=global:h&&(m=self);var f=!m.JS_SHA3_NO_COMMON_JS&&Y.exports,d=x.amdO,b=!m.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",S="0123456789abcdef".split(""),v=[4,1024,262144,67108864],A=[0,8,16,24],P=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],D=[224,256,384,512],T=[128,256],M=["hex","buffer","arrayBuffer","array","digest"],k={128:168,256:136};(m.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(H){return"[object Array]"===Object.prototype.toString.call(H)}),b&&(m.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(H){return"object"==typeof H&&H.buffer&&H.buffer.constructor===ArrayBuffer});for(var F=function(H,Ee,Ie){return function(xe){return new Ne(H,Ee,H).update(xe)[Ie]()}},j=function(H,Ee,Ie){return function(xe,He){return new Ne(H,Ee,He).update(xe)[Ie]()}},C=function(H,Ee,Ie){return function(xe,He,We,Je){return X["cshake"+H].update(xe,He,We,Je)[Ie]()}},O=function(H,Ee,Ie){return function(xe,He,We,Je){return X["kmac"+H].update(xe,He,We,Je)[Ie]()}},V=function(H,Ee,Ie,xe){for(var He=0;He>5,this.byteCount=this.blockCount<<2,this.outputBlocks=Ie>>5,this.extraBytes=(31&Ie)>>3;for(var xe=0;xe<50;++xe)this.s[xe]=0}function be(H,Ee,Ie){Ne.call(this,H,Ee,Ie)}Ne.prototype.update=function(H){if(this.finalized)throw new Error("finalize already called");var Ee,Ie=typeof H;if("string"!==Ie){if("object"!==Ie)throw new Error(u);if(null===H)throw new Error(u);if(b&&H.constructor===ArrayBuffer)H=new Uint8Array(H);else if(!(Array.isArray(H)||b&&ArrayBuffer.isView(H)))throw new Error(u);Ee=!0}for(var pt,_t,xe=this.blocks,He=this.byteCount,We=H.length,Je=this.blockCount,Xe=0,Nt=this.s;Xe>2]|=H[Xe]<>2]|=_t<>2]|=(192|_t>>6)<>2]|=(128|63&_t)<=57344?(xe[pt>>2]|=(224|_t>>12)<>2]|=(128|_t>>6&63)<>2]|=(128|63&_t)<>2]|=(240|_t>>18)<>2]|=(128|_t>>12&63)<>2]|=(128|_t>>6&63)<>2]|=(128|63&_t)<=He){for(this.start=pt-He,this.block=xe[Je],pt=0;pt>=8);Ie>0;)He.unshift(Ie),Ie=255&(H>>=8),++xe;return Ee?He.push(xe):He.unshift(xe),this.update(He),He.length},Ne.prototype.encodeString=function(H){var Ee,Ie=typeof H;if("string"!==Ie){if("object"!==Ie)throw new Error(u);if(null===H)throw new Error(u);if(b&&H.constructor===ArrayBuffer)H=new Uint8Array(H);else if(!(Array.isArray(H)||b&&ArrayBuffer.isView(H)))throw new Error(u);Ee=!0}var xe=0;if(Ee)xe=H.length;else for(var We=0;We=57344?xe+=3:(Je=65536+((1023&Je)<<10|1023&H.charCodeAt(++We)),xe+=4)}return xe+=this.encode(8*xe),this.update(H),xe},Ne.prototype.bytepad=function(H,Ee){for(var Ie=this.encode(Ee),xe=0;xe>2]|=this.padding[3&Ee],this.lastByteIndex===this.byteCount)for(H[0]=H[Ie],Ee=1;Ee>4&15]+S[15&Xe]+S[Xe>>12&15]+S[Xe>>8&15]+S[Xe>>20&15]+S[Xe>>16&15]+S[Xe>>28&15]+S[Xe>>24&15];We%H==0&&(je(Ee),He=0)}return xe&&(Je+=S[(Xe=Ee[He])>>4&15]+S[15&Xe],xe>1&&(Je+=S[Xe>>12&15]+S[Xe>>8&15]),xe>2&&(Je+=S[Xe>>20&15]+S[Xe>>16&15])),Je},Ne.prototype.buffer=Ne.prototype.arrayBuffer=function(){this.finalize();var Xe,H=this.blockCount,Ee=this.s,Ie=this.outputBlocks,xe=this.extraBytes,He=0,We=0,Je=this.outputBits>>3;Xe=xe?new ArrayBuffer(Ie+1<<2):new ArrayBuffer(Je);for(var Nt=new Uint32Array(Xe);We>8&255,Je[Xe+2]=Nt>>16&255,Je[Xe+3]=Nt>>24&255;We%H==0&&je(Ee)}return xe&&(Je[Xe=We<<2]=255&(Nt=Ee[He]),xe>1&&(Je[Xe+1]=Nt>>8&255),xe>2&&(Je[Xe+2]=Nt>>16&255)),Je},(be.prototype=new Ne).finalize=function(){return this.encode(this.outputBits,!0),Ne.prototype.finalize.call(this)};var je=function(H){var Ee,Ie,xe,He,We,Je,Xe,Nt,pt,_t,Or,pr,Hr,ie,fe,ye,me,_e,Me,Qe,qe,it,nt,Ke,we,ge,De,Fe,Be,dt,xt,vt,et,An,Bt,gn,tn,ft,fn,st,Kt,wt,er,Pr,kn,En,ur,Zn,bn,Ft,ct,ce,ve,mt,Dt,yn,ze,Ye,Ae,Ge,ht,Et,ut;for(xe=0;xe<48;xe+=2)He=H[0]^H[10]^H[20]^H[30]^H[40],We=H[1]^H[11]^H[21]^H[31]^H[41],Nt=H[4]^H[14]^H[24]^H[34]^H[44],pt=H[5]^H[15]^H[25]^H[35]^H[45],_t=H[6]^H[16]^H[26]^H[36]^H[46],Or=H[7]^H[17]^H[27]^H[37]^H[47],Ie=(Hr=H[9]^H[19]^H[29]^H[39]^H[49])^((Xe=H[3]^H[13]^H[23]^H[33]^H[43])<<1|(Je=H[2]^H[12]^H[22]^H[32]^H[42])>>>31),H[0]^=Ee=(pr=H[8]^H[18]^H[28]^H[38]^H[48])^(Je<<1|Xe>>>31),H[1]^=Ie,H[10]^=Ee,H[11]^=Ie,H[20]^=Ee,H[21]^=Ie,H[30]^=Ee,H[31]^=Ie,H[40]^=Ee,H[41]^=Ie,Ie=We^(pt<<1|Nt>>>31),H[2]^=Ee=He^(Nt<<1|pt>>>31),H[3]^=Ie,H[12]^=Ee,H[13]^=Ie,H[22]^=Ee,H[23]^=Ie,H[32]^=Ee,H[33]^=Ie,H[42]^=Ee,H[43]^=Ie,Ie=Xe^(Or<<1|_t>>>31),H[4]^=Ee=Je^(_t<<1|Or>>>31),H[5]^=Ie,H[14]^=Ee,H[15]^=Ie,H[24]^=Ee,H[25]^=Ie,H[34]^=Ee,H[35]^=Ie,H[44]^=Ee,H[45]^=Ie,Ie=pt^(Hr<<1|pr>>>31),H[6]^=Ee=Nt^(pr<<1|Hr>>>31),H[7]^=Ie,H[16]^=Ee,H[17]^=Ie,H[26]^=Ee,H[27]^=Ie,H[36]^=Ee,H[37]^=Ie,H[46]^=Ee,H[47]^=Ie,Ie=Or^(We<<1|He>>>31),H[8]^=Ee=_t^(He<<1|We>>>31),H[9]^=Ie,H[18]^=Ee,H[19]^=Ie,H[28]^=Ee,H[29]^=Ie,H[38]^=Ee,H[39]^=Ie,H[48]^=Ee,H[49]^=Ie,fe=H[1],En=H[11]<<4|H[10]>>>28,ur=H[10]<<4|H[11]>>>28,Fe=H[20]<<3|H[21]>>>29,Be=H[21]<<3|H[20]>>>29,Ge=H[31]<<9|H[30]>>>23,ht=H[30]<<9|H[31]>>>23,wt=H[40]<<18|H[41]>>>14,er=H[41]<<18|H[40]>>>14,An=H[2]<<1|H[3]>>>31,Bt=H[3]<<1|H[2]>>>31,me=H[12]<<12|H[13]>>>20,Zn=H[22]<<10|H[23]>>>22,bn=H[23]<<10|H[22]>>>22,dt=H[33]<<13|H[32]>>>19,xt=H[32]<<13|H[33]>>>19,Et=H[42]<<2|H[43]>>>30,ut=H[43]<<2|H[42]>>>30,mt=H[5]<<30|H[4]>>>2,Dt=H[4]<<30|H[5]>>>2,gn=H[14]<<6|H[15]>>>26,tn=H[15]<<6|H[14]>>>26,Me=H[24]<<11|H[25]>>>21,Ft=H[34]<<15|H[35]>>>17,ct=H[35]<<15|H[34]>>>17,vt=H[45]<<29|H[44]>>>3,et=H[44]<<29|H[45]>>>3,Ke=H[6]<<28|H[7]>>>4,we=H[7]<<28|H[6]>>>4,yn=H[17]<<23|H[16]>>>9,ze=H[16]<<23|H[17]>>>9,ft=H[26]<<25|H[27]>>>7,fn=H[27]<<25|H[26]>>>7,Qe=H[36]<<21|H[37]>>>11,qe=H[37]<<21|H[36]>>>11,ce=H[47]<<24|H[46]>>>8,ve=H[46]<<24|H[47]>>>8,Pr=H[8]<<27|H[9]>>>5,kn=H[9]<<27|H[8]>>>5,ge=H[18]<<20|H[19]>>>12,De=H[19]<<20|H[18]>>>12,Ye=H[29]<<7|H[28]>>>25,Ae=H[28]<<7|H[29]>>>25,st=H[38]<<8|H[39]>>>24,Kt=H[39]<<8|H[38]>>>24,it=H[48]<<14|H[49]>>>18,nt=H[49]<<14|H[48]>>>18,H[0]=(ie=H[0])^~(ye=H[13]<<12|H[12]>>>20)&(_e=H[25]<<11|H[24]>>>21),H[1]=fe^~me&Me,H[10]=Ke^~ge&Fe,H[11]=we^~De&Be,H[20]=An^~gn&ft,H[21]=Bt^~tn&fn,H[30]=Pr^~En&Zn,H[31]=kn^~ur&bn,H[40]=mt^~yn&Ye,H[41]=Dt^~ze&Ae,H[2]=ye^~_e&Qe,H[3]=me^~Me&qe,H[12]=ge^~Fe&dt,H[13]=De^~Be&xt,H[22]=gn^~ft&st,H[23]=tn^~fn&Kt,H[32]=En^~Zn&Ft,H[33]=ur^~bn&ct,H[42]=yn^~Ye&Ge,H[43]=ze^~Ae&ht,H[4]=_e^~Qe&it,H[5]=Me^~qe&nt,H[14]=Fe^~dt&vt,H[15]=Be^~xt&et,H[24]=ft^~st&wt,H[25]=fn^~Kt&er,H[34]=Zn^~Ft&ce,H[35]=bn^~ct&ve,H[44]=Ye^~Ge&Et,H[45]=Ae^~ht&ut,H[6]=Qe^~it&ie,H[7]=qe^~nt&fe,H[16]=dt^~vt&Ke,H[17]=xt^~et&we,H[26]=st^~wt&An,H[27]=Kt^~er&Bt,H[36]=Ft^~ce&Pr,H[37]=ct^~ve&kn,H[46]=Ge^~Et&mt,H[47]=ht^~ut&Dt,H[8]=it^~ie&ye,H[9]=nt^~fe&me,H[18]=vt^~Ke&ge,H[19]=et^~we&De,H[28]=wt^~An&gn,H[29]=er^~Bt&tn,H[38]=ce^~Pr&En,H[39]=ve^~kn&ur,H[48]=Et^~mt&yn,H[49]=ut^~Dt&ze,H[0]^=P[xe],H[1]^=P[xe+1]};if(f)Y.exports=X;else{for(ne=0;neObject.defineProperty(p,I,{value:A,writable:!0,enumerable:!0,configurable:!0}),m=this,h={concatArrays:!1,ignoreUndefined:!1},c=p=>{const I=[];for(const A in p)u.call(p,A)&&I.push(A);if(Object.getOwnPropertySymbols){const A=Object.getOwnPropertySymbols(p);for(const P of A)g.call(p,P)&&I.push(P)}return I};function f(p){return Array.isArray(p)?function d(p){const I=p.slice(0,0);return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):y(p)?function b(p){const I=null===Object.getPrototypeOf(p)?Object.create(null):{};return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):p}const S=(p,I,A,P)=>(A.forEach(D=>{typeof I[D]>"u"&&P.ignoreUndefined||(D in p&&p[D]!==Object.getPrototypeOf(p)?w(p,D,v(p[D],I[D],P)):w(p,D,f(I[D])))}),p);function v(p,I,A){return A.concatArrays&&Array.isArray(p)&&Array.isArray(I)?((p,I,A)=>{let P=p.slice(0,0),D=0;return[p,I].forEach(T=>{const M=[];for(let k=0;k!M.includes(k)),A)}),P})(p,I,A):y(I)&&y(p)?S(p,I,c(I),A):f(I)}Y.exports=function(...p){const I=v(f(h),this!==m&&this||{},h);let A={_:{}};for(const P of p)if(void 0!==P){if(!y(P))throw new TypeError("`"+P+"` is not an Option Object");A=v(A,{_:P},I)}return A._}},4366:Y=>{var U=1e3,x=60*U,y=60*x,u=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Y.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*u;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*U;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=u?f(d,b,u,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=U?f(d,b,U,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=u?Math.round(d/u)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=U?Math.round(d/U)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},344:Y=>{"use strict";function U(x){if(Array.isArray(x)){for(var y=0,u=Array(x.length);y>>24,(f&255<<16)>>>16,(65280&f)>>>8,255&f].join(".")},h=function(f){var d,S,E,v,p;for(d=[],S=E=0;E<=3&&0!==f.length;S=++E){if(S>0){if("."!==f[0])throw new Error("Invalid IP");f=f.substring(1)}v=(p=y(f))[0],f=f.substring(p[1]),d.push(v)}if(0!==f.length)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},g=(u=function(f){return f.charCodeAt(0)})("0"),m=u("a"),w=u("A"),y=function(f){var d,b,S,E,v;for(E=0,d=10,b="9",S=0,f.length>1&&"0"===f[S]&&("x"===f[S+1]||"X"===f[S+1]?(S+=2,d=16):"0"<=f[S+1]&&f[S+1]<="9"&&(S++,d=8,b="7")),v=S;S>>0;else{if(16!==d)break;if("a"<=f[S]&&f[S]<="f")E=E*d+(10+u(f[S])-m)>>>0;else{if(!("A"<=f[S]&&f[S]<="F"))break;E=E*d+(10+u(f[S])-w)>>>0}}if(E>4294967295)throw new Error("too large");S++}if(S===v)throw new Error("empty octet");return[E,S]},x=function(){function f(d,b){var E,v,p;if("string"!=typeof d)throw new Error("Missing `net' parameter");if(b||(p=d.split("/",2),d=p[0],b=p[1]),b||(b=32),"string"==typeof b&&b.indexOf(".")>-1){try{this.maskLong=h(b)}catch(I){throw new Error("Invalid mask: "+b)}for(E=v=32;v>=0;E=--v)if(this.maskLong===4294967295<<32-E>>>0){this.bitmask=E;break}}else{if(!b&&0!==b)throw new Error("Invalid mask: empty");this.bitmask=parseInt(b,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(h(d)&this.maskLong)>>>0}catch(I){throw new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+b);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=c(this.bitmask<=30?this.netLong+this.size-2:this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return f.prototype.contains=function(d){return"string"==typeof d&&(d.indexOf("/")>0||4!==d.split(".").length)&&(d=new f(d)),d instanceof f?this.contains(d.base)&&this.contains(d.broadcast||d.last):(h(d)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},f.prototype.next=function(d){return null==d&&(d=1),new f(c(this.netLong+this.size*d),this.mask)},f.prototype.forEach=function(d){var b,S,E;for(E=h(this.first),S=h(this.last),b=0;E<=S;)d(c(E),E,b),b++,E++},f.prototype.toString=function(){return this.base+"/"+this.bitmask},f}(),U.ip2long=h,U.long2ip=c,U.Netmask=x}).call(this)},1298:(Y,U,x)=>{var y=x(8659);function u(p,I){y.cipher.registerAlgorithm(p,function(){return new y.aes.Algorithm(p,I)})}x(3311),x(3481),x(4747),Y.exports=y.aes=y.aes||{},y.aes.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P});return D.start(I),D},y.aes.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.aes.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P});return D.start(I),D},y.aes.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.aes.Algorithm=function(p,I){g||b();var A=this;A.name=p,A.mode=new I({blockSize:16,cipher:{encrypt:function(P,D){return E(A._w,P,D,!1)},decrypt:function(P,D){return E(A._w,P,D,!0)}}}),A._init=!1},y.aes.Algorithm.prototype.initialize=function(p){if(!this._init){var A,I=p.key;if("string"!=typeof I||16!==I.length&&24!==I.length&&32!==I.length){if(y.util.isArray(I)&&(16===I.length||24===I.length||32===I.length)){A=I,I=y.util.createBuffer();for(var P=0;P>>=2,P=0;P>8^255&k^99,h[k]=A,j=(F=p[k])<<24^k<<16^k<<8^k^F,C=((D=p[A])^(T=p[D])^(M=p[T]))<<24^(A^M)<<16^(A^T^M)<<8^A^D^M;for(var O=0;O<4;++O)f[O][A]=j,d[O][k]=C,j=j<<24|j>>>8,C=C<<24|C>>>8;0===A?A=P=1:(A=D^p[p[p[D^M]]],P^=p[p[P]])}}function S(p,I){for(var P,A=p.slice(0),D=1,T=A.length,k=4*(T+6+1),F=T;F>>16&255]<<24^m[P>>>8&255]<<16^m[255&P]<<8^m[P>>>24]^c[D]<<24,D++):T>6&&F%T==4&&(P=m[P>>>24]<<24^m[P>>>16&255]<<16^m[P>>>8&255]<<8^m[255&P]),A[F]=A[F-T]^P;if(I){for(var j,C=d[0],O=d[1],V=d[2],L=d[3],K=A.slice(0),re=(F=0,(k=A.length)-4);F>>24]]^O[m[j>>>16&255]]^V[m[j>>>8&255]]^L[m[255&j]];A=K}return A}function E(p,I,A,P){var T,M,k,F,j,C,O,V,L,K,re,G,D=p.length/4-1;P?(T=d[0],M=d[1],k=d[2],F=d[3],j=h):(T=f[0],M=f[1],k=f[2],F=f[3],j=m),C=I[0]^p[0],O=I[P?3:1]^p[1],V=I[2]^p[2],L=I[P?1:3]^p[3];for(var te=3,X=1;X>>24]^M[O>>>16&255]^k[V>>>8&255]^F[255&L]^p[++te],re=T[O>>>24]^M[V>>>16&255]^k[L>>>8&255]^F[255&C]^p[++te],G=T[V>>>24]^M[L>>>16&255]^k[C>>>8&255]^F[255&O]^p[++te],L=T[L>>>24]^M[C>>>16&255]^k[O>>>8&255]^F[255&V]^p[++te],C=K,O=re,V=G;A[0]=j[C>>>24]<<24^j[O>>>16&255]<<16^j[V>>>8&255]<<8^j[255&L]^p[++te],A[P?3:1]=j[O>>>24]<<24^j[V>>>16&255]<<16^j[L>>>8&255]<<8^j[255&C]^p[++te],A[2]=j[V>>>24]<<24^j[L>>>16&255]<<16^j[C>>>8&255]<<8^j[255&O]^p[++te],A[P?1:3]=j[L>>>24]<<24^j[C>>>16&255]<<16^j[O>>>8&255]<<8^j[255&V]^p[++te]}function v(p){var P,A="AES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},7791:(Y,U,x)=>{var y=x(8659);x(4747),x(6078);var u=Y.exports=y.asn1=y.asn1||{};function g(c,f,d){if(d>f){var b=new Error("Too few bytes to parse DER.");throw b.available=c.length(),b.remaining=f,b.requested=d,b}}function m(c,f,d,b){var S;g(c,f,2);var E=c.getByte();f--;var v=192&E,p=31&E;S=c.length();var I=function(c,f){var d=c.getByte();if(f--,128!==d){var b;if(128&d){var E=127&d;g(c,f,E),b=c.getInt(E<<3)}else b=d;if(b<0)throw new Error("Negative length: "+b);return b}}(c,f);if(f-=S-c.length(),void 0!==I&&I>f){if(b.strict){var A=new Error("Too few bytes to read ASN.1 value.");throw A.available=c.length(),A.remaining=f,A.requested=I,A}I=f}var P,D,T=32==(32&E);if(T)if(P=[],void 0===I)for(;;){if(g(c,f,2),c.bytes(2)===String.fromCharCode(0,0)){c.getBytes(2),f-=2;break}S=c.length(),P.push(m(c,f,d+1,b)),f-=S-c.length()}else for(;I>0;)S=c.length(),P.push(m(c,I,d+1,b)),f-=S-c.length(),I-=S-c.length();if(void 0===P&&v===u.Class.UNIVERSAL&&p===u.Type.BITSTRING&&(D=c.bytes(I)),void 0===P&&b.decodeBitStrings&&v===u.Class.UNIVERSAL&&p===u.Type.BITSTRING&&I>1){var M=c.read,k=f,F=0;if(p===u.Type.BITSTRING&&(g(c,f,1),F=c.getByte(),f--),0===F)try{S=c.length();var C=m(c,f,d+1,{strict:!0,decodeBitStrings:!0}),O=S-c.length();f-=O,p==u.Type.BITSTRING&&O++;var V=C.tagClass;O===I&&(V===u.Class.UNIVERSAL||V===u.Class.CONTEXT_SPECIFIC)&&(P=[C])}catch{}void 0===P&&(c.read=M,f=k)}if(void 0===P){if(void 0===I){if(b.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");I=f}if(p===u.Type.BMPSTRING)for(P="";I>0;I-=2)g(c,f,2),P+=String.fromCharCode(c.getInt16()),f-=2;else P=c.getBytes(I),f-=I}return u.create(v,p,T,P,void 0===D?null:{bitStringContents:D})}u.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},u.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},u.create=function(c,f,d,b,S){if(y.util.isArray(b)){for(var E=[],v=0;v1&&(0===c.value.charCodeAt(0)&&0==(128&c.value.charCodeAt(1))||255===c.value.charCodeAt(0)&&128==(128&c.value.charCodeAt(1)))?b.putBytes(c.value.substr(1)):b.putBytes(c.value);if(f.putByte(d),b.length()<=127)f.putByte(127&b.length());else{var v=b.length(),p="";do{p+=String.fromCharCode(255&v),v>>>=8}while(v>0);for(f.putByte(128|p.length),E=p.length-1;E>=0;--E)f.putByte(p.charCodeAt(E))}return f.putBuffer(b),f},u.oidToDer=function(c){var f=c.split("."),d=y.util.createBuffer();d.putByte(40*parseInt(f[0],10)+parseInt(f[1],10));for(var b,S,E,v,p=2;p>>=7,b||(v|=128),S.push(v),b=!1}while(E>0);for(var I=S.length-1;I>=0;--I)d.putByte(S[I])}return d},u.derToOid=function(c){var f;"string"==typeof c&&(c=y.util.createBuffer(c));var d=c.getByte();f=Math.floor(d/40)+"."+d%40;for(var b=0;c.length()>0;)b<<=7,128&(d=c.getByte())?b+=127&d:(f+="."+(b+d),b=0);return f},u.utcTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,2),10);d=d>=50?1900+d:2e3+d;var b=parseInt(c.substr(2,2),10)-1,S=parseInt(c.substr(4,2),10),E=parseInt(c.substr(6,2),10),v=parseInt(c.substr(8,2),10),p=0;if(c.length>11){var I=c.charAt(10),A=10;"+"!==I&&"-"!==I&&(p=parseInt(c.substr(10,2),10),A+=2)}if(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,0),A&&("+"===(I=c.charAt(A))||"-"===I)){var T=60*parseInt(c.substr(A+1,2),10)+parseInt(c.substr(A+4,2),10);T*=6e4,f.setTime("+"===I?+f-T:+f+T)}return f},u.generalizedTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,4),10),b=parseInt(c.substr(4,2),10)-1,S=parseInt(c.substr(6,2),10),E=parseInt(c.substr(8,2),10),v=parseInt(c.substr(10,2),10),p=parseInt(c.substr(12,2),10),I=0,A=0,P=!1;"Z"===c.charAt(c.length-1)&&(P=!0);var D=c.length-5,T=c.charAt(D);return"+"!==T&&"-"!==T||(A=60*parseInt(c.substr(D+1,2),10)+parseInt(c.substr(D+4,2),10),A*=6e4,"+"===T&&(A*=-1),P=!0),"."===c.charAt(14)&&(I=1e3*parseFloat(c.substr(14),10)),P?(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,I),f.setTime(+f+A)):(f.setFullYear(d,b,S),f.setHours(E,v,p,I)),f},u.dateToUtcTime=function(c){if("string"==typeof c)return c;var f="",d=[];d.push((""+c.getUTCFullYear()).substr(2)),d.push(""+(c.getUTCMonth()+1)),d.push(""+c.getUTCDate()),d.push(""+c.getUTCHours()),d.push(""+c.getUTCMinutes()),d.push(""+c.getUTCSeconds());for(var b=0;b=-128&&c<128)return f.putSignedInt(c,8);if(c>=-32768&&c<32768)return f.putSignedInt(c,16);if(c>=-8388608&&c<8388608)return f.putSignedInt(c,24);if(c>=-2147483648&&c<2147483648)return f.putSignedInt(c,32);var d=new Error("Integer too large; max is 32-bits.");throw d.integer=c,d},u.derToInteger=function(c){"string"==typeof c&&(c=y.util.createBuffer(c));var f=8*c.length();if(f>32)throw new Error("Integer too large; max is 32-bits.");return c.getSignedInt(f)},u.validate=function(c,f,d,b){var S=!1;if((c.tagClass===f.tagClass||typeof f.tagClass>"u")&&(c.type===f.type||typeof f.type>"u"))if(c.constructed===f.constructed||typeof f.constructed>"u"){if(S=!0,f.value&&y.util.isArray(f.value))for(var E=0,v=0;S&&v0&&(b+="\n");for(var S="",E=0;E1?"0x"+y.util.bytesToHex(c.value.slice(1)):"(none)",c.value.length>0){var A=c.value.charCodeAt(0);1==A?b+=" (1 unused bit shown)":A>1&&(b+=" ("+A+" unused bits shown)")}}else if(c.type===u.Type.OCTETSTRING)h.test(c.value)||(b+="("+c.value+") "),b+="0x"+y.util.bytesToHex(c.value);else if(c.type===u.Type.UTF8)try{b+=y.util.decodeUtf8(c.value)}catch(P){if("URI malformed"!==P.message)throw P;b+="0x"+y.util.bytesToHex(c.value)+" (malformed UTF8)"}else c.type===u.Type.PRINTABLESTRING||c.type===u.Type.IA5String?b+=c.value:h.test(c.value)?b+="0x"+y.util.bytesToHex(c.value):b+=0===c.value.length?"[null]":c.value}return b}},2020:Y=>{var U={};Y.exports=U;var x={};U.encode=function(u,g,w){if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');if(void 0!==w&&"number"!=typeof w)throw new TypeError('"maxline" must be a number.');var m="";if(u instanceof Uint8Array){var h=0,c=g.length,f=g.charAt(0),d=[0];for(h=0;h0;)d.push(S%c),S=S/c|0}for(h=0;0===u[h]&&h=0;--h)m+=g[d[h]]}else m=function y(u,g){var w=0,m=g.length,h=g.charAt(0),c=[0];for(w=0;w0;)c.push(d%m),d=d/m|0}var b="";for(w=0;0===u.at(w)&&w=0;--w)b+=g[c[w]];return b}(u,g);if(w){var E=new RegExp(".{1,"+w+"}","g");m=m.match(E).join("\r\n")}return m},U.decode=function(u,g){if("string"!=typeof u)throw new TypeError('"input" must be a string.');if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');var w=x[g];if(!w){w=x[g]=[];for(var m=0;m>=8;for(;S>0;)f.push(255&S),S>>=8}for(var E=0;u[E]===c&&E{var y=x(8659);x(4747),Y.exports=y.cipher=y.cipher||{},y.cipher.algorithms=y.cipher.algorithms||{},y.cipher.createCipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!1})},y.cipher.createDecipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!0})},y.cipher.registerAlgorithm=function(g,w){g=g.toUpperCase(),y.cipher.algorithms[g]=w},y.cipher.getAlgorithm=function(g){return(g=g.toUpperCase())in y.cipher.algorithms?y.cipher.algorithms[g]:null};var u=y.cipher.BlockCipher=function(g){this.algorithm=g.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=g.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=g.decrypt,this.algorithm.initialize(g)};u.prototype.start=function(g){g=g||{};var w={};for(var m in g)w[m]=g[m];w.decrypt=this._decrypt,this._finish=!1,this._input=y.util.createBuffer(),this.output=g.output||y.util.createBuffer(),this.mode.start(w)},u.prototype.update=function(g){for(g&&this._input.putBuffer(g);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},u.prototype.finish=function(g){g&&("ECB"===this.mode.name||"CBC"===this.mode.name)&&(this.mode.pad=function(m){return g(this.blockSize,m,!1)},this.mode.unpad=function(m){return g(this.blockSize,m,!0)});var w={};return w.decrypt=this._decrypt,w.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,w)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,w))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,w))}},3481:(Y,U,x)=>{var y=x(8659);x(4747),y.cipher=y.cipher||{};var u=Y.exports=y.cipher.modes=y.cipher.modes||{};function g(h,c){if("string"==typeof h&&(h=y.util.createBuffer(h)),y.util.isArray(h)&&h.length>4){var f=h;h=y.util.createBuffer();for(var d=0;d0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},u.cbc=function(h){h=h||{},this.name="CBC",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},u.cbc.prototype.start=function(h){if(null===h.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._prev=this._iv.slice(0)}},u.cbc.prototype.encrypt=function(h,c,f){if(h.length()0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},u.cfb=function(h){h=h||{},this.name="CFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},u.cfb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.cfb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.cfb.prototype.decrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.ofb=function(h){h=h||{},this.name="OFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},u.ofb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.ofb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===h.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.ofb.prototype.decrypt=u.ofb.prototype.encrypt,u.ctr=function(h){h=h||{},this.name="CTR",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},u.ctr.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.ctr.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&(h.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}w(this._inBlock)},u.ctr.prototype.decrypt=u.ctr.prototype.encrypt,u.gcm=function(h){h=h||{},this.name="GCM",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0,this._R=3774873600},u.gcm.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");var f,c=y.util.createBuffer(h.iv);if(this._cipherLength=0,f="additionalData"in h?y.util.createBuffer(h.additionalData):y.util.createBuffer(),this._tagLength="tagLength"in h?h.tagLength:128,this._tag=null,h.decrypt&&(this._tag=y.util.createBuffer(h.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var d=c.length();if(12===d)this._j0=[c.getInt32(),c.getInt32(),c.getInt32(),1];else{for(this._j0=[0,0,0,0];c.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[c.getInt32(),c.getInt32(),c.getInt32(),c.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(m(8*d)))}this._inBlock=this._j0.slice(0),w(this._inBlock),this._partialBytes=0,f=y.util.createBuffer(f),this._aDataLength=m(8*f.length());var b=f.length()%this.blockSize;for(b&&f.fillWithByte(0,this.blockSize-b),this._s=[0,0,0,0];f.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[f.getInt32(),f.getInt32(),f.getInt32(),f.getInt32()])},u.gcm.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return h.read-=this.blockSize,c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),w(this._inBlock)},u.gcm.prototype.decrypt=function(h,c,f){var d=h.length();if(d0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),w(this._inBlock),this._hashBlock[0]=h.getInt32(),this._hashBlock[1]=h.getInt32(),this._hashBlock[2]=h.getInt32(),this._hashBlock[3]=h.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var b=0;b0;--d)c[d]=h[d]>>>1|(1&h[d-1])<<31;c[0]=h[0]>>>1,f&&(c[0]^=this._R)},u.gcm.prototype.tableMultiply=function(h){for(var c=[0,0,0,0],f=0;f<32;++f){var S=this._m[f][h[f/8|0]>>>4*(7-f%8)&15];c[0]^=S[0],c[1]^=S[1],c[2]^=S[2],c[3]^=S[3]}return c},u.gcm.prototype.ghash=function(h,c,f){return c[0]^=f[0],c[1]^=f[1],c[2]^=f[2],c[3]^=f[3],this.tableMultiply(c)},u.gcm.prototype.generateHashTable=function(h,c){for(var f=8/c,d=4*f,b=16*f,S=new Array(b),E=0;E>>1,b=new Array(f);b[d]=h.slice(0);for(var S=d>>>1;S>0;)this.pow(b[2*S],b[S]=[]),S>>=1;for(S=2;S{var y=x(8659);function u(p,I){y.cipher.registerAlgorithm(p,function(){return new y.des.Algorithm(p,I)})}x(3311),x(3481),x(4747),Y.exports=y.des=y.des||{},y.des.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.des.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.des.Algorithm=function(p,I){var A=this;A.name=p,A.mode=new I({blockSize:8,cipher:{encrypt:function(P,D){return E(A._keys,P,D,!1)},decrypt:function(P,D){return E(A._keys,P,D,!0)}}}),A._init=!1},y.des.Algorithm.prototype.initialize=function(p){if(!this._init){var I=y.util.createBuffer(p.key);if(0===this.name.indexOf("3DES")&&24!==I.length())throw new Error("Invalid Triple-DES key size: "+8*I.length());this._keys=function S(p){for(var q,I=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],A=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],P=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],D=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],T=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],M=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],k=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],F=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],j=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],C=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],O=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],V=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],L=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],K=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],re=p.length()>8?3:1,G=[],te=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],X=0,ne=0;ne>>4^de))<<4,oe^=q=65535&((de^=q)>>>-16^oe),oe^=(q=858993459&(oe>>>2^(de^=q<<-16)))<<2,oe^=q=65535&((de^=q)>>>-16^oe),oe^=(q=1431655765&(oe>>>1^(de^=q<<-16)))<<1,oe^=q=16711935&((de^=q)>>>8^oe),q=(oe^=(q=1431655765&(oe>>>1^(de^=q<<8)))<<1)<<8|(de^=q)>>>20&240,oe=de<<24|de<<8&16711680|de>>>8&65280|de>>>24&240,de=q;for(var pe=0;pe>>26,de=de<<2|de>>>26):(oe=oe<<1|oe>>>27,de=de<<1|de>>>27);var Le=I[(oe&=-15)>>>28]|A[oe>>>24&15]|P[oe>>>20&15]|D[oe>>>16&15]|T[oe>>>12&15]|M[oe>>>8&15]|k[oe>>>4&15],Se=F[(de&=-15)>>>28]|j[de>>>24&15]|C[de>>>20&15]|O[de>>>16&15]|V[de>>>12&15]|L[de>>>8&15]|K[de>>>4&15];G[X++]=Le^(q=65535&(Se>>>16^Le)),G[X++]=Se^q<<16}}return G}(I),this._init=!0}},u("DES-ECB",y.cipher.modes.ecb),u("DES-CBC",y.cipher.modes.cbc),u("DES-CFB",y.cipher.modes.cfb),u("DES-OFB",y.cipher.modes.ofb),u("DES-CTR",y.cipher.modes.ctr),u("3DES-ECB",y.cipher.modes.ecb),u("3DES-CBC",y.cipher.modes.cbc),u("3DES-CFB",y.cipher.modes.cfb),u("3DES-OFB",y.cipher.modes.ofb),u("3DES-CTR",y.cipher.modes.ctr);var g=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],w=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],m=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],h=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],c=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],f=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],d=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],b=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function E(p,I,A,P){var T,D=32===p.length?3:9;T=3===D?P?[30,-2,-2]:[0,32,2]:P?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var M,k=I[0],F=I[1];k^=(M=252645135&(k>>>4^F))<<4,k^=(M=65535&(k>>>16^(F^=M)))<<16,k^=M=858993459&((F^=M)>>>2^k),k^=M=16711935&((F^=M<<2)>>>8^k),k=(k^=(M=1431655765&(k>>>1^(F^=M<<8)))<<1)<<1|k>>>31,F=(F^=M)<<1|F>>>31;for(var j=0;j>>4|F<<28)^p[V+1];M=k,k=F,F=M^(w[L>>>24&63]|h[L>>>16&63]|f[L>>>8&63]|b[63&L]|g[K>>>24&63]|m[K>>>16&63]|c[K>>>8&63]|d[63&K])}M=k,k=F,F=M}F=F>>>1|F<<31,F^=M=1431655765&((k=k>>>1|k<<31)>>>1^F),F^=(M=16711935&(F>>>8^(k^=M<<1)))<<8,F^=(M=858993459&(F>>>2^(k^=M)))<<2,F^=M=65535&((k^=M)>>>16^F),F^=M=252645135&((k^=M<<16)>>>4^F),A[0]=k^=M<<4,A[1]=F}function v(p){var P,A="DES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},8659:Y=>{Y.exports={options:{usePureJavaScript:!1}}},9032:(Y,U,x)=>{var y=x(8659);x(979),x(4747),(Y.exports=y.hmac=y.hmac||{}).create=function(){var g=null,w=null,m=null,h=null,c={start:function(f,d){if(null!==f)if("string"==typeof f){if(!((f=f.toLowerCase())in y.md.algorithms))throw new Error('Unknown hash algorithm "'+f+'"');w=y.md.algorithms[f].create()}else w=f;if(null===d)d=g;else{if("string"==typeof d)d=y.util.createBuffer(d);else if(y.util.isArray(d)){var b=d;d=y.util.createBuffer();for(var S=0;Sw.blockLength&&(w.start(),w.update(d.bytes()),d=w.digest()),m=y.util.createBuffer(),h=y.util.createBuffer(),E=d.length(),S=0;S{var u,y=x(8659);function m(W,Q,ee){this.data=[],null!=W&&("number"==typeof W?this.fromNumber(W,Q,ee):this.fromString(W,null==Q&&"string"!=typeof W?256:Q))}function h(){return new m(null)}function d(W,Q,ee,le,ke,Ve){for(var tt=16383&Q,Ze=Q>>14;--Ve>=0;){var sn=16383&this.data[W],gr=this.data[W++]>>14,di=Ze*sn+gr*tt;ke=((sn=tt*sn+((16383&di)<<14)+ee.data[le]+ke)>>28)+(di>>14)+Ze*gr,ee.data[le++]=268435455&sn}return ke}Y.exports=y.jsbn=y.jsbn||{},y.jsbn.BigInteger=m,typeof navigator>"u"?(m.prototype.am=d,u=28):"Microsoft Internet Explorer"==navigator.appName?(m.prototype.am=function f(W,Q,ee,le,ke,Ve){for(var tt=32767&Q,Ze=Q>>15;--Ve>=0;){var sn=32767&this.data[W],gr=this.data[W++]>>15,di=Ze*sn+gr*tt;ke=((sn=tt*sn+((32767&di)<<15)+ee.data[le]+(1073741823&ke))>>>30)+(di>>>15)+Ze*gr+(ke>>>30),ee.data[le++]=1073741823&sn}return ke},u=30):"Netscape"!=navigator.appName?(m.prototype.am=function c(W,Q,ee,le,ke,Ve){for(;--Ve>=0;){var tt=Q*this.data[W++]+ee.data[le]+ke;ke=Math.floor(tt/67108864),ee.data[le++]=67108863&tt}return ke},u=26):(m.prototype.am=d,u=28),m.prototype.DB=u,m.prototype.DM=(1<>>16)&&(W=ee,Q+=16),0!=(ee=W>>8)&&(W=ee,Q+=8),0!=(ee=W>>4)&&(W=ee,Q+=4),0!=(ee=W>>2)&&(W=ee,Q+=2),0!=(ee=W>>1)&&(W=ee,Q+=1),Q}function pe(W){this.m=W}function Ee(W){this.m=W,this.mp=W.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,Q+=16),0==(255&W)&&(W>>=8,Q+=8),0==(15&W)&&(W>>=4,Q+=4),0==(3&W)&&(W>>=2,Q+=2),0==(1&W)&&++Q,Q}function tn(W){for(var Q=0;0!=W;)W&=W-1,++Q;return Q}function ve(){}function mt(W){return W}function Ge(W){this.r2=h(),this.q3=h(),m.ONE.dlShiftTo(2*W.t,this.r2),this.mu=this.r2.divide(W),this.m=W}pe.prototype.convert=function Le(W){return W.s<0||W.compareTo(this.m)>=0?W.mod(this.m):W},pe.prototype.revert=function Se(W){return W},pe.prototype.reduce=function Ne(W){W.divRemTo(this.m,null,W)},pe.prototype.mulTo=function be(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},pe.prototype.sqrTo=function je(W,Q){W.squareTo(Q),this.reduce(Q)},Ee.prototype.convert=function Ie(W){var Q=h();return W.abs().dlShiftTo(this.m.t,Q),Q.divRemTo(this.m,null,Q),W.s<0&&Q.compareTo(m.ZERO)>0&&this.m.subTo(Q,Q),Q},Ee.prototype.revert=function xe(W){var Q=h();return W.copyTo(Q),this.reduce(Q),Q},Ee.prototype.reduce=function He(W){for(;W.t<=this.mt2;)W.data[W.t++]=0;for(var Q=0;Q>15)*this.mpl&this.um)<<15)&W.DM;for(W.data[ee=Q+this.m.t]+=this.m.am(0,le,W,Q,0,this.m.t);W.data[ee]>=W.DV;)W.data[ee]-=W.DV,W.data[++ee]++}W.clamp(),W.drShiftTo(this.m.t,W),W.compareTo(this.m)>=0&&W.subTo(this.m,W)},Ee.prototype.mulTo=function Je(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},Ee.prototype.sqrTo=function We(W,Q){W.squareTo(Q),this.reduce(Q)},m.prototype.copyTo=function P(W){for(var Q=this.t-1;Q>=0;--Q)W.data[Q]=this.data[Q];W.t=this.t,W.s=this.s},m.prototype.fromInt=function D(W){this.t=1,this.s=W<0?-1:0,W>0?this.data[0]=W:W<-1?this.data[0]=W+this.DV:this.t=0},m.prototype.fromString=function M(W,Q){var ee;if(16==Q)ee=4;else if(8==Q)ee=3;else if(256==Q)ee=8;else if(2==Q)ee=1;else if(32==Q)ee=5;else{if(4!=Q)return void this.fromRadix(W,Q);ee=2}this.t=0,this.s=0;for(var le=W.length,ke=!1,Ve=0;--le>=0;){var tt=8==ee?255&W[le]:A(W,le);tt<0?"-"==W.charAt(le)&&(ke=!0):(ke=!1,0==Ve?this.data[this.t++]=tt:Ve+ee>this.DB?(this.data[this.t-1]|=(tt&(1<>this.DB-Ve):this.data[this.t-1]|=tt<=this.DB&&(Ve-=this.DB))}8==ee&&0!=(128&W[0])&&(this.s=-1,Ve>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==W;)--this.t},m.prototype.dlShiftTo=function K(W,Q){var ee;for(ee=this.t-1;ee>=0;--ee)Q.data[ee+W]=this.data[ee];for(ee=W-1;ee>=0;--ee)Q.data[ee]=0;Q.t=this.t+W,Q.s=this.s},m.prototype.drShiftTo=function re(W,Q){for(var ee=W;ee=0;--Ze)Q.data[Ze+Ve+1]=this.data[Ze]>>le|tt,tt=(this.data[Ze]&ke)<=0;--Ze)Q.data[Ze]=0;Q.data[Ve]=tt,Q.t=this.t+Ve+1,Q.s=this.s,Q.clamp()},m.prototype.rShiftTo=function te(W,Q){Q.s=this.s;var ee=Math.floor(W/this.DB);if(ee>=this.t)Q.t=0;else{var le=W%this.DB,ke=this.DB-le,Ve=(1<>le;for(var tt=ee+1;tt>le;le>0&&(Q.data[this.t-ee-1]|=(this.s&Ve)<>=this.DB;if(W.t>=this.DB;le+=this.s}else{for(le+=this.s;ee>=this.DB;le-=W.s}Q.s=le<0?-1:0,le<-1?Q.data[ee++]=this.DV+le:le>0&&(Q.data[ee++]=le),Q.t=ee,Q.clamp()},m.prototype.multiplyTo=function q(W,Q){var ee=this.abs(),le=W.abs(),ke=ee.t;for(Q.t=ke+le.t;--ke>=0;)Q.data[ke]=0;for(ke=0;ke=0;)W.data[ee]=0;for(ee=0;ee=Q.DV&&(W.data[ee+Q.t]-=Q.DV,W.data[ee+Q.t+1]=1)}W.t>0&&(W.data[W.t-1]+=Q.am(ee,Q.data[ee],W,2*ee,0,1)),W.s=0,W.clamp()},m.prototype.divRemTo=function oe(W,Q,ee){var le=W.abs();if(!(le.t<=0)){var ke=this.abs();if(ke.t0?(le.lShiftTo(sn,Ve),ke.lShiftTo(sn,ee)):(le.copyTo(Ve),ke.copyTo(ee));var gr=Ve.t,di=Ve.data[gr-1];if(0!=di){var ei=di*(1<1?Ve.data[gr-2]>>this.F2:0),ns=this.FV/ei,Io=(1<=0&&(ee.data[ee.t++]=1,ee.subTo(Li,ee)),m.ONE.dlShiftTo(gr,Li),Li.subTo(Ve,Ve);Ve.t=0;){var vu=ee.data[--ti]==di?this.DM:Math.floor(ee.data[ti]*ns+(ee.data[ti-1]+Jt)*Io);if((ee.data[ti]+=Ve.am(0,vu,ee,wn,0,gr))0&&ee.rShiftTo(sn,ee),tt<0&&m.ZERO.subTo(ee,ee)}}},m.prototype.invDigit=function H(){if(this.t<1)return 0;var W=this.data[0];if(0==(1&W))return 0;var Q=3&W;return(Q=(Q=(Q=(Q=Q*(2-(15&W)*Q)&15)*(2-(255&W)*Q)&255)*(2-((65535&W)*Q&65535))&65535)*(2-W*Q%this.DV)%this.DV)>0?this.DV-Q:-Q},m.prototype.isEven=function Xe(){return 0==(this.t>0?1&this.data[0]:this.s)},m.prototype.exp=function Nt(W,Q){if(W>4294967295||W<1)return m.ONE;var ee=h(),le=h(),ke=Q.convert(this),Ve=V(W)-1;for(ke.copyTo(ee);--Ve>=0;)if(Q.sqrTo(ee,le),(W&1<0)Q.mulTo(le,ke,ee);else{var tt=ee;ee=le,le=tt}return Q.revert(ee)},m.prototype.toString=function F(W){if(this.s<0)return"-"+this.negate().toString(W);var Q;if(16==W)Q=4;else if(8==W)Q=3;else if(2==W)Q=1;else if(32==W)Q=5;else{if(4!=W)return this.toRadix(W);Q=2}var le,ee=(1<0)for(Ze>Ze)>0&&(ke=!0,Ve=I(le));tt>=0;)Ze>(Ze+=this.DB-Q)):(le=this.data[tt]>>(Ze-=Q)&ee,Ze<=0&&(Ze+=this.DB,--tt)),le>0&&(ke=!0),ke&&(Ve+=I(le));return ke?Ve:"0"},m.prototype.negate=function j(){var W=h();return m.ZERO.subTo(this,W),W},m.prototype.abs=function C(){return this.s<0?this.negate():this},m.prototype.compareTo=function O(W){var Q=this.s-W.s;if(0!=Q)return Q;var ee=this.t;if(0!=(Q=ee-W.t))return this.s<0?-Q:Q;for(;--ee>=0;)if(0!=(Q=this.data[ee]-W.data[ee]))return Q;return 0},m.prototype.bitLength=function L(){return this.t<=0?0:this.DB*(this.t-1)+V(this.data[this.t-1]^this.s&this.DM)},m.prototype.mod=function de(W){var Q=h();return this.abs().divRemTo(W,null,Q),this.s<0&&Q.compareTo(m.ZERO)>0&&W.subTo(Q,Q),Q},m.prototype.modPowInt=function pt(W,Q){var ee;return ee=W<256||Q.isEven()?new pe(Q):new Ee(Q),this.exp(W,ee)},m.ZERO=T(0),m.ONE=T(1),ve.prototype.convert=mt,ve.prototype.revert=mt,ve.prototype.mulTo=function Dt(W,Q,ee){W.multiplyTo(Q,ee)},ve.prototype.sqrTo=function yn(W,Q){W.squareTo(Q)},Ge.prototype.convert=function ht(W){if(W.s<0||W.t>2*this.m.t)return W.mod(this.m);if(W.compareTo(this.m)<0)return W;var Q=h();return W.copyTo(Q),this.reduce(Q),Q},Ge.prototype.revert=function Et(W){return W},Ge.prototype.reduce=function ut(W){for(W.drShiftTo(this.m.t-1,this.r2),W.t>this.m.t+1&&(W.t=this.m.t+1,W.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);W.compareTo(this.r2)<0;)W.dAddOffset(1,this.m.t+1);for(W.subTo(this.r2,W);W.compareTo(this.m)>=0;)W.subTo(this.m,W)},Ge.prototype.mulTo=function $t(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},Ge.prototype.sqrTo=function St(W,Q){W.squareTo(Q),this.reduce(Q)};var Xn=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],ca=(1<<26)/Xn[Xn.length-1];m.prototype.chunkSize=function ie(W){return Math.floor(Math.LN2*this.DB/Math.log(W))},m.prototype.toRadix=function ye(W){if(null==W&&(W=10),0==this.signum()||W<2||W>36)return"0";var Q=this.chunkSize(W),ee=Math.pow(W,Q),le=T(ee),ke=h(),Ve=h(),tt="";for(this.divRemTo(le,ke,Ve);ke.signum()>0;)tt=(ee+Ve.intValue()).toString(W).substr(1)+tt,ke.divRemTo(le,ke,Ve);return Ve.intValue().toString(W)+tt},m.prototype.fromRadix=function me(W,Q){this.fromInt(0),null==Q&&(Q=10);for(var ee=this.chunkSize(Q),le=Math.pow(Q,ee),ke=!1,Ve=0,tt=0,Ze=0;Ze=ee&&(this.dMultiply(le),this.dAddOffset(tt,0),Ve=0,tt=0))}Ve>0&&(this.dMultiply(Math.pow(Q,Ve)),this.dAddOffset(tt,0)),ke&&m.ZERO.subTo(this,this)},m.prototype.fromNumber=function _e(W,Q,ee){if("number"==typeof Q)if(W<2)this.fromInt(1);else for(this.fromNumber(W,ee),this.testBit(W-1)||this.bitwiseTo(m.ONE.shiftLeft(W-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(Q);)this.dAddOffset(2,0),this.bitLength()>W&&this.subTo(m.ONE.shiftLeft(W-1),this);else{var le=new Array,ke=7&W;le.length=1+(W>>3),Q.nextBytes(le),ke>0?le[0]&=(1<>=this.DB;if(W.t>=this.DB;le+=this.s}else{for(le+=this.s;ee>=this.DB;le+=W.s}Q.s=le<0?-1:0,le>0?Q.data[ee++]=le:le<-1&&(Q.data[ee++]=this.DV+le),Q.t=ee,Q.clamp()},m.prototype.dMultiply=function ct(W){this.data[this.t]=this.am(0,W-1,this,0,0,this.t),++this.t,this.clamp()},m.prototype.dAddOffset=function ce(W,Q){if(0!=W){for(;this.t<=Q;)this.data[this.t++]=0;for(this.data[Q]+=W;this.data[Q]>=this.DV;)this.data[Q]-=this.DV,++Q>=this.t&&(this.data[this.t++]=0),++this.data[Q]}},m.prototype.multiplyLowerTo=function Ye(W,Q,ee){var ke,le=Math.min(this.t+W.t,Q);for(ee.s=0,ee.t=le;le>0;)ee.data[--le]=0;for(ke=ee.t-this.t;le=0;)ee.data[le]=0;for(le=Math.max(Q-this.t,0);le0)if(0==Q)ee=this.data[0]%W;else for(var le=this.t-1;le>=0;--le)ee=(Q*ee+this.data[le])%W;return ee},m.prototype.millerRabin=function of(W){var Q=this.subtract(m.ONE),ee=Q.getLowestSetBit();if(ee<=0)return!1;for(var Ve,le=Q.shiftRight(ee),ke=function ua(){return{nextBytes:function(W){for(var Q=0;Q=0);var Ze=Ve.modPow(le,this);if(0!=Ze.compareTo(m.ONE)&&0!=Ze.compareTo(Q)){for(var sn=1;sn++>24},m.prototype.shortValue=function Hr(){return 0==this.t?this.s:this.data[0]<<16>>16},m.prototype.signum=function fe(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},m.prototype.toByteArray=function Me(){var W=this.t,Q=new Array;Q[0]=this.s;var le,ee=this.DB-W*this.DB%8,ke=0;if(W-- >0)for(ee>ee)!=(this.s&this.DM)>>ee&&(Q[ke++]=le|this.s<=0;)ee<8?(le=(this.data[W]&(1<>(ee+=this.DB-8)):(le=this.data[W]>>(ee-=8)&255,ee<=0&&(ee+=this.DB,--W)),0!=(128&le)&&(le|=-256),0==ke&&(128&this.s)!=(128&le)&&++ke,(ke>0||le!=this.s)&&(Q[ke++]=le);return Q},m.prototype.equals=function Qe(W){return 0==this.compareTo(W)},m.prototype.min=function qe(W){return this.compareTo(W)<0?this:W},m.prototype.max=function it(W){return this.compareTo(W)>0?this:W},m.prototype.and=function we(W){var Q=h();return this.bitwiseTo(W,Ke,Q),Q},m.prototype.or=function De(W){var Q=h();return this.bitwiseTo(W,ge,Q),Q},m.prototype.xor=function Be(W){var Q=h();return this.bitwiseTo(W,Fe,Q),Q},m.prototype.andNot=function xt(W){var Q=h();return this.bitwiseTo(W,dt,Q),Q},m.prototype.not=function vt(){for(var W=h(),Q=0;Q=this.t?0!=this.s:0!=(this.data[Q]&1<1){var di=h();for(Ve.sqrTo(tt[1],di);Ze<=gr;)tt[Ze]=h(),Ve.mulTo(di,tt[Ze-2],tt[Ze]),Ze+=2}var ns,ti,ei=W.t-1,Io=!0,Jt=h();for(ee=V(W.data[ei])-1;ei>=0;){for(ee>=sn?ns=W.data[ei]>>ee-sn&gr:(ns=(W.data[ei]&(1<0&&(ns|=W.data[ei-1]>>this.DB+ee-sn)),Ze=le;0==(1&ns);)ns>>=1,--Ze;if((ee-=Ze)<0&&(ee+=this.DB,--ei),Io)tt[ns].copyTo(ke),Io=!1;else{for(;Ze>1;)Ve.sqrTo(ke,Jt),Ve.sqrTo(Jt,ke),Ze-=2;Ze>0?Ve.sqrTo(ke,Jt):(ti=ke,ke=Jt,Jt=ti),Ve.mulTo(Jt,tt[ns],ke)}for(;ei>=0&&0==(W.data[ei]&1<=0?(ee.subTo(le,ee),Q&&ke.subTo(tt,ke),Ve.subTo(Ze,Ve)):(le.subTo(ee,le),Q&&tt.subTo(ke,tt),Ze.subTo(Ve,Ze))}return 0!=le.compareTo(m.ONE)?m.ZERO:Ze.compareTo(W)>=0?Ze.subtract(W):Ze.signum()<0?(Ze.addTo(W,Ze),Ze.signum()<0?Ze.add(W):Ze):Ze},m.prototype.pow=function ze(W){return this.exp(W,new ve)},m.prototype.gcd=function xn(W){var Q=this.s<0?this.negate():this.clone(),ee=W.s<0?W.negate():W.clone();if(Q.compareTo(ee)<0){var le=Q;Q=ee,ee=le}var ke=Q.getLowestSetBit(),Ve=ee.getLowestSetBit();if(Ve<0)return Q;for(ke0&&(Q.rShiftTo(Ve,Q),ee.rShiftTo(Ve,ee));Q.signum()>0;)(ke=Q.getLowestSetBit())>0&&Q.rShiftTo(ke,Q),(ke=ee.getLowestSetBit())>0&&ee.rShiftTo(ke,ee),Q.compareTo(ee)>=0?(Q.subTo(ee,Q),Q.rShiftTo(1,Q)):(ee.subTo(Q,ee),ee.rShiftTo(1,ee));return Ve>0&&ee.lShiftTo(Ve,ee),ee},m.prototype.isProbablePrime=function Co(W){var Q,ee=this.abs();if(1==ee.t&&ee.data[0]<=Xn[Xn.length-1]){for(Q=0;Q{var y=x(8659);Y.exports=y.md=y.md||{},y.md.algorithms=y.md.algorithms||{}},9386:(Y,U,x)=>{var y=x(8659);x(8449),Y.exports=y.mgf=y.mgf||{},y.mgf.mgf1=y.mgf1},8449:(Y,U,x)=>{var y=x(8659);x(4747),y.mgf=y.mgf||{},(Y.exports=y.mgf.mgf1=y.mgf1=y.mgf1||{}).create=function(g){return{generate:function(m,h){for(var c=new y.util.ByteBuffer,f=Math.ceil(h/g.digestLength),d=0;d{var y=x(8659);y.pki=y.pki||{};var u=Y.exports=y.pki.oids=y.oids=y.oids||{};function g(m,h){u[m]=h,u[h]=m}function w(m,h){u[m]=h}g("1.2.840.113549.1.1.1","rsaEncryption"),g("1.2.840.113549.1.1.4","md5WithRSAEncryption"),g("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),g("1.2.840.113549.1.1.7","RSAES-OAEP"),g("1.2.840.113549.1.1.8","mgf1"),g("1.2.840.113549.1.1.9","pSpecified"),g("1.2.840.113549.1.1.10","RSASSA-PSS"),g("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),g("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),g("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),g("1.3.101.112","EdDSA25519"),g("1.2.840.10040.4.3","dsa-with-sha1"),g("1.3.14.3.2.7","desCBC"),g("1.3.14.3.2.26","sha1"),g("1.3.14.3.2.29","sha1WithRSASignature"),g("2.16.840.1.101.3.4.2.1","sha256"),g("2.16.840.1.101.3.4.2.2","sha384"),g("2.16.840.1.101.3.4.2.3","sha512"),g("2.16.840.1.101.3.4.2.4","sha224"),g("2.16.840.1.101.3.4.2.5","sha512-224"),g("2.16.840.1.101.3.4.2.6","sha512-256"),g("1.2.840.113549.2.2","md2"),g("1.2.840.113549.2.5","md5"),g("1.2.840.113549.1.7.1","data"),g("1.2.840.113549.1.7.2","signedData"),g("1.2.840.113549.1.7.3","envelopedData"),g("1.2.840.113549.1.7.4","signedAndEnvelopedData"),g("1.2.840.113549.1.7.5","digestedData"),g("1.2.840.113549.1.7.6","encryptedData"),g("1.2.840.113549.1.9.1","emailAddress"),g("1.2.840.113549.1.9.2","unstructuredName"),g("1.2.840.113549.1.9.3","contentType"),g("1.2.840.113549.1.9.4","messageDigest"),g("1.2.840.113549.1.9.5","signingTime"),g("1.2.840.113549.1.9.6","counterSignature"),g("1.2.840.113549.1.9.7","challengePassword"),g("1.2.840.113549.1.9.8","unstructuredAddress"),g("1.2.840.113549.1.9.14","extensionRequest"),g("1.2.840.113549.1.9.20","friendlyName"),g("1.2.840.113549.1.9.21","localKeyId"),g("1.2.840.113549.1.9.22.1","x509Certificate"),g("1.2.840.113549.1.12.10.1.1","keyBag"),g("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),g("1.2.840.113549.1.12.10.1.3","certBag"),g("1.2.840.113549.1.12.10.1.4","crlBag"),g("1.2.840.113549.1.12.10.1.5","secretBag"),g("1.2.840.113549.1.12.10.1.6","safeContentsBag"),g("1.2.840.113549.1.5.13","pkcs5PBES2"),g("1.2.840.113549.1.5.12","pkcs5PBKDF2"),g("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),g("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),g("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),g("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),g("1.2.840.113549.2.7","hmacWithSHA1"),g("1.2.840.113549.2.8","hmacWithSHA224"),g("1.2.840.113549.2.9","hmacWithSHA256"),g("1.2.840.113549.2.10","hmacWithSHA384"),g("1.2.840.113549.2.11","hmacWithSHA512"),g("1.2.840.113549.3.7","des-EDE3-CBC"),g("2.16.840.1.101.3.4.1.2","aes128-CBC"),g("2.16.840.1.101.3.4.1.22","aes192-CBC"),g("2.16.840.1.101.3.4.1.42","aes256-CBC"),g("2.5.4.3","commonName"),g("2.5.4.4","surname"),g("2.5.4.5","serialNumber"),g("2.5.4.6","countryName"),g("2.5.4.7","localityName"),g("2.5.4.8","stateOrProvinceName"),g("2.5.4.9","streetAddress"),g("2.5.4.10","organizationName"),g("2.5.4.11","organizationalUnitName"),g("2.5.4.12","title"),g("2.5.4.13","description"),g("2.5.4.15","businessCategory"),g("2.5.4.17","postalCode"),g("2.5.4.42","givenName"),g("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),g("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),g("2.16.840.1.113730.1.1","nsCertType"),g("2.16.840.1.113730.1.13","nsComment"),w("2.5.29.1","authorityKeyIdentifier"),w("2.5.29.2","keyAttributes"),w("2.5.29.3","certificatePolicies"),w("2.5.29.4","keyUsageRestriction"),w("2.5.29.5","policyMapping"),w("2.5.29.6","subtreesConstraint"),w("2.5.29.7","subjectAltName"),w("2.5.29.8","issuerAltName"),w("2.5.29.9","subjectDirectoryAttributes"),w("2.5.29.10","basicConstraints"),w("2.5.29.11","nameConstraints"),w("2.5.29.12","policyConstraints"),w("2.5.29.13","basicConstraints"),g("2.5.29.14","subjectKeyIdentifier"),g("2.5.29.15","keyUsage"),w("2.5.29.16","privateKeyUsagePeriod"),g("2.5.29.17","subjectAltName"),g("2.5.29.18","issuerAltName"),g("2.5.29.19","basicConstraints"),w("2.5.29.20","cRLNumber"),w("2.5.29.21","cRLReason"),w("2.5.29.22","expirationDate"),w("2.5.29.23","instructionCode"),w("2.5.29.24","invalidityDate"),w("2.5.29.25","cRLDistributionPoints"),w("2.5.29.26","issuingDistributionPoint"),w("2.5.29.27","deltaCRLIndicator"),w("2.5.29.28","issuingDistributionPoint"),w("2.5.29.29","certificateIssuer"),w("2.5.29.30","nameConstraints"),g("2.5.29.31","cRLDistributionPoints"),g("2.5.29.32","certificatePolicies"),w("2.5.29.33","policyMappings"),w("2.5.29.34","policyConstraints"),g("2.5.29.35","authorityKeyIdentifier"),w("2.5.29.36","policyConstraints"),g("2.5.29.37","extKeyUsage"),w("2.5.29.46","freshestCRL"),w("2.5.29.54","inhibitAnyPolicy"),g("1.3.6.1.4.1.11129.2.4.2","timestampList"),g("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),g("1.3.6.1.5.5.7.3.1","serverAuth"),g("1.3.6.1.5.5.7.3.2","clientAuth"),g("1.3.6.1.5.5.7.3.3","codeSigning"),g("1.3.6.1.5.5.7.3.4","emailProtection"),g("1.3.6.1.5.5.7.3.8","timeStamping")},2158:(Y,U,x)=>{var y=x(8659);if(x(1298),x(7791),x(279),x(979),x(6078),x(7949),x(8604),x(8365),x(209),x(5517),x(4747),typeof u>"u")var u=y.jsbn.BigInteger;var g=y.asn1,w=y.pki=y.pki||{};Y.exports=w.pbe=y.pbe=y.pbe||{};var m=w.oids,h={name:"EncryptedPrivateKeyInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},c={name:"PBES2Algorithms",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},f={name:"pkcs-12PbeParams",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"iterations"}]};function d(v,p){return v.start().update(p).digest().getBytes()}function b(v){var p;if(v){if(!(p=w.oids[g.derToOid(v)])){var I=new Error("Unsupported PRF OID.");throw I.oid=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}}else p="hmacWithSHA1";return S(p)}function S(v){var p=y.md;switch(v){case"hmacWithSHA224":p=y.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":v=v.substr(8).toLowerCase();break;default:var I=new Error("Unsupported PRF algorithm.");throw I.algorithm=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}if(!p||!(v in p))throw new Error("Unknown hash algorithm: "+v);return p[v].create()}w.encryptPrivateKeyInfo=function(v,p,I){(I=I||{}).saltSize=I.saltSize||8,I.count=I.count||2048,I.algorithm=I.algorithm||"aes128",I.prfAlgorithm=I.prfAlgorithm||"sha1";var T,M,k,A=y.random.getBytesSync(I.saltSize),P=I.count,D=g.integerToDer(P);if(0===I.algorithm.indexOf("aes")||"des"===I.algorithm){var F,j,C;switch(I.algorithm){case"aes128":T=16,F=16,j=m["aes128-CBC"],C=y.aes.createEncryptionCipher;break;case"aes192":T=24,F=16,j=m["aes192-CBC"],C=y.aes.createEncryptionCipher;break;case"aes256":T=32,F=16,j=m["aes256-CBC"],C=y.aes.createEncryptionCipher;break;case"des":T=8,F=8,j=m.desCBC,C=y.des.createEncryptionCipher;break;default:throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O}var V="hmacWith"+I.prfAlgorithm.toUpperCase(),L=S(V),K=y.pkcs5.pbkdf2(p,A,P,T,L),re=y.random.getBytesSync(F);(G=C(K)).start(re),G.update(g.toDer(v)),G.finish(),k=G.output.getBytes();var te=function E(v,p,I,A){var P=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,v),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,p.getBytes())]);return"hmacWithSHA1"!==A&&P.value.push(g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,y.util.hexToBytes(I.toString(16))),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(w.oids[A]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")])),P}(A,D,T,V);M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBES2).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBKDF2).getBytes()),te]),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(j).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,re)])])])}else{var O;if("3des"!==I.algorithm)throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O;T=24;var G,X=new y.util.ByteBuffer(A);K=w.pbe.generatePkcs12Key(p,X,1,P,T),re=w.pbe.generatePkcs12Key(p,X,2,P,T),(G=y.des.createEncryptionCipher(K)).start(re),G.update(g.toDer(v)),G.finish(),k=G.output.getBytes(),M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,A),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,D.getBytes())])])}return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[M,g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,k)])},w.decryptPrivateKeyInfo=function(v,p){var I=null,A={},P=[];if(!g.validate(v,h,A,P)){var D=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw D.errors=P,D}var T=g.derToOid(A.encryptionOid),M=w.pbe.getCipher(T,A.encryptionParams,p),k=y.util.createBuffer(A.encryptedData);return M.update(k),M.finish()&&(I=g.fromDer(M.output)),I},w.encryptedPrivateKeyToPem=function(v,p){var I={type:"ENCRYPTED PRIVATE KEY",body:g.toDer(v).getBytes()};return y.pem.encode(I,{maxline:p})},w.encryptedPrivateKeyFromPem=function(v){var p=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==p.type){var I=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw I.headerType=p.type,I}if(p.procType&&"ENCRYPTED"===p.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return g.fromDer(p.body)},w.encryptRsaPrivateKey=function(v,p,I){if(!(I=I||{}).legacy){var A=w.wrapRsaPrivateKey(w.privateKeyToAsn1(v));return A=w.encryptPrivateKeyInfo(A,p,I),w.encryptedPrivateKeyToPem(A)}var P,D,T,M;switch(I.algorithm){case"aes128":P="AES-128-CBC",T=16,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes192":P="AES-192-CBC",T=24,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes256":P="AES-256-CBC",T=32,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"3des":P="DES-EDE3-CBC",T=24,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;case"des":P="DES-CBC",T=8,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;default:var k=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+I.algorithm+'".');throw k.algorithm=I.algorithm,k}var j=M(y.pbe.opensslDeriveBytes(p,D.substr(0,8),T));j.start(D),j.update(g.toDer(w.privateKeyToAsn1(v))),j.finish();var C={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:P,parameters:y.util.bytesToHex(D).toUpperCase()},body:j.output.getBytes()};return y.pem.encode(C)},w.decryptRsaPrivateKey=function(v,p){var I=null,A=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==A.type&&"PRIVATE KEY"!==A.type&&"RSA PRIVATE KEY"!==A.type)throw(P=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=P,P;if(A.procType&&"ENCRYPTED"===A.procType.type){var D,T;switch(A.dekInfo.algorithm){case"DES-CBC":D=8,T=y.des.createDecryptionCipher;break;case"DES-EDE3-CBC":D=24,T=y.des.createDecryptionCipher;break;case"AES-128-CBC":D=16,T=y.aes.createDecryptionCipher;break;case"AES-192-CBC":D=24,T=y.aes.createDecryptionCipher;break;case"AES-256-CBC":D=32,T=y.aes.createDecryptionCipher;break;case"RC2-40-CBC":D=5,T=function(C){return y.rc2.createDecryptionCipher(C,40)};break;case"RC2-64-CBC":D=8,T=function(C){return y.rc2.createDecryptionCipher(C,64)};break;case"RC2-128-CBC":D=16,T=function(C){return y.rc2.createDecryptionCipher(C,128)};break;default:var P;throw(P=new Error('Could not decrypt private key; unsupported encryption algorithm "'+A.dekInfo.algorithm+'".')).algorithm=A.dekInfo.algorithm,P}var M=y.util.hexToBytes(A.dekInfo.parameters),F=T(y.pbe.opensslDeriveBytes(p,M.substr(0,8),D));if(F.start(M),F.update(y.util.createBuffer(A.body)),!F.finish())return I;I=F.output.getBytes()}else I=A.body;return null!==(I="ENCRYPTED PRIVATE KEY"===A.type?w.decryptPrivateKeyInfo(g.fromDer(I),p):g.fromDer(I))&&(I=w.privateKeyFromAsn1(I)),I},w.pbe.generatePkcs12Key=function(v,p,I,A,P,D){var T,M;if(typeof D>"u"||null===D){if(!("sha1"in y.md))throw new Error('"sha1" hash algorithm unavailable.');D=y.md.sha1.create()}var k=D.digestLength,F=D.blockLength,j=new y.util.ByteBuffer,C=new y.util.ByteBuffer;if(null!=v){for(M=0;M=0;M--)be>>=8,be+=pe.at(M)+Ne.at(M),Ne.setAt(M,255&be);Se.putBuffer(Ne)}X=Se,j.putBuffer(oe)}return j.truncate(j.length()-P),j},w.pbe.getCipher=function(v,p,I){switch(v){case w.oids.pkcs5PBES2:return w.pbe.getCipherForPBES2(v,p,I);case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case w.oids["pbewithSHAAnd40BitRC2-CBC"]:return w.pbe.getCipherForPKCS12PBE(v,p,I);default:var A=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw A.oid=v,A.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],A}},w.pbe.getCipherForPBES2=function(v,p,I){var D,A={},P=[];if(!g.validate(p,c,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;if((v=g.derToOid(A.kdfOid))!==w.oids.pkcs5PBKDF2)throw(D=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=v,D.supportedOids=["pkcs5PBKDF2"],D;if((v=g.derToOid(A.encOid))!==w.oids["aes128-CBC"]&&v!==w.oids["aes192-CBC"]&&v!==w.oids["aes256-CBC"]&&v!==w.oids["des-EDE3-CBC"]&&v!==w.oids.desCBC)throw(D=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=v,D.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],D;var k,F,T=A.kdfSalt,M=y.util.createBuffer(A.kdfIterationCount);switch(M=M.getInt(M.length()<<3),w.oids[v]){case"aes128-CBC":k=16,F=y.aes.createDecryptionCipher;break;case"aes192-CBC":k=24,F=y.aes.createDecryptionCipher;break;case"aes256-CBC":k=32,F=y.aes.createDecryptionCipher;break;case"des-EDE3-CBC":k=24,F=y.des.createDecryptionCipher;break;case"desCBC":k=8,F=y.des.createDecryptionCipher}var j=b(A.prfOid),C=y.pkcs5.pbkdf2(I,T,M,k,j),O=A.encIv,V=F(C);return V.start(O),V},w.pbe.getCipherForPKCS12PBE=function(v,p,I){var A={},P=[];if(!g.validate(p,f,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;var k,F,j,T=y.util.createBuffer(A.salt),M=y.util.createBuffer(A.iterations);switch(M=M.getInt(M.length()<<3),v){case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:k=24,F=8,j=y.des.startDecrypting;break;case w.oids["pbewithSHAAnd40BitRC2-CBC"]:k=5,F=8,j=function(K,re){var G=y.rc2.createDecryptionCipher(K,40);return G.start(re,null),G};break;default:var D;throw(D=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=v,D}var C=b(A.prfOid),O=w.pbe.generatePkcs12Key(I,T,1,M,k,C);return C.start(),j(O,w.pbe.generatePkcs12Key(I,T,2,M,F,C))},w.pbe.opensslDeriveBytes=function(v,p,I,A){if(typeof A>"u"||null===A){if(!("md5"in y.md))throw new Error('"md5" hash algorithm unavailable.');A=y.md.md5.create()}null===p&&(p="");for(var P=[d(A,v+p)],D=16,T=1;D{var y=x(8659);x(9032),x(979),x(4747);var g,u=y.pkcs5=y.pkcs5||{};y.util.isNodejs&&!y.options.usePureJavaScript&&(g=x(5819)),Y.exports=y.pbkdf2=u.pbkdf2=function(w,m,h,c,f,d){if("function"==typeof f&&(d=f,f=null),y.util.isNodejs&&!y.options.usePureJavaScript&&g.pbkdf2&&(null===f||"object"!=typeof f)&&(g.pbkdf2Sync.length>4||!f||"sha1"===f))return"string"!=typeof f&&(f="sha1"),w=Buffer.from(w,"binary"),m=Buffer.from(m,"binary"),d?4===g.pbkdf2Sync.length?g.pbkdf2(w,m,h,c,function(j,C){if(j)return d(j);d(null,C.toString("binary"))}):g.pbkdf2(w,m,h,c,f,function(j,C){if(j)return d(j);d(null,C.toString("binary"))}):4===g.pbkdf2Sync.length?g.pbkdf2Sync(w,m,h,c).toString("binary"):g.pbkdf2Sync(w,m,h,c,f).toString("binary");if((typeof f>"u"||null===f)&&(f="sha1"),"string"==typeof f){if(!(f in y.md.algorithms))throw new Error("Unknown hash algorithm: "+f);f=y.md[f].create()}var b=f.digestLength;if(c>4294967295*b){var S=new Error("Derived key is too long.");if(d)return d(S);throw S}var E=Math.ceil(c/b),v=c-(E-1)*b,p=y.hmac.create();p.start(f,w);var A,P,D,I="";if(!d){for(var T=1;T<=E;++T){p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes();for(var M=2;M<=h;++M)p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P;I+=TE)return d(null,I);p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes(),M=2,F()}function F(){if(M<=h)return p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P,++M,y.util.setImmediate(F);I+=T{var y=x(8659);x(4747);var u=Y.exports=y.pem=y.pem||{};function g(m){for(var h=m.name+": ",c=[],f=function(v,p){return" "+p},d=0;d65&&-1!==S){var E=h[S];","===E?(++S,h=h.substr(0,S)+"\r\n "+h.substr(S)):h=h.substr(0,S)+"\r\n"+E+h.substr(S+1),b=d-S-1,S=-1,++d}else(" "===h[d]||"\t"===h[d]||","===h[d])&&(S=d);return h}function w(m){return m.replace(/^\s+/,"")}u.encode=function(m,h){h=h||{};var f,c="-----BEGIN "+m.type+"-----\r\n";if(m.procType&&(c+=g(f={name:"Proc-Type",values:[String(m.procType.version),m.procType.type]})),m.contentDomain&&(c+=g(f={name:"Content-Domain",values:[m.contentDomain]})),m.dekInfo&&(f={name:"DEK-Info",values:[m.dekInfo.algorithm]},m.dekInfo.parameters&&f.values.push(m.dekInfo.parameters),c+=g(f)),m.headers)for(var d=0;d{var y=x(8659);x(4747),x(8365),x(7690);var u=Y.exports=y.pkcs1=y.pkcs1||{};function g(w,m,h){h||(h=y.md.sha1.create());for(var c="",f=Math.ceil(m/h.digestLength),d=0;d>24&255,d>>16&255,d>>8&255,255&d);h.start(),h.update(w+b),c+=h.digest().getBytes()}return c.substring(0,m)}u.encode_rsa_oaep=function(w,m,h){var c,f,d,b;"string"==typeof h?(c=h,f=arguments[3]||void 0,d=arguments[4]||void 0):h&&(c=h.label||void 0,f=h.seed||void 0,d=h.md||void 0,h.mgf1&&h.mgf1.md&&(b=h.mgf1.md)),d?d.start():d=y.md.sha1.create(),b||(b=d);var S=Math.ceil(w.n.bitLength()/8),E=S-2*d.digestLength-2;if(m.length>E)throw(v=new Error("RSAES-OAEP input message length is too long.")).length=m.length,v.maxLength=E,v;c||(c=""),d.update(c,"raw");for(var p=d.digest(),I="",A=E-m.length,P=0;P{var y=x(8659);x(1298),x(7791),x(279),x(6078),x(8604),x(4957),x(8365),x(4747),x(5911);var u=y.asn1,g=Y.exports=y.pkcs7=y.pkcs7||{};function w(A){var P={},D=[];if(!u.validate(A,g.asn1.recipientInfoValidator,P,D)){var T=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw T.errors=D,T}return{version:P.version.charCodeAt(0),issuer:y.pki.RDNAttributesAsArray(P.issuer),serialNumber:y.util.createBuffer(P.serial).toHex(),encryptedContent:{algorithm:u.derToOid(P.encAlgorithm),parameter:P.encParameter?P.encParameter.value:void 0,content:P.encKey}}}function m(A){return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(A.version).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[y.pki.distinguishedNameToAsn1({attributes:A.issuer}),u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,y.util.hexToBytes(A.serialNumber))]),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.encryptedContent.algorithm).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")]),u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,A.encryptedContent.content)])}function c(A){for(var P=[],D=0;D0){for(var D=u.create(u.Class.CONTEXT_SPECIFIC,1,!0,[]),T=0;T=D&&M0&&F.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!0,T)),k.length>0&&F.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,k)),F.value[0].value.push(u.create(u.Class.UNIVERSAL,u.Type.SET,!0,A.signerInfos)),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.type).getBytes()),F])},addSigner:function(T){var M=T.issuer,k=T.serialNumber;if(T.certificate){var F=T.certificate;"string"==typeof F&&(F=y.pki.certificateFromPem(F)),M=F.issuer.attributes,k=F.serialNumber}var j=T.key;if(!j)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof j&&(j=y.pki.privateKeyFromPem(j));var C=T.digestAlgorithm||y.pki.oids.sha1;switch(C){case y.pki.oids.sha1:case y.pki.oids.sha256:case y.pki.oids.sha384:case y.pki.oids.sha512:case y.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+C)}var O=T.authenticatedAttributes||[];if(O.length>0){for(var V=!1,L=!1,K=0;K{var y=x(8659);x(7791),x(4747);var u=y.asn1,g=Y.exports=y.pkcs7asn1=y.pkcs7asn1||{};y.pkcs7=y.pkcs7||{},y.pkcs7.asn1=g;var w={name:"ContentInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};g.contentInfoValidator=w;var m={name:"EncryptedContentInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:u.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};g.envelopedDataValidator={name:"EnvelopedData",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:u.Class.UNIVERSAL,type:u.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(m)},g.encryptedDataValidator={name:"EncryptedData",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"version"}].concat(m)},g.signedDataValidator={name:"SignedData",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:u.Class.UNIVERSAL,type:u.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},w,{name:"SignedData.Certificates",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:u.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:u.Class.UNIVERSAL,type:u.Type.SET,capture:"signerInfos",optional:!0,value:[{name:"SignerInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:u.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:u.Class.UNIVERSAL,type:u.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:u.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]}]}]},g.recipientInfoValidator={name:"RecipientInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:u.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:u.Class.UNIVERSAL,type:u.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},9709:(Y,U,x)=>{var y=x(8659);x(4747),x(730),x(8365),function(){if(y.prime)Y.exports=y.prime;else{var u=Y.exports=y.prime=y.prime||{},g=y.jsbn.BigInteger,w=[6,4,2,4,2,4,6,2],m=new g(null);m.fromInt(30);var h=function(v,p){return v|p};u.generateProbablePrime=function(v,p,I){"function"==typeof p&&(I=p,p={});var A=(p=p||{}).algorithm||"PRIMEINC";"string"==typeof A&&(A={name:A}),A.options=A.options||{};var P=p.prng||y.random;if("PRIMEINC"===A.name)return function c(v,p,I,A){return"workers"in I?function b(v,p,I,A){if(typeof Worker>"u")return f(v,p,I,A);var P=S(v,p),D=I.workers,T=I.workLoad||100,M=30*T/8,k=I.workerScript||"forge/prime.worker.js";if(-1===D)return y.util.estimateCores(function(j,C){j&&(C=2),D=C-1,F()});function F(){D=Math.max(1,D);for(var j=[],C=0;Cv&&(P=S(v,p));var te=P.toString(16);K.target.postMessage({hex:te,workLoad:T}),P.dAddOffset(M,0)}}}F()}(v,p,I,A):f(v,p,I,A)}(v,{nextBytes:function(T){for(var M=P.getBytesSync(T.length),k=0;kp&&(v=S(p,I)),v.isProbablePrime(P))return T(null,v);v.dAddOffset(w[A++%8],0)}while(D<0||+new Date-M{var y=x(8659);x(4747);var u=null;y.util.isNodejs&&!y.options.usePureJavaScript&&!process.versions["node-webkit"]&&(u=x(5819)),(Y.exports=y.prng=y.prng||{}).create=function(w){for(var m={plugin:w,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},h=w.md,c=new Array(32),f=0;f<32;++f)c[f]=h.create();function b(){if(m.pools[0].messageLength>=32)return S();m.collect(m.seedFileSync(32-m.pools[0].messageLength<<5)),S()}function S(){m.reseeds=4294967295===m.reseeds?0:m.reseeds+1;var v=m.plugin.md.create();v.update(m.keyBytes);for(var p=1,I=0;I<32;++I)m.reseeds%p==0&&(v.update(m.pools[I].digest().getBytes()),m.pools[I].start()),p<<=1;m.keyBytes=v.digest().getBytes(),v.start(),v.update(m.keyBytes);var A=v.digest().getBytes();m.key=m.plugin.formatKey(m.keyBytes),m.seed=m.plugin.formatSeed(A),m.generated=0}function E(v){var p=null,I=y.util.globalScope,A=I.crypto||I.msCrypto;A&&A.getRandomValues&&(p=function(O){return A.getRandomValues(O)});var P=y.util.createBuffer();if(p)for(;P.length()>16)))<<16,C=4294967295&(F=(2147483647&(F+=k>>15))+(F>>31)),M=0;M<3;++M)j=C>>>(M<<3),j^=Math.floor(256*Math.random()),P.putByte(255&j);return P.getBytes(v)}return m.pools=c,m.pool=0,m.generate=function(v,p){if(!p)return m.generateSync(v);var I=m.plugin.cipher,A=m.plugin.increment,P=m.plugin.formatKey,D=m.plugin.formatSeed,T=y.util.createBuffer();m.key=null,function M(k){if(k)return p(k);if(T.length()>=v)return p(null,T.getBytes(v));if(m.generated>1048575&&(m.key=null),null===m.key)return y.util.nextTick(function(){!function d(v){if(m.pools[0].messageLength>=32)return S(),v();m.seedFile(32-m.pools[0].messageLength<<5,function(I,A){if(I)return v(I);m.collect(A),S(),v()})}(M)});var F=I(m.key,m.seed);m.generated+=F.length,T.putBytes(F),m.key=P(I(m.key,A(m.seed))),m.seed=D(I(m.key,m.seed)),y.util.setImmediate(M)}()},m.generateSync=function(v){var p=m.plugin.cipher,I=m.plugin.increment,A=m.plugin.formatKey,P=m.plugin.formatSeed;m.key=null;for(var D=y.util.createBuffer();D.length()1048575&&(m.key=null),null===m.key&&b();var T=p(m.key,m.seed);m.generated+=T.length,D.putBytes(T),m.key=A(p(m.key,I(m.seed))),m.seed=P(p(m.key,m.seed))}return D.getBytes(v)},u?(m.seedFile=function(v,p){u.randomBytes(v,function(I,A){if(I)return p(I);p(null,A.toString())})},m.seedFileSync=function(v){return u.randomBytes(v).toString()}):(m.seedFile=function(v,p){try{p(null,E(v))}catch(I){p(I)}},m.seedFileSync=E),m.collect=function(v){for(var p=v.length,I=0;I>A&255);m.collect(I)},m.registerWorker=function(v){v===self?m.seedFile=function(I,A){self.addEventListener("message",function P(D){var T=D.data;T.forge&&T.forge.prng&&(self.removeEventListener("message",P),A(T.forge.prng.err,T.forge.prng.bytes))}),self.postMessage({forge:{prng:{needed:I}}})}:v.addEventListener("message",function(I){var A=I.data;A.forge&&A.forge.prng&&m.seedFile(A.forge.prng.needed,function(P,D){v.postMessage({forge:{prng:{err:P,bytes:D}}})})})},m}},7256:(Y,U,x)=>{var y=x(8659);x(8365),x(4747),(Y.exports=y.pss=y.pss||{}).create=function(g){3===arguments.length&&(g={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var f,w=g.md,m=g.mgf,h=w.digestLength,c=g.salt||null;if("string"==typeof c&&(c=y.util.createBuffer(c)),"saltLength"in g)f=g.saltLength;else{if(null===c)throw new Error("Salt length not specified or specific salt not given.");f=c.length()}if(null!==c&&c.length()!==f)throw new Error("Given salt length does not match length of given salt.");var d=g.prng||y.random,b={encode:function(S,E){var v,P,p=E-1,I=Math.ceil(p/8),A=S.digest().getBytes();if(I>8*I-p&255;return(C=String.fromCharCode(C.charCodeAt(0)&~O)+C.substr(1))+T+String.fromCharCode(188)},verify:function(S,E,v){var p,I=v-1,A=Math.ceil(I/8);if(E=E.substr(-A),A>8*A-I&255;if(0!=(D.charCodeAt(0)&M))throw new Error("Bits beyond keysize not zero as expected.");var k=m.generate(T,P),F="";for(p=0;p{var y=x(8659);x(1298),x(1594),x(4473),x(4747),y.random&&y.random.getBytes?Y.exports=y.random:function(u){var g={},w=new Array(4),m=y.util.createBuffer();function h(){var v=y.prng.create(g);return v.getBytes=function(p,I){return v.generate(p,I)},v.getBytesSync=function(p){return v.generate(p)},v}g.formatKey=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),y.aes._expandKey(v,!1)},g.formatSeed=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),v},g.cipher=function(v,p){return y.aes._updateBlock(v,p,w,!1),m.putInt32(w[0]),m.putInt32(w[1]),m.putInt32(w[2]),m.putInt32(w[3]),m.getBytes()},g.increment=function(v){return++v[3],v},g.md=y.md.sha256;var c=h(),f=null,d=y.util.globalScope,b=d.crypto||d.msCrypto;if(b&&b.getRandomValues&&(f=function(v){return b.getRandomValues(v)}),y.options.usePureJavaScript||!y.util.isNodejs&&!f){if(typeof window>"u"||window,c.collectInt(+new Date,32),typeof navigator<"u"){var S="";for(var E in navigator)try{"string"==typeof navigator[E]&&(S+=navigator[E])}catch{}c.collect(S),S=null}u&&(u().mousemove(function(v){c.collectInt(v.clientX,16),c.collectInt(v.clientY,16)}),u().keypress(function(v){c.collectInt(v.charCode,8)}))}if(y.random)for(var E in c)y.random[E]=c[E];else y.random=c;y.random.createInstance=h,Y.exports=y.random}(typeof jQuery<"u"?jQuery:null)},209:(Y,U,x)=>{var y=x(8659);x(4747);var u=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],g=[1,2,3,5],w=function(c,f){return c<>16-f},m=function(c,f){return(65535&c)>>f|c<<16-f&65535};Y.exports=y.rc2=y.rc2||{},y.rc2.expandKey=function(c,f){"string"==typeof c&&(c=y.util.createBuffer(c)),f=f||128;var p,d=c,b=c.length(),S=f,E=Math.ceil(S/8),v=255>>(7&S);for(p=b;p<128;p++)d.putByte(u[d.at(p-1)+d.at(p-b)&255]);for(d.setAt(128-E,u[d.at(128-E)&v]),p=127-E;p>=0;p--)d.setAt(p,u[d.at(p+1)^d.at(p+E)]);return d};var h=function(c,f,d){var p,I,A,P,b=!1,S=null,E=null,v=null,D=[];for(c=y.rc2.expandKey(c,f),A=0;A<64;A++)D.push(c.getInt16Le());d?(p=function(k){for(A=0;A<4;A++)k[A]+=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),k[A]=w(k[A],g[A]),P++},I=function(k){for(A=0;A<4;A++)k[A]+=D[63&k[(A+3)%4]]}):(p=function(k){for(A=3;A>=0;A--)k[A]=m(k[A],g[A]),k[A]-=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),P--},I=function(k){for(A=3;A>=0;A--)k[A]-=D[63&k[(A+3)%4]]});var T=function(k){var F=[];for(A=0;A<4;A++){var j=S.getInt16Le();null!==v&&(d?j^=v.getInt16Le():v.putInt16Le(j)),F.push(65535&j)}P=d?0:63;for(var C=0;C=8;)T([[5,p],[1,I],[6,p],[1,I],[5,p]])},finish:function(k){var F=!0;if(d)if(k)F=k(8,S,!d);else{var j=8===S.length()?8:8-S.length();S.fillWithByte(j,j)}if(F&&(b=!0,M.update()),!d&&(F=0===S.length()))if(k)F=k(8,E,!d);else{var C=E.length(),O=E.at(C-1);O>C?F=!1:E.truncate(O)}return F}}};y.rc2.startEncrypting=function(c,f,d){var b=y.rc2.createEncryptionCipher(c,128);return b.start(f,d),b},y.rc2.createEncryptionCipher=function(c,f){return h(c,f,!0)},y.rc2.startDecrypting=function(c,f,d){var b=y.rc2.createDecryptionCipher(c,128);return b.start(f,d),b},y.rc2.createDecryptionCipher=function(c,f){return h(c,f,!1)}},5517:(Y,U,x)=>{var y=x(8659);if(x(7791),x(730),x(6078),x(7246),x(9709),x(8365),x(4747),typeof u>"u")var u=y.jsbn.BigInteger;var g=y.util.isNodejs?x(5819):null,w=y.asn1,m=y.util;y.pki=y.pki||{},Y.exports=y.pki.rsa=y.rsa=y.rsa||{};var h=y.pki,c=[6,4,2,4,2,4,6,2],f={name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},d={name:"RSAPrivateKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},b={name:"RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},S=y.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},E={name:"DigestInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:w.Class.UNIVERSAL,type:w.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},v=function(L){if(!(L.algorithm in h.oids)){var re=new Error("Unknown message digest algorithm.");throw re.algorithm=L.algorithm,re}var G=w.oidToDer(h.oids[L.algorithm]).getBytes(),te=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]),X=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]);X.value.push(w.create(w.Class.UNIVERSAL,w.Type.OID,!1,G)),X.value.push(w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,""));var q=w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,L.digest().getBytes());return te.value.push(X),te.value.push(q),w.toDer(te).getBytes()},p=function(L,K,re){if(re)return L.modPow(K.e,K.n);if(!K.p||!K.q)return L.modPow(K.d,K.n);var G;K.dP||(K.dP=K.d.mod(K.p.subtract(u.ONE))),K.dQ||(K.dQ=K.d.mod(K.q.subtract(u.ONE))),K.qInv||(K.qInv=K.q.modInverse(K.p));do{G=new u(y.util.bytesToHex(y.random.getBytes(K.n.bitLength()/8)),16)}while(G.compareTo(K.n)>=0||!G.gcd(K.n).equals(u.ONE));for(var te=(L=L.multiply(G.modPow(K.e,K.n)).mod(K.n)).mod(K.p).modPow(K.dP,K.p),X=L.mod(K.q).modPow(K.dQ,K.q);te.compareTo(X)<0;)te=te.add(K.p);var q=te.subtract(X).multiply(K.qInv).mod(K.p).multiply(K.q).add(X);return q.multiply(G.modInverse(K.n)).mod(K.n)};function I(L,K,re){var G=y.util.createBuffer(),te=Math.ceil(K.n.bitLength()/8);if(L.length>te-11){var X=new Error("Message is too long for PKCS#1 v1.5 padding.");throw X.length=L.length,X.max=te-11,X}G.putByte(0),G.putByte(re);var ne,q=te-3-L.length;if(0===re||1===re){ne=0===re?0:255;for(var oe=0;oe0;){var de=0,pe=y.random.getBytes(q);for(oe=0;oe"u")throw new Error("Encryption block is invalid.");var oe=0;if(0===ne){oe=te-3-G;for(var de=0;de1;){if(255!==X.getByte()){--X.read;break}++oe}else if(2===ne)for(oe=0;X.length()>1;){if(0===X.getByte()){--X.read;break}++oe}if(0!==X.getByte()||oe!==te-3-X.length())throw new Error("Encryption block is invalid.");return X.getBytes()}function P(L,K,re){"function"==typeof K&&(re=K,K={});var G={algorithm:{name:(K=K||{}).algorithm||"PRIMEINC",options:{workers:K.workers||2,workLoad:K.workLoad||100,workerScript:K.workerScript}}};function te(){X(L.pBits,function(ne,oe){return ne?re(ne):(L.p=oe,null!==L.q?q(ne,L.q):void X(L.qBits,q))})}function X(ne,oe){y.prime.generateProbablePrime(ne,G,oe)}function q(ne,oe){if(ne)return re(ne);if(L.q=oe,L.p.compareTo(L.q)<0){var de=L.p;L.p=L.q,L.q=de}if(0!==L.p.subtract(u.ONE).gcd(L.e).compareTo(u.ONE))return L.p=null,void te();if(0!==L.q.subtract(u.ONE).gcd(L.e).compareTo(u.ONE))return L.q=null,void X(L.qBits,q);if(L.p1=L.p.subtract(u.ONE),L.q1=L.q.subtract(u.ONE),L.phi=L.p1.multiply(L.q1),0!==L.phi.gcd(L.e).compareTo(u.ONE))return L.p=L.q=null,void te();if(L.n=L.p.multiply(L.q),L.n.bitLength()!==L.bits)return L.q=null,void X(L.qBits,q);var pe=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,pe,L.p,L.q,pe.mod(L.p1),pe.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)},re(null,L.keys)}"prng"in K&&(G.prng=K.prng),te()}function D(L){var K=L.toString(16);K[0]>="8"&&(K="00"+K);var re=y.util.hexToBytes(K);return re.length>1&&(0===re.charCodeAt(0)&&0==(128&re.charCodeAt(1))||255===re.charCodeAt(0)&&128==(128&re.charCodeAt(1)))?re.substr(1):re}function T(L){return L<=100?27:L<=150?18:L<=200?15:L<=250?12:L<=300?9:L<=350?8:L<=400?7:L<=500?6:L<=600?5:L<=800?4:L<=1250?3:2}function M(L){return y.util.isNodejs&&"function"==typeof g[L]}function k(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.crypto&&"object"==typeof m.globalScope.crypto.subtle&&"function"==typeof m.globalScope.crypto.subtle[L]}function F(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.msCrypto&&"object"==typeof m.globalScope.msCrypto.subtle&&"function"==typeof m.globalScope.msCrypto.subtle[L]}function j(L){for(var K=y.util.hexToBytes(L.toString(16)),re=new Uint8Array(K.length),G=0;G0;)de.putByte(0),--pe;return de.putBytes(y.util.hexToBytes(oe)),de.getBytes()},h.rsa.decrypt=function(L,K,re,G){var te=Math.ceil(K.n.bitLength()/8);if(L.length!==te){var X=new Error("Encrypted message length is invalid.");throw X.length=L.length,X.expected=te,X}var q=new u(y.util.createBuffer(L).toHex(),16);if(q.compareTo(K.n)>=0)throw new Error("Encrypted message is invalid.");for(var oe=p(q,K,re).toString(16),de=y.util.createBuffer(),pe=te-Math.ceil(oe.length/2);pe>0;)de.putByte(0),--pe;return de.putBytes(y.util.hexToBytes(oe)),!1!==G?A(de.getBytes(),K,re):de.getBytes()},h.rsa.createKeyPairGenerationState=function(L,K,re){"string"==typeof L&&(L=parseInt(L,10)),L=L||2048;var q,G=(re=re||{}).prng||y.random,te={nextBytes:function(ne){for(var oe=G.getBytesSync(ne.length),de=0;de>1,pBits:L-(L>>1),pqState:0,num:null,keys:null}).e.fromInt(q.eInt),q},h.rsa.stepKeyPairGenerationState=function(L,K){"algorithm"in L||(L.algorithm="PRIMEINC");var re=new u(null);re.fromInt(30);for(var q,G=0,te=function(Le,Se){return Le|Se},X=+new Date,ne=0;null===L.keys&&(K<=0||neoe?L.pqState=0:L.num.isProbablePrime(T(L.num.bitLength()))?++L.pqState:L.num.dAddOffset(c[G++%8],0):2===L.pqState?L.pqState=0===L.num.subtract(u.ONE).gcd(L.e).compareTo(u.ONE)?3:0:3===L.pqState&&(L.pqState=0,null===L.p?L.p=L.num:L.q=L.num,null!==L.p&&null!==L.q&&++L.state,L.num=null)}else if(1===L.state)L.p.compareTo(L.q)<0&&(L.num=L.p,L.p=L.q,L.q=L.num),++L.state;else if(2===L.state)L.p1=L.p.subtract(u.ONE),L.q1=L.q.subtract(u.ONE),L.phi=L.p1.multiply(L.q1),++L.state;else if(3===L.state)0===L.phi.gcd(L.e).compareTo(u.ONE)?++L.state:(L.p=null,L.q=null,L.state=0);else if(4===L.state)L.n=L.p.multiply(L.q),L.n.bitLength()===L.bits?++L.state:(L.q=null,L.state=0);else if(5===L.state){var pe=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,pe,L.p,L.q,pe.mod(L.p1),pe.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)}}ne+=(q=+new Date)-X,X=q}return null!==L.keys},h.rsa.generateKeyPair=function(L,K,re,G){if(1===arguments.length?"object"==typeof L?(re=L,L=void 0):"function"==typeof L&&(G=L,L=void 0):2===arguments.length?"number"==typeof L?"function"==typeof K?(G=K,K=void 0):"number"!=typeof K&&(re=K,K=void 0):(re=L,G=K,L=void 0,K=void 0):3===arguments.length&&("number"==typeof K?"function"==typeof re&&(G=re,re=void 0):(G=re,re=K,K=void 0)),re=re||{},void 0===L&&(L=re.bits||2048),void 0===K&&(K=re.e||65537),!y.options.usePureJavaScript&&!re.prng&&L>=256&&L<=16384&&(65537===K||3===K))if(G){if(M("generateKeyPair"))return g.generateKeyPair("rsa",{modulusLength:L,publicExponent:K,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(ne,oe,de){if(ne)return G(ne);G(null,{privateKey:h.privateKeyFromPem(de),publicKey:h.publicKeyFromPem(oe)})});if(k("generateKey")&&k("exportKey"))return m.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:j(K),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(ne){return m.globalScope.crypto.subtle.exportKey("pkcs8",ne.privateKey)}).then(void 0,function(ne){G(ne)}).then(function(ne){if(ne){var oe=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(ne)));G(null,{privateKey:oe,publicKey:h.setRsaPublicKey(oe.n,oe.e)})}});if(F("generateKey")&&F("exportKey")){var te=m.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:j(K),hash:{name:"SHA-256"}},!0,["sign","verify"]);return te.oncomplete=function(ne){var de=m.globalScope.msCrypto.subtle.exportKey("pkcs8",ne.target.result.privateKey);de.oncomplete=function(pe){var Se=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(pe.target.result)));G(null,{privateKey:Se,publicKey:h.setRsaPublicKey(Se.n,Se.e)})},de.onerror=function(pe){G(pe)}},void(te.onerror=function(ne){G(ne)})}}else if(M("generateKeyPairSync")){var X=g.generateKeyPairSync("rsa",{modulusLength:L,publicExponent:K,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:h.privateKeyFromPem(X.privateKey),publicKey:h.publicKeyFromPem(X.publicKey)}}var q=h.rsa.createKeyPairGenerationState(L,K,re);if(!G)return h.rsa.stepKeyPairGenerationState(q,0),q.keys;P(q,re,G)},h.setRsaPublicKey=h.rsa.setPublicKey=function(L,K){var re={n:L,e:K,encrypt:function(G,te,X){if("string"==typeof te?te=te.toUpperCase():void 0===te&&(te="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===te)te={encode:function(ne,oe,de){return I(ne,oe,2).getBytes()}};else if("RSA-OAEP"===te||"RSAES-OAEP"===te)te={encode:function(ne,oe){return y.pkcs1.encode_rsa_oaep(oe,ne,X)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(te))te={encode:function(ne){return ne}};else if("string"==typeof te)throw new Error('Unsupported encryption scheme: "'+te+'".');var q=te.encode(G,re,!0);return h.rsa.encrypt(q,re,!0)},verify:function(G,te,X,q){"string"==typeof X?X=X.toUpperCase():void 0===X&&(X="RSASSA-PKCS1-V1_5"),void 0===q&&(q={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in q||(q._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===X?X={verify:function(oe,de){de=A(de,re,!0);var pe=w.fromDer(de,{parseAllBytes:q._parseAllDigestBytes}),Le={},Se=[];if(!w.validate(pe,E,Le,Se))throw(Ne=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=Se,Ne;var Ne,be=w.derToOid(Le.algorithmIdentifier);if(be!==y.oids.md2&&be!==y.oids.md5&&be!==y.oids.sha1&&be!==y.oids.sha224&&be!==y.oids.sha256&&be!==y.oids.sha384&&be!==y.oids.sha512&&be!==y.oids["sha512-224"]&&be!==y.oids["sha512-256"])throw(Ne=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=be,Ne;if((be===y.oids.md2||be===y.oids.md5)&&!("parameters"in Le))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return oe===Le.digest}}:("NONE"===X||"NULL"===X||null===X)&&(X={verify:function(oe,de){return oe===A(de,re,!0)}});var ne=h.rsa.decrypt(te,re,!0,!1);return X.verify(G,ne,re.n.bitLength())}};return re},h.setRsaPrivateKey=h.rsa.setPrivateKey=function(L,K,re,G,te,X,q,ne){var oe={n:L,e:K,d:re,p:G,q:te,dP:X,dQ:q,qInv:ne,decrypt:function(de,pe,Le){"string"==typeof pe?pe=pe.toUpperCase():void 0===pe&&(pe="RSAES-PKCS1-V1_5");var Se=h.rsa.decrypt(de,oe,!1,!1);if("RSAES-PKCS1-V1_5"===pe)pe={decode:A};else if("RSA-OAEP"===pe||"RSAES-OAEP"===pe)pe={decode:function(Ne,be){return y.pkcs1.decode_rsa_oaep(be,Ne,Le)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(pe))throw new Error('Unsupported encryption scheme: "'+pe+'".');pe={decode:function(Ne){return Ne}}}return pe.decode(Se,oe,!1)},sign:function(de,pe){var Le=!1;"string"==typeof pe&&(pe=pe.toUpperCase()),void 0===pe||"RSASSA-PKCS1-V1_5"===pe?(pe={encode:v},Le=1):("NONE"===pe||"NULL"===pe||null===pe)&&(pe={encode:function(){return de}},Le=1);var Se=pe.encode(de,oe.n.bitLength());return h.rsa.encrypt(Se,oe,Le)}};return oe},h.wrapRsaPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,w.toDer(L).getBytes())])},h.privateKeyFromAsn1=function(L){var te,X,q,ne,oe,de,pe,Le,K={},re=[];if(w.validate(L,f,K,re)&&(L=w.fromDer(y.util.createBuffer(K.privateKey))),!w.validate(L,d,K={},re=[])){var G=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw G.errors=re,G}return te=y.util.createBuffer(K.privateKeyModulus).toHex(),X=y.util.createBuffer(K.privateKeyPublicExponent).toHex(),q=y.util.createBuffer(K.privateKeyPrivateExponent).toHex(),ne=y.util.createBuffer(K.privateKeyPrime1).toHex(),oe=y.util.createBuffer(K.privateKeyPrime2).toHex(),de=y.util.createBuffer(K.privateKeyExponent1).toHex(),pe=y.util.createBuffer(K.privateKeyExponent2).toHex(),Le=y.util.createBuffer(K.privateKeyCoefficient).toHex(),h.setRsaPrivateKey(new u(te,16),new u(X,16),new u(q,16),new u(ne,16),new u(oe,16),new u(de,16),new u(pe,16),new u(Le,16))},h.privateKeyToAsn1=h.privateKeyToRSAPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.d)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.p)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.q)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dP)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dQ)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.qInv))])},h.publicKeyFromAsn1=function(L){var K={},re=[];if(w.validate(L,S,K,re)){var te,G=w.derToOid(K.publicKeyOid);if(G!==h.oids.rsaEncryption)throw(te=new Error("Cannot read public key. Unknown OID.")).oid=G,te;L=K.rsaPublicKey}if(!w.validate(L,b,K,re=[]))throw(te=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=re,te;var X=y.util.createBuffer(K.publicKeyModulus).toHex(),q=y.util.createBuffer(K.publicKeyExponent).toHex();return h.setRsaPublicKey(new u(X,16),new u(q,16))},h.publicKeyToAsn1=h.publicKeyToSubjectPublicKeyInfo=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.BITSTRING,!1,[h.publicKeyToRSAPublicKey(L)])])},h.publicKeyToRSAPublicKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e))])}},7690:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var u=Y.exports=y.sha1=y.sha1||{};y.md.sha1=y.md.algorithms.sha1=u,u.create=function(){w||function m(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),w=!0}();var c=null,f=y.util.createBuffer(),d=new Array(80),b={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){b.messageLength=0,b.fullMessageLength=b.messageLength64=[];for(var S=b.messageLengthSize/4,E=0;E>>0,v>>>0];for(var p=b.fullMessageLength.length-1;p>=0;--p)b.fullMessageLength[p]+=v[1],v[1]=v[0]+(b.fullMessageLength[p]/4294967296>>>0),b.fullMessageLength[p]=b.fullMessageLength[p]>>>0,v[0]=v[1]/4294967296>>>0;return f.putBytes(S),h(c,d,f),(f.read>2048||0===f.length())&&f.compact(),b},b.digest=function(){var S=y.util.createBuffer();S.putBytes(f.bytes()),S.putBytes(g.substr(0,b.blockLength-(b.fullMessageLength[b.fullMessageLength.length-1]+b.messageLengthSize&b.blockLength-1)));for(var p,A=8*b.fullMessageLength[0],P=0;P>>0)>>>0),A=p>>>0;S.putInt32(A);var D={h0:c.h0,h1:c.h1,h2:c.h2,h3:c.h3,h4:c.h4};h(D,d,S);var T=y.util.createBuffer();return T.putInt32(D.h0),T.putInt32(D.h1),T.putInt32(D.h2),T.putInt32(D.h3),T.putInt32(D.h4),T},b};var g=null,w=!1;function h(c,f,d){for(var b,S,E,v,p,I,P,D=d.length();D>=64;){for(S=c.h0,E=c.h1,v=c.h2,p=c.h3,I=c.h4,P=0;P<16;++P)b=d.getInt32(),f[P]=b,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<20;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<32;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<40;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<60;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E&v|p&(E^v))+I+2400959708+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<80;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+3395469782+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;c.h0=c.h0+S|0,c.h1=c.h1+E|0,c.h2=c.h2+v|0,c.h3=c.h3+p|0,c.h4=c.h4+I|0,D-=64}}},1594:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var u=Y.exports=y.sha256=y.sha256||{};y.md.sha256=y.md.algorithms.sha256=u,u.create=function(){w||function h(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),m=[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],w=!0}();var f=null,d=y.util.createBuffer(),b=new Array(64),S={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){S.messageLength=0,S.fullMessageLength=S.messageLength64=[];for(var E=S.messageLengthSize/4,v=0;v>>0,p>>>0];for(var I=S.fullMessageLength.length-1;I>=0;--I)S.fullMessageLength[I]+=p[1],p[1]=p[0]+(S.fullMessageLength[I]/4294967296>>>0),S.fullMessageLength[I]=S.fullMessageLength[I]>>>0,p[0]=p[1]/4294967296>>>0;return d.putBytes(E),c(f,b,d),(d.read>2048||0===d.length())&&d.compact(),S},S.digest=function(){var E=y.util.createBuffer();E.putBytes(d.bytes()),E.putBytes(g.substr(0,S.blockLength-(S.fullMessageLength[S.fullMessageLength.length-1]+S.messageLengthSize&S.blockLength-1)));for(var I,P=8*S.fullMessageLength[0],D=0;D>>0)>>>0),P=I>>>0;E.putInt32(P);var T={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4,h5:f.h5,h6:f.h6,h7:f.h7};c(T,b,E);var M=y.util.createBuffer();return M.putInt32(T.h0),M.putInt32(T.h1),M.putInt32(T.h2),M.putInt32(T.h3),M.putInt32(T.h4),M.putInt32(T.h5),M.putInt32(T.h6),M.putInt32(T.h7),M},S};var g=null,w=!1,m=null;function c(f,d,b){for(var S,E,A,P,D,T,M,k,F,j,C,O,V=b.length();V>=64;){for(P=0;P<16;++P)d[P]=b.getInt32();for(;P<64;++P)d[P]=(S=((S=d[P-2])>>>17|S<<15)^(S>>>19|S<<13)^S>>>10)+d[P-7]+(E=((E=d[P-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3)+d[P-16]|0;for(D=f.h0,T=f.h1,M=f.h2,k=f.h3,F=f.h4,j=f.h5,C=f.h6,O=f.h7,P=0;P<64;++P)A=D&T|M&(D^T),S=O+((F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7))+(C^F&(j^C))+m[P]+d[P],O=C,C=j,j=F,F=k+S>>>0,k=M,M=T,T=D,D=S+(E=((D>>>2|D<<30)^(D>>>13|D<<19)^(D>>>22|D<<10))+A)>>>0;f.h0=f.h0+D|0,f.h1=f.h1+T|0,f.h2=f.h2+M|0,f.h3=f.h3+k|0,f.h4=f.h4+F|0,f.h5=f.h5+j|0,f.h6=f.h6+C|0,f.h7=f.h7+O|0,V-=64}}},8985:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var u=Y.exports=y.sha512=y.sha512||{};y.md.sha512=y.md.algorithms.sha512=u;var g=y.sha384=y.sha512.sha384=y.sha512.sha384||{};g.create=function(){return u.create("SHA-384")},y.md.sha384=y.md.algorithms.sha384=g,y.sha512.sha256=y.sha512.sha256||{create:function(){return u.create("SHA-512/256")}},y.md["sha512/256"]=y.md.algorithms["sha512/256"]=y.sha512.sha256,y.sha512.sha224=y.sha512.sha224||{create:function(){return u.create("SHA-512/224")}},y.md["sha512/224"]=y.md.algorithms["sha512/224"]=y.sha512.sha224,u.create=function(b){if(m||function f(){w=String.fromCharCode(128),w+=y.util.fillString(String.fromCharCode(0),128),h=[[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]],(c={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],m=!0}(),typeof b>"u"&&(b="SHA-512"),!(b in c))throw new Error("Invalid SHA-512 algorithm: "+b);for(var S=c[b],E=null,v=y.util.createBuffer(),p=new Array(80),I=0;I<80;++I)p[I]=new Array(2);var A=64;switch(b){case"SHA-384":A=48;break;case"SHA-512/256":A=32;break;case"SHA-512/224":A=28}var P={algorithm:b.replace("-","").toLowerCase(),blockLength:128,digestLength:A,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){P.messageLength=0,P.fullMessageLength=P.messageLength128=[];for(var D=P.messageLengthSize/4,T=0;T>>0,M>>>0];for(var k=P.fullMessageLength.length-1;k>=0;--k)P.fullMessageLength[k]+=M[1],M[1]=M[0]+(P.fullMessageLength[k]/4294967296>>>0),P.fullMessageLength[k]=P.fullMessageLength[k]>>>0,M[0]=M[1]/4294967296>>>0;return v.putBytes(D),d(E,p,v),(v.read>2048||0===v.length())&&v.compact(),P},P.digest=function(){var D=y.util.createBuffer();D.putBytes(v.bytes()),D.putBytes(w.substr(0,P.blockLength-(P.fullMessageLength[P.fullMessageLength.length-1]+P.messageLengthSize&P.blockLength-1)));for(var k,j=8*P.fullMessageLength[0],C=0;C>>0)>>>0),j=k>>>0;D.putInt32(j);var O=new Array(E.length);for(C=0;C=128;){for(be=0;be<16;++be)S[be][0]=E.getInt32()>>>0,S[be][1]=E.getInt32()>>>0;for(;be<80;++be)p=(((je=(Ee=S[be-2])[0])<<13|(H=Ee[1])>>>19)^(H<<3|je>>>29)^(je<<26|H>>>6))>>>0,S[be][0]=(v=((je>>>19|H<<13)^(H>>>29|je<<3)^je>>>6)>>>0)+(Ie=S[be-7])[0]+(I=(((je=(xe=S[be-15])[0])>>>1|(H=xe[1])<<31)^(je>>>8|H<<24)^je>>>7)>>>0)+(He=S[be-16])[0]+((H=p+Ie[1]+(A=((je<<31|H>>>1)^(je<<24|H>>>8)^(je<<25|H>>>7))>>>0)+He[1])/4294967296>>>0)>>>0,S[be][1]=H>>>0;for(O=b[0][0],V=b[0][1],L=b[1][0],K=b[1][1],re=b[2][0],G=b[2][1],te=b[3][0],X=b[3][1],q=b[4][0],ne=b[4][1],oe=b[5][0],de=b[5][1],pe=b[6][0],Le=b[6][1],Se=b[7][0],Ne=b[7][1],be=0;be<80;++be)v=Se+(((q>>>14|ne<<18)^(q>>>18|ne<<14)^(ne>>>9|q<<23))>>>0)+((pe^q&(oe^pe))>>>0)+h[be][0]+S[be][0]+((H=Ne+(((q<<18|ne>>>14)^(q<<14|ne>>>18)^(ne<<23|q>>>9))>>>0)+((Le^ne&(de^Le))>>>0)+h[be][1]+S[be][1])/4294967296>>>0)>>>0,p=H>>>0,I=(((O>>>28|V<<4)^(V>>>2|O<<30)^(V>>>7|O<<25))>>>0)+((O&L|re&(O^L))>>>0)+((H=(((O<<4|V>>>28)^(V<<30|O>>>2)^(V<<25|O>>>7))>>>0)+((V&K|G&(V^K))>>>0))/4294967296>>>0)>>>0,A=H>>>0,Se=pe,Ne=Le,pe=oe,Le=de,oe=q,de=ne,q=te+v+((H=X+p)/4294967296>>>0)>>>0,ne=H>>>0,te=re,X=G,re=L,G=K,L=O,K=V,O=v+I+((H=p+A)/4294967296>>>0)>>>0,V=H>>>0;b[0][0]=b[0][0]+O+((H=b[0][1]+V)/4294967296>>>0)>>>0,b[0][1]=H>>>0,b[1][0]=b[1][0]+L+((H=b[1][1]+K)/4294967296>>>0)>>>0,b[1][1]=H>>>0,b[2][0]=b[2][0]+re+((H=b[2][1]+G)/4294967296>>>0)>>>0,b[2][1]=H>>>0,b[3][0]=b[3][0]+te+((H=b[3][1]+X)/4294967296>>>0)>>>0,b[3][1]=H>>>0,b[4][0]=b[4][0]+q+((H=b[4][1]+ne)/4294967296>>>0)>>>0,b[4][1]=H>>>0,b[5][0]=b[5][0]+oe+((H=b[5][1]+de)/4294967296>>>0)>>>0,b[5][1]=H>>>0,b[6][0]=b[6][0]+pe+((H=b[6][1]+Le)/4294967296>>>0)>>>0,b[6][1]=H>>>0,b[7][0]=b[7][0]+Se+((H=b[7][1]+Ne)/4294967296>>>0)>>>0,b[7][1]=H>>>0,We-=128}}},4747:(Y,U,x)=>{var y=x(8659),u=x(2020),g=Y.exports=y.util=y.util||{};function w(D){if(8!==D&&16!==D&&24!==D&&32!==D)throw new Error("Only 8, 16, 24, or 32 bits supported: "+D)}function m(D){if(this.data="",this.read=0,"string"==typeof D)this.data=D;else if(g.isArrayBuffer(D)||g.isArrayBufferView(D))if(typeof Buffer<"u"&&D instanceof Buffer)this.data=D.toString("binary");else{var T=new Uint8Array(D);try{this.data=String.fromCharCode.apply(null,T)}catch{for(var M=0;M15?(M=Date.now(),j(V)):(T.push(V),1===T.length&&F.setAttribute("a",k=!k))}}g.nextTick=g.setImmediate})(),g.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,g.globalScope=g.isNodejs?global:typeof self>"u"?window:self,g.isArray=Array.isArray||function(D){return"[object Array]"===Object.prototype.toString.call(D)},g.isArrayBuffer=function(D){return typeof ArrayBuffer<"u"&&D instanceof ArrayBuffer},g.isArrayBufferView=function(D){return D&&g.isArrayBuffer(D.buffer)&&void 0!==D.byteLength},g.ByteBuffer=m,g.ByteStringBuffer=m,g.ByteStringBuffer.prototype._optimizeConstructedString=function(D){this._constructedStringLength+=D,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},g.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},g.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},g.ByteStringBuffer.prototype.putByte=function(D){return this.putBytes(String.fromCharCode(D))},g.ByteStringBuffer.prototype.fillWithByte=function(D,T){D=String.fromCharCode(D);for(var M=this.data;T>0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return this.data=M,this._optimizeConstructedString(T),this},g.ByteStringBuffer.prototype.putBytes=function(D){return this.data+=D,this._optimizeConstructedString(D.length),this},g.ByteStringBuffer.prototype.putString=function(D){return this.putBytes(g.encodeUtf8(D))},g.ByteStringBuffer.prototype.putInt16=function(D){return this.putBytes(String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt24=function(D){return this.putBytes(String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt32=function(D){return this.putBytes(String.fromCharCode(D>>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt16Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255))},g.ByteStringBuffer.prototype.putInt24Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255))},g.ByteStringBuffer.prototype.putInt32Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>24&255))},g.ByteStringBuffer.prototype.putInt=function(D,T){w(T);var M="";do{T-=8,M+=String.fromCharCode(D>>T&255)}while(T>0);return this.putBytes(M)},g.ByteStringBuffer.prototype.putSignedInt=function(D,T){return D<0&&(D+=2<0);return T},g.ByteStringBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.ByteStringBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.ByteStringBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.ByteStringBuffer.prototype.at=function(D){return this.data.charCodeAt(this.read+D)},g.ByteStringBuffer.prototype.setAt=function(D,T){return this.data=this.data.substr(0,this.read+D)+String.fromCharCode(T)+this.data.substr(this.read+D+1),this},g.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},g.ByteStringBuffer.prototype.copy=function(){var D=g.createBuffer(this.data);return D.read=this.read,D},g.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},g.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},g.ByteStringBuffer.prototype.truncate=function(D){var T=Math.max(0,this.length()-D);return this.data=this.data.substr(this.read,T),this.read=0,this},g.ByteStringBuffer.prototype.toHex=function(){for(var D="",T=this.read;T=D)return this;T=Math.max(T||this.growSize,D);var M=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),k=new Uint8Array(this.length()+T);return k.set(M),this.data=new DataView(k.buffer),this},g.DataBuffer.prototype.putByte=function(D){return this.accommodate(1),this.data.setUint8(this.write++,D),this},g.DataBuffer.prototype.fillWithByte=function(D,T){this.accommodate(T);for(var M=0;M>8&65535),this.data.setInt8(this.write,D>>16&255),this.write+=3,this},g.DataBuffer.prototype.putInt32=function(D){return this.accommodate(4),this.data.setInt32(this.write,D),this.write+=4,this},g.DataBuffer.prototype.putInt16Le=function(D){return this.accommodate(2),this.data.setInt16(this.write,D,!0),this.write+=2,this},g.DataBuffer.prototype.putInt24Le=function(D){return this.accommodate(3),this.data.setInt8(this.write,D>>16&255),this.data.setInt16(this.write,D>>8&65535,!0),this.write+=3,this},g.DataBuffer.prototype.putInt32Le=function(D){return this.accommodate(4),this.data.setInt32(this.write,D,!0),this.write+=4,this},g.DataBuffer.prototype.putInt=function(D,T){w(T),this.accommodate(T/8);do{T-=8,this.data.setInt8(this.write++,D>>T&255)}while(T>0);return this},g.DataBuffer.prototype.putSignedInt=function(D,T){return w(T),this.accommodate(T/8),D<0&&(D+=2<0);return T},g.DataBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.DataBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.DataBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.DataBuffer.prototype.at=function(D){return this.data.getUint8(this.read+D)},g.DataBuffer.prototype.setAt=function(D,T){return this.data.setUint8(D,T),this},g.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},g.DataBuffer.prototype.copy=function(){return new g.DataBuffer(this)},g.DataBuffer.prototype.compact=function(){if(this.read>0){var D=new Uint8Array(this.data.buffer,this.read),T=new Uint8Array(D.byteLength);T.set(D),this.data=new DataView(T),this.write-=this.read,this.read=0}return this},g.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},g.DataBuffer.prototype.truncate=function(D){return this.write=Math.max(0,this.length()-D),this.read=Math.min(this.read,this.write),this},g.DataBuffer.prototype.toHex=function(){for(var D="",T=this.read;T0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return M},g.xorBytes=function(D,T,M){for(var k="",F="",j="",C=0,O=0;M>0;--M,++C)F=D.charCodeAt(C)^T.charCodeAt(C),O>=10&&(k+=j,j="",O=0),j+=String.fromCharCode(F),++O;return k+j},g.hexToBytes=function(D){var T="",M=0;for(!0&D.length&&(M=1,T+=String.fromCharCode(parseInt(D[0],16)));M>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D)};var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";g.encode64=function(D,T){for(var F,j,C,M="",k="",O=0;O>2),M+=f.charAt((3&F)<<4|j>>4),isNaN(j)?M+="==":(M+=f.charAt((15&j)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.decode64=function(D){D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var M,k,F,j,T="",C=0;C>4),64!==F&&(T+=String.fromCharCode((15&k)<<4|F>>2),64!==j&&(T+=String.fromCharCode((3&F)<<6|j)));return T},g.encodeUtf8=function(D){return unescape(encodeURIComponent(D))},g.decodeUtf8=function(D){return decodeURIComponent(escape(D))},g.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:u.encode,decode:u.decode}},g.binary.raw.encode=function(D){return String.fromCharCode.apply(null,D)},g.binary.raw.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,j=0;j>2),M+=f.charAt((3&F)<<4|j>>4),isNaN(j)?M+="==":(M+=f.charAt((15&j)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.binary.base64.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(3*Math.ceil(D.length/4))),D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var F,j,C,O,V=0,L=M=M||0;V>4,64!==C&&(k[L++]=(15&j)<<4|C>>2,64!==O&&(k[L++]=(3&C)<<6|O));return T?L-M:k.subarray(0,L)},g.binary.base58.encode=function(D,T){return g.binary.baseN.encode(D,b,T)},g.binary.base58.decode=function(D,T){return g.binary.baseN.decode(D,b,T)},g.text={utf8:{},utf16:{}},g.text.utf8.encode=function(D,T,M){D=g.encodeUtf8(D);var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,j=0;j"u"&&(M=["web","flash"]);var F,j=!1,C=null;for(var O in M){F=M[O];try{if("flash"===F||"both"===F){if(null===T[0])throw new Error("Flash local storage not available.");k=D.apply(this,T),j="flash"===F}("web"===F||"both"===F)&&(T[0]=localStorage,k=D.apply(this,T),j=!0)}catch(V){C=V}if(j)break}if(!j)throw C;return k};g.setItem=function(D,T,M,k,F){P(v,arguments,F)},g.getItem=function(D,T,M,k){return P(p,arguments,k)},g.removeItem=function(D,T,M,k){P(I,arguments,k)},g.clearItems=function(D,T,M){P(A,arguments,M)},g.isEmpty=function(D){for(var T in D)if(D.hasOwnProperty(T))return!1;return!0},g.format=function(D){for(var M,k,T=/%./g,F=0,j=[],C=0;M=T.exec(D);){(k=D.substring(C,T.lastIndex-2)).length>0&&j.push(k),C=T.lastIndex;var O=M[0][1];switch(O){case"s":case"o":j.push(F");break;case"%":j.push("%");break;default:j.push("<%"+O+"?>")}}return j.push(D.substring(C)),j.join("")},g.formatNumber=function(D,T,M,k){var F=D,j=isNaN(T=Math.abs(T))?2:T,C=void 0===M?",":M,O=void 0===k?".":k,V=F<0?"-":"",L=parseInt(F=Math.abs(+F||0).toFixed(j),10)+"",K=L.length>3?L.length%3:0;return V+(K?L.substr(0,K)+O:"")+L.substr(K).replace(/(\d{3})(?=\d)/g,"$1"+O)+(j?C+Math.abs(F-L).toFixed(j).slice(2):"")},g.formatSize=function(D){return D>=1073741824?g.formatNumber(D/1073741824,2,".","")+" GiB":D>=1048576?g.formatNumber(D/1048576,2,".","")+" MiB":D>=1024?g.formatNumber(D/1024,0)+" KiB":g.formatNumber(D,0)+" bytes"},g.bytesFromIP=function(D){return-1!==D.indexOf(".")?g.bytesFromIPv4(D):-1!==D.indexOf(":")?g.bytesFromIPv6(D):null},g.bytesFromIPv4=function(D){if(4!==(D=D.split(".")).length)return null;for(var T=g.createBuffer(),M=0;MM[k].end-M[k].start&&(k=M.length-1)):M.push({start:O,end:O})}T.push(j)}if(M.length>0){var V=M[k];V.end-V.start>0&&(T.splice(V.start,V.end-V.start+1,""),0===V.start&&T.unshift(""),7===V.end&&T.push(""))}return T.join(":")},g.estimateCores=function(D,T){if("function"==typeof D&&(T=D,D={}),D=D||{},"cores"in g&&!D.update)return T(null,g.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return g.cores=navigator.hardwareConcurrency,T(null,g.cores);if(typeof Worker>"u")return g.cores=1,T(null,g.cores);if(typeof Blob>"u")return g.cores=2,T(null,g.cores);var M=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(C){for(var O=Date.now(),V=O+4;Date.now()te.st&&K.stK.st&&te.st{var y=x(8659);x(1298),x(7791),x(279),x(979),x(9386),x(6078),x(8604),x(7256),x(5517),x(4747);var u=y.asn1,g=Y.exports=y.pki=y.pki||{},w=g.oids,m={};m.CN=w.commonName,m.commonName="CN",m.C=w.countryName,m.countryName="C",m.L=w.localityName,m.localityName="L",m.ST=w.stateOrProvinceName,m.stateOrProvinceName="ST",m.O=w.organizationName,m.organizationName="O",m.OU=w.organizationalUnitName,m.organizationalUnitName="OU",m.E=w.emailAddress,m.emailAddress="E";var h=y.pki.rsa.publicKeyValidator,c={name:"Certificate",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:u.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:u.Class.UNIVERSAL,type:u.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:u.Class.UNIVERSAL,type:u.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:u.Class.UNIVERSAL,type:u.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:u.Class.UNIVERSAL,type:u.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},h,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:u.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:u.Class.UNIVERSAL,type:u.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:u.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:u.Class.UNIVERSAL,type:u.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:u.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:u.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:u.Class.UNIVERSAL,type:u.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},f={name:"rsapss",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:u.Class.UNIVERSAL,type:u.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:u.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:u.Class.UNIVERSAL,type:u.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:u.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:u.Class.UNIVERSAL,type:u.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:u.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:u.Class.UNIVERSAL,type:u.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},b={name:"CertificationRequest",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[{name:"CertificationRequestInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},h,{name:"CertificationRequestInfo.attributes",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:u.Class.UNIVERSAL,type:u.Type.SET,constructed:!0}]}]}]},{name:"CertificationRequest.signatureAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:u.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:u.Class.UNIVERSAL,type:u.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function S(C,O){"string"==typeof O&&(O={shortName:O});for(var L,V=null,K=0;null===V&&K"u"&&(O.type&&O.type in g.oids?O.name=g.oids[O.type]:O.shortName&&O.shortName in m&&(O.name=g.oids[m[O.shortName]])),typeof O.type>"u"){if(!O.name||!(O.name in g.oids))throw(L=new Error("Attribute type not specified.")).attribute=O,L;O.type=g.oids[O.name]}if(typeof O.shortName>"u"&&O.name&&O.name in m&&(O.shortName=m[O.name]),O.type===w.extensionRequest&&(O.valueConstructed=!0,O.valueTagClass=u.Type.SEQUENCE,!O.value&&O.extensions)){O.value=[];for(var K=0;K"u")throw(L=new Error("Attribute value not specified.")).attribute=O,L}}function D(C,O){if(O=O||{},typeof C.name>"u"&&C.id&&C.id in g.oids&&(C.name=g.oids[C.id]),typeof C.id>"u"){if(!C.name||!(C.name in g.oids))throw(V=new Error("Extension ID not specified.")).extension=C,V;C.id=g.oids[C.name]}if(typeof C.value<"u")return C;if("keyUsage"===C.name){var L=0,K=0,re=0;C.digitalSignature&&(K|=128,L=7),C.nonRepudiation&&(K|=64,L=6),C.keyEncipherment&&(K|=32,L=5),C.dataEncipherment&&(K|=16,L=4),C.keyAgreement&&(K|=8,L=3),C.keyCertSign&&(K|=4,L=2),C.cRLSign&&(K|=2,L=1),C.encipherOnly&&(K|=1,L=0),C.decipherOnly&&(re|=128,L=7);var G=String.fromCharCode(L);0!==re?G+=String.fromCharCode(K)+String.fromCharCode(re):0!==K&&(G+=String.fromCharCode(K)),C.value=u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,G)}else if("basicConstraints"===C.name)C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),C.cA&&C.value.value.push(u.create(u.Class.UNIVERSAL,u.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in C&&C.value.value.push(u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(C.pathLenConstraint).getBytes()));else if("extKeyUsage"===C.name){C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);var te=C.value.value;for(var X in C)!0===C[X]&&(X in w?te.push(u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(w[X]).getBytes())):-1!==X.indexOf(".")&&te.push(u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(X).getBytes())))}else if("nsCertType"===C.name)L=0,K=0,C.client&&(K|=128,L=7),C.server&&(K|=64,L=6),C.email&&(K|=32,L=5),C.objsign&&(K|=16,L=4),C.reserved&&(K|=8,L=3),C.sslCA&&(K|=4,L=2),C.emailCA&&(K|=2,L=1),C.objCA&&(K|=1,L=0),G=String.fromCharCode(L),0!==K&&(G+=String.fromCharCode(K)),C.value=u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,G);else if("subjectAltName"===C.name||"issuerAltName"===C.name){C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);for(var ne=0;ne128)throw new Error('Invalid "nsComment" content.');C.value=u.create(u.Class.UNIVERSAL,u.Type.IA5STRING,!1,C.comment)}else if("subjectKeyIdentifier"===C.name&&O.cert){var oe=O.cert.generateSubjectKeyIdentifier();C.subjectKeyIdentifier=oe.toHex(),C.value=u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,oe.getBytes())}else if("authorityKeyIdentifier"===C.name&&O.cert){if(C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),te=C.value.value,C.keyIdentifier){var de=!0===C.keyIdentifier?O.cert.generateSubjectKeyIdentifier().getBytes():C.keyIdentifier;te.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!1,de))}if(C.authorityCertIssuer){var pe=[u.create(u.Class.CONTEXT_SPECIFIC,4,!0,[I(!0===C.authorityCertIssuer?O.cert.issuer:C.authorityCertIssuer)])];te.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,pe))}if(C.serialNumber){var Le=y.util.hexToBytes(!0===C.serialNumber?O.cert.serialNumber:C.serialNumber);te.push(u.create(u.Class.CONTEXT_SPECIFIC,2,!1,Le))}}else if("cRLDistributionPoints"===C.name){C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),te=C.value.value;var q,Se=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),Ne=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[]);for(ne=0;ne"u")throw(V=new Error("Extension value not specified.")).extension=C,V;return C}function T(C,O){if(C===w["RSASSA-PSS"]){var V=[];return void 0!==O.hash.algorithmOid&&V.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(O.hash.algorithmOid).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")])])),void 0!==O.mgf.algorithmOid&&V.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,[u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(O.mgf.algorithmOid).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(O.mgf.hash.algorithmOid).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")])])])),void 0!==O.saltLength&&V.push(u.create(u.Class.CONTEXT_SPECIFIC,2,!0,[u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(O.saltLength).getBytes())])),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,V)}return u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")}function M(C){var O=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===C.attributes.length)return O;for(var V=C.attributes,L=0;L2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(X.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(G.validity.notBefore=X[0],G.validity.notAfter=X[1],G.tbsCertificate=V.tbsCertificate,O){G.md=v({signatureOid:G.signatureOid,type:"certificate"});var q=u.toDer(G.tbsCertificate);G.md.update(q.getBytes())}var ne=y.md.sha1.create(),oe=u.toDer(V.certIssuer);ne.update(oe.getBytes()),G.issuer.getField=function(Le){return S(G.issuer,Le)},G.issuer.addField=function(Le){P([Le]),G.issuer.attributes.push(Le)},G.issuer.attributes=g.RDNAttributesAsArray(V.certIssuer),V.certIssuerUniqueId&&(G.issuer.uniqueId=V.certIssuerUniqueId),G.issuer.hash=ne.digest().toHex();var de=y.md.sha1.create(),pe=u.toDer(V.certSubject);return de.update(pe.getBytes()),G.subject.getField=function(Le){return S(G.subject,Le)},G.subject.addField=function(Le){P([Le]),G.subject.attributes.push(Le)},G.subject.attributes=g.RDNAttributesAsArray(V.certSubject),V.certSubjectUniqueId&&(G.subject.uniqueId=V.certSubjectUniqueId),G.subject.hash=de.digest().toHex(),G.extensions=V.certExtensions?g.certificateExtensionsFromAsn1(V.certExtensions):[],G.publicKey=g.publicKeyFromAsn1(V.subjectPublicKeyInfo),G},g.certificateExtensionsFromAsn1=function(C){for(var O=[],V=0;V1&&(L=V.value.charCodeAt(1),K=V.value.length>2?V.value.charCodeAt(2):0),O.digitalSignature=128==(128&L),O.nonRepudiation=64==(64&L),O.keyEncipherment=32==(32&L),O.dataEncipherment=16==(16&L),O.keyAgreement=8==(8&L),O.keyCertSign=4==(4&L),O.cRLSign=2==(2&L),O.encipherOnly=1==(1&L),O.decipherOnly=128==(128&K)}else if("basicConstraints"===O.name){var V=u.fromDer(O.value);O.cA=V.value.length>0&&V.value[0].type===u.Type.BOOLEAN&&0!==V.value[0].value.charCodeAt(0);var re=null;V.value.length>0&&V.value[0].type===u.Type.INTEGER?re=V.value[0].value:V.value.length>1&&(re=V.value[1].value),null!==re&&(O.pathLenConstraint=u.derToInteger(re))}else if("extKeyUsage"===O.name){V=u.fromDer(O.value);for(var G=0;G1&&(L=V.value.charCodeAt(1)),O.client=128==(128&L),O.server=64==(64&L),O.email=32==(32&L),O.objsign=16==(16&L),O.reserved=8==(8&L),O.sslCA=4==(4&L),O.emailCA=2==(2&L),O.objCA=1==(1&L);else if("subjectAltName"===O.name||"issuerAltName"===O.name){O.altNames=[],V=u.fromDer(O.value);for(var X,q=0;q=k&&C0&&L.value.push(g.certificateExtensionsToAsn1(C.extensions)),L},g.getCertificationRequestInfo=function(C){return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(C.version).getBytes()),I(C.subject),g.publicKeyToAsn1(C.publicKey),M(C)])},g.distinguishedNameToAsn1=function(C){return I(C)},g.certificateToAsn1=function(C){var O=C.tbsCertificate||g.getTBSCertificate(C);return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[O,u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(C.signatureOid).getBytes()),T(C.signatureOid,C.signatureParameters)]),u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,String.fromCharCode(0)+C.signature)])},g.certificateExtensionsToAsn1=function(C){var O=u.create(u.Class.CONTEXT_SPECIFIC,3,!0,[]),V=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);O.value.push(V);for(var L=0;L"u"&&(K=new Date);var re=!0,G=null,te=0;do{var X=O.shift(),q=null,ne=!1;if(K&&(KX.validity.notAfter)&&(G={message:"Certificate is not valid yet or has expired.",error:g.certificateError.certificate_expired,notBefore:X.validity.notBefore,notAfter:X.validity.notAfter,now:K}),null===G){if(null===(q=O[0]||C.getIssuer(X))&&X.isIssuer(X)&&(ne=!0,q=X),q){var oe=q;y.util.isArray(oe)||(oe=[oe]);for(var de=!1;!de&&oe.length>0;){q=oe.shift();try{de=q.verify(X)}catch{}}de||(G={message:"Certificate signature is invalid.",error:g.certificateError.bad_certificate})}null===G&&(!q||ne)&&!C.hasCertificate(X)&&(G={message:"Certificate is not trusted.",error:g.certificateError.unknown_ca})}if(null===G&&q&&!X.isIssuer(q)&&(G={message:"Certificate issuer is invalid.",error:g.certificateError.bad_certificate}),null===G)for(var pe={keyUsage:!0,basicConstraints:!0},Le=0;null===G&&LeNe.pathLenConstraint&&(G={message:"Certificate basicConstraints pathLenConstraint violated.",error:g.certificateError.bad_certificate})}var H=null===G||G.error,Ee=V.verify?V.verify(H,te,L):H;if(!0!==Ee)throw!0===H&&(G={message:"The application rejected the certificate.",error:g.certificateError.bad_certificate}),(Ee||0===Ee)&&("object"!=typeof Ee||y.util.isArray(Ee)?"string"==typeof Ee&&(G.error=Ee):(Ee.message&&(G.message=Ee.message),Ee.error&&(G.error=Ee.error))),G;G=null,re=!1,++te}while(O.length>0);return!0}},8614:(Y,U,x)=>{const y=x(1159),u=x(281);Y.exports=class{constructor(){this._buffer=new y,this._waitingConsumers=new y}push(w){const{promise:m,resolve:h}=u();return this._buffer.push({chunk:w,resolve:h}),this._consume(),m}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const w=this._waitingConsumers.shift(),m=this._buffer.shift();w.resolve(m.chunk),m.resolve()}}shift(){const{promise:w,resolve:m}=u();return this._waitingConsumers.push({resolve:m}),this._consume(),w}isEmpty(){return this._buffer.isEmpty()}}},281:Y=>{"use strict";Y.exports=()=>{const x={};return x.promise=new Promise((y,u)=>{x.resolve=y,x.reject=u}),x}},4108:(Y,U,x)=>{"use strict";Y.exports=x(8777).default},8777:function(Y,U,x){"use strict";var y=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(U,"__esModule",{value:!0});const u=x(7910),g=y(x(4066)),w=y(x(382)),m=x(1396),c=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map(b=>new u.Netmask(b));function d(b){return/^::$/.test(b)||/^::1$/.test(b)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(b)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(b)||/^ff([0-9a-fA-F]{2,2}):/i.test(b)}U.default=b=>{if((0,m.isValid)(b)){const S=(0,m.parse)(b);if("ipv4"===S.kind())return function f(b){for(let S of c)if(S.contains(b))return!0;return!1}(S.toNormalizedString());if("ipv6"===S.kind())return d(b)}else if((0,w.default)(b)&&g.default.v6().test(b))return d(b)}},382:(Y,U,x)=>{"use strict";const y=x(4066),u=g=>y({exact:!0}).test(g);u.v4=g=>y.v4({exact:!0}).test(g),u.v6=g=>y.v6({exact:!0}).test(g),u.version=g=>u(g)?u.v4(g)?4:6:void 0,Y.exports=u},3863:(Y,U,x)=>{"use strict";Y.exports=x(2540)},4599:Y=>{"use strict";Y.exports=x;var y,U=/\/|\./;function x(u,g){U.test(u)||(u="google/protobuf/"+u+".proto",g={nested:{google:{nested:{protobuf:{nested:g}}}}}),x[u]=g}x("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),x("duration",{Duration:y={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),x("timestamp",{Timestamp:y}),x("empty",{Empty:{fields:{}}}),x("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),x("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),x("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),x.get=function(g){return x[g]||null}},6533:(Y,U,x)=>{"use strict";var y=U,u=x(4269),g=x(8572);function w(h,c,f,d){var b=!1;if(c.resolvedType)if(c.resolvedType instanceof u){h("switch(d%s){",d);for(var S=c.resolvedType.values,E=Object.keys(S),v=0;v>>0",d,d);break;case"int32":case"sint32":case"sfixed32":h("m%s=d%s|0",d,d);break;case"uint64":p=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",d,d,p)('else if(typeof d%s==="string")',d)("m%s=parseInt(d%s,10)",d,d)('else if(typeof d%s==="number")',d)("m%s=d%s",d,d)('else if(typeof d%s==="object")',d)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",d,d,d,p?"true":"");break;case"bytes":h('if(typeof d%s==="string")',d)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",d,d,d)("else if(d%s.length >= 0)",d)("m%s=d%s",d,d);break;case"string":h("m%s=String(d%s)",d,d);break;case"bool":h("m%s=Boolean(d%s)",d,d)}}return h}function m(h,c,f,d){if(c.resolvedType)c.resolvedType instanceof u?h("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",d,f,d,d,f,d,d):h("d%s=types[%i].toObject(m%s,o)",d,f,d);else{var b=!1;switch(c.type){case"double":case"float":h("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",d,d,d,d);break;case"uint64":b=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h('if(typeof m%s==="number")',d)("d%s=o.longs===String?String(m%s):m%s",d,d,d)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",d,d,d,d,b?"true":"",d);break;case"bytes":h("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",d,d,d,d,d);break;default:h("d%s=m%s",d,d)}}return h}y.fromObject=function(c){var f=c.fieldsArray,d=g.codegen(["d"],c.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!f.length)return d("return new this.ctor");d("var m=new this.ctor");for(var b=0;b{"use strict";Y.exports=function m(h){var c=g.codegen(["r","l"],h.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(h.fieldsArray.filter(function(v){return v.map}).length?",k,value":""))("while(r.pos>>3){");for(var f=0;f>>3){")("case 1: k=r.%s(); break",d.keyType)("case 2:"),void 0===u.basic[b]?c("value=types[%i].decode(r,r.uint32())",f):c("value=r.%s()",b),c("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),c(void 0!==u.long[d.keyType]?'%s[typeof k==="object"?util.longToHash(k):k]=value':"%s[k]=value",S)):d.repeated?(c("if(!(%s&&%s.length))",S,S)("%s=[]",S),void 0!==u.packed[b]&&c("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";Y.exports=function m(h){for(var d,c=g.codegen(["m","w"],h.name+"$encode")("if(!w)")("w=Writer.create()"),b=h.fieldsArray.slice().sort(g.compareFieldsById),f=0;f>>0,8|u.mapKey[S.keyType],S.keyType),void 0===p?c("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",E,d):c(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|p,v,d),c("}")("}")):S.repeated?(c("if(%s!=null&&%s.length){",d,d),S.packed&&void 0!==u.packed[v]?c("w.uint32(%i).fork()",(S.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",d)("w.%s(%s[i])",v,d)("w.ldelim()"):(c("for(var i=0;i<%s.length;++i)",d),void 0===p?w(c,S,E,d+"[i]"):c("w.uint32(%i).%s(%s[i])",(S.id<<3|p)>>>0,v,d)),c("}")):(S.optional&&c("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",d,S.name),void 0===p?w(c,S,E,d):c("w.uint32(%i).%s(%s)",(S.id<<3|p)>>>0,v,d))}return c("return w")};var y=x(4269),u=x(688),g=x(8572);function w(h,c,f,d){return c.resolvedType.group?h("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",f,d,(c.id<<3|3)>>>0,(c.id<<3|4)>>>0):h("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",f,d,(c.id<<3|2)>>>0)}},4269:(Y,U,x)=>{"use strict";Y.exports=w;var y=x(9487);((w.prototype=Object.create(y.prototype)).constructor=w).className="Enum";var u=x(326),g=x(8572);function w(m,h,c,f,d,b){if(y.call(this,m,c),h&&"object"!=typeof h)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=f,this.comments=d||{},this.valuesOptions=b,this.reserved=void 0,h)for(var S=Object.keys(h),E=0;E{"use strict";Y.exports=c;var y=x(9487);((c.prototype=Object.create(y.prototype)).constructor=c).className="Field";var m,u=x(4269),g=x(688),w=x(8572),h=/^required|optional|repeated$/;function c(f,d,b,S,E,v,p){if(w.isObject(S)?(p=E,v=S,S=E=void 0):w.isObject(E)&&(p=v,v=E,E=void 0),y.call(this,f,v),!w.isInteger(d)||d<0)throw TypeError("id must be a non-negative integer");if(!w.isString(b))throw TypeError("type must be a string");if(void 0!==S&&!h.test(S=S.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==E&&!w.isString(E))throw TypeError("extend must be a string");"proto3_optional"===S&&(S="optional"),this.rule=S&&"optional"!==S?S:void 0,this.type=b,this.id=d,this.extend=E||void 0,this.required="required"===S,this.optional=!this.required,this.repeated="repeated"===S,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!w.Long&&void 0!==g.long[b],this.bytes="bytes"===b,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=p}c.fromJSON=function(d,b){return new c(d,b.id,b.type,b.rule,b.extend,b.options,b.comment)},Object.defineProperty(c.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),c.prototype.setOption=function(d,b,S){return"packed"===d&&(this._packed=null),y.prototype.setOption.call(this,d,b,S)},c.prototype.toJSON=function(d){var b=!!d&&Boolean(d.keepComments);return w.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",b?this.comment:void 0])},c.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=g.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.typeDefault=this.resolvedType instanceof m?null:this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof u&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&((!0===this.options.packed||void 0!==this.options.packed&&this.resolvedType&&!(this.resolvedType instanceof u))&&delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=w.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var d;w.base64.test(this.typeDefault)?w.base64.decode(this.typeDefault,d=w.newBuffer(w.base64.length(this.typeDefault)),0):w.utf8.write(this.typeDefault,d=w.newBuffer(w.utf8.length(this.typeDefault)),0),this.typeDefault=d}return this.defaultValue=this.map?w.emptyObject:this.repeated?w.emptyArray:this.typeDefault,this.parent instanceof m&&(this.parent.ctor.prototype[this.name]=this.defaultValue),y.prototype.resolve.call(this)},c.d=function(d,b,S,E){return"function"==typeof b?b=w.decorateType(b).name:b&&"object"==typeof b&&(b=w.decorateEnum(b).name),function(p,I){w.decorateType(p.constructor).add(new c(I,d,b,S,{default:E}))}},c._configure=function(d){m=d}},5803:(Y,U,x)=>{"use strict";var y=Y.exports=x(95);y.build="light",y.load=function u(w,m,h){return"function"==typeof m?(h=m,m=new y.Root):m||(m=new y.Root),m.load(w,h)},y.loadSync=function g(w,m){return m||(m=new y.Root),m.loadSync(w)},y.encoder=x(133),y.decoder=x(225),y.verifier=x(8617),y.converter=x(6533),y.ReflectionObject=x(9487),y.Namespace=x(326),y.Root=x(5257),y.Enum=x(4269),y.Type=x(7845),y.Field=x(2986),y.OneOf=x(7397),y.MapField=x(9455),y.Service=x(9630),y.Method=x(1618),y.Message=x(1413),y.wrappers=x(761),y.types=x(688),y.util=x(8572),y.ReflectionObject._configure(y.Root),y.Namespace._configure(y.Type,y.Service,y.Enum),y.Root._configure(y.Type),y.Field._configure(y.Type)},95:(Y,U,x)=>{"use strict";var y=U;function u(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(1650),y.BufferWriter=x(813),y.Reader=x(7270),y.BufferReader=x(4354),y.util=x(7211),y.rpc=x(7830),y.roots=x(6671),y.configure=u,u()},2540:(Y,U,x)=>{"use strict";var y=Y.exports=x(5803);y.build="full",y.tokenize=x(691),y.parse=x(8992),y.common=x(4599),y.Root._configure(y.Type,y.parse,y.common)},9455:(Y,U,x)=>{"use strict";Y.exports=w;var y=x(2986);((w.prototype=Object.create(y.prototype)).constructor=w).className="MapField";var u=x(688),g=x(8572);function w(m,h,c,f,d,b){if(y.call(this,m,h,f,void 0,void 0,d,b),!g.isString(c))throw TypeError("keyType must be a string");this.keyType=c,this.resolvedKeyType=null,this.map=!0}w.fromJSON=function(h,c){return new w(h,c.id,c.keyType,c.type,c.options,c.comment)},w.prototype.toJSON=function(h){var c=!!h&&Boolean(h.keepComments);return g.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",c?this.comment:void 0])},w.prototype.resolve=function(){if(this.resolved)return this;if(void 0===u.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return y.prototype.resolve.call(this)},w.d=function(h,c,f){return"function"==typeof f?f=g.decorateType(f).name:f&&"object"==typeof f&&(f=g.decorateEnum(f).name),function(b,S){g.decorateType(b.constructor).add(new w(S,h,c,f))}}},1413:(Y,U,x)=>{"use strict";Y.exports=u;var y=x(7211);function u(g){if(g)for(var w=Object.keys(g),m=0;m{"use strict";Y.exports=g;var y=x(9487);((g.prototype=Object.create(y.prototype)).constructor=g).className="Method";var u=x(8572);function g(w,m,h,c,f,d,b,S,E){if(u.isObject(f)?(b=f,f=d=void 0):u.isObject(d)&&(b=d,d=void 0),void 0!==m&&!u.isString(m))throw TypeError("type must be a string");if(!u.isString(h))throw TypeError("requestType must be a string");if(!u.isString(c))throw TypeError("responseType must be a string");y.call(this,w,b),this.type=m||"rpc",this.requestType=h,this.requestStream=!!f||void 0,this.responseType=c,this.responseStream=!!d||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=S,this.parsedOptions=E}g.fromJSON=function(m,h){return new g(m,h.type,h.requestType,h.responseType,h.requestStream,h.responseStream,h.options,h.comment,h.parsedOptions)},g.prototype.toJSON=function(m){var h=!!m&&Boolean(m.keepComments);return u.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",h?this.comment:void 0,"parsedOptions",this.parsedOptions])},g.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),y.prototype.resolve.call(this))}},326:(Y,U,x)=>{"use strict";Y.exports=d;var y=x(9487);((d.prototype=Object.create(y.prototype)).constructor=d).className="Namespace";var m,h,c,u=x(2986),g=x(8572),w=x(7397);function f(S,E){if(S&&S.length){for(var v={},p=0;pv)return!0;return!1},d.isReservedName=function(E,v){if(E)for(var p=0;p0;){var I=E.shift();if(p.nested&&p.nested[I]){if(!((p=p.nested[I])instanceof d))throw Error("path conflicts with non-namespace objects")}else p.add(p=new d(I))}return v&&p.addJSON(v),p},d.prototype.resolveAll=function(){for(var E=this.nestedArray,v=0;v-1)return I}else if(I instanceof d&&(I=I.lookup(E.slice(1),v,!0)))return I}else for(var A=0;A{"use strict";Y.exports=g,g.className="ReflectionObject";var u,y=x(8572);function g(w,m){if(!y.isString(w))throw TypeError("name must be a string");if(m&&!y.isObject(m))throw TypeError("options must be an object");this.options=m,this.parsedOptions=null,this.name=w,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(g.prototype,{root:{get:function(){for(var w=this;null!==w.parent;)w=w.parent;return w}},fullName:{get:function(){for(var w=[this.name],m=this.parent;m;)w.unshift(m.name),m=m.parent;return w.join(".")}}}),g.prototype.toJSON=function(){throw Error()},g.prototype.onAdd=function(m){this.parent&&this.parent!==m&&this.parent.remove(this),this.parent=m,this.resolved=!1;var h=m.root;h instanceof u&&h._handleAdd(this)},g.prototype.onRemove=function(m){var h=m.root;h instanceof u&&h._handleRemove(this),this.parent=null,this.resolved=!1},g.prototype.resolve=function(){return this.resolved||this.root instanceof u&&(this.resolved=!0),this},g.prototype.getOption=function(m){if(this.options)return this.options[m]},g.prototype.setOption=function(m,h,c){return(!c||!this.options||void 0===this.options[m])&&((this.options||(this.options={}))[m]=h),this},g.prototype.setParsedOption=function(m,h,c){this.parsedOptions||(this.parsedOptions=[]);var f=this.parsedOptions;if(c){var d=f.find(function(E){return Object.prototype.hasOwnProperty.call(E,m)});d?y.setProperty(d[m],c,h):((d={})[m]=y.setProperty({},c,h),f.push(d))}else{var S={};S[m]=h,f.push(S)}return this},g.prototype.setOptions=function(m,h){if(m)for(var c=Object.keys(m),f=0;f{"use strict";Y.exports=w;var y=x(9487);((w.prototype=Object.create(y.prototype)).constructor=w).className="OneOf";var u=x(2986),g=x(8572);function w(h,c,f,d){if(Array.isArray(c)||(f=c,c=void 0),y.call(this,h,f),void 0!==c&&!Array.isArray(c))throw TypeError("fieldNames must be an Array");this.oneof=c||[],this.fieldsArray=[],this.comment=d}function m(h){if(h.parent)for(var c=0;c-1&&this.oneof.splice(f,1),c.partOf=null,this},w.prototype.onAdd=function(c){y.prototype.onAdd.call(this,c);for(var d=0;d{"use strict";Y.exports=F,F.filename=null,F.defaults={keepCase:!1};var y=x(691),u=x(5257),g=x(7845),w=x(2986),m=x(9455),h=x(7397),c=x(4269),f=x(9630),d=x(1618),b=x(688),S=x(8572),E=/^[1-9][0-9]*$/,v=/^-?[1-9][0-9]*$/,p=/^0[x][0-9a-fA-F]+$/,I=/^-?0[x][0-9a-fA-F]+$/,A=/^0[0-7]+$/,P=/^-?0[0-7]+$/,D=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,T=/^[a-zA-Z_][a-zA-Z_0-9]*$/,M=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,k=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function F(j,C,O){C instanceof u||(O=C,C=new u),O||(O=F.defaults);var ne,oe,de,pe,Ke,V=O.preferTrailingComment||!1,L=y(j,O.alternateCommentMode||!1),K=L.next,re=L.push,G=L.peek,te=L.skip,X=L.cmnt,q=!0,Le=!1,Se=C,Ne=O.keepCase?function(we){return we}:S.camelCase;function be(we,ge,De){var Fe=F.filename;return De||(F.filename=null),Error("illegal "+(ge||"token")+" '"+we+"' ("+(Fe?Fe+", ":"")+"line "+L.line+")")}function je(){var ge,we=[];do{if('"'!==(ge=K())&&"'"!==ge)throw be(ge);we.push(K()),te(ge),ge=G()}while('"'===ge||"'"===ge);return we.join("")}function H(we){var ge=K();switch(ge){case"'":case'"':return re(ge),je();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function Ie(we,ge){var De=1;switch("-"===we.charAt(0)&&(De=-1,we=we.substring(1)),we){case"inf":case"INF":case"Inf":return De*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(E.test(we))return De*parseInt(we,10);if(p.test(we))return De*parseInt(we,16);if(A.test(we))return De*parseInt(we,8);if(D.test(we))return De*parseFloat(we);throw be(we,"number",ge)}(ge,!0)}catch{if(we&&M.test(ge))return ge;throw be(ge,"value")}}function Ee(we,ge){var De,Fe;do{!ge||'"'!==(De=G())&&"'"!==De?we.push([Fe=xe(K()),te("to",!0)?xe(K()):Fe]):we.push(je())}while(te(",",!0));te(";")}function xe(we,ge){switch(we){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!ge&&"-"===we.charAt(0))throw be(we,"id");if(v.test(we))return parseInt(we,10);if(I.test(we))return parseInt(we,16);if(P.test(we))return parseInt(we,8);throw be(we,"id")}function He(){if(void 0!==ne)throw be("package");if(ne=K(),!M.test(ne))throw be(ne,"name");Se=Se.define(ne),te(";")}function We(){var ge,we=G();switch(we){case"weak":ge=de||(de=[]),K();break;case"public":K();default:ge=oe||(oe=[])}we=je(),te(";"),ge.push(we)}function Je(){if(te("="),pe=je(),!(Le="proto3"===pe)&&"proto2"!==pe)throw be(pe,"syntax");te(";")}function Xe(we,ge){switch(ge){case"option":return ye(we,ge),te(";"),!0;case"message":return pt(we,ge),!0;case"enum":return ie(we,ge),!0;case"service":return function qe(we,ge){if(!T.test(ge=K()))throw be(ge,"service name");var De=new f(ge);Nt(De,function(Be){if(!Xe(De,Be)){if("rpc"!==Be)throw be(Be);!function it(we,ge){var De=X(),Fe=ge;if(!T.test(ge=K()))throw be(ge,"name");var dt,xt,vt,et,Be=ge;if(te("("),te("stream",!0)&&(xt=!0),!M.test(ge=K())||(dt=ge,te(")"),te("returns"),te("("),te("stream",!0)&&(et=!0),!M.test(ge=K())))throw be(ge);vt=ge,te(")");var An=new d(Be,Fe,dt,vt,xt,et);An.comment=De,Nt(An,function(gn){if("option"!==gn)throw be(gn);ye(An,gn),te(";")}),we.add(An)}(De,Be)}}),we.add(De)}(we,ge),!0;case"extend":return function nt(we,ge){if(!M.test(ge=K()))throw be(ge,"reference");var De=ge;Nt(null,function(Be){switch(Be){case"required":case"repeated":_t(we,Be,De);break;case"optional":_t(we,Le?"proto3_optional":"optional",De);break;default:if(!Le||!M.test(Be))throw be(Be);re(Be),_t(we,"optional",De)}})}(we,ge),!0}return!1}function Nt(we,ge,De){var Fe=L.line;if(we&&("string"!=typeof we.comment&&(we.comment=X()),we.filename=F.filename),te("{",!0)){for(var Be;"}"!==(Be=K());)ge(Be);te(";",!0)}else De&&De(),te(";"),we&&("string"!=typeof we.comment||V)&&(we.comment=X(Fe)||we.comment)}function pt(we,ge){if(!T.test(ge=K()))throw be(ge,"type name");var De=new g(ge);Nt(De,function(Be){if(!Xe(De,Be))switch(Be){case"map":!function pr(we){te("<");var ge=K();if(void 0===b.mapKey[ge])throw be(ge,"type");te(",");var De=K();if(!M.test(De))throw be(De,"type");te(">");var Fe=K();if(!T.test(Fe))throw be(Fe,"name");te("=");var Be=new m(Ne(Fe),xe(K()),ge,De);Nt(Be,function(xt){if("option"!==xt)throw be(xt);ye(Be,xt),te(";")},function(){Qe(Be)}),we.add(Be)}(De);break;case"required":case"repeated":_t(De,Be);break;case"optional":_t(De,Le?"proto3_optional":"optional");break;case"oneof":!function Hr(we,ge){if(!T.test(ge=K()))throw be(ge,"name");var De=new h(Ne(ge));Nt(De,function(Be){"option"===Be?(ye(De,Be),te(";")):(re(Be),_t(De,"optional"))}),we.add(De)}(De,Be);break;case"extensions":Ee(De.extensions||(De.extensions=[]));break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:if(!Le||!M.test(Be))throw be(Be);re(Be),_t(De,"optional")}}),we.add(De)}function _t(we,ge,De){var Fe=K();if("group"!==Fe){if(!M.test(Fe))throw be(Fe,"type");var Be=K();if(!T.test(Be))throw be(Be,"name");Be=Ne(Be),te("=");var dt=new w(Be,xe(K()),Fe,ge,De);if(Nt(dt,function(et){if("option"!==et)throw be(et);ye(dt,et),te(";")},function(){Qe(dt)}),"proto3_optional"===ge){var xt=new h("_"+Be);dt.setOption("proto3_optional",!0),xt.add(dt),we.add(xt)}else we.add(dt);!Le&&dt.repeated&&(void 0!==b.packed[Fe]||void 0===b.basic[Fe])&&dt.setOption("packed",!1,!0)}else!function Or(we,ge){var De=K();if(!T.test(De))throw be(De,"name");var Fe=S.lcFirst(De);De===Fe&&(De=S.ucFirst(De)),te("=");var Be=xe(K()),dt=new g(De);dt.group=!0;var xt=new w(Fe,Be,De,ge);xt.filename=F.filename,Nt(dt,function(et){switch(et){case"option":ye(dt,et),te(";");break;case"required":case"repeated":_t(dt,et);break;case"optional":_t(dt,Le?"proto3_optional":"optional");break;case"message":pt(dt,et);break;case"enum":ie(dt,et);break;default:throw be(et)}}),we.add(dt).add(xt)}(we,ge)}function ie(we,ge){if(!T.test(ge=K()))throw be(ge,"name");var De=new c(ge);Nt(De,function(Be){switch(Be){case"option":ye(De,Be),te(";");break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:!function fe(we,ge){if(!T.test(ge))throw be(ge,"name");te("=");var De=xe(K(),!0),Fe={options:void 0,setOption:function(Be,dt){void 0===this.options&&(this.options={}),this.options[Be]=dt}};Nt(Fe,function(dt){if("option"!==dt)throw be(dt);ye(Fe,dt),te(";")},function(){Qe(Fe)}),we.add(ge,De,Fe.comment,Fe.options)}(De,Be)}}),we.add(De)}function ye(we,ge){var De=te("(",!0);if(!M.test(ge=K()))throw be(ge,"name");var dt,Fe=ge,Be=Fe;De&&(te(")"),Be=Fe="("+Fe+")",ge=G(),k.test(ge)&&(dt=ge.slice(1),Fe+=ge,K())),te("="),function Me(we,ge,De,Fe){we.setParsedOption&&we.setParsedOption(ge,De,Fe)}(we,Be,me(we,Fe),dt)}function me(we,ge){if(te("{",!0)){for(var De={};!te("}",!0);){if(!T.test(Ke=K()))throw be(Ke,"name");var Fe,Be=Ke;if(te(":",!0),"{"===G())Fe=me(we,ge+"."+Ke);else if("["===G()){var dt;if(Fe=[],te("[",!0)){do{dt=H(!0),Fe.push(dt)}while(te(",",!0));te("]"),typeof dt<"u"&&_e(we,ge+"."+Ke,dt)}}else Fe=H(!0),_e(we,ge+"."+Ke,Fe);var xt=De[Be];xt&&(Fe=[].concat(xt).concat(Fe)),De[Be]=Fe,te(",",!0),te(";",!0)}return De}var vt=H(!0);return _e(we,ge,vt),vt}function _e(we,ge,De){we.setOption&&we.setOption(ge,De)}function Qe(we){if(te("[",!0)){do{ye(we,"option")}while(te(",",!0));te("]")}return we}for(;null!==(Ke=K());)switch(Ke){case"package":if(!q)throw be(Ke);He();break;case"import":if(!q)throw be(Ke);We();break;case"syntax":if(!q)throw be(Ke);Je();break;case"option":ye(Se,Ke),te(";");break;default:if(Xe(Se,Ke)){q=!1;continue}throw be(Ke)}return F.filename=null,{package:ne,imports:oe,weakImports:de,syntax:pe,root:C}}},7270:(Y,U,x)=>{"use strict";Y.exports=h;var u,y=x(7211),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new u(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){u=E,h.create=f(),u._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},4354:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(7270);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(7211);function g(w){y.call(this,w)}g._configure=function(){u.Buffer&&(g.prototype._slice=u.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},5257:(Y,U,x)=>{"use strict";Y.exports=d;var y=x(326);((d.prototype=Object.create(y.prototype)).constructor=d).className="Root";var h,c,f,u=x(2986),g=x(4269),w=x(7397),m=x(8572);function d(v){y.call(this,"",v),this.deferred=[],this.files=[]}function b(){}d.fromJSON=function(p,I){return I||(I=new d),p.options&&I.setOptions(p.options),I.addJSON(p.nested)},d.prototype.resolvePath=m.path.resolve,d.prototype.fetch=m.fetch,d.prototype.load=function v(p,I,A){"function"==typeof I&&(A=I,I=void 0);var P=this;if(!A)return m.asPromise(v,P,p,I);var D=A===b;function T(V,L){if(A){var K=A;if(A=null,D)throw V;K(V,L)}}function M(V){var L=V.lastIndexOf("google/protobuf/");if(L>-1){var K=V.substring(L);if(K in f)return K}return null}function k(V,L){try{if(m.isString(L)&&"{"===L.charAt(0)&&(L=JSON.parse(L)),m.isString(L)){c.filename=V;var re,K=c(L,P,I),G=0;if(K.imports)for(;G-1)){if(P.files.push(V),V in f)return void(D?k(V,f[V]):(++j,setTimeout(function(){--j,k(V,f[V])})));if(D){var K;try{K=m.fs.readFileSync(V).toString("utf8")}catch(re){return void(L||T(re))}k(V,K)}else++j,P.fetch(V,function(re,G){if(--j,A){if(re)return void(L?j||T(null,P):T(re));k(V,G)}})}}var j=0;m.isString(p)&&(p=[p]);for(var O,C=0;C-1&&this.deferred.splice(I,1)}}else if(p instanceof g)S.test(p.name)&&delete p.parent[p.name];else if(p instanceof y){for(var A=0;A{"use strict";Y.exports={}},7830:(Y,U,x)=>{"use strict";U.Service=x(6346)},6346:(Y,U,x)=>{"use strict";Y.exports=u;var y=x(7211);function u(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(u.prototype=Object.create(y.EventEmitter.prototype)).constructor=u,u.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},u.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},9630:(Y,U,x)=>{"use strict";Y.exports=m;var y=x(326);((m.prototype=Object.create(y.prototype)).constructor=m).className="Service";var u=x(1618),g=x(8572),w=x(7830);function m(c,f){y.call(this,c,f),this.methods={},this._methodsArray=null}function h(c){return c._methodsArray=null,c}m.fromJSON=function(f,d){var b=new m(f,d.options);if(d.methods)for(var S=Object.keys(d.methods),E=0;E{"use strict";Y.exports=d;var U=/[\s{}=;:[\],'"()<>]/g,x=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,y=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,u=/^ *[*/]+ */,g=/^\s*\*?\/*/,w=/\n/g,m=/\s/,h=/\\(.?)/g,c={0:"\0",r:"\r",n:"\n",t:"\t"};function f(b){return b.replace(h,function(S,E){switch(E){case"\\":case"":return E;default:return c[E]||""}})}function d(b,S){b=b.toString();var E=0,v=b.length,p=1,I=0,A={},P=[],D=null;function T(G){return Error("illegal "+G+" (line "+p+")")}function k(G){return b.charAt(G)}function F(G,te,X){var de,q={type:b.charAt(G++),lineEmpty:!1,leading:X},oe=G-(S?2:3);do{if(--oe<0||"\n"===(de=b.charAt(oe))){q.lineEmpty=!0;break}}while(" "===de||"\t"===de);for(var pe=b.substring(G,te).split(w),Le=0;Le0)return P.shift();if(D)return function M(){var G="'"===D?y:x;G.lastIndex=E-1;var te=G.exec(b);if(!te)throw T("string");return E=G.lastIndex,V(D),D=null,f(te[1])}();var G,te,X,q,ne,oe=0===E;do{if(E===v)return null;for(G=!1;m.test(X=k(E));)if("\n"===X&&(oe=!0,++p),++E===v)return null;if("/"===k(E)){if(++E===v)throw T("comment");if("/"===k(E))if(S){if(q=E,ne=!1,j(E)){ne=!0;do{if((E=C(E))===v||(E++,!oe))break}while(j(E))}else E=Math.min(v,C(E)+1);ne&&(F(q,E,oe),oe=!0),p++,G=!0}else{for(ne="/"===k(q=E+1);"\n"!==k(++E);)if(E===v)return null;++E,ne&&(F(q,E-1,oe),oe=!0),++p,G=!0}else{if("*"!==(X=k(E)))return"/";q=E+1,ne=S||"*"===k(q);do{if("\n"===X&&++p,++E===v)throw T("comment");te=X,X=k(E)}while("*"!==te||"/"!==X);++E,ne&&(F(q,E-2,oe),oe=!0),G=!0}}}while(G);var de=E;if(U.lastIndex=0,!U.test(k(de++)))for(;de{"use strict";Y.exports=A;var y=x(326);((A.prototype=Object.create(y.prototype)).constructor=A).className="Type";var u=x(4269),g=x(7397),w=x(2986),m=x(9455),h=x(9630),c=x(1413),f=x(7270),d=x(1650),b=x(8572),S=x(133),E=x(225),v=x(8617),p=x(6533),I=x(761);function A(D,T){y.call(this,D,T),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function P(D){return D._fieldsById=D._fieldsArray=D._oneofsArray=null,delete D.encode,delete D.decode,delete D.verify,D}Object.defineProperties(A.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var D=Object.keys(this.fields),T=0;T{"use strict";var y=U,u=x(8572),g=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function w(m,h){var c=0,f={};for(h|=0;c{"use strict";var g,w,y=Y.exports=x(7211),u=x(6671);y.codegen=x(9749),y.fetch=x(8832),y.path=x(1311),y.fs=y.inquire("fs"),y.toArray=function(b){if(b){for(var S=Object.keys(b),E=new Array(S.length),v=0;v0)p[P]=v(p[P]||{},I,A);else{var D=p[P];D&&(A=[].concat(D).concat(A)),p[P]=A}return p}(b,S=S.split("."),E)},Object.defineProperty(y,"decorateRoot",{get:function(){return u.decorated||(u.decorated=new(x(5257)))}})},942:(Y,U,x)=>{"use strict";Y.exports=u;var y=x(7211);function u(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=u.zero=new u(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=u.zeroHash="\0\0\0\0\0\0\0\0";u.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new u(d,b)},u.from=function(c){if("number"==typeof c)return u.fromNumber(c);if(y.isString(c)){if(!y.Long)return u.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new u(c.low>>>0,c.high>>>0):g},u.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},u.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;u.fromHash=function(c){return c===w?g:new u((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},u.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},u.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},u.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},u.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},7211:function(Y,U,x){"use strict";var y=U;function u(w,m,h){for(var c=Object.keys(m),f=0;fw,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),m}y.asPromise=x(1280),y.base64=x(9039),y.EventEmitter=x(9889),y.float=x(530),y.inquire=x(716),y.utf8=x(7768),y.pool=x(4479),y.LongBits=x(942),y.isNode=Boolean(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),y.global=y.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||this,y.emptyArray=Object.freeze?Object.freeze([]):[],y.emptyObject=Object.freeze?Object.freeze({}):{},y.isInteger=Number.isInteger||function(m){return"number"==typeof m&&isFinite(m)&&Math.floor(m)===m},y.isString=function(m){return"string"==typeof m||m instanceof String},y.isObject=function(m){return m&&"object"==typeof m},y.isset=y.isSet=function(m,h){var c=m[h];return!(null==c||!m.hasOwnProperty(h))&&("object"!=typeof c||(Array.isArray(c)?c.length:Object.keys(c).length)>0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=u,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Y.exports=function h(c){var f=u.codegen(["m"],c.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),b={};c.oneofsArray.length&&f("var p={}");for(var S=0;S{"use strict";var y=U,u=x(1413);y[".google.protobuf.Any"]={fromObject:function(g){if(g&&g["@type"]){var w=g["@type"].substring(g["@type"].lastIndexOf("/")+1),m=this.lookup(w);if(m){var h="."===g["@type"].charAt(0)?g["@type"].slice(1):g["@type"];return-1===h.indexOf("/")&&(h="/"+h),this.create({type_url:h,value:m.encode(m.fromObject(g)).finish()})}}return this.fromObject(g)},toObject:function(g,w){var h="",c="";if(w&&w.json&&g.type_url&&g.value){c=g.type_url.substring(g.type_url.lastIndexOf("/")+1),h=g.type_url.substring(0,g.type_url.lastIndexOf("/")+1);var f=this.lookup(c);f&&(g=f.decode(g.value))}if(!(g instanceof this.ctor)&&g instanceof u){var d=g.$type.toObject(g,w),b="."===g.$type.fullName[0]?g.$type.fullName.slice(1):g.$type.fullName;return""===h&&(h="type.googleapis.com/"),d["@type"]=c=h+b,d}return this.toObject(g,w)}}},1650:(Y,U,x)=>{"use strict";Y.exports=d;var u,y=x(7211),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new u})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){u=P,d.create=b(),u._configure()}},813:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(1650);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(7211);function g(){y.call(this)}function w(m,h,c){m.length<40?u.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=u._Buffer_allocUnsafe,g.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&"set"===u.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=u.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},7813:(Y,U,x)=>{const y=x(9301),u=x(6217),g=x(7840),w=x(939),{RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c}=x(9644),f=x(4849),d=x(6492),b=x(5936),S=x(8592),E=x(2816),v=x(9062),p=x(9658);Y.exports={RateLimiterRedis:y,RateLimiterMongo:u,RateLimiterMySQL:g,RateLimiterPostgres:w,RateLimiterMemory:f,RateLimiterMemcache:d,RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c,RLWrapperBlackAndWhite:b,RateLimiterUnion:S,RateLimiterQueue:E,BurstyRateLimiter:v,RateLimiterRes:p}},9062:(Y,U,x)=>{const y=x(9658);Y.exports=class{constructor(g,w){this._rateLimiter=g,this._burstLimiter=w}_combineRes(g,w){return new y(g.remainingPoints,Math.min(g.msBeforeNext,w.msBeforeNext),g.consumedPoints,g.isFirstInDuration)}consume(g,w=1,m={}){return this._rateLimiter.consume(g,w,m).catch(h=>h instanceof y?this._burstLimiter.consume(g,w,m).then(c=>Promise.resolve(this._combineRes(h,c))).catch(c=>Promise.reject(c instanceof y?this._combineRes(h,c):c)):Promise.reject(h))}get(g){return Promise.all([this._rateLimiter.get(g),this._burstLimiter.get(g)]).then(([w,m])=>this._combineRes(w,m))}get points(){return this._rateLimiter.points}}},5936:(Y,U,x)=>{const y=x(9658);Y.exports=class{constructor(g={}){this.limiter=g.limiter,this.blackList=g.blackList,this.whiteList=g.whiteList,this.isBlackListed=g.isBlackListed,this.isWhiteListed=g.isWhiteListed,this.runActionAnyway=g.runActionAnyway}get limiter(){return this._limiter}set limiter(g){if(typeof g>"u")throw new Error("limiter is not set");this._limiter=g}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(g){this._runActionAnyway=!(typeof g>"u")&&g}get blackList(){return this._blackList}set blackList(g){this._blackList=Array.isArray(g)?g:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isBlackListed must be function");this._isBlackListed=g}get whiteList(){return this._whiteList}set whiteList(g){this._whiteList=Array.isArray(g)?g:[]}get isWhiteListed(){return this._isWhiteListed}set isWhiteListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isWhiteListed must be function");this._isWhiteListed=g}isBlackListedSomewhere(g){return this.blackList.indexOf(g)>=0||this.isBlackListed(g)}isWhiteListedSomewhere(g){return this.whiteList.indexOf(g)>=0||this.isWhiteListed(g)}getBlackRes(){return new y(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new y(Number.MAX_SAFE_INTEGER,0,0,!1)}rejectBlack(){return Promise.reject(this.getBlackRes())}resolveBlack(){return Promise.resolve(this.getBlackRes())}resolveWhite(){return Promise.resolve(this.getWhiteRes())}consume(g,w=1){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.rejectBlack()),typeof m>"u"?this.limiter.consume(g,w):(this.runActionAnyway&&this.limiter.consume(g,w).catch(()=>{}),m)}block(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.block(g,w):(this.runActionAnyway&&this.limiter.block(g,w).catch(()=>{}),m)}penalty(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.penalty(g,w):(this.runActionAnyway&&this.limiter.penalty(g,w).catch(()=>{}),m)}reward(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.reward(g,w):(this.runActionAnyway&&this.limiter.reward(g,w).catch(()=>{}),m)}get(g){let w;return this.isWhiteListedSomewhere(g)?w=this.resolveWhite():this.isBlackListedSomewhere(g)&&(w=this.resolveBlack()),typeof w>"u"||this.runActionAnyway?this.limiter.get(g):w}delete(g){return this.limiter.delete(g)}}},6953:Y=>{Y.exports=class{constructor(x={}){this.points=x.points,this.duration=x.duration,this.blockDuration=x.blockDuration,this.execEvenly=x.execEvenly,this.execEvenlyMinDelayMs=x.execEvenlyMinDelayMs,this.keyPrefix=x.keyPrefix}get points(){return this._points}set points(x){this._points=x>=0?x:4}get duration(){return this._duration}set duration(x){this._duration=typeof x>"u"?1:x}get msDuration(){return 1e3*this.duration}get blockDuration(){return this._blockDuration}set blockDuration(x){this._blockDuration=typeof x>"u"?0:x}get msBlockDuration(){return 1e3*this.blockDuration}get execEvenly(){return this._execEvenly}set execEvenly(x){this._execEvenly=!(typeof x>"u")&&Boolean(x)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(x){this._execEvenlyMinDelayMs=typeof x>"u"?Math.ceil(this.msDuration/this.points):x}get keyPrefix(){return this._keyPrefix}set keyPrefix(x){if(typeof x>"u"&&(x="rlflx"),"string"!=typeof x)throw new Error("keyPrefix must be string");this._keyPrefix=x}_getKeySecDuration(x={}){return x&&x.customDuration>=0?x.customDuration:this.duration}getKey(x){return this.keyPrefix.length>0?`${this.keyPrefix}:${x}`:x}parseKey(x){return x.substring(this.keyPrefix.length)}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}},9644:(Y,U,x)=>{const y=x(1265),u=x(5539),g=x(6953),w=x(4849),m=x(9658),h="rate_limiter_flexible";let c=null;const f=function(D,T,M,k){let F;F=null===k||!0===k||!1===k?k:{remainingPoints:k.remainingPoints,msBeforeNext:k.msBeforeNext,consumedPoints:k.consumedPoints,isFirstInDuration:k.isFirstInDuration},D.send({channel:h,keyPrefix:T.keyPrefix,promiseId:T.promiseId,type:M,data:F})},d=function(D){setTimeout(()=>{this._initiated?process.send(D):typeof this._promises[D.promiseId]<"u"&&d.call(this,D)},30)},b=function(D,T,M,k,F){const j={channel:h,keyPrefix:this.keyPrefix,func:D,promiseId:T,data:{key:M,arg:k,opts:F}};this._initiated?process.send(j):d.call(this,j)},S=function(D,T){if(!T||T.channel!==h||typeof this._rateLimiters[T.keyPrefix]>"u")return!1;let M;switch(T.func){case"consume":M=this._rateLimiters[T.keyPrefix].consume(T.data.key,T.data.arg,T.data.opts);break;case"penalty":M=this._rateLimiters[T.keyPrefix].penalty(T.data.key,T.data.arg,T.data.opts);break;case"reward":M=this._rateLimiters[T.keyPrefix].reward(T.data.key,T.data.arg,T.data.opts);break;case"block":M=this._rateLimiters[T.keyPrefix].block(T.data.key,T.data.arg,T.data.opts);break;case"get":M=this._rateLimiters[T.keyPrefix].get(T.data.key,T.data.opts);break;case"delete":M=this._rateLimiters[T.keyPrefix].delete(T.data.key,T.data.opts);break;default:return!1}M&&M.then(k=>{f(D,T,"resolve",k)}).catch(k=>{f(D,T,"reject",k)})},E=function(D){if(!D||D.channel!==h||D.keyPrefix!==this.keyPrefix)return!1;if(this._promises[D.promiseId]){let T;switch(clearTimeout(this._promises[D.promiseId].timeoutId),T=null===D.data||!0===D.data||!1===D.data?D.data:new m(D.data.remainingPoints,D.data.msBeforeNext,D.data.consumedPoints,D.data.isFirstInDuration),D.type){case"resolve":this._promises[D.promiseId].resolve(T);break;case"reject":this._promises[D.promiseId].reject(T);break;default:throw new Error(`RateLimiterCluster: no such message type '${D.type}'`)}delete this._promises[D.promiseId]}},v=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},p=function(D,T){const M=process.hrtime();let k=M[0].toString()+M[1].toString();return typeof this._promises[k]<"u"&&(k+=u.randomBytes(12).toString("base64")),this._promises[k]={resolve:D,reject:T,timeoutId:setTimeout(()=>{delete this._promises[k],T(new Error("RateLimiterCluster timeout: no answer from master in time"))},this.timeoutMs)},k};Y.exports={RateLimiterClusterMaster:class I{constructor(){if(c)return c;this._rateLimiters={},y.setMaxListeners(0),y.on("message",(T,M)=>{M&&M.channel===h&&"init"===M.type?(typeof this._rateLimiters[M.opts.keyPrefix]>"u"&&(this._rateLimiters[M.opts.keyPrefix]=new w(M.opts)),T.send({channel:h,type:"init",keyPrefix:M.opts.keyPrefix})):S.call(this,T,M)}),c=this}},RateLimiterClusterMasterPM2:class A{constructor(T){if(c)return c;this._rateLimiters={},T.launchBus((M,k)=>{k.on("process:msg",F=>{const j=F.raw;j&&j.channel===h&&"init"===j.type?(typeof this._rateLimiters[j.opts.keyPrefix]>"u"&&(this._rateLimiters[j.opts.keyPrefix]=new w(j.opts)),T.sendDataToProcessId(F.process.pm_id,{data:{},topic:h,channel:h,type:"init",keyPrefix:j.opts.keyPrefix},(C,O)=>{C&&console.log(C,O)})):S.call(this,{send:O=>{const V=O;V.topic=h,typeof V.data>"u"&&(V.data={}),T.sendDataToProcessId(F.process.pm_id,V,(L,K)=>{L&&console.log(L,K)})}},j)})}),c=this}},RateLimiterCluster:class P extends g{get timeoutMs(){return this._timeoutMs}set timeoutMs(T){this._timeoutMs=typeof T>"u"?5e3:Math.abs(parseInt(T))}constructor(T={}){super(T),process.setMaxListeners(0),this.timeoutMs=T.timeoutMs,this._initiated=!1,process.on("message",M=>{M&&M.channel===h&&"init"===M.type&&M.keyPrefix===this.keyPrefix?this._initiated=!0:E.call(this,M)}),process.send({channel:h,type:"init",opts:v.call(this)}),this._promises={}}consume(T,M=1,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"consume",C,T,M,k)})}penalty(T,M=1,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"penalty",C,T,M,k)})}reward(T,M=1,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"reward",C,T,M,k)})}block(T,M,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"block",C,T,M,k)})}get(T,M={}){return new Promise((k,F)=>{const j=p.call(this,k,F);b.call(this,"get",j,T,M)})}delete(T,M={}){return new Promise((k,F)=>{const j=p.call(this,k,F);b.call(this,"delete",j,T,M)})}}}},6492:(Y,U,x)=>{const y=x(3129),u=x(9658);Y.exports=class g extends y{constructor(m){super(m),this.client=m.storeClient}_getRateLimiterRes(m,h,c){const f=new u;return f.consumedPoints=parseInt(c.consumedPoints),f.isFirstInDuration=c.consumedPoints===h,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=c.msBeforeNext,f}_upsert(m,h,c,f=!1,d={}){return new Promise((b,S)=>{const E=Date.now(),v=Math.floor(c/1e3);f?this.client.set(m,h,v,p=>{p?S(p):this.client.set(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.incr(m,h,(p,I)=>{p||!1===I?this.client.add(m,h,v,(A,P)=>{if(A||!P)if(typeof d.attemptNumber>"u"||d.attemptNumber<3){const D=Object.assign({},d);D.attemptNumber=D.attemptNumber?D.attemptNumber+1:1,this._upsert(m,h,c,f,D).then(T=>b(T)).catch(T=>S(T))}else S(new Error("Can not add key"));else this.client.add(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.get(`${m}_expire`,(A,P)=>{if(A)S(A);else{const D=!1===P?0:P,T={consumedPoints:I,msBeforeNext:D>=0?Math.max(D-E,0):-1};b(T)}})})})}_get(m){return new Promise((h,c)=>{const f=Date.now();this.client.get(m,(d,b)=>{b?this.client.get(`${m}_expire`,(S,E)=>{if(S)c(S);else{const v=!1===E?0:E,p={consumedPoints:b,msBeforeNext:v>=0?Math.max(v-f,0):-1};h(p)}}):h(null)})})}_delete(m){return new Promise((h,c)=>{this.client.del(m,(f,d)=>{f?c(f):!1===d?h(d):this.client.del(`${m}_expire`,b=>{b?c(b):h(d)})})})}}},4849:(Y,U,x)=>{const y=x(6953),u=x(6216),g=x(9658);Y.exports=class w extends y{constructor(h={}){super(h),this._memoryStorage=new u}consume(h,c=1,f={}){return new Promise((d,b)=>{const S=this.getKey(h),E=this._getKeySecDuration(f);let v=this._memoryStorage.incrby(S,c,E);if(v.remainingPoints=Math.max(this.points-v.consumedPoints,0),v.consumedPoints>this.points)this.blockDuration>0&&v.consumedPoints<=this.points+c&&(v=this._memoryStorage.set(S,v.consumedPoints,this.blockDuration)),b(v);else if(this.execEvenly&&v.msBeforeNext>0&&!v.isFirstInDuration){let p=Math.ceil(v.msBeforeNext/(v.remainingPoints+2));p{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}reward(h,c=1,f={}){const d=this.getKey(h);return new Promise(b=>{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,-c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}block(h,c){const f=1e3*c,d=this.points+1;return this._memoryStorage.set(this.getKey(h),d,c),Promise.resolve(new g(0,0===f?-1:f,d))}set(h,c,f){const d=1e3*(f>=0?f:this.duration);return this._memoryStorage.set(this.getKey(h),c,f),Promise.resolve(new g(0,0===d?-1:d,c))}get(h){const c=this._memoryStorage.get(this.getKey(h));return null!==c&&(c.remainingPoints=Math.max(this.points-c.consumedPoints,0)),Promise.resolve(c)}delete(h){return Promise.resolve(this._memoryStorage.delete(this.getKey(h)))}}},6217:(Y,U,x)=>{const y=x(3129),u=x(9658);function g(m){try{const h=m.client?m.client:m,{version:c}=h.topology.s.options.metadata.driver,f=c.split(".").map(d=>parseInt(d));return{major:f[0],feature:f[1],patch:f[2]}}catch{return{major:0,feature:0,patch:0}}}class w extends y{constructor(h){super(h),this.dbName=h.dbName,this.tableName=h.tableName,this.indexKeyPrefix=h.indexKeyPrefix,this.client=h.mongo?h.mongo:h.storeClient,"function"==typeof this.client.then?this.client.then(c=>{this.client=c,this._initCollection(),this._driverVersion=g(this.client)}):(this._initCollection(),this._driverVersion=g(this.client))}get dbName(){return this._dbName}set dbName(h){this._dbName=typeof h>"u"?w.getDbName():h}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(h){this._tableName=typeof h>"u"?this.keyPrefix:h}get client(){return this._client}set client(h){if(typeof h>"u")throw new Error("mongo is not set");this._client=h}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(h){this._indexKeyPrefix=h||{}}_initCollection(){const c=("function"==typeof this.client.db?this.client.db(this.dbName):this.client).collection(this.tableName);c.createIndex({expire:-1},{expireAfterSeconds:0}),c.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=c}_getRateLimiterRes(h,c,f){const d=new u;let b;return b=typeof f.value>"u"?f:f.value,d.isFirstInDuration=b.points===c,d.consumedPoints=b.points,d.remainingPoints=Math.max(this.points-d.consumedPoints,0),d.msBeforeNext=null!==b.expire?Math.max(new Date(b.expire).getTime()-Date.now(),0):-1,d}_upsert(h,c,f,d=!1,b={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const S=b.attrs||{};let E,v;d?(E={key:h},E=Object.assign(E,S),v={$set:{key:h,points:c,expire:f>0?new Date(Date.now()+f):null}},v.$set=Object.assign(v.$set,S)):(E={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:h},E=Object.assign(E,S),v={$setOnInsert:{key:h,expire:f>0?new Date(Date.now()+f):null},$inc:{points:c}},v.$setOnInsert=Object.assign(v.$setOnInsert,S));const p={upsert:!0};return this._driverVersion.major>=4||3===this._driverVersion.major&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?p.returnDocument="after":p.returnOriginal=!1,new Promise((I,A)=>{this._collection.findOneAndUpdate(E,v,p).then(P=>{I(P)}).catch(P=>{if(P&&11e3===P.code){const D=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:h},S),T={$set:Object.assign({key:h,points:c,expire:f>0?new Date(Date.now()+f):null},S)};this._collection.findOneAndUpdate(D,T,p).then(M=>{I(M)}).catch(M=>{M&&11e3===M.code?this._upsert(h,c,f,d).then(k=>I(k)).catch(k=>A(k)):A(M)})}else A(P)})})}_get(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const f=c.attrs||{},d=Object.assign({key:h,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},f);return this._collection.findOne(d)}_delete(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const d=Object.assign({key:h},c.attrs||{});return this._collection.deleteOne(d).then(b=>b.deletedCount>0)}}Y.exports=w},7840:(Y,U,x)=>{const y=x(3129),u=x(9658);Y.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.dbName=m.dbName,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()):this._createDbAndTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._getConnection().then(c=>{c.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,m],()=>{this._releaseConnection(c),h()})}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise((m,h)=>{this.client.getConnection((c,f)=>{if(c)return h(c);m(f)})});case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(m){switch(this.clientType){case"pool":return m.release();case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m);default:return!0}}_createDbAndTable(){return new Promise((m,h)=>{this._getConnection().then(c=>{c.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`,f=>{if(f)return this._releaseConnection(c),h(f);c.query(this._getCreateTableStmt(),d=>{if(d)return this._releaseConnection(c),h(d);this._releaseConnection(c),m()})})}).catch(c=>{h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${this.tableName}\` (\`key\` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\`points\` INT(9) NOT NULL default 0,\`expire\` BIGINT UNSIGNED,PRIMARY KEY (\`key\`)) ENGINE = INNODB;`}get clientType(){return this._clientType}set clientType(m){if(typeof m>"u")if("Connection"===this.client.constructor.name)m="connection";else if("Pool"===this.client.constructor.name)m="pool";else{if("Sequelize"!==this.client.constructor.name)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get dbName(){return this._dbName}set dbName(m){this._dbName=typeof m>"u"?"rtlmtrflx":m}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new u,[d]=c;return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_upsertTransaction(m,h,c,f,d){return new Promise((b,S)=>{m.query("BEGIN",E=>{if(E)return m.rollback(),S(E);const v=Date.now(),p=f>0?v+f:null;let I,A;d?(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = ?, \n expire = ?;",A=[this.dbName,this.tableName,h,c,p,c,p]):(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = IF(expire <= ?, ?, points + (?)), \n expire = IF(expire <= ?, ?, expire);",A=[this.dbName,this.tableName,h,c,p,v,c,c,v,p]),m.query(I,A,P=>{if(P)return m.rollback(),S(P);m.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,h],(D,T)=>{if(D)return m.rollback(),S(D);m.query("COMMIT",M=>{if(M)return m.rollback(),S(M);b(T)})})})})})}_upsert(m,h,c,f=!1){return this.tableCreated?new Promise((d,b)=>{this._getConnection().then(S=>{this._upsertTransaction(S,m,h,c,f).then(E=>{d(E),this._releaseConnection(S)}).catch(E=>{b(E),this._releaseConnection(S)})}).catch(S=>{b(S)})}):Promise.reject(Error("Table is not created yet"))}_get(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)",[this.dbName,this.tableName,m,Date.now()],(d,b)=>{d?c(d):h(0===b.length?null:b),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("DELETE FROM ??.?? WHERE `key` = ?",[this.dbName,this.tableName,m],(d,b)=>{d?c(d):h(b.affectedRows>0),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}}},939:(Y,U,x)=>{const y=x(3129),u=x(9658);Y.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?"function"==typeof h&&h():this._createTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._query({name:"rlflx-clear-expired",text:`DELETE FROM ${this.tableName} WHERE expire < $1`,values:[m]}).then(()=>{h()}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":default:return Promise.resolve(this.client);case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();case"typeorm":return Promise.resolve(this.client.driver.master)}}_releaseConnection(m){switch(this.clientType){case"pool":case"typeorm":default:return!0;case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m)}}_createTable(){return new Promise((m,h)=>{this._query({text:this._getCreateTableStmt()}).then(()=>{m()}).catch(c=>{"23505"===c.code?m():h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS ${this.tableName} ( \n key varchar(255) PRIMARY KEY,\n points integer NOT NULL DEFAULT 0,\n expire bigint\n );`}get clientType(){return this._clientType}set clientType(m){const h=this.client.constructor.name;if(typeof m>"u")if("Client"===h)m="client";else if("Pool"===h||"BoundPool"===h)m="pool";else{if("Sequelize"!==h)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new u,d=c.rows[0];return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_query(m){const c={name:`${this.tableName.toLowerCase()}:${m.name}`,text:m.text,values:m.values};return new Promise((f,d)=>{this._getConnection().then(b=>{b.query(c).then(S=>{f(S),this._releaseConnection(b)}).catch(S=>{d(S),this._releaseConnection(b)})}).catch(b=>{d(b)})})}_upsert(m,h,c,f=!1){if(!this.tableCreated)return Promise.reject(Error("Table is not created yet"));const d=c>0?Date.now()+c:null;return this._query({name:f?"rlflx-upsert-force":"rlflx-upsert",text:`\n INSERT INTO ${this.tableName} VALUES ($1, $2, $3)\n ON CONFLICT(key) DO UPDATE SET\n points = CASE\n WHEN (${this.tableName}.expire <= $4 OR 1=${f?1:0}) THEN $2\n ELSE ${this.tableName}.points + ($2)\n END,\n expire = ${f?" $3 ":` CASE\n WHEN ${this.tableName}.expire <= $4 THEN $3\n ELSE ${this.tableName}.expire\n END `}\n RETURNING points, expire;`,values:[m,h,d,Date.now()]})}_get(m){return this.tableCreated?new Promise((h,c)=>{this._query({name:"rlflx-get",text:`\n SELECT points, expire FROM ${this.tableName} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,values:[m,Date.now()]}).then(f=>{0===f.rowCount&&(f=null),h(f)}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?this._query({name:"rlflx-delete",text:`DELETE FROM ${this.tableName} WHERE key = $1`,values:[m]}).then(h=>h.rowCount>0):Promise.reject(Error("Table is not created yet"))}}},2816:(Y,U,x)=>{const y=x(2047),u=4294967295,g="limiter";Y.exports=class{constructor(h,c={maxQueueSize:u}){this._queueLimiters={KEY_DEFAULT:new w(h,c)},this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(h=g){return this._queueLimiters[h]?this._queueLimiters[h].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(h,c=g){return this._queueLimiters[c]||(this._queueLimiters[c]=new w(this._limiterFlexible,{key:c,maxQueueSize:this._maxQueueSize})),this._queueLimiters[c].removeTokens(h)}};class w{constructor(h,c={maxQueueSize:u,key:g}){this._key=c.key,this._waitTimeout=null,this._queue=[],this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(){return this._limiterFlexible.get(this._key).then(h=>null!==h?h.remainingPoints:this._limiterFlexible.points)}removeTokens(h){const c=this;return new Promise((f,d)=>{h>c._limiterFlexible.points?d(new y(`Requested tokens ${h} exceeds maximum ${c._limiterFlexible.points} tokens per interval`)):c._queue.length>0?c._queueRequest.call(c,f,d,h):c._limiterFlexible.consume(c._key,h).then(b=>{f(b.remainingPoints)}).catch(b=>{b instanceof Error?d(b):(c._queueRequest.call(c,f,d,h),null===c._waitTimeout&&(c._waitTimeout=setTimeout(c._processFIFO.bind(c),b.msBeforeNext)))})})}_queueRequest(h,c,f){const d=this;d._queue.length{c.resolve(f.remainingPoints),h._processFIFO.call(h)}).catch(f=>{f instanceof Error?(c.reject(f),h._processFIFO.call(h)):(h._queue.unshift(c),null===h._waitTimeout&&(h._waitTimeout=setTimeout(h._processFIFO.bind(h),f.msBeforeNext)))})}}},9301:(Y,U,x)=>{const y=x(3129),u=x(9658),g="redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') local consumed = redis.call('incrby', KEYS[1], ARGV[1]) local ttl = redis.call('pttl', KEYS[1]) if ttl == -1 then redis.call('expire', KEYS[1], ARGV[2]) ttl = 1000 * ARGV[2] end return {consumed, ttl} ";Y.exports=class w extends y{constructor(h){super(h),this.client=h.redis?h.redis:h.storeClient,"function"==typeof this.client.defineCommand&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:g})}_getRateLimiterRes(h,c,f){let[d,b]=f;Array.isArray(d)&&([,d]=d,[,b]=b);const S=new u;return S.consumedPoints=parseInt(d),S.isFirstInDuration=S.consumedPoints===c,S.remainingPoints=Math.max(this.points-S.consumedPoints,0),S.msBeforeNext=b,S}_upsert(h,c,f,d=!1){return new Promise((b,S)=>{const E=Math.floor(f/1e3),v=this.client.multi();if(d)E>0?v.set(h,c,"EX",E):v.set(h,c),v.pttl(h).exec((p,I)=>p?S(p):b(I));else if(E>0){const p=function(I,A){return I?S(I):b(A)};"function"==typeof this.client.rlflxIncr?this.client.rlflxIncr(h,c,E,p):this.client.eval(g,1,h,c,E,p)}else v.incrby(h,c).pttl(h).exec((p,I)=>p?S(p):b(I))})}_get(h){return new Promise((c,f)=>{this.client.multi().get(h).pttl(h).exec((d,b)=>{if(d)f(d);else{const[S]=b;if(null===S)return c(null);c(b)}})})}_delete(h){return new Promise((c,f)=>{this.client.del(h,(d,b)=>{d?f(d):c(b>0)})})}}},9658:Y=>{Y.exports=class{constructor(x,y,u,g){this.remainingPoints=typeof x>"u"?0:x,this.msBeforeNext=typeof y>"u"?0:y,this.consumedPoints=typeof u>"u"?0:u,this.isFirstInDuration=!(typeof g>"u")&&g}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(x){return this._msBeforeNext=x,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(x){return this._remainingPoints=x,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(x){return this._consumedPoints=x,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(x){this._isFirstInDuration=Boolean(x)}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}},3129:(Y,U,x)=>{const y=x(6953),u=x(8442),g=x(9658);Y.exports=class extends y{constructor(m={}){super(m),this.inmemoryBlockOnConsumed=m.inmemoryBlockOnConsumed,this.inmemoryBlockDuration=m.inmemoryBlockDuration,this.insuranceLimiter=m.insuranceLimiter,this._inmemoryBlockedKeys=new u}get client(){return this._client}set client(m){if(typeof m>"u")throw new Error("storeClient is not set");this._client=m}_afterConsume(m,h,c,f,d,b={}){const S=this._getRateLimiterRes(c,f,d);if(this.inmemoryBlockOnConsumed>0&&!(this.inmemoryBlockDuration>0)&&S.consumedPoints>=this.inmemoryBlockOnConsumed)return this._inmemoryBlockedKeys.addMs(c,S.msBeforeNext),S.consumedPoints>this.points?h(S):m(S);if(S.consumedPoints>this.points){let E=Promise.resolve();this.blockDuration>0&&S.consumedPoints<=this.points+f&&(S.msBeforeNext=this.msBlockDuration,E=this._block(c,S.consumedPoints,this.msBlockDuration,b)),this.inmemoryBlockOnConsumed>0&&S.consumedPoints>=this.inmemoryBlockOnConsumed&&(this._inmemoryBlockedKeys.add(c,this.inmemoryBlockDuration),S.msBeforeNext=this.msInmemoryBlockDuration),E.then(()=>{h(S)}).catch(v=>{h(v)})}else if(this.execEvenly&&S.msBeforeNext>0&&!S.isFirstInDuration){let E=Math.ceil(S.msBeforeNext/(S.remainingPoints+2));E{c(E)}).catch(E=>{f(E)}):f(m)}getInmemoryBlockMsBeforeExpire(m){return this.inmemoryBlockOnConsumed>0?this._inmemoryBlockedKeys.msBeforeExpire(m):0}get inmemoryBlockOnConsumed(){return this._inmemoryBlockOnConsumed}set inmemoryBlockOnConsumed(m){if(this._inmemoryBlockOnConsumed=m?parseInt(m):0,this.inmemoryBlockOnConsumed>0&&this.points>this.inmemoryBlockOnConsumed)throw new Error('inmemoryBlockOnConsumed option must be greater or equal "points" option')}get inmemoryBlockDuration(){return this._inmemoryBlockDuration}set inmemoryBlockDuration(m){if(this._inmemoryBlockDuration=m?parseInt(m):0,this.inmemoryBlockDuration>0&&0===this.inmemoryBlockOnConsumed)throw new Error("inmemoryBlockOnConsumed option must be set up")}get msInmemoryBlockDuration(){return 1e3*this._inmemoryBlockDuration}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(m){if(typeof m<"u"&&!(m instanceof y))throw new Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=m,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(m,h,c={}){const f=1e3*h;return this._block(this.getKey(m),this.points+1,f,c)}set(m,h,c,f={}){const d=1e3*(c>=0?c:this.duration);return this._block(this.getKey(m),h,d,f)}consume(m,h=1,c={}){return new Promise((f,d)=>{const b=this.getKey(m),S=this.getInmemoryBlockMsBeforeExpire(b);if(S>0)return d(new g(0,S));this._upsert(b,h,1e3*this._getKeySecDuration(c),!1,c).then(E=>{this._afterConsume(f,d,b,h,E)}).catch(E=>{this._handleError(E,"consume",f,d,m,h,c)})})}penalty(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,h,S))}).catch(S=>{this._handleError(S,"penalty",d,b,m,h,c)})})}reward(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,-h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,-h,S))}).catch(S=>{this._handleError(S,"reward",d,b,m,h,c)})})}get(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._get(c,h).then(b=>{f(null===b||typeof b>"u"?null:this._getRateLimiterRes(c,0,b))}).catch(b=>{this._handleError(b,"get",f,d,m,h)})})}delete(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._delete(c,h).then(b=>{this._inmemoryBlockedKeys.delete(c),f(b)}).catch(b=>{this._handleError(b,"delete",f,d,m,h)})})}deleteInMemoryBlockedAll(){this._inmemoryBlockedKeys.delete()}_getRateLimiterRes(m,h,c){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(m,h,c,f={}){return new Promise((d,b)=>{this._upsert(m,h,c,!0,f).then(()=>{d(new g(0,c>0?c:-1,h))}).catch(S=>{this._handleError(S,"block",d,b,this.parseKey(m),c/1e3,f)})})}_get(m,h={}){throw new Error("You have to implement the method '_get'!")}_delete(m,h={}){throw new Error("You have to implement the method '_delete'!")}_upsert(){throw new Error("You have to implement the method '_upsert'!")}}},8592:(Y,U,x)=>{const y=x(6953);Y.exports=class{constructor(...g){if(g.length<2)throw new Error("RateLimiterUnion: at least two limiters have to be set");g.forEach(w=>{if(!(w instanceof y))throw new Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")}),this._limiters=g}consume(g,w=1){return new Promise((m,h)=>{const c=[];this._limiters.forEach(f=>{c.push(f.consume(g,w).catch(d=>({rejected:!0,rej:d})))}),Promise.all(c).then(f=>{const d={};let b=!1;f.forEach(S=>{!0===S.rejected&&(b=!0)});for(let S=0;S{Y.exports=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){const x=Date.now();Object.keys(this._keys).forEach(y=>{this._keys[y]<=x&&delete this._keys[y]}),this._addedKeysAmount=Object.keys(this._keys).length}add(x,y){this.addMs(x,1e3*y)}addMs(x,y){this._keys[x]=Date.now()+y,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(x){const y=this._keys[x];if(y&&y>=Date.now()){this.collectExpired();const u=Date.now();return y>=u?y-u:0}return 0}delete(x){x?delete this._keys[x]:Object.keys(this._keys).forEach(y=>{delete this._keys[y]})}}},8442:(Y,U,x)=>{const y=x(2585);Y.exports=y},6216:(Y,U,x)=>{const y=x(7105),u=x(9658);Y.exports=class{constructor(){this._storage={}}incrby(w,m,h){if(this._storage[w]){const c=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return 0!==c?(this._storage[w].value=this._storage[w].value+m,new u(0,c,this._storage[w].value,!1)):this.set(w,m,h)}return this.set(w,m,h)}set(w,m,h){const c=1e3*h;return this._storage[w]&&this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),this._storage[w]=new y(m,c>0?new Date(Date.now()+c):null),c>0&&(this._storage[w].timeoutId=setTimeout(()=>{delete this._storage[w]},c),this._storage[w].timeoutId.unref&&this._storage[w].timeoutId.unref()),new u(0,0===c?-1:c,this._storage[w].value,!0)}get(w){if(this._storage[w]){const m=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return new u(0,m,this._storage[w].value,!1)}return null}delete(w){return!!this._storage[w]&&(this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),delete this._storage[w],!0)}}},7105:Y=>{Y.exports=class{constructor(x,y,u=null){this.value=x,this.expiresAt=y,this.timeoutId=u}get value(){return this._value}set value(x){this._value=parseInt(x)}get expiresAt(){return this._expiresAt}set expiresAt(x){!(x instanceof Date)&&Number.isInteger(x)&&(x=new Date(x)),this._expiresAt=x}get timeoutId(){return this._timeoutId}set timeoutId(x){this._timeoutId=x}}},2047:Y=>{Y.exports=class extends Error{constructor(x,y){super(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="CustomError",this.message=x,y&&(this.extra=y)}}},4033:(Y,U,x)=>{"use strict";Y.exports=m;var y=x(4366),u=m.prototype,g=new Date%1e9;function m(h){this.id=(h=h||{}).id||function w(){return(1e9*Math.random()>>>0)+g++}(),this.max=h.max||1/0,this.items=h.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(h.lastModified||new Date);for(var c,f,d=this.items.length;d--;)c=this.items[d],f=new Date(c.expires)-new Date,this._lookup[c.key]=c,f>0?this.expire(c.key,f):f<=0&&this.delete(c.key)}u.has=function(h){return h in this._lookup},u.get=function(h){if(!this.has(h))return null;var c=this._lookup[h];return c.refresh&&this.expire(h,c.refresh),this.items.splice(this.items.indexOf(c),1),this.items.push(c),c.value},u.meta=function(h){if(!this.has(h))return null;var c=this._lookup[h];return"meta"in c?c.meta:null},u.set=function(h,c,f){var d=this._lookup[h],b=this._lookup[h]={key:h,value:c};return this.lastModified=new Date,d?(clearTimeout(d.timeout),this.items.splice(this.items.indexOf(d),1,b)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(b),this.size++),f&&("ttl"in f&&this.expire(h,f.ttl),"meta"in f&&(b.meta=f.meta),f.refresh&&(b.refresh=f.ttl)),this},u.delete=function(h){var c=this._lookup[h];return!!c&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(c),1),clearTimeout(c.timeout),delete this._lookup[h],this.size--,this)},u.expire=function(h,c){var f=c||0,d=this._lookup[h];if(!d)return this;if("string"==typeof f&&(f=y(c)),"number"!=typeof f)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(d.timeout),d.timeout=setTimeout(this.delete.bind(this,d.key),f),d.expires=Number(new Date)+f,this},u.clear=function(){for(var h=this.items.length;h--;)this.delete(this.items[h].key);return this},u.toJSON=function(){for(var c,h=new Array(this.items.length),f=h.length;f--;)h[f]={key:(c=this.items[f]).key,meta:c.meta,value:c.value,expires:c.expires,refresh:c.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:h}}},2502:(Y,U,x)=>{"use strict";const y=x(7806);class u{constructor(m,h,c){const f=this;this._started=y(),this._rescheduled=0,this._scheduled=h,this._args=c,this._triggered=!1,this._timerWrapper=()=>{f._rescheduled>0?(f._scheduled=f._rescheduled-(y()-f._started),f._schedule(f._scheduled)):(f._triggered=!0,m.apply(null,f._args))},this._timer=setTimeout(this._timerWrapper,h)}reschedule(m){m||(m=this._scheduled);const h=y();h+m-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(m)):this._triggered?this._schedule(m):(this._started=h,this._rescheduled=m)}_schedule(m){this._triggered=!1,this._started=y(),this._rescheduled=0,this._scheduled=m,this._timer=setTimeout(this._timerWrapper,m)}clear(){clearTimeout(this._timer)}}Y.exports=function g(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");let w;if(arguments.length>0){w=new Array(arguments.length-2);for(var m=0;m{"use strict";Y.exports=function(){return Date.now()}},9014:(Y,U,x)=>{"use strict";var y=x(9942),u=/[\/\?<>\\:\*\|"]/g,g=/[\x00-\x1f\x80-\x9f]/g,w=/^\.+$/,m=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,h=/[\. ]+$/;function c(f,d){if("string"!=typeof f)throw new Error("Input must be string");var b=f.replace(u,d).replace(g,d).replace(w,d).replace(m,d).replace(h,d);return y(b,255)}Y.exports=function(f,d){var b=d&&d.replacement||"",S=c(f,b);return""===b?S:c(S,"")}},1466:(Y,U,x)=>{"use strict";var y=x(7156).default;const u=new Map;function m(){return(m=y(function*(f,d,b){for(;u.get(b);){try{yield f()}catch(S){setTimeout(()=>{throw S},1);break}if(!u.get(b))break;yield new Promise(S=>{const E=setTimeout(S,d);u.set(b,E)})}})).apply(this,arguments)}Y.exports={setDelayedInterval:function h(f,d,b){b=b||d;const S=`${Date.now()}:${Math.floor(1e6*Math.random())}`,E=setTimeout(()=>{!function w(f,d,b){m.apply(this,arguments)}(f,d,S)},b);return u.set(S,E),S},clearDelayedInterval:function c(f){const d=u.get(f);d&&(clearTimeout(d),u.delete(f))}}},1420:(Y,U,x)=>{"use strict";const{AbortController:y}=globalThis,u=x(2502);class g extends y{constructor(m){super(),this._ms=m,this._timer=u(()=>this.abort(),m),Object.setPrototypeOf(this,g.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=u(()=>this.abort(),this._ms)}}Y.exports={TimeoutController:g}},9942:(Y,U,x)=>{"use strict";var y=x(8831),u=x(8871);Y.exports=y.bind(null,u)},8831:Y=>{"use strict";function x(y){return y>=56320&&y<=57343}Y.exports=function(u,g,w){if("string"!=typeof g)throw new Error("Input must be string");for(var c,f,m=g.length,h=0,d=0;d=55296&&y<=56319&&x(g.charCodeAt(d+1))&&(f+=g[d+=1]),(h+=u(f))===w)return g.slice(0,d+1);if(h>w)return g.slice(0,d-f.length+1)}var y;return g}},8871:Y=>{"use strict";function U(y){return y>=55296&&y<=56319}Y.exports=function(u){if("string"!=typeof u)throw new Error("Input must be string");for(var g=u.length,w=0,m=null,h=null,c=0;c=56320&&y<=57343?null!=h&&U(h)?w+=1:w+=3:m<=127?w+=1:m>=128&&m<=2047?w+=2:m>=2048&&m<=65535&&(w+=3),h=m;var y;return w}},3004:Y=>{Y.exports=function y(u,m){var f,w=0,h=0,c=m=m||0,d=u.length;do{if(c>=d||h>49)throw y.bytes=0,new RangeError("Could not decode varint");f=u[c++],w+=h<28?(127&f)<=128);return y.bytes=c-m,w}},5723:Y=>{Y.exports=function g(w,m,h){if(Number.MAX_SAFE_INTEGER&&w>Number.MAX_SAFE_INTEGER)throw g.bytes=0,new RangeError("Could not encode varint");m=m||[];for(var c=h=h||0;w>=u;)m[h++]=255&w|128,w/=128;for(;-128&w;)m[h++]=255&w|128,w>>>=7;return m[h]=0|w,g.bytes=h-c+1,m};var u=Math.pow(2,31)},1732:(Y,U,x)=>{Y.exports={encode:x(5723),decode:x(3004),encodingLength:x(4036)}},4036:Y=>{var U=Math.pow(2,7),x=Math.pow(2,14),y=Math.pow(2,21),u=Math.pow(2,28),g=Math.pow(2,35),w=Math.pow(2,42),m=Math.pow(2,49),h=Math.pow(2,56),c=Math.pow(2,63);Y.exports=function(f){return f{"use strict";!function(ie){const fe=ie.performance;function ye(Ft){fe&&fe.mark&&fe.mark(Ft)}function me(Ft,ct){fe&&fe.measure&&fe.measure(Ft,ct)}ye("Zone");const _e=ie.__Zone_symbol_prefix||"__zone_symbol__";function Me(Ft){return _e+Ft}const Qe=!0===ie[Me("forceDuplicateZoneCheck")];if(ie.Zone){if(Qe||"function"!=typeof ie.Zone.__symbol__)throw new Error("Zone already loaded.");return ie.Zone}let qe=(()=>{class Ft{constructor(ce,ve){this._parent=ce,this._name=ve?ve.name||"unnamed":"",this._properties=ve&&ve.properties||{},this._zoneDelegate=new nt(this,this._parent&&this._parent._zoneDelegate,ve)}static assertZonePatched(){if(ie.Promise!==Pr.ZoneAwarePromise)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")}static get root(){let ce=Ft.current;for(;ce.parent;)ce=ce.parent;return ce}static get current(){return En.zone}static get currentTask(){return ur}static __load_patch(ce,ve,mt=!1){if(Pr.hasOwnProperty(ce)){if(!mt&&Qe)throw Error("Already loaded patch: "+ce)}else if(!ie["__Zone_disable_"+ce]){const Dt="Zone:"+ce;ye(Dt),Pr[ce]=ve(ie,Ft,kn),me(Dt,Dt)}}get parent(){return this._parent}get name(){return this._name}get(ce){const ve=this.getZoneWith(ce);if(ve)return ve._properties[ce]}getZoneWith(ce){let ve=this;for(;ve;){if(ve._properties.hasOwnProperty(ce))return ve;ve=ve._parent}return null}fork(ce){if(!ce)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,ce)}wrap(ce,ve){if("function"!=typeof ce)throw new Error("Expecting function got: "+ce);const mt=this._zoneDelegate.intercept(this,ce,ve),Dt=this;return function(){return Dt.runGuarded(mt,this,arguments,ve)}}run(ce,ve,mt,Dt){En={parent:En,zone:this};try{return this._zoneDelegate.invoke(this,ce,ve,mt,Dt)}finally{En=En.parent}}runGuarded(ce,ve=null,mt,Dt){En={parent:En,zone:this};try{try{return this._zoneDelegate.invoke(this,ce,ve,mt,Dt)}catch(yn){if(this._zoneDelegate.handleError(this,yn))throw yn}}finally{En=En.parent}}runTask(ce,ve,mt){if(ce.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(ce.zone||An).name+"; Execution: "+this.name+")");if(ce.state===Bt&&(ce.type===er||ce.type===wt))return;const Dt=ce.state!=ft;Dt&&ce._transitionTo(ft,tn),ce.runCount++;const yn=ur;ur=ce,En={parent:En,zone:this};try{ce.type==wt&&ce.data&&!ce.data.isPeriodic&&(ce.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,ce,ve,mt)}catch(ze){if(this._zoneDelegate.handleError(this,ze))throw ze}}finally{ce.state!==Bt&&ce.state!==st&&(ce.type==er||ce.data&&ce.data.isPeriodic?Dt&&ce._transitionTo(tn,ft):(ce.runCount=0,this._updateTaskCount(ce,-1),Dt&&ce._transitionTo(Bt,ft,Bt))),En=En.parent,ur=yn}}scheduleTask(ce){if(ce.zone&&ce.zone!==this){let mt=this;for(;mt;){if(mt===ce.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${ce.zone.name}`);mt=mt.parent}}ce._transitionTo(gn,Bt);const ve=[];ce._zoneDelegates=ve,ce._zone=this;try{ce=this._zoneDelegate.scheduleTask(this,ce)}catch(mt){throw ce._transitionTo(st,gn,Bt),this._zoneDelegate.handleError(this,mt),mt}return ce._zoneDelegates===ve&&this._updateTaskCount(ce,1),ce.state==gn&&ce._transitionTo(tn,gn),ce}scheduleMicroTask(ce,ve,mt,Dt){return this.scheduleTask(new Ke(Kt,ce,ve,mt,Dt,void 0))}scheduleMacroTask(ce,ve,mt,Dt,yn){return this.scheduleTask(new Ke(wt,ce,ve,mt,Dt,yn))}scheduleEventTask(ce,ve,mt,Dt,yn){return this.scheduleTask(new Ke(er,ce,ve,mt,Dt,yn))}cancelTask(ce){if(ce.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(ce.zone||An).name+"; Execution: "+this.name+")");ce._transitionTo(fn,tn,ft);try{this._zoneDelegate.cancelTask(this,ce)}catch(ve){throw ce._transitionTo(st,fn),this._zoneDelegate.handleError(this,ve),ve}return this._updateTaskCount(ce,-1),ce._transitionTo(Bt,fn),ce.runCount=0,ce}_updateTaskCount(ce,ve){const mt=ce._zoneDelegates;-1==ve&&(ce._zoneDelegates=null);for(let Dt=0;DtFt.hasTask(ce,ve),onScheduleTask:(Ft,ct,ce,ve)=>Ft.scheduleTask(ce,ve),onInvokeTask:(Ft,ct,ce,ve,mt,Dt)=>Ft.invokeTask(ce,ve,mt,Dt),onCancelTask:(Ft,ct,ce,ve)=>Ft.cancelTask(ce,ve)};class nt{constructor(ct,ce,ve){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=ct,this._parentDelegate=ce,this._forkZS=ve&&(ve&&ve.onFork?ve:ce._forkZS),this._forkDlgt=ve&&(ve.onFork?ce:ce._forkDlgt),this._forkCurrZone=ve&&(ve.onFork?this.zone:ce._forkCurrZone),this._interceptZS=ve&&(ve.onIntercept?ve:ce._interceptZS),this._interceptDlgt=ve&&(ve.onIntercept?ce:ce._interceptDlgt),this._interceptCurrZone=ve&&(ve.onIntercept?this.zone:ce._interceptCurrZone),this._invokeZS=ve&&(ve.onInvoke?ve:ce._invokeZS),this._invokeDlgt=ve&&(ve.onInvoke?ce:ce._invokeDlgt),this._invokeCurrZone=ve&&(ve.onInvoke?this.zone:ce._invokeCurrZone),this._handleErrorZS=ve&&(ve.onHandleError?ve:ce._handleErrorZS),this._handleErrorDlgt=ve&&(ve.onHandleError?ce:ce._handleErrorDlgt),this._handleErrorCurrZone=ve&&(ve.onHandleError?this.zone:ce._handleErrorCurrZone),this._scheduleTaskZS=ve&&(ve.onScheduleTask?ve:ce._scheduleTaskZS),this._scheduleTaskDlgt=ve&&(ve.onScheduleTask?ce:ce._scheduleTaskDlgt),this._scheduleTaskCurrZone=ve&&(ve.onScheduleTask?this.zone:ce._scheduleTaskCurrZone),this._invokeTaskZS=ve&&(ve.onInvokeTask?ve:ce._invokeTaskZS),this._invokeTaskDlgt=ve&&(ve.onInvokeTask?ce:ce._invokeTaskDlgt),this._invokeTaskCurrZone=ve&&(ve.onInvokeTask?this.zone:ce._invokeTaskCurrZone),this._cancelTaskZS=ve&&(ve.onCancelTask?ve:ce._cancelTaskZS),this._cancelTaskDlgt=ve&&(ve.onCancelTask?ce:ce._cancelTaskDlgt),this._cancelTaskCurrZone=ve&&(ve.onCancelTask?this.zone:ce._cancelTaskCurrZone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const mt=ve&&ve.onHasTask;(mt||ce&&ce._hasTaskZS)&&(this._hasTaskZS=mt?ve:it,this._hasTaskDlgt=ce,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=ct,ve.onScheduleTask||(this._scheduleTaskZS=it,this._scheduleTaskDlgt=ce,this._scheduleTaskCurrZone=this.zone),ve.onInvokeTask||(this._invokeTaskZS=it,this._invokeTaskDlgt=ce,this._invokeTaskCurrZone=this.zone),ve.onCancelTask||(this._cancelTaskZS=it,this._cancelTaskDlgt=ce,this._cancelTaskCurrZone=this.zone))}fork(ct,ce){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,ct,ce):new qe(ct,ce)}intercept(ct,ce,ve){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,ct,ce,ve):ce}invoke(ct,ce,ve,mt,Dt){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,ct,ce,ve,mt,Dt):ce.apply(ve,mt)}handleError(ct,ce){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,ct,ce)}scheduleTask(ct,ce){let ve=ce;if(this._scheduleTaskZS)this._hasTaskZS&&ve._zoneDelegates.push(this._hasTaskDlgtOwner),ve=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,ct,ce),ve||(ve=ce);else if(ce.scheduleFn)ce.scheduleFn(ce);else{if(ce.type!=Kt)throw new Error("Task is missing scheduleFn.");vt(ce)}return ve}invokeTask(ct,ce,ve,mt){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,ct,ce,ve,mt):ce.callback.apply(ve,mt)}cancelTask(ct,ce){let ve;if(this._cancelTaskZS)ve=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,ct,ce);else{if(!ce.cancelFn)throw Error("Task is not cancelable");ve=ce.cancelFn(ce)}return ve}hasTask(ct,ce){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,ct,ce)}catch(ve){this.handleError(ct,ve)}}_updateTaskCount(ct,ce){const ve=this._taskCounts,mt=ve[ct],Dt=ve[ct]=mt+ce;if(Dt<0)throw new Error("More tasks executed then were scheduled.");0!=mt&&0!=Dt||this.hasTask(this.zone,{microTask:ve.microTask>0,macroTask:ve.macroTask>0,eventTask:ve.eventTask>0,change:ct})}}class Ke{constructor(ct,ce,ve,mt,Dt,yn){if(this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=ct,this.source=ce,this.data=mt,this.scheduleFn=Dt,this.cancelFn=yn,!ve)throw new Error("callback is not defined");this.callback=ve;const ze=this;this.invoke=ct===er&&mt&&mt.useG?Ke.invokeTask:function(){return Ke.invokeTask.call(ie,ze,this,arguments)}}static invokeTask(ct,ce,ve){ct||(ct=this),Zn++;try{return ct.runCount++,ct.zone.runTask(ct,ce,ve)}finally{1==Zn&&et(),Zn--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(Bt,gn)}_transitionTo(ct,ce,ve){if(this._state!==ce&&this._state!==ve)throw new Error(`${this.type} '${this.source}': can not transition to '${ct}', expecting state '${ce}'${ve?" or '"+ve+"'":""}, was '${this._state}'.`);this._state=ct,ct==Bt&&(this._zoneDelegates=null)}toString(){return this.data&&typeof this.data.handleId<"u"?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const we=Me("setTimeout"),ge=Me("Promise"),De=Me("then");let dt,Fe=[],Be=!1;function xt(Ft){if(dt||ie[ge]&&(dt=ie[ge].resolve(0)),dt){let ct=dt[De];ct||(ct=dt.then),ct.call(dt,Ft)}else ie[we](Ft,0)}function vt(Ft){0===Zn&&0===Fe.length&&xt(et),Ft&&Fe.push(Ft)}function et(){if(!Be){for(Be=!0;Fe.length;){const Ft=Fe;Fe=[];for(let ct=0;ctEn,onUnhandledError:bn,microtaskDrainDone:bn,scheduleMicroTask:vt,showUncaughtError:()=>!qe[Me("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:bn,patchMethod:()=>bn,bindArguments:()=>[],patchThen:()=>bn,patchMacroTask:()=>bn,patchEventPrototype:()=>bn,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>bn,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>bn,wrapWithCurrentZone:()=>bn,filterProperties:()=>[],attachOriginToPatched:()=>bn,_redefineProperty:()=>bn,patchCallbacks:()=>bn,nativeScheduleMicroTask:xt};let En={parent:null,zone:new qe(null,null)},ur=null,Zn=0;function bn(){}me("Zone","Zone"),ie.Zone=qe}(typeof window<"u"&&window||typeof self<"u"&&self||global);const Y=Object.getOwnPropertyDescriptor,U=Object.defineProperty,x=Object.getPrototypeOf,y=Object.create,u=Array.prototype.slice,g="addEventListener",w="removeEventListener",m=Zone.__symbol__(g),h=Zone.__symbol__(w),c="true",f="false",d=Zone.__symbol__("");function b(ie,fe){return Zone.current.wrap(ie,fe)}function S(ie,fe,ye,me,_e){return Zone.current.scheduleMacroTask(ie,fe,ye,me,_e)}const E=Zone.__symbol__,v=typeof window<"u",p=v?window:void 0,I=v&&p||"object"==typeof self&&self||global;function P(ie,fe){for(let ye=ie.length-1;ye>=0;ye--)"function"==typeof ie[ye]&&(ie[ye]=b(ie[ye],fe+"_"+ye));return ie}function T(ie){return!ie||!1!==ie.writable&&!("function"==typeof ie.get&&typeof ie.set>"u")}const M=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,k=!("nw"in I)&&typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process),F=!k&&!M&&!(!v||!p.HTMLElement),j=typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process)&&!M&&!(!v||!p.HTMLElement),C={},O=function(ie){if(!(ie=ie||I.event))return;let fe=C[ie.type];fe||(fe=C[ie.type]=E("ON_PROPERTY"+ie.type));const ye=this||ie.target||I,me=ye[fe];let _e;if(F&&ye===p&&"error"===ie.type){const Me=ie;_e=me&&me.call(this,Me.message,Me.filename,Me.lineno,Me.colno,Me.error),!0===_e&&ie.preventDefault()}else _e=me&&me.apply(this,arguments),null!=_e&&!_e&&ie.preventDefault();return _e};function V(ie,fe,ye){let me=Y(ie,fe);if(!me&&ye&&Y(ye,fe)&&(me={enumerable:!0,configurable:!0}),!me||!me.configurable)return;const _e=E("on"+fe+"patched");if(ie.hasOwnProperty(_e)&&ie[_e])return;delete me.writable,delete me.value;const Me=me.get,Qe=me.set,qe=fe.slice(2);let it=C[qe];it||(it=C[qe]=E("ON_PROPERTY"+qe)),me.set=function(nt){let Ke=this;!Ke&&ie===I&&(Ke=I),Ke&&("function"==typeof Ke[it]&&Ke.removeEventListener(qe,O),Qe&&Qe.call(Ke,null),Ke[it]=nt,"function"==typeof nt&&Ke.addEventListener(qe,O,!1))},me.get=function(){let nt=this;if(!nt&&ie===I&&(nt=I),!nt)return null;const Ke=nt[it];if(Ke)return Ke;if(Me){let we=Me.call(this);if(we)return me.set.call(this,we),"function"==typeof nt.removeAttribute&&nt.removeAttribute(fe),we}return null},U(ie,fe,me),ie[_e]=!0}function L(ie,fe,ye){if(fe)for(let me=0;mefunction(Qe,qe){const it=ye(Qe,qe);return it.cbIdx>=0&&"function"==typeof qe[it.cbIdx]?S(it.name,qe[it.cbIdx],it,_e):Me.apply(Qe,qe)})}function X(ie,fe){ie[E("OriginalDelegate")]=fe}let q=!1,ne=!1;function de(){if(q)return ne;q=!0;try{const ie=p.navigator.userAgent;(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/")||-1!==ie.indexOf("Edge/"))&&(ne=!0)}catch{}return ne}Zone.__load_patch("ZoneAwarePromise",(ie,fe,ye)=>{const me=Object.getOwnPropertyDescriptor,_e=Object.defineProperty,Qe=ye.symbol,qe=[],it=!0===ie[Qe("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")],nt=Qe("Promise"),Ke=Qe("then");ye.onUnhandledError=ze=>{if(ye.showUncaughtError()){const Ye=ze&&ze.rejection;Ye?console.error("Unhandled Promise rejection:",Ye instanceof Error?Ye.message:Ye,"; Zone:",ze.zone.name,"; Task:",ze.task&&ze.task.source,"; Value:",Ye,Ye instanceof Error?Ye.stack:void 0):console.error(ze)}},ye.microtaskDrainDone=()=>{for(;qe.length;){const ze=qe.shift();try{ze.zone.runGuarded(()=>{throw ze.throwOriginal?ze.rejection:ze})}catch(Ye){De(Ye)}}};const ge=Qe("unhandledPromiseRejectionHandler");function De(ze){ye.onUnhandledError(ze);try{const Ye=fe[ge];"function"==typeof Ye&&Ye.call(this,ze)}catch{}}function Fe(ze){return ze&&ze.then}function Be(ze){return ze}function dt(ze){return ce.reject(ze)}const xt=Qe("state"),vt=Qe("value"),et=Qe("finally"),An=Qe("parentPromiseValue"),Bt=Qe("parentPromiseState"),tn=null,fn=!1;function Kt(ze,Ye){return Ae=>{try{kn(ze,Ye,Ae)}catch(Ge){kn(ze,!1,Ge)}}}const wt=function(){let ze=!1;return function(Ae){return function(){ze||(ze=!0,Ae.apply(null,arguments))}}},Pr=Qe("currentTaskTrace");function kn(ze,Ye,Ae){const Ge=wt();if(ze===Ae)throw new TypeError("Promise resolved with itself");if(ze[xt]===tn){let ht=null;try{("object"==typeof Ae||"function"==typeof Ae)&&(ht=Ae&&Ae.then)}catch(Et){return Ge(()=>{kn(ze,!1,Et)})(),ze}if(Ye!==fn&&Ae instanceof ce&&Ae.hasOwnProperty(xt)&&Ae.hasOwnProperty(vt)&&Ae[xt]!==tn)ur(Ae),kn(ze,Ae[xt],Ae[vt]);else if(Ye!==fn&&"function"==typeof ht)try{ht.call(Ae,Ge(Kt(ze,Ye)),Ge(Kt(ze,!1)))}catch(Et){Ge(()=>{kn(ze,!1,Et)})()}else{ze[xt]=Ye;const Et=ze[vt];if(ze[vt]=Ae,ze[et]===et&&!0===Ye&&(ze[xt]=ze[Bt],ze[vt]=ze[An]),Ye===fn&&Ae instanceof Error){const ut=fe.currentTask&&fe.currentTask.data&&fe.currentTask.data.__creationTrace__;ut&&_e(Ae,Pr,{configurable:!0,enumerable:!1,writable:!0,value:ut})}for(let ut=0;ut{try{const St=ze[vt],$t=!!Ae&&et===Ae[et];$t&&(Ae[An]=St,Ae[Bt]=Et);const Ut=Ye.run(ut,void 0,$t&&ut!==dt&&ut!==Be?[]:[St]);kn(Ae,!0,Ut)}catch(St){kn(Ae,!1,St)}},Ae)}const Ft=function(){},ct=ie.AggregateError;class ce{static toString(){return"function ZoneAwarePromise() { [native code] }"}static resolve(Ye){return kn(new this(null),!0,Ye)}static reject(Ye){return kn(new this(null),fn,Ye)}static any(Ye){if(!Ye||"function"!=typeof Ye[Symbol.iterator])return Promise.reject(new ct([],"All promises were rejected"));const Ae=[];let Ge=0;try{for(let ut of Ye)Ge++,Ae.push(ce.resolve(ut))}catch{return Promise.reject(new ct([],"All promises were rejected"))}if(0===Ge)return Promise.reject(new ct([],"All promises were rejected"));let ht=!1;const Et=[];return new ce((ut,St)=>{for(let $t=0;$t{ht||(ht=!0,ut(Ut))},Ut=>{Et.push(Ut),Ge--,0===Ge&&(ht=!0,St(new ct(Et,"All promises were rejected")))})})}static race(Ye){let Ae,Ge,ht=new this((St,$t)=>{Ae=St,Ge=$t});function Et(St){Ae(St)}function ut(St){Ge(St)}for(let St of Ye)Fe(St)||(St=this.resolve(St)),St.then(Et,ut);return ht}static all(Ye){return ce.allWithCallback(Ye)}static allSettled(Ye){return(this&&this.prototype instanceof ce?this:ce).allWithCallback(Ye,{thenCallback:Ge=>({status:"fulfilled",value:Ge}),errorCallback:Ge=>({status:"rejected",reason:Ge})})}static allWithCallback(Ye,Ae){let Ge,ht,Et=new this((Ut,xn)=>{Ge=Ut,ht=xn}),ut=2,St=0;const $t=[];for(let Ut of Ye){Fe(Ut)||(Ut=this.resolve(Ut));const xn=St;try{Ut.then(Sn=>{$t[xn]=Ae?Ae.thenCallback(Sn):Sn,ut--,0===ut&&Ge($t)},Sn=>{Ae?($t[xn]=Ae.errorCallback(Sn),ut--,0===ut&&Ge($t)):ht(Sn)})}catch(Sn){ht(Sn)}ut++,St++}return ut-=2,0===ut&&Ge($t),Et}constructor(Ye){const Ae=this;if(!(Ae instanceof ce))throw new Error("Must be an instanceof Promise.");Ae[xt]=tn,Ae[vt]=[];try{const Ge=wt();Ye&&Ye(Ge(Kt(Ae,!0)),Ge(Kt(Ae,fn)))}catch(Ge){kn(Ae,!1,Ge)}}get[Symbol.toStringTag](){return"Promise"}get[Symbol.species](){return ce}then(Ye,Ae){var Ge;let ht=null===(Ge=this.constructor)||void 0===Ge?void 0:Ge[Symbol.species];(!ht||"function"!=typeof ht)&&(ht=this.constructor||ce);const Et=new ht(Ft),ut=fe.current;return this[xt]==tn?this[vt].push(ut,Et,Ye,Ae):Zn(this,ut,Et,Ye,Ae),Et}catch(Ye){return this.then(null,Ye)}finally(Ye){var Ae;let Ge=null===(Ae=this.constructor)||void 0===Ae?void 0:Ae[Symbol.species];(!Ge||"function"!=typeof Ge)&&(Ge=ce);const ht=new Ge(Ft);ht[et]=et;const Et=fe.current;return this[xt]==tn?this[vt].push(Et,ht,Ye,Ye):Zn(this,Et,ht,Ye,Ye),ht}}ce.resolve=ce.resolve,ce.reject=ce.reject,ce.race=ce.race,ce.all=ce.all;const ve=ie[nt]=ie.Promise;ie.Promise=ce;const mt=Qe("thenPatched");function Dt(ze){const Ye=ze.prototype,Ae=me(Ye,"then");if(Ae&&(!1===Ae.writable||!Ae.configurable))return;const Ge=Ye.then;Ye[Ke]=Ge,ze.prototype.then=function(ht,Et){return new ce((St,$t)=>{Ge.call(this,St,$t)}).then(ht,Et)},ze[mt]=!0}return ye.patchThen=Dt,ve&&(Dt(ve),G(ie,"fetch",ze=>function yn(ze){return function(Ye,Ae){let Ge=ze.apply(Ye,Ae);if(Ge instanceof ce)return Ge;let ht=Ge.constructor;return ht[mt]||Dt(ht),Ge}}(ze))),Promise[fe.__symbol__("uncaughtPromiseErrors")]=qe,ce}),Zone.__load_patch("toString",ie=>{const fe=Function.prototype.toString,ye=E("OriginalDelegate"),me=E("Promise"),_e=E("Error"),Me=function(){if("function"==typeof this){const nt=this[ye];if(nt)return"function"==typeof nt?fe.call(nt):Object.prototype.toString.call(nt);if(this===Promise){const Ke=ie[me];if(Ke)return fe.call(Ke)}if(this===Error){const Ke=ie[_e];if(Ke)return fe.call(Ke)}}return fe.call(this)};Me[ye]=fe,Function.prototype.toString=Me;const Qe=Object.prototype.toString;Object.prototype.toString=function(){return"function"==typeof Promise&&this instanceof Promise?"[object Promise]":Qe.call(this)}});let pe=!1;if(typeof window<"u")try{const ie=Object.defineProperty({},"passive",{get:function(){pe=!0}});window.addEventListener("test",ie,ie),window.removeEventListener("test",ie,ie)}catch{pe=!1}const Le={useG:!0},Se={},Ne={},be=new RegExp("^"+d+"(\\w+)(true|false)$"),je=E("propagationStopped");function H(ie,fe){const ye=(fe?fe(ie):ie)+f,me=(fe?fe(ie):ie)+c,_e=d+ye,Me=d+me;Se[ie]={},Se[ie][f]=_e,Se[ie][c]=Me}function Ee(ie,fe,ye,me){const _e=me&&me.add||g,Me=me&&me.rm||w,Qe=me&&me.listeners||"eventListeners",qe=me&&me.rmAll||"removeAllListeners",it=E(_e),nt="."+_e+":",ge=function(vt,et,An){if(vt.isRemoved)return;const Bt=vt.callback;let gn;"object"==typeof Bt&&Bt.handleEvent&&(vt.callback=ft=>Bt.handleEvent(ft),vt.originalDelegate=Bt);try{vt.invoke(vt,et,[An])}catch(ft){gn=ft}const tn=vt.options;return tn&&"object"==typeof tn&&tn.once&&et[Me].call(et,An.type,vt.originalDelegate?vt.originalDelegate:vt.callback,tn),gn};function De(vt,et,An){if(!(et=et||ie.event))return;const Bt=vt||et.target||ie,gn=Bt[Se[et.type][An?c:f]];if(gn){const tn=[];if(1===gn.length){const ft=ge(gn[0],Bt,et);ft&&tn.push(ft)}else{const ft=gn.slice();for(let fn=0;fn{throw fn})}}}const Fe=function(vt){return De(this,vt,!1)},Be=function(vt){return De(this,vt,!0)};function dt(vt,et){if(!vt)return!1;let An=!0;et&&void 0!==et.useG&&(An=et.useG);const Bt=et&&et.vh;let gn=!0;et&&void 0!==et.chkDup&&(gn=et.chkDup);let tn=!1;et&&void 0!==et.rt&&(tn=et.rt);let ft=vt;for(;ft&&!ft.hasOwnProperty(_e);)ft=x(ft);if(!ft&&vt[_e]&&(ft=vt),!ft||ft[it])return!1;const fn=et&&et.eventNameToString,st={},Kt=ft[it]=ft[_e],wt=ft[E(Me)]=ft[Me],er=ft[E(Qe)]=ft[Qe],Pr=ft[E(qe)]=ft[qe];let kn;function En(Ae,Ge){return!pe&&"object"==typeof Ae&&Ae?!!Ae.capture:pe&&Ge?"boolean"==typeof Ae?{capture:Ae,passive:!0}:Ae?"object"==typeof Ae&&!1!==Ae.passive?Object.assign(Object.assign({},Ae),{passive:!0}):Ae:{passive:!0}:Ae}et&&et.prepend&&(kn=ft[E(et.prepend)]=ft[et.prepend]);const ce=An?function(Ae){if(!st.isExisting)return Kt.call(st.target,st.eventName,st.capture?Be:Fe,st.options)}:function(Ae){return Kt.call(st.target,st.eventName,Ae.invoke,st.options)},ve=An?function(Ae){if(!Ae.isRemoved){const Ge=Se[Ae.eventName];let ht;Ge&&(ht=Ge[Ae.capture?c:f]);const Et=ht&&Ae.target[ht];if(Et)for(let ut=0;utfunction(_e,Me){_e[je]=!0,me&&me.apply(_e,Me)})}function He(ie,fe,ye,me,_e){const Me=Zone.__symbol__(me);if(fe[Me])return;const Qe=fe[Me]=fe[me];fe[me]=function(qe,it,nt){return it&&it.prototype&&_e.forEach(function(Ke){const we=`${ye}.${me}::`+Ke,ge=it.prototype;try{if(ge.hasOwnProperty(Ke)){const De=ie.ObjectGetOwnPropertyDescriptor(ge,Ke);De&&De.value?(De.value=ie.wrapWithCurrentZone(De.value,we),ie._redefineProperty(it.prototype,Ke,De)):ge[Ke]&&(ge[Ke]=ie.wrapWithCurrentZone(ge[Ke],we))}else ge[Ke]&&(ge[Ke]=ie.wrapWithCurrentZone(ge[Ke],we))}catch{}}),Qe.call(fe,qe,it,nt)},ie.attachOriginToPatched(fe[me],Qe)}function We(ie,fe,ye){if(!ye||0===ye.length)return fe;const me=ye.filter(Me=>Me.target===ie);if(!me||0===me.length)return fe;const _e=me[0].ignoreProperties;return fe.filter(Me=>-1===_e.indexOf(Me))}function Je(ie,fe,ye,me){ie&&L(ie,We(ie,fe,ye),me)}function Xe(ie){return Object.getOwnPropertyNames(ie).filter(fe=>fe.startsWith("on")&&fe.length>2).map(fe=>fe.substring(2))}Zone.__load_patch("util",(ie,fe,ye)=>{const me=Xe(ie);ye.patchOnProperties=L,ye.patchMethod=G,ye.bindArguments=P,ye.patchMacroTask=te;const _e=fe.__symbol__("BLACK_LISTED_EVENTS"),Me=fe.__symbol__("UNPATCHED_EVENTS");ie[Me]&&(ie[_e]=ie[Me]),ie[_e]&&(fe[_e]=fe[Me]=ie[_e]),ye.patchEventPrototype=xe,ye.patchEventTarget=Ee,ye.isIEOrEdge=de,ye.ObjectDefineProperty=U,ye.ObjectGetOwnPropertyDescriptor=Y,ye.ObjectCreate=y,ye.ArraySlice=u,ye.patchClass=re,ye.wrapWithCurrentZone=b,ye.filterProperties=We,ye.attachOriginToPatched=X,ye._redefineProperty=Object.defineProperty,ye.patchCallbacks=He,ye.getGlobalObjects=()=>({globalSources:Ne,zoneSymbolEventNames:Se,eventNames:me,isBrowser:F,isMix:j,isNode:k,TRUE_STR:c,FALSE_STR:f,ZONE_SYMBOL_PREFIX:d,ADD_EVENT_LISTENER_STR:g,REMOVE_EVENT_LISTENER_STR:w})});const pt=E("zoneTask");function _t(ie,fe,ye,me){let _e=null,Me=null;ye+=me;const Qe={};function qe(nt){const Ke=nt.data;return Ke.args[0]=function(){return nt.invoke.apply(this,arguments)},Ke.handleId=_e.apply(ie,Ke.args),nt}function it(nt){return Me.call(ie,nt.data.handleId)}_e=G(ie,fe+=me,nt=>function(Ke,we){if("function"==typeof we[0]){const ge={isPeriodic:"Interval"===me,delay:"Timeout"===me||"Interval"===me?we[1]||0:void 0,args:we},De=we[0];we[0]=function(){try{return De.apply(this,arguments)}finally{ge.isPeriodic||("number"==typeof ge.handleId?delete Qe[ge.handleId]:ge.handleId&&(ge.handleId[pt]=null))}};const Fe=S(fe,we[0],ge,qe,it);if(!Fe)return Fe;const Be=Fe.data.handleId;return"number"==typeof Be?Qe[Be]=Fe:Be&&(Be[pt]=Fe),Be&&Be.ref&&Be.unref&&"function"==typeof Be.ref&&"function"==typeof Be.unref&&(Fe.ref=Be.ref.bind(Be),Fe.unref=Be.unref.bind(Be)),"number"==typeof Be||Be?Be:Fe}return nt.apply(ie,we)}),Me=G(ie,ye,nt=>function(Ke,we){const ge=we[0];let De;"number"==typeof ge?De=Qe[ge]:(De=ge&&ge[pt],De||(De=ge)),De&&"string"==typeof De.type?"notScheduled"!==De.state&&(De.cancelFn&&De.data.isPeriodic||0===De.runCount)&&("number"==typeof ge?delete Qe[ge]:ge&&(ge[pt]=null),De.zone.cancelTask(De)):nt.apply(ie,we)})}Zone.__load_patch("legacy",ie=>{const fe=ie[Zone.__symbol__("legacyPatch")];fe&&fe()}),Zone.__load_patch("queueMicrotask",(ie,fe,ye)=>{ye.patchMethod(ie,"queueMicrotask",me=>function(_e,Me){fe.current.scheduleMicroTask("queueMicrotask",Me[0])})}),Zone.__load_patch("timers",ie=>{const ye="clear";_t(ie,"set",ye,"Timeout"),_t(ie,"set",ye,"Interval"),_t(ie,"set",ye,"Immediate")}),Zone.__load_patch("requestAnimationFrame",ie=>{_t(ie,"request","cancel","AnimationFrame"),_t(ie,"mozRequest","mozCancel","AnimationFrame"),_t(ie,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(ie,fe)=>{const ye=["alert","prompt","confirm"];for(let me=0;mefunction(it,nt){return fe.current.run(Me,ie,nt,qe)})}),Zone.__load_patch("EventTarget",(ie,fe,ye)=>{(function Hr(ie,fe){fe.patchEventPrototype(ie,fe)})(ie,ye),function pr(ie,fe){if(Zone[fe.symbol("patchEventTarget")])return;const{eventNames:ye,zoneSymbolEventNames:me,TRUE_STR:_e,FALSE_STR:Me,ZONE_SYMBOL_PREFIX:Qe}=fe.getGlobalObjects();for(let it=0;it{re("MutationObserver"),re("WebKitMutationObserver")}),Zone.__load_patch("IntersectionObserver",(ie,fe,ye)=>{re("IntersectionObserver")}),Zone.__load_patch("FileReader",(ie,fe,ye)=>{re("FileReader")}),Zone.__load_patch("on_property",(ie,fe,ye)=>{!function Nt(ie,fe){if(k&&!j||Zone[ie.symbol("patchEvents")])return;const ye=fe.__Zone_ignore_on_properties;let me=[];if(F){const _e=window;me=me.concat(["Document","SVGElement","Element","HTMLElement","HTMLBodyElement","HTMLMediaElement","HTMLFrameSetElement","HTMLFrameElement","HTMLIFrameElement","HTMLMarqueeElement","Worker"]);const Me=function oe(){try{const ie=p.navigator.userAgent;if(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/"))return!0}catch{}return!1}()?[{target:_e,ignoreProperties:["error"]}]:[];Je(_e,Xe(_e),ye&&ye.concat(Me),x(_e))}me=me.concat(["XMLHttpRequest","XMLHttpRequestEventTarget","IDBIndex","IDBRequest","IDBOpenDBRequest","IDBDatabase","IDBTransaction","IDBCursor","WebSocket"]);for(let _e=0;_e{!function Or(ie,fe){const{isBrowser:ye,isMix:me}=fe.getGlobalObjects();(ye||me)&&ie.customElements&&"customElements"in ie&&fe.patchCallbacks(fe,ie.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}(ie,ye)}),Zone.__load_patch("XHR",(ie,fe)=>{!function it(nt){const Ke=nt.XMLHttpRequest;if(!Ke)return;const we=Ke.prototype;let De=we[m],Fe=we[h];if(!De){const st=nt.XMLHttpRequestEventTarget;if(st){const Kt=st.prototype;De=Kt[m],Fe=Kt[h]}}const Be="readystatechange",dt="scheduled";function xt(st){const Kt=st.data,wt=Kt.target;wt[Me]=!1,wt[qe]=!1;const er=wt[_e];De||(De=wt[m],Fe=wt[h]),er&&Fe.call(wt,Be,er);const Pr=wt[_e]=()=>{if(wt.readyState===wt.DONE)if(!Kt.aborted&&wt[Me]&&st.state===dt){const En=wt[fe.__symbol__("loadfalse")];if(0!==wt.status&&En&&En.length>0){const ur=st.invoke;st.invoke=function(){const Zn=wt[fe.__symbol__("loadfalse")];for(let bn=0;bnfunction(st,Kt){return st[me]=0==Kt[2],st[Qe]=Kt[1],An.apply(st,Kt)}),gn=E("fetchTaskAborting"),tn=E("fetchTaskScheduling"),ft=G(we,"send",()=>function(st,Kt){if(!0===fe.current[tn]||st[me])return ft.apply(st,Kt);{const wt={target:st,url:st[Qe],isPeriodic:!1,args:Kt,aborted:!1},er=S("XMLHttpRequest.send",vt,wt,xt,et);st&&!0===st[qe]&&!wt.aborted&&er.state===dt&&er.invoke()}}),fn=G(we,"abort",()=>function(st,Kt){const wt=function ge(st){return st[ye]}(st);if(wt&&"string"==typeof wt.type){if(null==wt.cancelFn||wt.data&&wt.data.aborted)return;wt.zone.cancelTask(wt)}else if(!0===fe.current[gn])return fn.apply(st,Kt)})}(ie);const ye=E("xhrTask"),me=E("xhrSync"),_e=E("xhrListener"),Me=E("xhrScheduled"),Qe=E("xhrURL"),qe=E("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",ie=>{ie.navigator&&ie.navigator.geolocation&&function D(ie,fe){const ye=ie.constructor.name;for(let me=0;me{const it=function(){return qe.apply(this,P(arguments,ye+"."+_e))};return X(it,qe),it})(Me)}}}(ie.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(ie,fe)=>{function ye(me){return function(_e){Ie(ie,me).forEach(Qe=>{const qe=ie.PromiseRejectionEvent;if(qe){const it=new qe(me,{promise:_e.promise,reason:_e.rejection});Qe.invoke(it)}})}}ie.PromiseRejectionEvent&&(fe[E("unhandledPromiseRejectionHandler")]=ye("unhandledrejection"),fe[E("rejectionHandledHandler")]=ye("rejectionhandled"))})},7420:()=>{},5856:()=>{},5883:()=>{},6577:()=>{},5819:()=>{},1265:()=>{},5539:()=>{},8479:function(Y,U,x){"use strict";var u,g;u=[x(1873)],void 0!==(g=function(w){var m=w.Reader,h=w.Writer,c=w.util,f=w.roots.default||(w.roots.default={});return f.RPC=function(){function d(S){if(this.subscriptions=[],this.messages=[],S)for(var E=Object.keys(S),v=0;v>>3){case 1:I.subscriptions&&I.subscriptions.length||(I.subscriptions=[]),I.subscriptions.push(f.RPC.SubOpts.decode(E,E.uint32()));break;case 2:I.messages&&I.messages.length||(I.messages=[]),I.messages.push(f.RPC.Message.decode(E,E.uint32()));break;case 3:I.control=f.RPC.ControlMessage.decode(E,E.uint32());break;default:E.skipType(7&A)}}return I},d.fromObject=function(E){if(E instanceof f.RPC)return E;var v=new f.RPC;if(E.subscriptions){if(!Array.isArray(E.subscriptions))throw TypeError(".RPC.subscriptions: array expected");v.subscriptions=[];for(var p=0;p>>3){case 1:P.subscribe=p.bool();break;case 2:P.topic=p.string();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.SubOpts)return p;var I=new f.RPC.SubOpts;return null!=p.subscribe&&(I.subscribe=Boolean(p.subscribe)),null!=p.topic&&(I.topic=String(p.topic)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.subscribe&&p.hasOwnProperty("subscribe")&&(A.subscribe=p.subscribe,I.oneofs&&(A._subscribe="subscribe")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic,I.oneofs&&(A._topic="topic")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.Message=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.from=p.bytes();break;case 2:P.data=p.bytes();break;case 3:P.seqno=p.bytes();break;case 4:P.topic=p.string();break;case 5:P.signature=p.bytes();break;case 6:P.key=p.bytes();break;default:p.skipType(7&D)}}if(!P.hasOwnProperty("topic"))throw c.ProtocolError("missing required 'topic'",{instance:P});return P},S.fromObject=function(p){if(p instanceof f.RPC.Message)return p;var I=new f.RPC.Message;return null!=p.from&&("string"==typeof p.from?c.base64.decode(p.from,I.from=c.newBuffer(c.base64.length(p.from)),0):p.from.length&&(I.from=p.from)),null!=p.data&&("string"==typeof p.data?c.base64.decode(p.data,I.data=c.newBuffer(c.base64.length(p.data)),0):p.data.length&&(I.data=p.data)),null!=p.seqno&&("string"==typeof p.seqno?c.base64.decode(p.seqno,I.seqno=c.newBuffer(c.base64.length(p.seqno)),0):p.seqno.length&&(I.seqno=p.seqno)),null!=p.topic&&(I.topic=String(p.topic)),null!=p.signature&&("string"==typeof p.signature?c.base64.decode(p.signature,I.signature=c.newBuffer(c.base64.length(p.signature)),0):p.signature.length&&(I.signature=p.signature)),null!=p.key&&("string"==typeof p.key?c.base64.decode(p.key,I.key=c.newBuffer(c.base64.length(p.key)),0):p.key.length&&(I.key=p.key)),I},S.toObject=function(p,I){I||(I={});var A={};return I.defaults&&(A.topic=""),null!=p.from&&p.hasOwnProperty("from")&&(A.from=I.bytes===String?c.base64.encode(p.from,0,p.from.length):I.bytes===Array?Array.prototype.slice.call(p.from):p.from,I.oneofs&&(A._from="from")),null!=p.data&&p.hasOwnProperty("data")&&(A.data=I.bytes===String?c.base64.encode(p.data,0,p.data.length):I.bytes===Array?Array.prototype.slice.call(p.data):p.data,I.oneofs&&(A._data="data")),null!=p.seqno&&p.hasOwnProperty("seqno")&&(A.seqno=I.bytes===String?c.base64.encode(p.seqno,0,p.seqno.length):I.bytes===Array?Array.prototype.slice.call(p.seqno):p.seqno,I.oneofs&&(A._seqno="seqno")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic),null!=p.signature&&p.hasOwnProperty("signature")&&(A.signature=I.bytes===String?c.base64.encode(p.signature,0,p.signature.length):I.bytes===Array?Array.prototype.slice.call(p.signature):p.signature,I.oneofs&&(A._signature="signature")),null!=p.key&&p.hasOwnProperty("key")&&(A.key=I.bytes===String?c.base64.encode(p.key,0,p.key.length):I.bytes===Array?Array.prototype.slice.call(p.key):p.key,I.oneofs&&(A._key="key")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlMessage=function(){function S(E){if(this.ihave=[],this.iwant=[],this.graft=[],this.prune=[],E)for(var v=Object.keys(E),p=0;p>>3){case 1:A.ihave&&A.ihave.length||(A.ihave=[]),A.ihave.push(f.RPC.ControlIHave.decode(v,v.uint32()));break;case 2:A.iwant&&A.iwant.length||(A.iwant=[]),A.iwant.push(f.RPC.ControlIWant.decode(v,v.uint32()));break;case 3:A.graft&&A.graft.length||(A.graft=[]),A.graft.push(f.RPC.ControlGraft.decode(v,v.uint32()));break;case 4:A.prune&&A.prune.length||(A.prune=[]),A.prune.push(f.RPC.ControlPrune.decode(v,v.uint32()));break;default:v.skipType(7&P)}}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlMessage)return v;var p=new f.RPC.ControlMessage;if(v.ihave){if(!Array.isArray(v.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");p.ihave=[];for(var I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.messageIDs&&P.messageIDs.length||(P.messageIDs=[]),P.messageIDs.push(p.bytes());break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlIHave)return p;var I=new f.RPC.ControlIHave;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.messageIDs){if(!Array.isArray(p.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");I.messageIDs=[];for(var A=0;A>>3==1?(A.messageIDs&&A.messageIDs.length||(A.messageIDs=[]),A.messageIDs.push(v.bytes())):v.skipType(7&P)}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlIWant)return v;var p=new f.RPC.ControlIWant;if(v.messageIDs){if(!Array.isArray(v.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");p.messageIDs=[];for(var I=0;I>>3==1?P.topicID=p.string():p.skipType(7&D)}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlGraft)return p;var I=new f.RPC.ControlGraft;return null!=p.topicID&&(I.topicID=String(p.topicID)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlPrune=function(){function S(v){if(this.peers=[],v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.peers&&P.peers.length||(P.peers=[]),P.peers.push(f.RPC.PeerInfo.decode(p,p.uint32()));break;case 3:P.backoff=p.uint64();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlPrune)return p;var I=new f.RPC.ControlPrune;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.peers){if(!Array.isArray(p.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");I.peers=[];for(var A=0;A>>0,p.backoff.high>>>0).toNumber(!0))),I},S.toObject=function(p,I){I||(I={});var A={};if((I.arrays||I.defaults)&&(A.peers=[]),null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),p.peers&&p.peers.length){A.peers=[];for(var P=0;P>>0,p.backoff.high>>>0).toNumber(!0):p.backoff,I.oneofs&&(A._backoff="backoff")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.PeerInfo=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.peerID=p.bytes();break;case 2:P.signedPeerRecord=p.bytes();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.PeerInfo)return p;var I=new f.RPC.PeerInfo;return null!=p.peerID&&("string"==typeof p.peerID?c.base64.decode(p.peerID,I.peerID=c.newBuffer(c.base64.length(p.peerID)),0):p.peerID.length&&(I.peerID=p.peerID)),null!=p.signedPeerRecord&&("string"==typeof p.signedPeerRecord?c.base64.decode(p.signedPeerRecord,I.signedPeerRecord=c.newBuffer(c.base64.length(p.signedPeerRecord)),0):p.signedPeerRecord.length&&(I.signedPeerRecord=p.signedPeerRecord)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.peerID&&p.hasOwnProperty("peerID")&&(A.peerID=I.bytes===String?c.base64.encode(p.peerID,0,p.peerID.length):I.bytes===Array?Array.prototype.slice.call(p.peerID):p.peerID,I.oneofs&&(A._peerID="peerID")),null!=p.signedPeerRecord&&p.hasOwnProperty("signedPeerRecord")&&(A.signedPeerRecord=I.bytes===String?c.base64.encode(p.signedPeerRecord,0,p.signedPeerRecord.length):I.bytes===Array?Array.prototype.slice.call(p.signedPeerRecord):p.signedPeerRecord,I.oneofs&&(A._signedPeerRecord="signedPeerRecord")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d}(),f}.apply(U,u))&&(Y.exports=g)},4642:(Y,U,x)=>{var y=x(9805);function u(g){var w,m;function c(d,b){try{var S=g[d](b),E=S.value,v=E instanceof y;Promise.resolve(v?E.wrapped:E).then(function(p){v?c("return"===d?"return":"next",p):f(S.done?"return":"normal",p)},function(p){c("throw",p)})}catch(p){f("throw",p)}}function f(d,b){switch(d){case"return":w.resolve({value:b,done:!0});break;case"throw":w.reject(b);break;default:w.resolve({value:b,done:!1})}(w=w.next)?c(w.key,w.arg):m=null}this._invoke=function h(d,b){return new Promise(function(S,E){var v={key:d,arg:b,resolve:S,reject:E,next:null};m?m=m.next=v:(w=m=v,c(d,b))})},"function"!=typeof g.return&&(this.return=void 0)}u.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},u.prototype.next=function(g){return this._invoke("next",g)},u.prototype.throw=function(g){return this._invoke("throw",g)},u.prototype.return=function(g){return this._invoke("return",g)},Y.exports=u,Y.exports.__esModule=!0,Y.exports.default=Y.exports},9805:Y=>{Y.exports=function U(x){this.wrapped=x},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8131:Y=>{Y.exports=function U(x,y){var u={},g=!1;function w(m,h){return g=!0,h=new Promise(function(c){c(x[m](h))}),{done:!1,value:y(h)}}return u[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},u.next=function(m){return g?(g=!1,m):w("next",m)},"function"==typeof x.throw&&(u.throw=function(m){if(g)throw g=!1,m;return w("throw",m)}),"function"==typeof x.return&&(u.return=function(m){return g?(g=!1,m):w("return",m)}),u},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8237:Y=>{function x(y){function u(g){if(Object(g)!==g)return Promise.reject(new TypeError(g+" is not an object."));var w=g.done;return Promise.resolve(g.value).then(function(m){return{value:m,done:w}})}return(x=function(w){this.s=w,this.n=w.next}).prototype={s:null,n:null,next:function(){return u(this.n.apply(this.s,arguments))},return:function(w){var m=this.s.return;return void 0===m?Promise.resolve({value:w,done:!0}):u(m.apply(this.s,arguments))},throw:function(w){var m=this.s.return;return void 0===m?Promise.reject(w):u(m.apply(this.s,arguments))}},new x(y)}Y.exports=function U(y){var u,g,w,m=2;for(typeof Symbol<"u"&&(g=Symbol.asyncIterator,w=Symbol.iterator);m--;){if(g&&null!=(u=y[g]))return u.call(y);if(w&&null!=(u=y[w]))return new x(u.call(y));g="@@asyncIterator",w="@@iterator"}throw new TypeError("Object is not async iterable")},Y.exports.__esModule=!0,Y.exports.default=Y.exports},7156:Y=>{function U(y,u,g,w,m,h,c){try{var f=y[h](c),d=f.value}catch(b){return void g(b)}f.done?u(d):Promise.resolve(d).then(w,m)}Y.exports=function x(y){return function(){var u=this,g=arguments;return new Promise(function(w,m){var h=y.apply(u,g);function c(d){U(h,w,m,c,f,"next",d)}function f(d){U(h,w,m,c,f,"throw",d)}c(void 0)})}},Y.exports.__esModule=!0,Y.exports.default=Y.exports},6737:(Y,U,x)=>{var y=x(9805);Y.exports=function u(g){return new y(g)},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8186:(Y,U,x)=>{var y=x(4642);Y.exports=function u(g){return function(){return new y(g.apply(this,arguments))}},Y.exports.__esModule=!0,Y.exports.default=Y.exports}},Y=>{Y(Y.s=8487)}]); \ No newline at end of file diff --git a/relay-angular-chat/main.cb9a512a8cc30d69.js b/relay-angular-chat/main.cb9a512a8cc30d69.js deleted file mode 100644 index 1dd0dc7..0000000 --- a/relay-angular-chat/main.cb9a512a8cc30d69.js +++ /dev/null @@ -1 +0,0 @@ -var D$=Object.defineProperty,S$=(Y,U,x)=>U in Y?D$(Y,U,{enumerable:!0,configurable:!0,writable:!0,value:x}):Y[U]=x,ob=(Y,U,x)=>(S$(Y,"symbol"!=typeof U?U+"":U,x),x),tx=(Y,U,x)=>{if(!U.has(Y))throw TypeError("Cannot "+x)},aa=(Y,U,x)=>(tx(Y,U,"read from private field"),x?x.call(Y):U.get(Y)),pp=(Y,U,x)=>{if(U.has(Y))throw TypeError("Cannot add the same private member more than once");U instanceof WeakSet?U.add(Y):U.set(Y,x)},So=(Y,U,x,y)=>(tx(Y,U,"write to private field"),y?y.call(Y,x):U.set(Y,x),x),ab=(Y,U,x,y)=>({set _(l){So(Y,U,l,x)},get _(){return aa(Y,U,y)}});(self.webpackChunkrelay_angular_chat=self.webpackChunkrelay_angular_chat||[]).push([[179],{1873:(Y,U,x)=>{"use strict";Y.exports=x(4729)},4729:(Y,U,x)=>{"use strict";var y=U;function l(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(3542),y.BufferWriter=x(989),y.Reader=x(6913),y.BufferReader=x(1872),y.util=x(6138),y.rpc=x(9852),y.roots=x(935),y.configure=l,l()},6913:(Y,U,x)=>{"use strict";Y.exports=h;var l,y=x(6138),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new l(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){l=E,h.create=f(),l._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},1872:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(6913);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(6138);function g(w){y.call(this,w)}g._configure=function(){l.Buffer&&(g.prototype._slice=l.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},935:Y=>{"use strict";Y.exports={}},9852:(Y,U,x)=>{"use strict";U.Service=x(3939)},3939:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(6138);function l(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(l.prototype=Object.create(y.EventEmitter.prototype)).constructor=l,l.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},l.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},6723:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(6138);function l(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=l.zero=new l(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=l.zeroHash="\0\0\0\0\0\0\0\0";l.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new l(d,b)},l.from=function(c){if("number"==typeof c)return l.fromNumber(c);if(y.isString(c)){if(!y.Long)return l.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new l(c.low>>>0,c.high>>>0):g},l.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},l.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;l.fromHash=function(c){return c===w?g:new l((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},l.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},l.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},l.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},l.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},6138:function(Y,U,x){"use strict";var y=U;function l(w,m,h){for(var c=Object.keys(m),f=0;f0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=l,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Y.exports=d;var l,y=x(6138),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new l})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){l=P,d.create=b(),l._configure()}},989:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(3542);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(6138);function g(){y.call(this)}function w(m,h,c){m.length<40?l.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=l._Buffer_allocUnsafe,g.writeBytesBuffer=l.Buffer&&l.Buffer.prototype instanceof Uint8Array&&"set"===l.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=l.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},8487:(Y,U,x)=>{var zs,Va,Ha,y={};x.r(y),x.d(y,{identity:()=>t6});var l={};x.r(l),x.d(l,{base2:()=>n6});var g={};x.r(g),x.d(g,{base8:()=>r6});var w={};x.r(w),x.d(w,{base10:()=>i6});var m={};x.r(m),x.d(m,{base16:()=>s6,base16upper:()=>o6});var h={};x.r(h),x.d(h,{base32:()=>co,base32hex:()=>l6,base32hexpad:()=>d6,base32hexpadupper:()=>h6,base32hexupper:()=>f6,base32pad:()=>c6,base32padupper:()=>u6,base32upper:()=>a6,base32z:()=>p6});var c={};x.r(c),x.d(c,{base36:()=>g6,base36upper:()=>y6});var f={};x.r(f),x.d(f,{base58btc:()=>ui,base58flickr:()=>m6});var d={};x.r(d),x.d(d,{base64:()=>Gd,base64pad:()=>v6,base64url:()=>E6,base64urlpad:()=>b6});var b={};x.r(b),x.d(b,{base256emoji:()=>C6});var S={};x.r(S),x.d(S,{sha256:()=>mi,sha512:()=>G6});var E={};x.r(E),x.d(E,{identity:()=>Hc});var v={};x.r(v),x.d(v,{code:()=>Y6,decode:()=>Z6,encode:()=>Q6,name:()=>q6});var p={};x.r(p),x.d(p,{code:()=>tF,decode:()=>rF,encode:()=>nF,name:()=>eF});var I={};x.r(I),x.d(I,{RsaPrivateKey:()=>sh,RsaPublicKey:()=>J0,fromJwk:()=>YF,generateKeyPair:()=>QF,unmarshalRsaPrivateKey:()=>WF,unmarshalRsaPublicKey:()=>qF});var A={};x.r(A),x.d(A,{Ed25519PrivateKey:()=>xl,Ed25519PublicKey:()=>bm,generateKeyPair:()=>_5,generateKeyPairFromSeed:()=>D5,unmarshalEd25519PrivateKey:()=>b5,unmarshalEd25519PublicKey:()=>w5});var P={};function D(n){return"function"==typeof n}function T(n){const t=n(r=>{Error.call(r),r.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}x.r(P),x.d(P,{Secp256k1PrivateKey:()=>Im,Secp256k1PublicKey:()=>Cm,generateKeyPair:()=>N5,unmarshalSecp256k1PrivateKey:()=>R5,unmarshalSecp256k1PublicKey:()=>P5});const M=T(n=>function(t){n(this),this.message=t?`${t.length} errors occurred during unsubscription:\n${t.map((r,i)=>`${i+1}) ${r.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=t});function k(n,e){if(n){const t=n.indexOf(e);0<=t&&n.splice(t,1)}}class F{constructor(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}unsubscribe(){let e;if(!this.closed){this.closed=!0;const{_parentage:t}=this;if(t)if(this._parentage=null,Array.isArray(t))for(const s of t)s.remove(this);else t.remove(this);const{initialTeardown:r}=this;if(D(r))try{r()}catch(s){e=s instanceof M?s.errors:[s]}const{_finalizers:i}=this;if(i){this._finalizers=null;for(const s of i)try{O(s)}catch(o){e=e??[],o instanceof M?e=[...e,...o.errors]:e.push(o)}}if(e)throw new M(e)}}add(e){var t;if(e&&e!==this)if(this.closed)O(e);else{if(e instanceof F){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(t=this._finalizers)&&void 0!==t?t:[]).push(e)}}_hasParent(e){const{_parentage:t}=this;return t===e||Array.isArray(t)&&t.includes(e)}_addParent(e){const{_parentage:t}=this;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e}_removeParent(e){const{_parentage:t}=this;t===e?this._parentage=null:Array.isArray(t)&&k(t,e)}remove(e){const{_finalizers:t}=this;t&&k(t,e),e instanceof F&&e._removeParent(this)}}F.EMPTY=(()=>{const n=new F;return n.closed=!0,n})();const j=F.EMPTY;function C(n){return n instanceof F||n&&"closed"in n&&D(n.remove)&&D(n.add)&&D(n.unsubscribe)}function O(n){D(n)?n():n.unsubscribe()}const V={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},L={setTimeout(n,e,...t){const{delegate:r}=L;return r?.setTimeout?r.setTimeout(n,e,...t):setTimeout(n,e,...t)},clearTimeout(n){const{delegate:e}=L;return(e?.clearTimeout||clearTimeout)(n)},delegate:void 0};function K(n){L.setTimeout(()=>{const{onUnhandledError:e}=V;if(!e)throw n;e(n)})}function re(){}const G=q("C",void 0,void 0);function q(n,e,t){return{kind:n,value:e,error:t}}let ne=null;function se(n){if(V.useDeprecatedSynchronousErrorHandling){const e=!ne;if(e&&(ne={errorThrown:!1,error:null}),n(),e){const{errorThrown:t,error:r}=ne;if(ne=null,t)throw r}}else n()}class pe extends F{constructor(e){super(),this.isStopped=!1,e?(this.destination=e,C(e)&&e.add(this)):this.destination=Ie}static create(e,t,r){return new be(e,t,r)}next(e){this.isStopped?Ee(function Z(n){return q("N",n,void 0)}(e),this):this._next(e)}error(e){this.isStopped?Ee(function te(n){return q("E",void 0,n)}(e),this):(this.isStopped=!0,this._error(e))}complete(){this.isStopped?Ee(G,this):(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe(),this.destination=null)}_next(e){this.destination.next(e)}_error(e){try{this.destination.error(e)}finally{this.unsubscribe()}}_complete(){try{this.destination.complete()}finally{this.unsubscribe()}}}const Le=Function.prototype.bind;function Se(n,e){return Le.call(n,e)}class Ne{constructor(e){this.partialObserver=e}next(e){const{partialObserver:t}=this;if(t.next)try{t.next(e)}catch(r){je(r)}}error(e){const{partialObserver:t}=this;if(t.error)try{t.error(e)}catch(r){je(r)}else je(e)}complete(){const{partialObserver:e}=this;if(e.complete)try{e.complete()}catch(t){je(t)}}}class be extends pe{constructor(e,t,r){let i;if(super(),D(e)||!e)i={next:e??void 0,error:t??void 0,complete:r??void 0};else{let s;this&&V.useDeprecatedNextContext?(s=Object.create(e),s.unsubscribe=()=>this.unsubscribe(),i={next:e.next&&Se(e.next,s),error:e.error&&Se(e.error,s),complete:e.complete&&Se(e.complete,s)}):i=e}this.destination=new Ne(i)}}function je(n){V.useDeprecatedSynchronousErrorHandling?function he(n){V.useDeprecatedSynchronousErrorHandling&&ne&&(ne.errorThrown=!0,ne.error=n)}(n):K(n)}function Ee(n,e){const{onStoppedNotification:t}=V;t&&L.setTimeout(()=>t(n,e))}const Ie={closed:!0,next:re,error:function H(n){throw n},complete:re},Re="function"==typeof Symbol&&Symbol.observable||"@@observable";function He(n){return n}let Xe=(()=>{class n{constructor(t){t&&(this._subscribe=t)}lift(t){const r=new n;return r.source=this,r.operator=t,r}subscribe(t,r,i){const s=function _t(n){return n&&n instanceof pe||function pt(n){return n&&D(n.next)&&D(n.error)&&D(n.complete)}(n)&&C(n)}(t)?t:new be(t,r,i);return se(()=>{const{operator:o,source:a}=this;s.add(o?o.call(s,a):a?this._subscribe(s):this._trySubscribe(s))}),s}_trySubscribe(t){try{return this._subscribe(t)}catch(r){t.error(r)}}forEach(t,r){return new(r=Nt(r))((i,s)=>{const o=new be({next:a=>{try{t(a)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});this.subscribe(o)})}_subscribe(t){var r;return null===(r=this.source)||void 0===r?void 0:r.subscribe(t)}[Re](){return this}pipe(...t){return function Je(n){return 0===n.length?He:1===n.length?n[0]:function(t){return n.reduce((r,i)=>i(r),t)}}(t)(this)}toPromise(t){return new(t=Nt(t))((r,i)=>{let s;this.subscribe(o=>s=o,o=>i(o),()=>r(s))})}}return n.create=e=>new n(e),n})();function Nt(n){var e;return null!==(e=n??V.Promise)&&void 0!==e?e:Promise}const Or=T(n=>function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let pr=(()=>{class n extends Xe{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(t){const r=new Hr(this,this);return r.operator=t,r}_throwIfClosed(){if(this.closed)throw new Or}next(t){se(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(const r of this.currentObservers)r.next(t)}})}error(t){se(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=t;const{observers:r}=this;for(;r.length;)r.shift().error(t)}})}complete(){se(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;const{observers:t}=this;for(;t.length;)t.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0}_trySubscribe(t){return this._throwIfClosed(),super._trySubscribe(t)}_subscribe(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)}_innerSubscribe(t){const{hasError:r,isStopped:i,observers:s}=this;return r||i?j:(this.currentObservers=null,s.push(t),new F(()=>{this.currentObservers=null,k(s,t)}))}_checkFinalizedStatuses(t){const{hasError:r,thrownError:i,isStopped:s}=this;r?t.error(i):s&&t.complete()}asObservable(){const t=new Xe;return t.source=this,t}}return n.create=(e,t)=>new Hr(e,t),n})();class Hr extends pr{constructor(e,t){super(),this.destination=e,this.source=t}next(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)}error(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)}complete(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)}_subscribe(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:j}}function fe(n){return e=>{if(function ie(n){return D(n?.lift)}(e))return e.lift(function(t){try{return n(t,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function ye(n,e,t,r,i){return new me(n,e,t,r,i)}class me extends pe{constructor(e,t,r,i,s,o){super(e),this.onFinalize=s,this.shouldUnsubscribe=o,this._next=t?function(a){try{t(a)}catch(u){e.error(u)}}:super._next,this._error=i?function(a){try{i(a)}catch(u){e.error(u)}finally{this.unsubscribe()}}:super._error,this._complete=r?function(){try{r()}catch(a){e.error(a)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){const{closed:t}=this;super.unsubscribe(),!t&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}}}function Bt(n){return this instanceof Bt?(this.v=n,this):new Bt(n)}function gn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=t.apply(n,e||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(B){r[B]&&(i[B]=function(z){return new Promise(function(X,J){s.push([B,z,X,J])>1||a(B,z)})})}function a(B,z){try{!function u(B){B.value instanceof Bt?Promise.resolve(B.value.v).then(_,R):N(s[0][2],B)}(r[B](z))}catch(X){N(s[0][3],X)}}function _(B){a("next",B)}function R(B){a("throw",B)}function N(B,z){B(z),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ft(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,e=n[Symbol.asyncIterator];return e?e.call(n):(n=function dt(n){var e="function"==typeof Symbol&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&"number"==typeof n.length)return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,u){!function i(s,o,a,u){Promise.resolve(u).then(function(_){s({value:_,done:a})},o)}(a,u,(o=n[s](o)).done,o.value)})}}}const En=n=>n&&"number"==typeof n.length&&"function"!=typeof n;function cr(n){return D(n?.then)}function Zn(n){return D(n[Re])}function bn(n){return Symbol.asyncIterator&&D(n?.[Symbol.asyncIterator])}function Ft(n){return new TypeError(`You provided ${null!==n&&"object"==typeof n?"an invalid object":`'${n}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}const ce=function ct(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}();function ve(n){return D(n?.[ce])}function mt(n){return gn(this,arguments,function*(){const t=n.getReader();try{for(;;){const{value:r,done:i}=yield Bt(t.read());if(i)return yield Bt(void 0);yield yield Bt(r)}}finally{t.releaseLock()}})}function Dt(n){return D(n?.getReader)}function yn(n){if(n instanceof Xe)return n;if(null!=n){if(Zn(n))return function ze(n){return new Xe(e=>{const t=n[Re]();if(D(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}(n);if(En(n))return function Ye(n){return new Xe(e=>{for(let t=0;t{n.then(t=>{e.closed||(e.next(t),e.complete())},t=>e.error(t)).then(null,K)})}(n);if(bn(n))return ht(n);if(ve(n))return function Ge(n){return new Xe(e=>{for(const t of n)if(e.next(t),e.closed)return;e.complete()})}(n);if(Dt(n))return function Et(n){return ht(mt(n))}(n)}throw Ft(n)}function ht(n){return new Xe(e=>{(function ut(n,e){var t,r,i,s;return function ge(n,e,t,r){return new(t||(t=Promise))(function(s,o){function a(R){try{_(r.next(R))}catch(N){o(N)}}function u(R){try{_(r.throw(R))}catch(N){o(N)}}function _(R){R.done?s(R.value):function i(s){return s instanceof t?s:new t(function(o){o(s)})}(R.value).then(a,u)}_((r=r.apply(n,e||[])).next())})}(this,void 0,void 0,function*(){try{for(t=ft(n);!(r=yield t.next()).done;)if(e.next(r.value),e.closed)return}catch(o){i={error:o}}finally{try{r&&!r.done&&(s=t.return)&&(yield s.call(t))}finally{if(i)throw i.error}}e.complete()})})(n,e).catch(t=>e.error(t))})}function St(n,e,t,r=0,i=!1){const s=e.schedule(function(){t(),i?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(s),!i)return s}function Ut(n,e,t=1/0){return D(e)?Ut((r,i)=>function _e(n,e){return fe((t,r)=>{let i=0;t.subscribe(ye(r,s=>{r.next(n.call(e,s,i++))}))})}((s,o)=>e(r,s,i,o))(yn(n(r,i))),t):("number"==typeof e&&(t=e),fe((r,i)=>function $t(n,e,t,r,i,s,o,a){const u=[];let _=0,R=0,N=!1;const B=()=>{N&&!u.length&&!_&&e.complete()},z=J=>_{s&&e.next(J),_++;let oe=!1;yn(t(J,R++)).subscribe(ye(e,de=>{i?.(de),s?z(de):e.next(de)},()=>{oe=!0},void 0,()=>{if(oe)try{for(_--;u.length&&_X(de)):X(de)}B()}catch(de){e.error(de)}}))};return n.subscribe(ye(e,z,()=>{N=!0,B()})),()=>{a?.()}}(r,i,n,t)))}const Sn=new Xe(n=>n.complete());function Co(n){return n[n.length-1]}function Q(n,e=0){return fe((t,r)=>{t.subscribe(ye(r,i=>St(r,n,()=>r.next(i),e),()=>St(r,n,()=>r.complete(),e),i=>St(r,n,()=>r.error(i),e)))})}function ee(n,e=0){return fe((t,r)=>{r.add(n.schedule(()=>t.subscribe(r),e))})}function Ze(n,e){if(!n)throw new Error("Iterable cannot be null");return new Xe(t=>{St(t,e,()=>{const r=n[Symbol.asyncIterator]();St(t,e,()=>{r.next().then(i=>{i.done?t.complete():t.next(i.value)})},0,!0)})})}function ei(...n){const e=function ua(n){return function ca(n){return n&&D(n.schedule)}(Co(n))?n.pop():void 0}(n),t=function W(n,e){return"number"==typeof Co(n)?n.pop():e}(n,1/0),r=n;return r.length?1===r.length?yn(r[0]):function xn(n=1/0){return Ut(He,n)}(t)(function di(n,e){return e?function gr(n,e){if(null!=n){if(Zn(n))return function le(n,e){return yn(n).pipe(ee(e),Q(e))}(n,e);if(En(n))return function Ve(n,e){return new Xe(t=>{let r=0;return e.schedule(function(){r===n.length?t.complete():(t.next(n[r++]),t.closed||this.schedule())})})}(n,e);if(cr(n))return function ke(n,e){return yn(n).pipe(ee(e),Q(e))}(n,e);if(bn(n))return Ze(n,e);if(ve(n))return function tt(n,e){return new Xe(t=>{let r;return St(t,e,()=>{r=n[ce](),St(t,e,()=>{let i,s;try{({value:i,done:s}=r.next())}catch(o){return void t.error(o)}s?t.complete():t.next(i)},0,!0)}),()=>D(r?.return)&&r.return()})}(n,e);if(Dt(n))return function sn(n,e){return Ze(mt(n),e)}(n,e)}throw Ft(n)}(n,e):yn(n)}(r,e)):Sn}function Io(n,e,...t){if(!0===e)return void n();if(!1===e)return;const r=new be({next:()=>{r.unsubscribe(),n()}});return e(...t).subscribe(r)}function Jt(n){for(let e in n)if(n[e]===Jt)return e;throw Error("Could not find renamed property on target object.")}function wn(n){if("string"==typeof n)return n;if(Array.isArray(n))return"["+n.map(wn).join(", ")+"]";if(null==n)return""+n;if(n.overriddenName)return`${n.overriddenName}`;if(n.name)return`${n.name}`;const e=n.toString();if(null==e)return""+e;const t=e.indexOf("\n");return-1===t?e:e.substring(0,t)}function Li(n,e){return null==n||""===n?null===e?"":e:null==e||""===e?n:n+" "+e}const bu=Jt({__forward_ref__:Jt});function gp(n){return n.__forward_ref__=gp,n.toString=function(){return wn(this())},n}function Rt(n){return function yp(n){return"function"==typeof n&&n.hasOwnProperty(bu)&&n.__forward_ref__===gp}(n)?n():n}class Tt extends Error{constructor(e,t){super(function cf(n,e){return`NG0${Math.abs(n)}${e?": "+e.trim():""}`}(e,t)),this.code=e}}function Vt(n){return"string"==typeof n?n:null==n?"":String(n)}function uf(n,e){throw new Tt(-201,!1)}function Ci(n,e){null==n&&function Rn(n,e,t,r){throw new Error(`ASSERTION ERROR: ${n}`+(null==r?"":` [Expected=> ${t} ${r} ${e} <=Actual]`))}(e,n,null,"!=")}function Wn(n){return{token:n.token,providedIn:n.providedIn||null,factory:n.factory,value:void 0}}function Ka(n){return{providers:n.providers||[],imports:n.imports||[]}}function lf(n){return cb(n,ff)||cb(n,lb)}function cb(n,e){return n.hasOwnProperty(e)?n[e]:null}function ub(n){return n&&(n.hasOwnProperty(mp)||n.hasOwnProperty(ux))?n[mp]:null}const ff=Jt({\u0275prov:Jt}),mp=Jt({\u0275inj:Jt}),lb=Jt({ngInjectableDef:Jt}),ux=Jt({ngInjectorDef:Jt});var Mt=(()=>((Mt=Mt||{})[Mt.Default=0]="Default",Mt[Mt.Host=1]="Host",Mt[Mt.Self=2]="Self",Mt[Mt.SkipSelf=4]="SkipSelf",Mt[Mt.Optional=8]="Optional",Mt))();let vp;function Bi(n){const e=vp;return vp=n,e}function fb(n,e,t){const r=lf(n);return r&&"root"==r.providedIn?void 0===r.value?r.value=r.factory():r.value:t&Mt.Optional?null:void 0!==e?e:void uf(wn(n))}function To(n){return{toString:n}.toString()}var rs=(()=>((rs=rs||{})[rs.OnPush=0]="OnPush",rs[rs.Default=1]="Default",rs))(),Is=(()=>{return(n=Is||(Is={}))[n.Emulated=0]="Emulated",n[n.None=2]="None",n[n.ShadowDom=3]="ShadowDom",Is;var n})();const Fn=(()=>typeof globalThis<"u"&&globalThis||typeof global<"u"&&global||typeof window<"u"&&window||typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self)(),$a={},In=[],df=Jt({\u0275cmp:Jt}),Ep=Jt({\u0275dir:Jt}),bp=Jt({\u0275pipe:Jt}),db=Jt({\u0275mod:Jt}),Ws=Jt({\u0275fac:Jt}),wu=Jt({__NG_ELEMENT_ID__:Jt});let fx=0;function hf(n){return To(()=>{const t=!0===n.standalone,r={},i={type:n.type,providersResolver:null,decls:n.decls,vars:n.vars,factory:null,template:n.template||null,consts:n.consts||null,ngContentSelectors:n.ngContentSelectors,hostBindings:n.hostBindings||null,hostVars:n.hostVars||0,hostAttrs:n.hostAttrs||null,contentQueries:n.contentQueries||null,declaredInputs:r,inputs:null,outputs:null,exportAs:n.exportAs||null,onPush:n.changeDetection===rs.OnPush,directiveDefs:null,pipeDefs:null,standalone:t,dependencies:t&&n.dependencies||null,getStandaloneInjector:null,selectors:n.selectors||In,viewQuery:n.viewQuery||null,features:n.features||null,data:n.data||{},encapsulation:n.encapsulation||Is.Emulated,id:"c"+fx++,styles:n.styles||In,_:null,setInput:null,schemas:n.schemas||null,tView:null},s=n.dependencies,o=n.features;return i.inputs=gb(n.inputs,r),i.outputs=gb(n.outputs),o&&o.forEach(a=>a(i)),i.directiveDefs=s?()=>("function"==typeof s?s():s).map(hb).filter(pb):null,i.pipeDefs=s?()=>("function"==typeof s?s():s).map(ri).filter(pb):null,i})}function hb(n){return Nn(n)||ni(n)}function pb(n){return null!==n}function _u(n){return To(()=>({type:n.type,bootstrap:n.bootstrap||In,declarations:n.declarations||In,imports:n.imports||In,exports:n.exports||In,transitiveCompileScopes:null,schemas:n.schemas||null,id:n.id||null}))}function gb(n,e){if(null==n)return $a;const t={};for(const r in n)if(n.hasOwnProperty(r)){let i=n[r],s=i;Array.isArray(i)&&(s=i[1],i=i[0]),t[i]=r,e&&(e[i]=s)}return t}const Fi=hf;function Nn(n){return n[df]||null}function ni(n){return n[Ep]||null}function ri(n){return n[bp]||null}function pi(n){return Array.isArray(n)&&"object"==typeof n[1]}function ss(n){return Array.isArray(n)&&!0===n[1]}function Dp(n){return 0!=(8&n.flags)}function mf(n){return 2==(2&n.flags)}function vf(n){return 1==(1&n.flags)}function os(n){return null!==n.template}function mx(n){return 0!=(256&n[2])}function pa(n,e){return n.hasOwnProperty(Ws)?n[Ws]:null}class bx{constructor(e,t,r){this.previousValue=e,this.currentValue=t,this.firstChange=r}isFirstChange(){return this.firstChange}}function vb(n){return n.type.prototype.ngOnChanges&&(n.setInput=_x),wx}function wx(){const n=bb(this),e=n?.current;if(e){const t=n.previous;if(t===$a)n.previous=e;else for(let r in e)t[r]=e[r];n.current=null,this.ngOnChanges(e)}}function _x(n,e,t,r){const i=bb(n)||function Dx(n,e){return n[Eb]=e}(n,{previous:$a,current:null}),s=i.current||(i.current={}),o=i.previous,a=this.declaredInputs[t],u=o[a];s[a]=new bx(u&&u.currentValue,e,o===$a),n[r]=e}const Eb="__ngSimpleChanges__";function bb(n){return n[Eb]||null}function yr(n){for(;Array.isArray(n);)n=n[0];return n}function Hi(n,e){return yr(e[n.index])}function Ap(n,e){return n.data[e]}function Ai(n,e){const t=e[n];return pi(t)?t:t[0]}function wf(n){return 64==(64&n[2])}function Ao(n,e){return null==e?null:n[e]}function _b(n){n[18]=0}function xp(n,e){n[5]+=e;let t=n,r=n[3];for(;null!==r&&(1===e&&1===t[5]||-1===e&&0===t[5]);)r[5]+=e,t=r,r=r[3]}const kt={lFrame:Pb(null),bindingsEnabled:!0};function Sb(){return kt.bindingsEnabled}function Ue(){return kt.lFrame.lView}function dn(){return kt.lFrame.tView}function Tr(){let n=Cb();for(;null!==n&&64===n.type;)n=n.parent;return n}function Cb(){return kt.lFrame.currentTNode}function Ts(n,e){const t=kt.lFrame;t.currentTNode=n,t.isParent=e}function Rp(){return kt.lFrame.isParent}function Ya(){return kt.lFrame.bindingIndex++}function Ux(n,e){const t=kt.lFrame;t.bindingIndex=t.bindingRootIndex=n,Np(e)}function Np(n){kt.lFrame.currentDirectiveIndex=n}function Op(n){kt.lFrame.currentQueryIndex=n}function Hx(n){const e=n[1];return 2===e.type?e.declTNode:1===e.type?n[6]:null}function xb(n,e,t){if(t&Mt.SkipSelf){let i=e,s=n;for(;!(i=i.parent,null!==i||t&Mt.Host||(i=Hx(s),null===i||(s=s[15],10&i.type))););if(null===i)return!1;e=i,n=s}const r=kt.lFrame=Rb();return r.currentTNode=e,r.lView=n,!0}function kp(n){const e=Rb(),t=n[1];kt.lFrame=e,e.currentTNode=t.firstChild,e.lView=n,e.tView=t,e.contextLView=n,e.bindingIndex=t.bindingStartIndex,e.inI18n=!1}function Rb(){const n=kt.lFrame,e=null===n?null:n.child;return null===e?Pb(n):e}function Pb(n){const e={currentTNode:null,isParent:!0,lView:null,tView:null,selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:n,child:null,inI18n:!1};return null!==n&&(n.child=e),e}function Nb(){const n=kt.lFrame;return kt.lFrame=n.parent,n.currentTNode=null,n.lView=null,n}const Mb=Nb;function Lp(){const n=Nb();n.isParent=!0,n.tView=null,n.selectedIndex=-1,n.contextLView=null,n.elementDepthCount=0,n.currentDirectiveIndex=-1,n.currentNamespace=null,n.bindingRootIndex=-1,n.bindingIndex=-1,n.currentQueryIndex=0}function si(){return kt.lFrame.selectedIndex}function xo(n){kt.lFrame.selectedIndex=n}function Df(n,e){for(let t=e.directiveStart,r=e.directiveEnd;t=r)break}else e[u]<0&&(n[18]+=65536),(a>11>16&&(3&n[2])===e){n[2]+=2048;try{s.call(a)}finally{}}}else try{s.call(a)}finally{}}class Au{constructor(e,t,r){this.factory=e,this.resolving=!1,this.canSeeViewProviders=t,this.injectImpl=r}}function If(n,e,t){let r=0;for(;re){o=s-1;break}}}for(;s>16}(n),r=e;for(;t>0;)r=r[15],t--;return r}let Up=!0;function Af(n){const e=Up;return Up=n,e}let nR=0;const As={};function Ru(n,e){const t=Hp(n,e);if(-1!==t)return t;const r=e[1];r.firstCreatePass&&(n.injectorIndex=e.length,Vp(r.data,n),Vp(e,null),Vp(r.blueprint,null));const i=xf(n,e),s=n.injectorIndex;if(Fb(i)){const o=Qa(i),a=Za(i,e),u=a[1].data;for(let _=0;_<8;_++)e[s+_]=a[o+_]|u[o+_]}return e[s+8]=i,s}function Vp(n,e){n.push(0,0,0,0,0,0,0,0,e)}function Hp(n,e){return-1===n.injectorIndex||n.parent&&n.parent.injectorIndex===n.injectorIndex||null===e[n.injectorIndex+8]?-1:n.injectorIndex}function xf(n,e){if(n.parent&&-1!==n.parent.injectorIndex)return n.parent.injectorIndex;let t=0,r=null,i=e;for(;null!==i;){if(r=Wb(i),null===r)return-1;if(t++,i=i[15],-1!==r.injectorIndex)return r.injectorIndex|t<<16}return-1}function Rf(n,e,t){!function rR(n,e,t){let r;"string"==typeof t?r=t.charCodeAt(0)||0:t.hasOwnProperty(wu)&&(r=t[wu]),null==r&&(r=t[wu]=nR++);const i=255&r;e.data[n+(i>>5)]|=1<=0?255&e:aR:e}(t);if("function"==typeof s){if(!xb(e,n,r))return r&Mt.Host?Hb(i,0,r):Kb(e,t,r,i);try{const o=s(r);if(null!=o||r&Mt.Optional)return o;uf()}finally{Mb()}}else if("number"==typeof s){let o=null,a=Hp(n,e),u=-1,_=r&Mt.Host?e[16][6]:null;for((-1===a||r&Mt.SkipSelf)&&(u=-1===a?xf(n,e):e[a+8],-1!==u&&Gb(r,!1)?(o=e[1],a=Qa(u),e=Za(u,e)):a=-1);-1!==a;){const R=e[1];if(zb(s,a,R.data)){const N=sR(a,e,t,o,r,_);if(N!==As)return N}u=e[a+8],-1!==u&&Gb(r,e[1].data[a+8]===_)&&zb(s,a,e)?(o=R,a=Qa(u),e=Za(u,e)):a=-1}}return i}function sR(n,e,t,r,i,s){const o=e[1],a=o.data[n+8],R=function Pf(n,e,t,r,i){const s=n.providerIndexes,o=e.data,a=1048575&s,u=n.directiveStart,R=s>>20,B=i?a+R:n.directiveEnd;for(let z=r?a:a+R;z=u&&X.type===t)return z}if(i){const z=o[u];if(z&&os(z)&&z.type===t)return u}return null}(a,o,t,null==r?mf(a)&&Up:r!=o&&0!=(3&a.type),i&Mt.Host&&s===a);return null!==R?Pu(e,o,R,a):As}function Pu(n,e,t,r){let i=n[t];const s=e.data;if(function Zx(n){return n instanceof Au}(i)){const o=i;o.resolving&&function nx(n,e){const t=e?`. Dependency path: ${e.join(" > ")} > ${n}`:"";throw new Tt(-200,`Circular dependency in DI detected for ${n}${t}`)}(function Cn(n){return"function"==typeof n?n.name||n.toString():"object"==typeof n&&null!=n&&"function"==typeof n.type?n.type.name||n.type.toString():Vt(n)}(s[t]));const a=Af(o.canSeeViewProviders);o.resolving=!0;const u=o.injectImpl?Bi(o.injectImpl):null;xb(n,r,Mt.Default);try{i=n[t]=o.factory(void 0,s,n,r),e.firstCreatePass&&t>=r.directiveStart&&function Yx(n,e,t){const{ngOnChanges:r,ngOnInit:i,ngDoCheck:s}=e.type.prototype;if(r){const o=vb(e);(t.preOrderHooks||(t.preOrderHooks=[])).push(n,o),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,o)}i&&(t.preOrderHooks||(t.preOrderHooks=[])).push(0-n,i),s&&((t.preOrderHooks||(t.preOrderHooks=[])).push(n,s),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,s))}(t,s[t],e)}finally{null!==u&&Bi(u),Af(a),o.resolving=!1,Mb()}}return i}function zb(n,e,t){return!!(t[e+(n>>5)]&1<{const r=function jp(n){return function(...t){if(n){const r=n(...t);for(const i in r)this[i]=r[i]}}}(e);function i(...s){if(this instanceof i)return r.apply(this,s),this;const o=new i(...s);return a.annotation=o,a;function a(u,_,R){const N=u.hasOwnProperty(ec)?u[ec]:Object.defineProperty(u,ec,{value:[]})[ec];for(;N.length<=R;)N.push(null);return(N[R]=N[R]||[]).push(o),u}}return t&&(i.prototype=Object.create(t.prototype)),i.prototype.ngMetadataName=n,i.annotationCls=i,i})}class on{constructor(e,t){this._desc=e,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,"number"==typeof t?this.__NG_ELEMENT_ID__=t:void 0!==t&&(this.\u0275prov=Wn({token:this,providedIn:t.providedIn||"root",factory:t.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}}function Qs(n,e){n.forEach(t=>Array.isArray(t)?Qs(t,e):e(t))}function Yb(n,e,t){e>=n.length?n.push(t):n.splice(e,0,t)}function Nf(n,e){return e>=n.length-1?n.pop():n.splice(e,1)[0]}const ku={},qp="__NG_DI_FLAG__",Of="ngTempTokenPath",wR=/\n/gm,Jb="__source";let Lu;function ic(n){const e=Lu;return Lu=n,e}function DR(n,e=Mt.Default){if(void 0===Lu)throw new Tt(-203,!1);return null===Lu?fb(n,void 0,e):Lu.get(n,e&Mt.Optional?null:void 0,e)}function Pn(n,e=Mt.Default){return(function lx(){return vp}()||DR)(Rt(n),e)}function Yp(n){const e=[];for(let t=0;t{const o=s;ig(o,t,[],r)&&(i||(i=[]),i.push(o))}),void 0!==i&&Tw(i,t),t}function Tw(n,e){for(let t=0;t{e.push(s)})}}function ig(n,e,t,r){if(!(n=Rt(n)))return!1;let i=null,s=ub(n);const o=!s&&Nn(n);if(s||o){if(o&&!o.standalone)return!1;i=n}else{const u=n.ngModule;if(s=ub(u),!s)return!1;i=u}const a=r.has(i);if(o){if(a)return!1;if(r.add(i),o.dependencies){const u="function"==typeof o.dependencies?o.dependencies():o.dependencies;for(const _ of u)ig(_,e,t,r)}}else{if(!s)return!1;{if(null!=s.imports&&!a){let _;r.add(i);try{Qs(s.imports,R=>{ig(R,e,t,r)&&(_||(_=[]),_.push(R))})}finally{}void 0!==_&&Tw(_,e)}if(!a){const _=pa(i)||(()=>new i);e.push({provide:i,useFactory:_,deps:In},{provide:Sw,useValue:i,multi:!0},{provide:_w,useValue:()=>Pn(i),multi:!0})}const u=s.providers;null==u||a||Qs(u,R=>{e.push(R)})}}return i!==n&&void 0!==n.providers}const lP=Jt({provide:String,useValue:Jt});function sg(n){return null!==n&&"object"==typeof n&&lP in n}function ga(n){return"function"==typeof n}const og=new on("Set Injector scope."),$f={},dP={};let ag;function jf(){return void 0===ag&&(ag=new Cw),ag}class ac{}class Rw extends ac{constructor(e,t,r,i){super(),this.parent=t,this.source=r,this.scopes=i,this.records=new Map,this._ngOnDestroyHooks=new Set,this._onDestroyHooks=[],this._destroyed=!1,ug(e,o=>this.processProvider(o)),this.records.set(Dw,cc(void 0,this)),i.has("environment")&&this.records.set(ac,cc(void 0,this));const s=this.records.get(og);null!=s&&"string"==typeof s.value&&this.scopes.add(s.value),this.injectorDefTypes=new Set(this.get(Sw.multi,In,Mt.Self))}get destroyed(){return this._destroyed}destroy(){this.assertNotDestroyed(),this._destroyed=!0;try{for(const e of this._ngOnDestroyHooks)e.ngOnDestroy();for(const e of this._onDestroyHooks)e()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear(),this._onDestroyHooks.length=0}}onDestroy(e){this._onDestroyHooks.push(e)}runInContext(e){this.assertNotDestroyed();const t=ic(this),r=Bi(void 0);try{return e()}finally{ic(t),Bi(r)}}get(e,t=ku,r=Mt.Default){this.assertNotDestroyed();const i=ic(this),s=Bi(void 0);try{if(!(r&Mt.SkipSelf)){let a=this.records.get(e);if(void 0===a){const u=function mP(n){return"function"==typeof n||"object"==typeof n&&n instanceof on}(e)&&lf(e);a=u&&this.injectableDefInScope(u)?cc(cg(e),$f):null,this.records.set(e,a)}if(null!=a)return this.hydrate(e,a)}return(r&Mt.Self?jf():this.parent).get(e,t=r&Mt.Optional&&t===ku?null:t)}catch(o){if("NullInjectorError"===o.name){if((o[Of]=o[Of]||[]).unshift(wn(e)),i)throw o;return function IR(n,e,t,r){const i=n[Of];throw e[Jb]&&i.unshift(e[Jb]),n.message=function TR(n,e,t,r=null){n=n&&"\n"===n.charAt(0)&&"\u0275"==n.charAt(1)?n.slice(2):n;let i=wn(e);if(Array.isArray(e))i=e.map(wn).join(" -> ");else if("object"==typeof e){let s=[];for(let o in e)if(e.hasOwnProperty(o)){let a=e[o];s.push(o+":"+("string"==typeof a?JSON.stringify(a):wn(a)))}i=`{${s.join(", ")}}`}return`${t}${r?"("+r+")":""}[${i}]: ${n.replace(wR,"\n ")}`}("\n"+n.message,i,t,r),n.ngTokenPath=i,n[Of]=null,n}(o,e,"R3InjectorError",this.source)}throw o}finally{Bi(s),ic(i)}}resolveInjectorInitializers(){const e=ic(this),t=Bi(void 0);try{const r=this.get(_w.multi,In,Mt.Self);for(const i of r)i()}finally{ic(e),Bi(t)}}toString(){const e=[],t=this.records;for(const r of t.keys())e.push(wn(r));return`R3Injector[${e.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new Tt(205,!1)}processProvider(e){let t=ga(e=Rt(e))?e:Rt(e&&e.provide);const r=function pP(n){return sg(n)?cc(void 0,n.useValue):cc(function Pw(n,e,t){let r;if(ga(n)){const i=Rt(n);return pa(i)||cg(i)}if(sg(n))r=()=>Rt(n.useValue);else if(function xw(n){return!(!n||!n.useFactory)}(n))r=()=>n.useFactory(...Yp(n.deps||[]));else if(function Aw(n){return!(!n||!n.useExisting)}(n))r=()=>Pn(Rt(n.useExisting));else{const i=Rt(n&&(n.useClass||n.provide));if(!function gP(n){return!!n.deps}(n))return pa(i)||cg(i);r=()=>new i(...Yp(n.deps))}return r}(n),$f)}(e);if(ga(e)||!0!==e.multi)this.records.get(t);else{let i=this.records.get(t);i||(i=cc(void 0,$f,!0),i.factory=()=>Yp(i.multi),this.records.set(t,i)),t=e,i.multi.push(e)}this.records.set(t,r)}hydrate(e,t){return t.value===$f&&(t.value=dP,t.value=t.factory()),"object"==typeof t.value&&t.value&&function yP(n){return null!==n&&"object"==typeof n&&"function"==typeof n.ngOnDestroy}(t.value)&&this._ngOnDestroyHooks.add(t.value),t.value}injectableDefInScope(e){if(!e.providedIn)return!1;const t=Rt(e.providedIn);return"string"==typeof t?"any"===t||this.scopes.has(t):this.injectorDefTypes.has(t)}}function cg(n){const e=lf(n),t=null!==e?e.factory:pa(n);if(null!==t)return t;if(n instanceof on)throw new Tt(204,!1);if(n instanceof Function)return function hP(n){const e=n.length;if(e>0)throw function Ou(n,e){const t=[];for(let r=0;rt.factory(n):()=>new n}(n);throw new Tt(204,!1)}function cc(n,e,t=!1){return{factory:n,value:e,multi:t?[]:void 0}}function vP(n){return!!n.\u0275providers}function ug(n,e){for(const t of n)Array.isArray(t)?ug(t,e):vP(t)?ug(t.\u0275providers,e):e(t)}class Nw{}class wP{resolveComponentFactory(e){throw function bP(n){const e=Error(`No component factory found for ${wn(n)}. Did you add it to @NgModule.entryComponents?`);return e.ngComponent=n,e}(e)}}let zf=(()=>{class n{}return n.NULL=new wP,n})();function _P(){return uc(Tr(),Ue())}function uc(n,e){return new lc(Hi(n,e))}let lc=(()=>{class n{constructor(t){this.nativeElement=t}}return n.__NG_ELEMENT_ID__=_P,n})();class Ow{}let CP=(()=>{class n{}return n.\u0275prov=Wn({token:n,providedIn:"root",factory:()=>null}),n})();class lg{constructor(e){this.full=e,this.major=e.split(".")[0],this.minor=e.split(".")[1],this.patch=e.split(".").slice(2).join(".")}}const IP=new lg("14.2.1"),fg={};function yg(n){return n.ngOriginalError}class fc{constructor(){this._console=console}handleError(e){const t=this._findOriginalError(e);this._console.error("ERROR",e),t&&this._console.error("ORIGINAL ERROR",t)}_findOriginalError(e){let t=e&&yg(e);for(;t&&yg(t);)t=yg(t);return t||null}}const mg=new Map;let FP=0;const Eg="__ngContext__";function jr(n,e){pi(e)?(n[Eg]=e[20],function VP(n){mg.set(n[20],n)}(e)):n[Eg]=e}function $u(n){const e=n[Eg];return"number"==typeof e?function Hw(n){return mg.get(n)||null}(e):e||null}function bg(n){const e=$u(n);return e?pi(e)?e:e.lView:null}var gi=(()=>((gi=gi||{})[gi.Important=1]="Important",gi[gi.DashCase=2]="DashCase",gi))();function _g(n,e){return undefined(n,e)}function ju(n){const e=n[3];return ss(e)?e[3]:e}function Dg(n){return qw(n[13])}function Sg(n){return qw(n[4])}function qw(n){for(;null!==n&&!ss(n);)n=n[4];return n}function hc(n,e,t,r,i){if(null!=r){let s,o=!1;ss(r)?s=r:pi(r)&&(o=!0,r=r[0]);const a=yr(r);0===n&&null!==t?null==i?e_(e,t,a):ya(e,t,a,i||null,!0):1===n&&null!==t?ya(e,t,a,i||null,!0):2===n?function a_(n,e,t){const r=Gf(n,e);r&&function hN(n,e,t,r){n.removeChild(e,t,r)}(n,r,e,t)}(e,a,o):3===n&&e.destroyNode(a),null!=s&&function yN(n,e,t,r,i){const s=t[7];s!==yr(t)&&hc(e,n,r,s,i);for(let a=10;a0&&(n[t-1][4]=r[4]);const s=Nf(n,10+e);!function sN(n,e){zu(n,e,e[11],2,null,null),e[0]=null,e[6]=null}(r[1],r);const o=s[19];null!==o&&o.detachView(s[1]),r[3]=null,r[4]=null,r[2]&=-65}return r}function Zw(n,e){if(!(128&e[2])){const t=e[11];t.destroyNode&&zu(n,e,t,3,null,null),function cN(n){let e=n[13];if(!e)return Ag(n[1],n);for(;e;){let t=null;if(pi(e))t=e[13];else{const r=e[10];r&&(t=r)}if(!t){for(;e&&!e[4]&&e!==n;)pi(e)&&Ag(e[1],e),e=e[3];null===e&&(e=n),pi(e)&&Ag(e[1],e),t=e&&e[4]}e=t}}(e)}}function Ag(n,e){if(!(128&e[2])){e[2]&=-65,e[2]|=128,function dN(n,e){let t;if(null!=n&&null!=(t=n.destroyHooks))for(let r=0;r=0?r[i=_]():r[i=-_].unsubscribe(),s+=2}else{const o=r[i=t[s+1]];t[s].call(o)}if(null!==r){for(let s=i+1;ss?"":i[N+1].toLowerCase();const z=8&r?B:null;if(z&&-1!==l_(z,_,0)||2&r&&_!==B){if(as(r))return!1;o=!0}}}}else{if(!o&&!as(r)&&!as(u))return!1;if(o&&as(u))continue;o=!1,r=u|1&r}}return as(r)||o}function as(n){return 0==(1&n)}function wN(n,e,t,r){if(null===e)return-1;let i=0;if(r||!t){let s=!1;for(;i-1)for(t++;t0?'="'+a+'"':"")+"]"}else 8&r?i+="."+o:4&r&&(i+=" "+o);else""!==i&&!as(o)&&(e+=p_(s,i),i=""),r=o,s=s||!as(r);t++}return""!==i&&(e+=p_(s,i)),e}const Ht={};function Gu(n){g_(dn(),Ue(),si()+n,!1)}function g_(n,e,t,r){if(!r)if(3==(3&e[2])){const s=n.preOrderCheckHooks;null!==s&&Sf(e,s,t)}else{const s=n.preOrderHooks;null!==s&&Cf(e,s,0,t)}xo(t)}function E_(n,e=null,t=null,r){const i=b_(n,e,t,r);return i.resolveInjectorInitializers(),i}function b_(n,e=null,t=null,r,i=new Set){const s=[t||In,uP(n)];return r=r||("object"==typeof n?void 0:wn(n)),new Rw(s,e||jf(),r||null,i)}let ma=(()=>{class n{static create(t,r){if(Array.isArray(t))return E_({name:""},r,t,"");{const i=t.name??"";return E_({name:i},t.parent,t.providers,i)}}}return n.THROW_IF_NOT_FOUND=ku,n.NULL=new Cw,n.\u0275prov=Wn({token:n,providedIn:"any",factory:()=>Pn(Dw)}),n.__NG_ELEMENT_ID__=-1,n})();function Zt(n,e=Mt.Default){const t=Ue();return null===t?Pn(n,e):$b(Tr(),t,Rt(n),e)}function B_(n,e){const t=n.contentQueries;if(null!==t)for(let r=0;r22&&g_(n,e,22,!1),t(r,i)}finally{xo(s)}}function qg(n,e,t){!Sb()||(function gM(n,e,t,r){const i=t.directiveStart,s=t.directiveEnd;n.firstCreatePass||Ru(t,e),jr(r,e);const o=t.initialInputs;for(let a=i;a0;){const t=n[--e];if("number"==typeof t&&t<0)return t}return 0})(a)!=u&&a.push(u),a.push(r,i,o)}}function G_(n,e){null!==n.hostBindings&&n.hostBindings(1,e)}function W_(n,e){e.flags|=2,(n.components||(n.components=[])).push(e.index)}function EM(n,e,t){if(t){if(e.exportAs)for(let r=0;r0&&Jg(t)}}function Jg(n){for(let r=Dg(n);null!==r;r=Sg(r))for(let i=10;i0&&Jg(s)}const t=n[1].components;if(null!==t)for(let r=0;r0&&Jg(i)}}function IM(n,e){const t=Ai(e,n),r=t[1];(function TM(n,e){for(let t=e.length;t-1&&(Tg(e,r),Nf(t,r))}this._attachedToViewContainer=!1}Zw(this._lView[1],this._lView)}onDestroy(e){!function H_(n,e,t,r){const i=X_(e);null===t?i.push(r):(i.push(t),n.firstCreatePass&&J_(n).push(r,i.length-1))}(this._lView[1],this._lView,null,e)}markForCheck(){ey(this._cdRefInjectingView||this._lView)}detach(){this._lView[2]&=-65}reattach(){this._lView[2]|=64}detectChanges(){!function ty(n,e,t){const r=e[10];r.begin&&r.begin();try{Wu(n,e,n.template,t)}catch(i){throw t1(e,i),i}finally{r.end&&r.end()}}(this._lView[1],this._lView,this.context)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new Tt(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,function aN(n,e){zu(n,e,e[11],2,null,null)}(this._lView[1],this._lView)}attachToAppRef(e){if(this._attachedToViewContainer)throw new Tt(902,!1);this._appRef=e}}class xM extends qu{constructor(e){super(e),this._view=e}detectChanges(){!function Z_(n){!function AM(n){for(let e=0;e0&&Ng(_,N,Te.join(" "))}if(de=Ap(X,22),void 0!==t){const ue=de.projection=[];for(let Te=0;Tea(yr(Ke[r.index])):r.index;let Te=null;if(!a&&u&&(Te=function nO(n,e,t,r){const i=n.cleanup;if(null!=i)for(let s=0;su?a[u]:null}"string"==typeof o&&(s+=2)}return null}(n,e,i,r.index)),null!==Te)(Te.__ngLastListenerFn__||Te).__ngNextListenerFn__=s,Te.__ngLastListenerFn__=s,z=!1;else{s=w1(r,e,N,s,!1);const Ke=t.listen(de,i,s);B.push(s,Ke),R&&R.push(i,ue,xe,xe+1)}}else s=w1(r,e,N,s,!1);const X=r.outputs;let J;if(z&&null!==X&&(J=X[i])){const oe=J.length;if(oe)for(let de=0;det()),this.destroyCbs=null}onDestroy(e){this.destroyCbs.push(e)}}class Dy extends class j3{}{constructor(e){super(),this.moduleType=e}create(e){return new FD(this.moduleType,e)}}function Cy(n){return e=>{setTimeout(n,void 0,e)}}const no=class bk extends pr{constructor(e=!1){super(),this.__isAsync=e}emit(e){super.next(e)}subscribe(e,t,r){let i=e,s=t||(()=>null),o=r;if(e&&"object"==typeof e){const u=e;i=u.next?.bind(u),s=u.error?.bind(u),o=u.complete?.bind(u)}this.__isAsync&&(s=Cy(s),i&&(i=Cy(i)),o&&(o=Cy(o)));const a=super.subscribe({next:i,error:s,complete:o});return e instanceof F&&e.add(a),a}};let ro=(()=>{class n{}return n.__NG_ELEMENT_ID__=Sk,n})();const _k=ro,Dk=class extends _k{constructor(e,t,r){super(),this._declarationLView=e,this._declarationTContainer=t,this.elementRef=r}createEmbeddedView(e,t){const r=this._declarationTContainer.tViews,i=Jf(this._declarationLView,r,e,16,null,r.declTNode,null,null,null,null,t||null);i[17]=this._declarationLView[this._declarationTContainer.index];const o=this._declarationLView[19];return null!==o&&(i[19]=o.createEmbeddedView(r)),ed(r,i,e),new qu(i)}};function Sk(){return function hd(n,e){return 4&n.type?new Dk(e,n,uc(n,e)):null}(Tr(),Ue())}let Os=(()=>{class n{}return n.__NG_ELEMENT_ID__=Ck,n})();function Ck(){return function JD(n,e){let t;const r=e[n.index];if(ss(r))t=r;else{let i;if(8&n.type)i=yr(r);else{const s=e[11];i=s.createComment("");const o=Hi(n,e);ya(s,Gf(s,o),i,function pN(n,e){return n.nextSibling(e)}(s,o),!1)}e[n.index]=t=Q_(r,e,i,n),td(e,t)}return new ZD(t,n,e)}(Tr(),Ue())}const Ik=Os,ZD=class extends Ik{constructor(e,t,r){super(),this._lContainer=e,this._hostTNode=t,this._hostLView=r}get element(){return uc(this._hostTNode,this._hostLView)}get injector(){return new Xa(this._hostTNode,this._hostLView)}get parentInjector(){const e=xf(this._hostTNode,this._hostLView);if(Fb(e)){const t=Za(e,this._hostLView),r=Qa(e);return new Xa(t[1].data[r+8],t)}return new Xa(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(e){const t=XD(this._lContainer);return null!==t&&t[e]||null}get length(){return this._lContainer.length-10}createEmbeddedView(e,t,r){let i,s;"number"==typeof r?i=r:null!=r&&(i=r.index,s=r.injector);const o=e.createEmbeddedView(t||{},s);return this.insert(o,i),o}createComponent(e,t,r,i,s){const o=e&&!function Mu(n){return"function"==typeof n}(e);let a;if(o)a=t;else{const N=t||{};a=N.index,r=N.injector,i=N.projectableNodes,s=N.environmentInjector||N.ngModuleRef}const u=o?e:new Yu(Nn(e)),_=r||this.parentInjector;if(!s&&null==u.ngModule){const B=(o?_:this.parentInjector).get(ac,null);B&&(s=B)}const R=u.create(_,i,void 0,s);return this.insert(R.hostView,a),R}insert(e,t){const r=e._lView,i=r[1];if(function xx(n){return ss(n[3])}(r)){const R=this.indexOf(e);if(-1!==R)this.detach(R);else{const N=r[3],B=new ZD(N,N[6],N[3]);B.detach(B.indexOf(e))}}const s=this._adjustIndex(t),o=this._lContainer;!function uN(n,e,t,r){const i=10+r,s=t.length;r>0&&(t[i-1][4]=e),r{class n{constructor(t){this.appInits=t,this.resolve=gd,this.reject=gd,this.initialized=!1,this.done=!1,this.donePromise=new Promise((r,i)=>{this.resolve=r,this.reject=i})}runInitializers(){if(this.initialized)return;const t=[],r=()=>{this.done=!0,this.resolve()};if(this.appInits)for(let i=0;i{s.subscribe({complete:a,error:u})});t.push(o)}}Promise.all(t).then(()=>{r()}).catch(i=>{this.reject(i)}),0===t.length&&r(),this.initialized=!0}}return n.\u0275fac=function(t){return new(t||n)(Pn(DS,8))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();const ol=new on("AppId",{providedIn:"root",factory:function SS(){return`${By()}${By()}${By()}`}});function By(){return String.fromCharCode(97+Math.floor(25*Math.random()))}const CS=new on("Platform Initializer"),IS=new on("Platform ID",{providedIn:"platform",factory:()=>"unknown"}),sL=new on("appBootstrapListener"),io=new on("LocaleId",{providedIn:"root",factory:()=>function SR(n,e=Mt.Default){return"number"!=typeof e&&(e=0|(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)),Pn(n,e)}(io,Mt.Optional|Mt.SkipSelf)||function oL(){return typeof $localize<"u"&&$localize.locale||xc}()}),fL=(()=>Promise.resolve(0))();function Fy(n){typeof Zone>"u"?fL.then(()=>{n&&n.apply(null,null)}):Zone.current.scheduleMicroTask("scheduleMicrotask",n)}class Gr{constructor({enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:t=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new no(!1),this.onMicrotaskEmpty=new no(!1),this.onStable=new no(!1),this.onError=new no(!1),typeof Zone>"u")throw new Tt(908,!1);Zone.assertZonePatched();const i=this;if(i._nesting=0,i._outer=i._inner=Zone.current,Zone.AsyncStackTaggingZoneSpec){const s=Zone.AsyncStackTaggingZoneSpec;i._inner=i._inner.fork(new s("Angular"))}Zone.TaskTrackingZoneSpec&&(i._inner=i._inner.fork(new Zone.TaskTrackingZoneSpec)),e&&Zone.longStackTraceZoneSpec&&(i._inner=i._inner.fork(Zone.longStackTraceZoneSpec)),i.shouldCoalesceEventChangeDetection=!r&&t,i.shouldCoalesceRunChangeDetection=r,i.lastRequestAnimationFrameId=-1,i.nativeRequestAnimationFrame=function dL(){let n=Fn.requestAnimationFrame,e=Fn.cancelAnimationFrame;if(typeof Zone<"u"&&n&&e){const t=n[Zone.__symbol__("OriginalDelegate")];t&&(n=t);const r=e[Zone.__symbol__("OriginalDelegate")];r&&(e=r)}return{nativeRequestAnimationFrame:n,nativeCancelAnimationFrame:e}}().nativeRequestAnimationFrame,function gL(n){const e=()=>{!function pL(n){n.isCheckStableRunning||-1!==n.lastRequestAnimationFrameId||(n.lastRequestAnimationFrameId=n.nativeRequestAnimationFrame.call(Fn,()=>{n.fakeTopEventTask||(n.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{n.lastRequestAnimationFrameId=-1,Vy(n),n.isCheckStableRunning=!0,Uy(n),n.isCheckStableRunning=!1},void 0,()=>{},()=>{})),n.fakeTopEventTask.invoke()}),Vy(n))}(n)};n._inner=n._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(t,r,i,s,o,a)=>{try{return xS(n),t.invokeTask(i,s,o,a)}finally{(n.shouldCoalesceEventChangeDetection&&"eventTask"===s.type||n.shouldCoalesceRunChangeDetection)&&e(),RS(n)}},onInvoke:(t,r,i,s,o,a,u)=>{try{return xS(n),t.invoke(i,s,o,a,u)}finally{n.shouldCoalesceRunChangeDetection&&e(),RS(n)}},onHasTask:(t,r,i,s)=>{t.hasTask(i,s),r===i&&("microTask"==s.change?(n._hasPendingMicrotasks=s.microTask,Vy(n),Uy(n)):"macroTask"==s.change&&(n.hasPendingMacrotasks=s.macroTask))},onHandleError:(t,r,i,s)=>(t.handleError(i,s),n.runOutsideAngular(()=>n.onError.emit(s)),!1)})}(i)}static isInAngularZone(){return typeof Zone<"u"&&!0===Zone.current.get("isAngularZone")}static assertInAngularZone(){if(!Gr.isInAngularZone())throw new Tt(909,!1)}static assertNotInAngularZone(){if(Gr.isInAngularZone())throw new Tt(909,!1)}run(e,t,r){return this._inner.run(e,t,r)}runTask(e,t,r,i){const s=this._inner,o=s.scheduleEventTask("NgZoneEvent: "+i,e,hL,gd,gd);try{return s.runTask(o,t,r)}finally{s.cancelTask(o)}}runGuarded(e,t,r){return this._inner.runGuarded(e,t,r)}runOutsideAngular(e){return this._outer.run(e)}}const hL={};function Uy(n){if(0==n._nesting&&!n.hasPendingMicrotasks&&!n.isStable)try{n._nesting++,n.onMicrotaskEmpty.emit(null)}finally{if(n._nesting--,!n.hasPendingMicrotasks)try{n.runOutsideAngular(()=>n.onStable.emit(null))}finally{n.isStable=!0}}}function Vy(n){n.hasPendingMicrotasks=!!(n._hasPendingMicrotasks||(n.shouldCoalesceEventChangeDetection||n.shouldCoalesceRunChangeDetection)&&-1!==n.lastRequestAnimationFrameId)}function xS(n){n._nesting++,n.isStable&&(n.isStable=!1,n.onUnstable.emit(null))}function RS(n){n._nesting--,Uy(n)}class yL{constructor(){this.hasPendingMicrotasks=!1,this.hasPendingMacrotasks=!1,this.isStable=!0,this.onUnstable=new no,this.onMicrotaskEmpty=new no,this.onStable=new no,this.onError=new no}run(e,t,r){return e.apply(t,r)}runGuarded(e,t,r){return e.apply(t,r)}runOutsideAngular(e){return e()}runTask(e,t,r,i){return e.apply(t,r)}}const PS=new on(""),md=new on("");let $y,Hy=(()=>{class n{constructor(t,r,i){this._ngZone=t,this.registry=r,this._pendingCount=0,this._isZoneStable=!0,this._didWork=!1,this._callbacks=[],this.taskTrackingZone=null,$y||(function mL(n){$y=n}(i),i.addToWindow(r)),this._watchAngularEvents(),t.run(()=>{this.taskTrackingZone=typeof Zone>"u"?null:Zone.current.get("TaskTrackingZone")})}_watchAngularEvents(){this._ngZone.onUnstable.subscribe({next:()=>{this._didWork=!0,this._isZoneStable=!1}}),this._ngZone.runOutsideAngular(()=>{this._ngZone.onStable.subscribe({next:()=>{Gr.assertNotInAngularZone(),Fy(()=>{this._isZoneStable=!0,this._runCallbacksIfReady()})}})})}increasePendingRequestCount(){return this._pendingCount+=1,this._didWork=!0,this._pendingCount}decreasePendingRequestCount(){if(this._pendingCount-=1,this._pendingCount<0)throw new Error("pending async requests below zero");return this._runCallbacksIfReady(),this._pendingCount}isStable(){return this._isZoneStable&&0===this._pendingCount&&!this._ngZone.hasPendingMacrotasks}_runCallbacksIfReady(){if(this.isStable())Fy(()=>{for(;0!==this._callbacks.length;){let t=this._callbacks.pop();clearTimeout(t.timeoutId),t.doneCb(this._didWork)}this._didWork=!1});else{let t=this.getPendingTasks();this._callbacks=this._callbacks.filter(r=>!r.updateCb||!r.updateCb(t)||(clearTimeout(r.timeoutId),!1)),this._didWork=!0}}getPendingTasks(){return this.taskTrackingZone?this.taskTrackingZone.macroTasks.map(t=>({source:t.source,creationLocation:t.creationLocation,data:t.data})):[]}addCallback(t,r,i){let s=-1;r&&r>0&&(s=setTimeout(()=>{this._callbacks=this._callbacks.filter(o=>o.timeoutId!==s),t(this._didWork,this.getPendingTasks())},r)),this._callbacks.push({doneCb:t,timeoutId:s,updateCb:i})}whenStable(t,r,i){if(i&&!this.taskTrackingZone)throw new Error('Task tracking zone is required when passing an update callback to whenStable(). Is "zone.js/plugins/task-tracking" loaded?');this.addCallback(t,r,i),this._runCallbacksIfReady()}getPendingRequestCount(){return this._pendingCount}registerApplication(t){this.registry.registerApplication(t,this)}unregisterApplication(t){this.registry.unregisterApplication(t)}findProviders(t,r,i){return[]}}return n.\u0275fac=function(t){return new(t||n)(Pn(Gr),Pn(Ky),Pn(md))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})(),Ky=(()=>{class n{constructor(){this._applications=new Map}registerApplication(t,r){this._applications.set(t,r)}unregisterApplication(t){this._applications.delete(t)}unregisterAllApplications(){this._applications.clear()}getTestability(t){return this._applications.get(t)||null}getAllTestabilities(){return Array.from(this._applications.values())}getAllRootElements(){return Array.from(this._applications.keys())}findTestabilityInTree(t,r=!0){return $y?.findTestabilityInTree(this,t,r)??null}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})(),Oo=null;const NS=new on("AllowMultipleToken"),jy=new on("PlatformDestroyListeners");function OS(n,e,t=[]){const r=`Platform: ${e}`,i=new on(r);return(s=[])=>{let o=zy();if(!o||o.injector.get(NS,!1)){const a=[...t,...s,{provide:i,useValue:!0}];n?n(a):function bL(n){if(Oo&&!Oo.get(NS,!1))throw new Tt(400,!1);Oo=n;const e=n.get(LS);(function MS(n){const e=n.get(CS,null);e&&e.forEach(t=>t())})(n)}(function kS(n=[],e){return ma.create({name:e,providers:[{provide:og,useValue:"platform"},{provide:jy,useValue:new Set([()=>Oo=null])},...n]})}(a,r))}return function _L(n){const e=zy();if(!e)throw new Tt(401,!1);return e}()}}function zy(){return Oo?.get(LS)??null}let LS=(()=>{class n{constructor(t){this._injector=t,this._modules=[],this._destroyListeners=[],this._destroyed=!1}bootstrapModuleFactory(t,r){const i=function FS(n,e){let t;return t="noop"===n?new yL:("zone.js"===n?void 0:n)||new Gr(e),t}(r?.ngZone,function BS(n){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:!(!n||!n.ngZoneEventCoalescing)||!1,shouldCoalesceRunChangeDetection:!(!n||!n.ngZoneRunCoalescing)||!1}}(r)),s=[{provide:Gr,useValue:i}];return i.run(()=>{const o=ma.create({providers:s,parent:this.injector,name:t.moduleType.name}),a=t.create(o),u=a.injector.get(fc,null);if(!u)throw new Tt(402,!1);return i.runOutsideAngular(()=>{const _=i.onError.subscribe({next:R=>{u.handleError(R)}});a.onDestroy(()=>{vd(this._modules,a),_.unsubscribe()})}),function US(n,e,t){try{const r=t();return fy(r)?r.catch(i=>{throw e.runOutsideAngular(()=>n.handleError(i)),i}):r}catch(r){throw e.runOutsideAngular(()=>n.handleError(r)),r}}(u,i,()=>{const _=a.injector.get(yd);return _.runInitializers(),_.donePromise.then(()=>(function hD(n){Ci(n,"Expected localeId to be defined"),"string"==typeof n&&(dD=n.toLowerCase().replace(/_/g,"-"))}(a.injector.get(io,xc)||xc),this._moduleDoBootstrap(a),a))})})}bootstrapModule(t,r=[]){const i=VS({},r);return function vL(n,e,t){const r=new Dy(t);return Promise.resolve(r)}(0,0,t).then(s=>this.bootstrapModuleFactory(s,i))}_moduleDoBootstrap(t){const r=t.injector.get(Gy);if(t._bootstrapComponents.length>0)t._bootstrapComponents.forEach(i=>r.bootstrap(i));else{if(!t.instance.ngDoBootstrap)throw new Tt(403,!1);t.instance.ngDoBootstrap(r)}this._modules.push(t)}onDestroy(t){this._destroyListeners.push(t)}get injector(){return this._injector}destroy(){if(this._destroyed)throw new Tt(404,!1);this._modules.slice().forEach(r=>r.destroy()),this._destroyListeners.forEach(r=>r());const t=this._injector.get(jy,null);t&&(t.forEach(r=>r()),t.clear()),this._destroyed=!0}get destroyed(){return this._destroyed}}return n.\u0275fac=function(t){return new(t||n)(Pn(ma))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})();function VS(n,e){return Array.isArray(e)?e.reduce(VS,n):{...n,...e}}let Gy=(()=>{class n{constructor(t,r,i){this._zone=t,this._injector=r,this._exceptionHandler=i,this._bootstrapListeners=[],this._views=[],this._runningTick=!1,this._stable=!0,this._destroyed=!1,this._destroyListeners=[],this.componentTypes=[],this.components=[],this._onMicrotaskEmptySubscription=this._zone.onMicrotaskEmpty.subscribe({next:()=>{this._zone.run(()=>{this.tick()})}});const s=new Xe(a=>{this._stable=this._zone.isStable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks,this._zone.runOutsideAngular(()=>{a.next(this._stable),a.complete()})}),o=new Xe(a=>{let u;this._zone.runOutsideAngular(()=>{u=this._zone.onStable.subscribe(()=>{Gr.assertNotInAngularZone(),Fy(()=>{!this._stable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks&&(this._stable=!0,a.next(!0))})})});const _=this._zone.onUnstable.subscribe(()=>{Gr.assertInAngularZone(),this._stable&&(this._stable=!1,this._zone.runOutsideAngular(()=>{a.next(!1)}))});return()=>{u.unsubscribe(),_.unsubscribe()}});this.isStable=ei(s,o.pipe(function ns(n={}){const{connector:e=(()=>new pr),resetOnError:t=!0,resetOnComplete:r=!0,resetOnRefCountZero:i=!0}=n;return s=>{let o,a,u,_=0,R=!1,N=!1;const B=()=>{a?.unsubscribe(),a=void 0},z=()=>{B(),o=u=void 0,R=N=!1},X=()=>{const J=o;z(),J?.unsubscribe()};return fe((J,oe)=>{_++,!N&&!R&&B();const de=u=u??e();oe.add(()=>{_--,0===_&&!N&&!R&&(a=Io(X,i))}),de.subscribe(oe),!o&&_>0&&(o=new be({next:xe=>de.next(xe),error:xe=>{N=!0,B(),a=Io(z,t,xe),de.error(xe)},complete:()=>{R=!0,B(),a=Io(z,r),de.complete()}}),yn(J).subscribe(o))})(s)}}()))}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(t,r){const i=t instanceof Nw;if(!this._injector.get(yd).done)throw!i&&function Du(n){const e=Nn(n)||ni(n)||ri(n);return null!==e&&e.standalone}(t),new Tt(405,false);let o;o=i?t:this._injector.get(zf).resolveComponentFactory(t),this.componentTypes.push(o.componentType);const a=function EL(n){return n.isBoundToModule}(o)?void 0:this._injector.get(Pc),_=o.create(ma.NULL,[],r||o.selector,a),R=_.location.nativeElement,N=_.injector.get(PS,null);return N?.registerApplication(R),_.onDestroy(()=>{this.detachView(_.hostView),vd(this.components,_),N?.unregisterApplication(R)}),this._loadComponent(_),_}tick(){if(this._runningTick)throw new Tt(101,!1);try{this._runningTick=!0;for(let t of this._views)t.detectChanges()}catch(t){this._zone.runOutsideAngular(()=>this._exceptionHandler.handleError(t))}finally{this._runningTick=!1}}attachView(t){const r=t;this._views.push(r),r.attachToAppRef(this)}detachView(t){const r=t;vd(this._views,r),r.detachFromAppRef()}_loadComponent(t){this.attachView(t.hostView),this.tick(),this.components.push(t),this._injector.get(sL,[]).concat(this._bootstrapListeners).forEach(i=>i(t))}ngOnDestroy(){if(!this._destroyed)try{this._destroyListeners.forEach(t=>t()),this._views.slice().forEach(t=>t.destroy()),this._onMicrotaskEmptySubscription.unsubscribe()}finally{this._destroyed=!0,this._views=[],this._bootstrapListeners=[],this._destroyListeners=[]}}onDestroy(t){return this._destroyListeners.push(t),()=>vd(this._destroyListeners,t)}destroy(){if(this._destroyed)throw new Tt(406,!1);const t=this._injector;t.destroy&&!t.destroyed&&t.destroy()}get viewCount(){return this._views.length}warnIfDestroyed(){}}return n.\u0275fac=function(t){return new(t||n)(Pn(Gr),Pn(ac),Pn(fc))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function vd(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}let KS=!0;class WS{constructor(){}supports(e){return Qu(e)}create(e){return new ML(e)}}const NL=(n,e)=>e;class ML{constructor(e){this.length=0,this._linkedRecords=null,this._unlinkedRecords=null,this._previousItHead=null,this._itHead=null,this._itTail=null,this._additionsHead=null,this._additionsTail=null,this._movesHead=null,this._movesTail=null,this._removalsHead=null,this._removalsTail=null,this._identityChangesHead=null,this._identityChangesTail=null,this._trackByFn=e||NL}forEachItem(e){let t;for(t=this._itHead;null!==t;t=t._next)e(t)}forEachOperation(e){let t=this._itHead,r=this._removalsHead,i=0,s=null;for(;t||r;){const o=!r||t&&t.currentIndex{o=this._trackByFn(i,a),null!==t&&Object.is(t.trackById,o)?(r&&(t=this._verifyReinsertion(t,a,o,i)),Object.is(t.item,a)||this._addIdentityChange(t,a)):(t=this._mismatch(t,a,o,i),r=!0),t=t._next,i++}),this.length=i;return this._truncate(t),this.collection=e,this.isDirty}get isDirty(){return null!==this._additionsHead||null!==this._movesHead||null!==this._removalsHead||null!==this._identityChangesHead}_reset(){if(this.isDirty){let e;for(e=this._previousItHead=this._itHead;null!==e;e=e._next)e._nextPrevious=e._next;for(e=this._additionsHead;null!==e;e=e._nextAdded)e.previousIndex=e.currentIndex;for(this._additionsHead=this._additionsTail=null,e=this._movesHead;null!==e;e=e._nextMoved)e.previousIndex=e.currentIndex;this._movesHead=this._movesTail=null,this._removalsHead=this._removalsTail=null,this._identityChangesHead=this._identityChangesTail=null}}_mismatch(e,t,r,i){let s;return null===e?s=this._itTail:(s=e._prev,this._remove(e)),null!==(e=null===this._unlinkedRecords?null:this._unlinkedRecords.get(r,null))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._reinsertAfter(e,s,i)):null!==(e=null===this._linkedRecords?null:this._linkedRecords.get(r,i))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._moveAfter(e,s,i)):e=this._addAfter(new OL(t,r),s,i),e}_verifyReinsertion(e,t,r,i){let s=null===this._unlinkedRecords?null:this._unlinkedRecords.get(r,null);return null!==s?e=this._reinsertAfter(s,e._prev,i):e.currentIndex!=i&&(e.currentIndex=i,this._addToMoves(e,i)),e}_truncate(e){for(;null!==e;){const t=e._next;this._addToRemovals(this._unlink(e)),e=t}null!==this._unlinkedRecords&&this._unlinkedRecords.clear(),null!==this._additionsTail&&(this._additionsTail._nextAdded=null),null!==this._movesTail&&(this._movesTail._nextMoved=null),null!==this._itTail&&(this._itTail._next=null),null!==this._removalsTail&&(this._removalsTail._nextRemoved=null),null!==this._identityChangesTail&&(this._identityChangesTail._nextIdentityChange=null)}_reinsertAfter(e,t,r){null!==this._unlinkedRecords&&this._unlinkedRecords.remove(e);const i=e._prevRemoved,s=e._nextRemoved;return null===i?this._removalsHead=s:i._nextRemoved=s,null===s?this._removalsTail=i:s._prevRemoved=i,this._insertAfter(e,t,r),this._addToMoves(e,r),e}_moveAfter(e,t,r){return this._unlink(e),this._insertAfter(e,t,r),this._addToMoves(e,r),e}_addAfter(e,t,r){return this._insertAfter(e,t,r),this._additionsTail=null===this._additionsTail?this._additionsHead=e:this._additionsTail._nextAdded=e,e}_insertAfter(e,t,r){const i=null===t?this._itHead:t._next;return e._next=i,e._prev=t,null===i?this._itTail=e:i._prev=e,null===t?this._itHead=e:t._next=e,null===this._linkedRecords&&(this._linkedRecords=new qS),this._linkedRecords.put(e),e.currentIndex=r,e}_remove(e){return this._addToRemovals(this._unlink(e))}_unlink(e){null!==this._linkedRecords&&this._linkedRecords.remove(e);const t=e._prev,r=e._next;return null===t?this._itHead=r:t._next=r,null===r?this._itTail=t:r._prev=t,e}_addToMoves(e,t){return e.previousIndex===t||(this._movesTail=null===this._movesTail?this._movesHead=e:this._movesTail._nextMoved=e),e}_addToRemovals(e){return null===this._unlinkedRecords&&(this._unlinkedRecords=new qS),this._unlinkedRecords.put(e),e.currentIndex=null,e._nextRemoved=null,null===this._removalsTail?(this._removalsTail=this._removalsHead=e,e._prevRemoved=null):(e._prevRemoved=this._removalsTail,this._removalsTail=this._removalsTail._nextRemoved=e),e}_addIdentityChange(e,t){return e.item=t,this._identityChangesTail=null===this._identityChangesTail?this._identityChangesHead=e:this._identityChangesTail._nextIdentityChange=e,e}}class OL{constructor(e,t){this.item=e,this.trackById=t,this.currentIndex=null,this.previousIndex=null,this._nextPrevious=null,this._prev=null,this._next=null,this._prevDup=null,this._nextDup=null,this._prevRemoved=null,this._nextRemoved=null,this._nextAdded=null,this._nextMoved=null,this._nextIdentityChange=null}}class kL{constructor(){this._head=null,this._tail=null}add(e){null===this._head?(this._head=this._tail=e,e._nextDup=null,e._prevDup=null):(this._tail._nextDup=e,e._prevDup=this._tail,e._nextDup=null,this._tail=e)}get(e,t){let r;for(r=this._head;null!==r;r=r._nextDup)if((null===t||t<=r.currentIndex)&&Object.is(r.trackById,e))return r;return null}remove(e){const t=e._prevDup,r=e._nextDup;return null===t?this._head=r:t._nextDup=r,null===r?this._tail=t:r._prevDup=t,null===this._head}}class qS{constructor(){this.map=new Map}put(e){const t=e.trackById;let r=this.map.get(t);r||(r=new kL,this.map.set(t,r)),r.add(e)}get(e,t){const i=this.map.get(e);return i?i.get(e,t):null}remove(e){const t=e.trackById;return this.map.get(t).remove(e)&&this.map.delete(t),e}get isEmpty(){return 0===this.map.size}clear(){this.map.clear()}}function YS(n,e,t){const r=n.previousIndex;if(null===r)return r;let i=0;return t&&r{class n{constructor(t){this.factories=t}static create(t,r){if(null!=r){const i=r.factories.slice();t=t.concat(i)}return new n(t)}static extend(t){return{provide:n,useFactory:r=>n.create(t,r||ZS()),deps:[[n,new Lf,new kf]]}}find(t){const r=this.factories.find(i=>i.supports(t));if(null!=r)return r;throw new Tt(901,!1)}}return n.\u0275prov=Wn({token:n,providedIn:"root",factory:ZS}),n})();const VL=OS(null,"core",[]);let HL=(()=>{class n{constructor(t){}}return n.\u0275fac=function(t){return new(t||n)(Pn(Gy))},n.\u0275mod=_u({type:n}),n.\u0275inj=Ka({}),n})(),_d=null;function cl(){return _d}const oo=new on("DocumentToken");class N8{constructor(e,t,r,i){this.$implicit=e,this.ngForOf=t,this.index=r,this.count=i}get first(){return 0===this.index}get last(){return this.index===this.count-1}get even(){return this.index%2==0}get odd(){return!this.even}}let lC=(()=>{class n{constructor(t,r,i){this._viewContainer=t,this._template=r,this._differs=i,this._ngForOf=null,this._ngForOfDirty=!0,this._differ=null}set ngForOf(t){this._ngForOf=t,this._ngForOfDirty=!0}set ngForTrackBy(t){this._trackByFn=t}get ngForTrackBy(){return this._trackByFn}set ngForTemplate(t){t&&(this._template=t)}ngDoCheck(){if(this._ngForOfDirty){this._ngForOfDirty=!1;const t=this._ngForOf;!this._differ&&t&&(this._differ=this._differs.find(t).create(this.ngForTrackBy))}if(this._differ){const t=this._differ.diff(this._ngForOf);t&&this._applyChanges(t)}}_applyChanges(t){const r=this._viewContainer;t.forEachOperation((i,s,o)=>{if(null==i.previousIndex)r.createEmbeddedView(this._template,new N8(i.item,this._ngForOf,-1,-1),null===o?void 0:o);else if(null==o)r.remove(null===s?void 0:s);else if(null!==s){const a=r.get(s);r.move(a,o),fC(a,i)}});for(let i=0,s=r.length;i{fC(r.get(i.currentIndex),i)})}static ngTemplateContextGuard(t,r){return!0}}return n.\u0275fac=function(t){return new(t||n)(Zt(Os),Zt(ro),Zt(wd))},n.\u0275dir=Fi({type:n,selectors:[["","ngFor","","ngForOf",""]],inputs:{ngForOf:"ngForOf",ngForTrackBy:"ngForTrackBy",ngForTemplate:"ngForTemplate"},standalone:!0}),n})();function fC(n,e){n.context.$implicit=e.item}let c4=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=_u({type:n}),n.\u0275inj=Ka({}),n})();class h0 extends class N4 extends class jL{}{constructor(){super(...arguments),this.supportsDOMEvents=!0}}{static makeCurrent(){!function $L(n){_d||(_d=n)}(new h0)}onAndCancel(e,t,r){return e.addEventListener(t,r,!1),()=>{e.removeEventListener(t,r,!1)}}dispatchEvent(e,t){e.dispatchEvent(t)}remove(e){e.parentNode&&e.parentNode.removeChild(e)}createElement(e,t){return(t=t||this.getDefaultDocument()).createElement(e)}createHtmlDocument(){return document.implementation.createHTMLDocument("fakeTitle")}getDefaultDocument(){return document}isElementNode(e){return e.nodeType===Node.ELEMENT_NODE}isShadowRoot(e){return e instanceof DocumentFragment}getGlobalEventTarget(e,t){return"window"===t?window:"document"===t?e:"body"===t?e.body:null}getBaseHref(e){const t=function M4(){return dl=dl||document.querySelector("base"),dl?dl.getAttribute("href"):null}();return null==t?null:function O4(n){Md=Md||document.createElement("a"),Md.setAttribute("href",n);const e=Md.pathname;return"/"===e.charAt(0)?e:`/${e}`}(t)}resetBaseElement(){dl=null}getUserAgent(){return window.navigator.userAgent}getCookie(e){return function x8(n,e){e=encodeURIComponent(e);for(const t of n.split(";")){const r=t.indexOf("="),[i,s]=-1==r?[t,""]:[t.slice(0,r),t.slice(r+1)];if(i.trim()===e)return decodeURIComponent(s)}return null}(document.cookie,e)}}let Md,dl=null;const bC=new on("TRANSITION_ID"),L4=[{provide:DS,useFactory:function k4(n,e,t){return()=>{t.get(yd).donePromise.then(()=>{const r=cl(),i=e.querySelectorAll(`style[ng-transition="${n}"]`);for(let s=0;s{class n{build(){return new XMLHttpRequest}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();const Od=new on("EventManagerPlugins");let kd=(()=>{class n{constructor(t,r){this._zone=r,this._eventNameToPlugin=new Map,t.forEach(i=>i.manager=this),this._plugins=t.slice().reverse()}addEventListener(t,r,i){return this._findPluginFor(r).addEventListener(t,r,i)}addGlobalEventListener(t,r,i){return this._findPluginFor(r).addGlobalEventListener(t,r,i)}getZone(){return this._zone}_findPluginFor(t){const r=this._eventNameToPlugin.get(t);if(r)return r;const i=this._plugins;for(let s=0;s{class n{constructor(){this._stylesSet=new Set}addStyles(t){const r=new Set;t.forEach(i=>{this._stylesSet.has(i)||(this._stylesSet.add(i),r.add(i))}),this.onStylesAdded(r)}onStylesAdded(t){}getAllStyles(){return Array.from(this._stylesSet)}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})(),hl=(()=>{class n extends _C{constructor(t){super(),this._doc=t,this._hostNodes=new Map,this._hostNodes.set(t.head,[])}_addStylesToHost(t,r,i){t.forEach(s=>{const o=this._doc.createElement("style");o.textContent=s,i.push(r.appendChild(o))})}addHost(t){const r=[];this._addStylesToHost(this._stylesSet,t,r),this._hostNodes.set(t,r)}removeHost(t){const r=this._hostNodes.get(t);r&&r.forEach(DC),this._hostNodes.delete(t)}onStylesAdded(t){this._hostNodes.forEach((r,i)=>{this._addStylesToHost(t,i,r)})}ngOnDestroy(){this._hostNodes.forEach(t=>t.forEach(DC))}}return n.\u0275fac=function(t){return new(t||n)(Pn(oo))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();function DC(n){cl().remove(n)}const p0={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/",math:"http://www.w3.org/1998/MathML/"},g0=/%COMP%/g;function Ld(n,e,t){for(let r=0;r{if("__ngUnwrap__"===e)return n;!1===n(e)&&(e.preventDefault(),e.returnValue=!1)}}let y0=(()=>{class n{constructor(t,r,i){this.eventManager=t,this.sharedStylesHost=r,this.appId=i,this.rendererByCompId=new Map,this.defaultRenderer=new m0(t)}createRenderer(t,r){if(!t||!r)return this.defaultRenderer;switch(r.encapsulation){case Is.Emulated:{let i=this.rendererByCompId.get(r.id);return i||(i=new j4(this.eventManager,this.sharedStylesHost,r,this.appId),this.rendererByCompId.set(r.id,i)),i.applyToHost(t),i}case 1:case Is.ShadowDom:return new z4(this.eventManager,this.sharedStylesHost,t,r);default:if(!this.rendererByCompId.has(r.id)){const i=Ld(r.id,r.styles,[]);this.sharedStylesHost.addStyles(i),this.rendererByCompId.set(r.id,this.defaultRenderer)}return this.defaultRenderer}}begin(){}end(){}}return n.\u0275fac=function(t){return new(t||n)(Pn(kd),Pn(hl),Pn(ol))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();class m0{constructor(e){this.eventManager=e,this.data=Object.create(null),this.destroyNode=null}destroy(){}createElement(e,t){return t?document.createElementNS(p0[t]||t,e):document.createElement(e)}createComment(e){return document.createComment(e)}createText(e){return document.createTextNode(e)}appendChild(e,t){(AC(e)?e.content:e).appendChild(t)}insertBefore(e,t,r){e&&(AC(e)?e.content:e).insertBefore(t,r)}removeChild(e,t){e&&e.removeChild(t)}selectRootElement(e,t){let r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error(`The selector "${e}" did not match any elements`);return t||(r.textContent=""),r}parentNode(e){return e.parentNode}nextSibling(e){return e.nextSibling}setAttribute(e,t,r,i){if(i){t=i+":"+t;const s=p0[i];s?e.setAttributeNS(s,t,r):e.setAttribute(t,r)}else e.setAttribute(t,r)}removeAttribute(e,t,r){if(r){const i=p0[r];i?e.removeAttributeNS(i,t):e.removeAttribute(`${r}:${t}`)}else e.removeAttribute(t)}addClass(e,t){e.classList.add(t)}removeClass(e,t){e.classList.remove(t)}setStyle(e,t,r,i){i&(gi.DashCase|gi.Important)?e.style.setProperty(t,r,i&gi.Important?"important":""):e.style[t]=r}removeStyle(e,t,r){r&gi.DashCase?e.style.removeProperty(t):e.style[t]=""}setProperty(e,t,r){e[t]=r}setValue(e,t){e.nodeValue=t}listen(e,t,r){return"string"==typeof e?this.eventManager.addGlobalEventListener(e,t,IC(r)):this.eventManager.addEventListener(e,t,IC(r))}}function AC(n){return"TEMPLATE"===n.tagName&&void 0!==n.content}class j4 extends m0{constructor(e,t,r,i){super(e),this.component=r;const s=Ld(i+"-"+r.id,r.styles,[]);t.addStyles(s),this.contentAttr=function H4(n){return"_ngcontent-%COMP%".replace(g0,n)}(i+"-"+r.id),this.hostAttr=function K4(n){return"_nghost-%COMP%".replace(g0,n)}(i+"-"+r.id)}applyToHost(e){super.setAttribute(e,this.hostAttr,"")}createElement(e,t){const r=super.createElement(e,t);return super.setAttribute(r,this.contentAttr,""),r}}class z4 extends m0{constructor(e,t,r,i){super(e),this.sharedStylesHost=t,this.hostEl=r,this.shadowRoot=r.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);const s=Ld(i.id,i.styles,[]);for(let o=0;o{class n extends wC{constructor(t){super(t)}supports(t){return!0}addEventListener(t,r,i){return t.addEventListener(r,i,!1),()=>this.removeEventListener(t,r,i)}removeEventListener(t,r,i){return t.removeEventListener(r,i)}}return n.\u0275fac=function(t){return new(t||n)(Pn(oo))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();const xC=["alt","control","meta","shift"],W4={"\b":"Backspace","\t":"Tab","\x7f":"Delete","\x1b":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},q4={alt:n=>n.altKey,control:n=>n.ctrlKey,meta:n=>n.metaKey,shift:n=>n.shiftKey};let Y4=(()=>{class n extends wC{constructor(t){super(t)}supports(t){return null!=n.parseEventName(t)}addEventListener(t,r,i){const s=n.parseEventName(r),o=n.eventCallback(s.fullKey,i,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>cl().onAndCancel(t,s.domEventName,o))}static parseEventName(t){const r=t.toLowerCase().split("."),i=r.shift();if(0===r.length||"keydown"!==i&&"keyup"!==i)return null;const s=n._normalizeKey(r.pop());let o="",a=r.indexOf("code");if(a>-1&&(r.splice(a,1),o="code."),xC.forEach(_=>{const R=r.indexOf(_);R>-1&&(r.splice(R,1),o+=_+".")}),o+=s,0!=r.length||0===s.length)return null;const u={};return u.domEventName=i,u.fullKey=o,u}static matchEventFullKeyCode(t,r){let i=W4[t.key]||t.key,s="";return r.indexOf("code.")>-1&&(i=t.code,s="code."),!(null==i||!i)&&(i=i.toLowerCase()," "===i?i="space":"."===i&&(i="dot"),xC.forEach(o=>{o!==i&&(0,q4[o])(t)&&(s+=o+".")}),s+=i,s===r)}static eventCallback(t,r,i){return s=>{n.matchEventFullKeyCode(s,t)&&i.runGuarded(()=>r(s))}}static _normalizeKey(t){return"esc"===t?"escape":t}}return n.\u0275fac=function(t){return new(t||n)(Pn(oo))},n.\u0275prov=Wn({token:n,factory:n.\u0275fac}),n})();const PC=[{provide:IS,useValue:"browser"},{provide:CS,useValue:function Q4(){h0.makeCurrent()},multi:!0},{provide:oo,useFactory:function X4(){return function BR(n){Zp=n}(document),document},deps:[]}],J4=OS(VL,"browser",PC),NC=new on(""),MC=[{provide:md,useClass:class B4{addToWindow(e){Fn.getAngularTestability=(r,i=!0)=>{const s=e.findTestabilityInTree(r,i);if(null==s)throw new Error("Could not find testability for element.");return s},Fn.getAllAngularTestabilities=()=>e.getAllTestabilities(),Fn.getAllAngularRootElements=()=>e.getAllRootElements(),Fn.frameworkStabilizers||(Fn.frameworkStabilizers=[]),Fn.frameworkStabilizers.push(r=>{const i=Fn.getAllAngularTestabilities();let s=i.length,o=!1;const a=function(u){o=o||u,s--,0==s&&r(o)};i.forEach(function(u){u.whenStable(a)})})}findTestabilityInTree(e,t,r){return null==t?null:e.getTestability(t)??(r?cl().isShadowRoot(t)?this.findTestabilityInTree(e,t.host,!0):this.findTestabilityInTree(e,t.parentElement,!0):null)}},deps:[]},{provide:PS,useClass:Hy,deps:[Gr,Ky,md]},{provide:Hy,useClass:Hy,deps:[Gr,Ky,md]}],OC=[{provide:og,useValue:"root"},{provide:fc,useFactory:function Z4(){return new fc},deps:[]},{provide:Od,useClass:G4,multi:!0,deps:[oo,Gr,IS]},{provide:Od,useClass:Y4,multi:!0,deps:[oo]},{provide:y0,useClass:y0,deps:[kd,hl,ol]},{provide:Ow,useExisting:y0},{provide:_C,useExisting:hl},{provide:hl,useClass:hl,deps:[oo]},{provide:kd,useClass:kd,deps:[Od,Gr]},{provide:class h4{},useClass:F4,deps:[]},[]];let eB=(()=>{class n{constructor(t){}static withServerTransition(t){return{ngModule:n,providers:[{provide:ol,useValue:t.appId},{provide:bC,useExisting:ol},L4]}}}return n.\u0275fac=function(t){return new(t||n)(Pn(NC,12))},n.\u0275mod=_u({type:n}),n.\u0275inj=Ka({providers:[...OC,...MC],imports:[c4,HL]}),n})();typeof window<"u"&&window;class lB extends pr{constructor(e){super(),this._value=e}get value(){return this.getValue()}_subscribe(e){const t=super._subscribe(e);return!t.closed&&e.next(this._value),t}getValue(){const{hasError:e,thrownError:t,_value:r}=this;if(e)throw t;return this._throwIfClosed(),r}next(e){super.next(this._value=e)}}function BC(n,e,t,r,i,s,o){try{var a=n[s](o),u=a.value}catch(_){return void t(_)}a.done?e(u):Promise.resolve(u).then(r,i)}function $(n){return function(){var e=this,t=arguments;return new Promise(function(r,i){var s=n.apply(e,t);function o(u){BC(s,r,i,o,a,"next",u)}function a(u){BC(s,r,i,o,a,"throw",u)}o(void 0)})}}var fB=x(5705),b0=x(5006),FC=x(893),UC=x(5876);const dB={hashSHA256:n=>(0,FC.vp)(n),getHKDF(n,e){const i=new fB.t(FC.mE,e,n).expand(96);return[i.subarray(0,32),i.subarray(32,64),i.subarray(64,96)]},generateX25519KeyPair(){const n=b0.Au();return{publicKey:n.publicKey,privateKey:n.secretKey}},generateX25519KeyPairFromSeed(n){const e=b0._w(n);return{publicKey:e.publicKey,privateKey:e.secretKey}},generateX25519SharedKey:(n,e)=>b0.gi(n,e),chaCha20Poly1305Encrypt:(n,e,t,r)=>new UC.OK(r).seal(e,n,t),chaCha20Poly1305Decrypt:(n,e,t,r)=>new UC.OK(r).open(e,n,t)};function VC(n){this.wrapped=n}function pl(n){var e,t;function i(o,a){try{var u=n[o](a),_=u.value,R=_ instanceof VC;Promise.resolve(R?_.wrapped:_).then(function(N){R?i("return"===o?"return":"next",N):s(u.done?"return":"normal",N)},function(N){i("throw",N)})}catch(N){s("throw",N)}}function s(o,a){switch(o){case"return":e.resolve({value:a,done:!0});break;case"throw":e.reject(a);break;default:e.resolve({value:a,done:!1})}(e=e.next)?i(e.key,e.arg):t=null}this._invoke=function r(o,a){return new Promise(function(u,_){var R={key:o,arg:a,resolve:u,reject:_,next:null};t?t=t.next=R:(e=t=R,i(o,a))})},"function"!=typeof n.return&&(this.return=void 0)}function hn(n){return function(){return new pl(n.apply(this,arguments))}}function lt(n){return new VC(n)}function Pt(n){var e,t,r,i=2;for(typeof Symbol<"u"&&(t=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(t&&null!=(e=n[t]))return e.call(n);if(r&&null!=(e=n[r]))return new Bd(e.call(n));t="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function Bd(n){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var r=t.done;return Promise.resolve(t.value).then(function(i){return{value:i,done:r}})}return(Bd=function(r){this.s=r,this.n=r.next}).prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(r){var i=this.s.return;return void 0===i?Promise.resolve({value:r,done:!0}):e(i.apply(this.s,arguments))},throw:function(r){var i=this.s.return;return void 0===i?Promise.reject(r):e(i.apply(this.s,arguments))}},new Bd(n)}function Mr(n,e){var t={},r=!1;function i(s,o){return r=!0,o=new Promise(function(a){a(n[s](o))}),{done:!1,value:e(o)}}return t[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},t.next=function(s){return r?(r=!1,s):i("next",s)},"function"==typeof n.throw&&(t.throw=function(s){if(r)throw r=!1,s;return i("throw",s)}),"function"==typeof n.return&&(t.return=function(s){return r?(r=!1,s):i("return",s)}),t}function Lo(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.alloc?globalThis.Buffer.alloc(n):new Uint8Array(n)}function Oc(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}function br(n,e){e||(e=n.reduce((i,s)=>i+s.length,0));const t=Oc(e);let r=0;for(const i of n)t.set(i,r),r+=i.length;return t}function kr(n,e){if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(const r of e)if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.push(r);else{if(!w0(r))throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.push(...r.bufs)}this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(const r of e.reverse())if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.unshift(r);else{if(!w0(r))throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.unshift(...r.bufs)}this.length+=t}get(e){const t=KC(this.bufs,e);return t.buf[t.index]}set(e,t){const r=KC(this.bufs,e);r.buf[r.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let r=0;r0;){if(!(e>=this.bufs[0].byteLength)){this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift()}}slice(e,t){const{bufs:r,length:i}=this._subList(e,t);return br(r,i)}subarray(e,t){const{bufs:r,length:i}=this._subList(e,t);return 1===r.length?r[0]:br(r,i)}sublist(e,t){const{bufs:r,length:i}=this._subList(e,t),s=new qr;return s.length=i,s.bufs=r,s}_subList(e,t){if((e=e??0)<0&&(e=this.length+e),(t=t??this.length)<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:[...this.bufs],length:this.length};const r=[];let i=0;for(let s=0;s=u)continue;const _=e>=a&&ea&&t<=u;if(_&&R){if(e===a&&t===u){r.push(o);break}const N=e-a;r.push(o.subarray(N,N+(t-e)));break}if(_){if(0===e){r.push(o);continue}r.push(o.subarray(e-a))}else{if(R){if(t===u){r.push(o);break}r.push(o.subarray(0,t-a));break}r.push(o)}}return{bufs:r,length:t-e}}getInt8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=Oc(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}getInt16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}setInt16(e,t,r){const i=Lo(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,t,r),this.write(i,e)}getInt32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}setInt32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,t,r),this.write(i,e)}getBigInt64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}setBigInt64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,t,r),this.write(i,e)}getUint8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){const r=Oc(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}getUint16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}setUint16(e,t,r){const i=Lo(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,t,r),this.write(i,e)}getUint32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}setUint32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,t,r),this.write(i,e)}getBigUint64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}setBigUint64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,t,r),this.write(i,e)}getFloat32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}setFloat32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,t,r),this.write(i,e)}getFloat64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}setFloat64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,r),this.write(i,e)}equals(e){if(null==e||!(e instanceof qr)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;ti+s.byteLength,0)),r.length=t,r}}class $C{constructor(e){if(!(e>0)||0!=(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class _0{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new $C(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=e?.byteLength?e.byteLength:1}push(e){null!=e?.value&&(this.size+=this.calculateSize(e.value)),this.head.push(e)||(this.head=this.head.next=new $C(2*this.head.buffer.length),this.head.push(e))}shift(){let e=this.tail.shift();if(void 0===e&&null!=this.tail.next){const t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return null!=e?.value&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}}function kc(n={}){return jC(t=>{const r=t.shift();if(null==r)return{done:!0};if(null!=r.error)throw r.error;return{done:!0===r.done,value:r.value}},n)}function jC(n,e){let i,s,o,t=(e=e??{}).onEnd,r=new _0;const a=function(){var J=$(function*(){return r.isEmpty()?o?{done:!0}:yield new Promise((oe,de)=>{s=xe=>{s=null,r.push(xe);try{oe(n(r))}catch(ue){de(ue)}return i}}):n(r)});return function(){return J.apply(this,arguments)}}(),u=J=>null!=s?s(J):(r.push(J),i),R=J=>{if(o)return i;if(!0!==e?.objectMode&&null==J?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:J})},N=J=>o?i:(o=!0,null!=J?(J=>(r=new _0,null!=s?s({error:J}):(r.push({error:J}),i)))(J):u({done:!0}));if(i={[Symbol.asyncIterator](){return this},next:a,return:()=>(r=new _0,N(),{done:!0}),throw:J=>(N(J),{done:!0}),push:R,end:N,get readableLength(){return r.size}},null==t)return i;const X=i;return i={[Symbol.asyncIterator](){return this},next:()=>X.next(),throw:J=>(X.throw(J),null!=t&&(t(J),t=void 0),{done:!0}),return:()=>(X.return(),null!=t&&(t(),t=void 0),{done:!0}),push:R,end:J=>(X.end(J),null!=t&&(t(J),t=void 0),i),get readableLength(){return X.readableLength}},i}function D0(){const n={};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),n}function Fd(n){const e=kc(),t=function hB(n){const e=hn(function*(){let t=yield,r=new qr;var o,i=!1,s=!1;try{for(var u,a=Pt(n);i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;if(null!=t)for(r.append(_);r.length>=t;){const R=r.sublist(0,t);if(r.consume(t),t=yield R,null==t){r.length>0&&(t=yield r,r=new qr);break}}else r.append(_),t=yield r,r=new qr}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}if(null!=t)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:r})})();return e.next(),e}(n.source),r=D0();let i;const s=n.sink(hn(function*(){yield*Mr(Pt(e),lt);const a=yield lt(r.promise);yield*Mr(Pt(a),lt)})());s.catch(a=>{i=a});const o={sink:(a=$(function*(u){return null!=i?yield Promise.reject(i):(r.resolve(u),yield s)}),function(_){return a.apply(this,arguments)}),source:t};var a;return{reader:t,writer:e,stream:o,rest:()=>e.end(),write:e.push,read:function(){var a=$(function*(){const u=yield t.next();if(null!=u.value)return u.value});return function(){return a.apply(this,arguments)}}()}}function zC(n){return n instanceof Uint8Array?{get:e=>n[e],set(e,t){n[e]=t}}:{get:e=>n.get(e),set(e,t){n.set(e,t)}}}const GC=4294967296;class zi{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(!0===e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!=0){const t=1+~this.lo>>>0;let r=~this.hi>>>0;return 0===t&&(r=r+1>>>0),-(BigInt(t)+(BigInt(r)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){const e=-(1&this.lo);return new zi((this.hi>>>1^e)>>>0,((this.lo>>>1|this.hi<<31)^e)>>>0)}zzEncode(){const e=this.hi>>31;return new zi(((this.hi<<1|this.lo>>>31)^e)>>>0,(this.lo<<1^e)>>>0)}toBytes(e,t=0){const r=zC(e);for(;this.hi>0;)r.set(t++,127&this.lo|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)r.set(t++,127&this.lo|128),this.lo=this.lo>>>7;r.set(t++,this.lo)}static fromBigInt(e){if(0n===e)return new zi;const t=e<0;t&&(e=-e);let r=0|Number(e>>32n),i=0|Number(e-(BigInt(r)<<32n));return t&&(r=~r>>>0,i=~i>>>0,++i>GC&&(i=0,++r>GC&&(r=0))),new zi(r,i)}static fromNumber(e){if(0===e)return new zi;const t=e<0;t&&(e=-e);let r=e>>>0,i=(e-r)/4294967296>>>0;return t&&(i=~i>>>0,r=~r>>>0,++r>4294967295&&(r=0,++i>4294967295&&(i=0))),new zi(i,r)}static fromBytes(e,t=0){const r=zC(e),i=new zi;let s=0;if(e.length-t>4){for(;s<4;++s)if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i;if(i.lo=(i.lo|(127&r.get(t))<<28)>>>0,i.hi=(i.hi|(127&r.get(t))>>4)>>>0,r.get(t++)<128)return i;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i}if(e.length-t>4){for(;s<5;++s)if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}else if(t=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}throw RangeError("invalid varint encoding")}}const gB=Math.pow(2,7),yB=Math.pow(2,14),mB=Math.pow(2,21),vB=Math.pow(2,28),EB=Math.pow(2,35),bB=Math.pow(2,42),wB=Math.pow(2,49),_B=Math.pow(2,56),DB=Math.pow(2,63),Ni={encodingLength:n=>nNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return null==e&&(e=Oc(Ni.encodingLength(n))),zi.fromNumber(n).toBytes(e,t),e},decode:(n,e=0)=>zi.fromBytes(n,e).toNumber(!0)},Ud=n=>{const e=Ni.encodingLength(n),t=function CB(n){return null!=globalThis?.Buffer?.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}(e);return Ni.encode(n,t),Ud.bytes=e,t};function ks(n){const e=(n=n??{}).lengthEncoder??Ud;return function(){var r=hn(function*(i){var a,s=!1,o=!1;try{for(var _,u=Pt(i);s=!(_=yield lt(u.next())).done;s=!1){const R=_.value,N=e(R.byteLength);N instanceof Uint8Array?yield N:yield*Mr(Pt(N),lt),R instanceof Uint8Array?yield R:yield*Mr(Pt(R),lt)}}catch(R){o=!0,a=R}finally{try{s&&null!=u.return&&(yield lt(u.return()))}finally{if(o)throw a}}});return function(s){return r.apply(this,arguments)}}()}Ud.bytes=0,ks.single=(n,e)=>new qr(((e=e??{}).lengthEncoder??Ud)(n.byteLength),n);var ae=x(2535),Bo=(()=>{return(n=Bo||(Bo={}))[n.LENGTH=0]="LENGTH",n[n.DATA=1]="DATA",Bo;var n})();const S0=n=>{const e=Ni.decode(n);return S0.bytes=Ni.encodingLength(e),e};function ps(n){return function(){var t=hn(function*(r){const i=new qr;let s=Bo.LENGTH,o=-1;const a=n?.lengthDecoder??S0,u=n?.maxLengthLength??8,_=n?.maxDataLength??4194304;var B,R=!1,N=!1;try{for(var X,z=Pt(r);R=!(X=yield lt(z.next())).done;R=!1)for(i.append(X.value);i.byteLength>0;){if(s===Bo.LENGTH)try{if(o=a(i),o<0)throw ae(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>_)throw ae(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");i.consume(a.bytes),null!=n?.onLength&&n.onLength(o),s=Bo.DATA}catch(oe){if(oe instanceof RangeError){if(i.byteLength>u)throw ae(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw oe}if(s===Bo.DATA){if(i.byteLength0)throw ae(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")});return function(i){return t.apply(this,arguments)}}()}function WC(n,e={}){const t=Fd(n),r=ps.fromReader(t.reader,e),i={read:(s=$(function*(o){const{value:a}=yield t.reader.next(o);if(null==a)throw new Error("Value is null");return a}),function(a){return s.apply(this,arguments)}),readLP:function(){var s=$(function*(){const{value:o}=yield r.next();if(null==o)throw new Error("Value is null");return o});return function(){return s.apply(this,arguments)}}(),readPB:function(){var s=$(function*(o){const a=yield i.readLP();if(null==a)throw new Error("Value is null");const u=a instanceof Uint8Array?a:a.slice();return o.decode(u)});return function(a){return s.apply(this,arguments)}}(),write:s=>{s instanceof Uint8Array?t.writer.push(s):t.writer.push(s.slice())},writeLP:s=>{i.write(ks.single(s,e))},writePB:(s,o)=>{i.writeLP(o.encode(s))},pb:s=>{return{read:(o=$(function*(){return yield i.readPB(s)}),function(){return o.apply(this,arguments)}),write:o=>i.writePB(o,s)};var o},unwrap:()=>(t.rest(),t.stream)};var s;return i}function qC(){const n=D0();let e=!1;return{sink:(t=$(function*(r){if(e)throw new Error("already piped");e=!0,n.resolve(r)}),function(i){return t.apply(this,arguments)}),source:hn(function*(){const t=yield lt(n.promise);yield*Mr(Pt(t),lt)})()};var t}S0.bytes=0,ps.fromReader=(n,e)=>{let t=1;const r=hn(function*(){for(;;)try{const{done:s,value:o}=yield lt(n.next(t));if(!0===s)return;null!=o&&(yield o)}catch(s){if("ERR_UNDER_READ"===s.code)return{done:!0,value:null};throw s}finally{t=1}})();return ps({...e??{},onLength:s=>{t=s}})(r)};var Vd=x(5061);const YC=n=>null!=n&&("function"==typeof n[Symbol.asyncIterator]||"function"==typeof n[Symbol.iterator]||"function"==typeof n.next),C0=n=>null!=n&&"function"==typeof n.sink&&YC(n.source),RB=n=>e=>{const t=n.sink(e);if(null!=t.then){const r=kc({objectMode:!0});return t.then(()=>{r.end()},s=>{r.end(s)}),Vd(r,function(){var s=hn(function*(){yield*Mr(Pt(n.source),lt),r.end()});return function(){return s.apply(this,arguments)}}()())}return n.source};function qn(n,...e){if(C0(n)){const r=n;n=()=>r.source}else if(YC(n)){const r=n;n=()=>r}const t=[n,...e];if(t.length>1&&C0(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let r=1;r{let e;for(;n.length>0;)e=n.shift()(e);return e})(...t)}const gl=65535,PB=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS),Hd=n=>{const e=globalThis.Buffer?globalThis.Buffer.allocUnsafe(2):new Uint8Array(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).setUint16(0,n,!1),e};Hd.bytes=2;const Kd=n=>{if(n.length<2)throw RangeError("Could not decode int16BE");return n instanceof Uint8Array?new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,!1):n.getUint16(0)};Kd.bytes=2;class $d extends Error{constructor(e="Unexpected Peer"){super(e),this.code=$d.code}static get code(){return"ERR_UNEXPECTED_PEER"}}class Lc extends Error{constructor(e="Invalid crypto exchange"){super(e),this.code=Lc.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}}Error;var I0=x(3863),T0=x.n(I0);const A0=I0.Reader;function Wt(n,e){const t=A0.create(n instanceof Uint8Array?n:n.subarray());return e.decode(t)}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=A0.prototype[n];A0.prototype[n]=function(){return BigInt(e.call(this).toString())}});const x0=I0.Writer;function qt(n,e){const t=x0.create();return e.encode(n,t,{lengthDelimited:!1}),t.finish()}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=x0.prototype[n];x0.prototype[n]=function(t){return e.call(this,t.toString())}});var yl=(()=>{return(n=yl||(yl={}))[n.VARINT=0]="VARINT",n[n.BIT64=1]="BIT64",n[n.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",n[n.START_GROUP=3]="START_GROUP",n[n.END_GROUP=4]="END_GROUP",n[n.BIT32=5]="BIT32",yl;var n})();function XC(n,e,t,r){return{name:n,type:e,encode:t,decode:r}}function Fo(n){function e(i){if(null==n[i.toString()])throw new Error("Invalid enum value");return n[i]}return XC("enum",yl.VARINT,function(s,o){const a=e(s);o.int32(a)},function(s){return e(s.uint32())})}function Yt(n,e){return XC("message",yl.LENGTH_DELIMITED,n,e)}var Bc,Fc,nr=(()=>{return(n=nr||(nr={})).RSA="RSA",n.Ed25519="Ed25519",n.Secp256k1="Secp256k1",nr;var n})(),jd=(()=>{return(n=jd||(jd={}))[n.RSA=0]="RSA",n[n.Ed25519=1]="Ed25519",n[n.Secp256k1=2]="Secp256k1",jd;var n})();(nr||(nr={})).codec=()=>Fo(jd),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(r.uint32(8),nr.codec().encode(t.Type,r),null==t.Data)throw new Error('Protocol error: required field "Data" was not found in object');r.uint32(18),r.bytes(t.Data),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={Type:nr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=nr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}if(null==i.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==i.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Bc||(Bc={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(r.uint32(8),nr.codec().encode(t.Type,r),null==t.Data)throw new Error('Protocol error: required field "Data" was not found in object');r.uint32(18),r.bytes(t.Data),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={Type:nr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=nr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}if(null==i.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==i.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Fc||(Fc={})),x(7791),x(2158);var Un=x(8659);const jB=function HB(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,ue=new Uint8Array(xe);X[J];){var Te=t[X.charCodeAt(J)];if(255===Te)return;for(var Ke=0,Pe=xe-1;(0!==Te||Ke>>0)%256>>>0,Te=Te/256>>>0;if(0!==Te)throw new Error("Non-zero carry");de=Ke,J++}if(" "!==X[J]){for(var bt=xe-de;bt!==xe&&0===ue[bt];)bt++;for(var yt=new Uint8Array(oe+(xe-bt)),Xt=oe;bt!==xe;)yt[Xt++]=ue[bt++];return yt}}}return{encode:function N(X){if(X instanceof Uint8Array||(ArrayBuffer.isView(X)?X=new Uint8Array(X.buffer,X.byteOffset,X.byteLength):Array.isArray(X)&&(X=Uint8Array.from(X))),!(X instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===X.length)return"";for(var J=0,oe=0,de=0,xe=X.length;de!==xe&&0===X[de];)de++,J++;for(var ue=(xe-de)*R+1>>>0,Te=new Uint8Array(ue);de!==xe;){for(var Ke=X[de],Pe=0,bt=ue-1;(0!==Ke||Pe>>0)%a>>>0,Ke=Ke/a>>>0;if(0!==Ke)throw new Error("Non-zero carry");oe=Pe,de++}for(var yt=ue-oe;yt!==ue&&0===Te[yt];)yt++;for(var Xt=u.repeat(J);yt{if(n instanceof Uint8Array&&"Uint8Array"===n.constructor.name)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")});class YB{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class QB{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return JC(this,e)}}class ZB{constructor(e){this.decoders=e}or(e){return JC(this,e)}decode(e){const r=this.decoders[e[0]];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const JC=(n,e)=>new ZB({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class XB{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new YB(e,t,r),this.decoder=new QB(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const zd=({name:n,prefix:e,encode:t,decode:r})=>new XB(n,e,t,r),ml=({prefix:n,name:e,alphabet:t})=>{const{encode:r,decode:i}=jB(t,e);return zd({prefix:n,name:e,encode:r,decode:s=>Uc(i(s))})},Lr=({name:n,prefix:e,bitsPerChar:t,alphabet:r})=>zd({prefix:e,name:n,encode:i=>((n,e,t)=>{const r="="===e[e.length-1],i=(1<t;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<((n,e,t,r)=>{const i={};for(let R=0;R=8&&(a-=8,o[_++]=255&u>>a)}if(a>=t||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return o})(i,r,t,n)}),t6=zd({prefix:"\0",name:"identity",encode:n=>(n=>(new TextDecoder).decode(n))(n),decode:n=>(n=>(new TextEncoder).encode(n))(n)}),n6=Lr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),r6=Lr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),i6=ml({prefix:"9",name:"base10",alphabet:"0123456789"}),s6=Lr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),o6=Lr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),co=Lr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),a6=Lr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),c6=Lr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),u6=Lr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),l6=Lr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),f6=Lr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),d6=Lr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),h6=Lr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),p6=Lr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),g6=ml({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),y6=ml({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ui=ml({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),m6=ml({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Gd=Lr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),v6=Lr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),E6=Lr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),b6=Lr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),eI=Array.from("\u{1f680}\u{1fa90}\u2604\u{1f6f0}\u{1f30c}\u{1f311}\u{1f312}\u{1f313}\u{1f314}\u{1f315}\u{1f316}\u{1f317}\u{1f318}\u{1f30d}\u{1f30f}\u{1f30e}\u{1f409}\u2600\u{1f4bb}\u{1f5a5}\u{1f4be}\u{1f4bf}\u{1f602}\u2764\u{1f60d}\u{1f923}\u{1f60a}\u{1f64f}\u{1f495}\u{1f62d}\u{1f618}\u{1f44d}\u{1f605}\u{1f44f}\u{1f601}\u{1f525}\u{1f970}\u{1f494}\u{1f496}\u{1f499}\u{1f622}\u{1f914}\u{1f606}\u{1f644}\u{1f4aa}\u{1f609}\u263a\u{1f44c}\u{1f917}\u{1f49c}\u{1f614}\u{1f60e}\u{1f607}\u{1f339}\u{1f926}\u{1f389}\u{1f49e}\u270c\u2728\u{1f937}\u{1f631}\u{1f60c}\u{1f338}\u{1f64c}\u{1f60b}\u{1f497}\u{1f49a}\u{1f60f}\u{1f49b}\u{1f642}\u{1f493}\u{1f929}\u{1f604}\u{1f600}\u{1f5a4}\u{1f603}\u{1f4af}\u{1f648}\u{1f447}\u{1f3b6}\u{1f612}\u{1f92d}\u2763\u{1f61c}\u{1f48b}\u{1f440}\u{1f62a}\u{1f611}\u{1f4a5}\u{1f64b}\u{1f61e}\u{1f629}\u{1f621}\u{1f92a}\u{1f44a}\u{1f973}\u{1f625}\u{1f924}\u{1f449}\u{1f483}\u{1f633}\u270b\u{1f61a}\u{1f61d}\u{1f634}\u{1f31f}\u{1f62c}\u{1f643}\u{1f340}\u{1f337}\u{1f63b}\u{1f613}\u2b50\u2705\u{1f97a}\u{1f308}\u{1f608}\u{1f918}\u{1f4a6}\u2714\u{1f623}\u{1f3c3}\u{1f490}\u2639\u{1f38a}\u{1f498}\u{1f620}\u261d\u{1f615}\u{1f33a}\u{1f382}\u{1f33b}\u{1f610}\u{1f595}\u{1f49d}\u{1f64a}\u{1f639}\u{1f5e3}\u{1f4ab}\u{1f480}\u{1f451}\u{1f3b5}\u{1f91e}\u{1f61b}\u{1f534}\u{1f624}\u{1f33c}\u{1f62b}\u26bd\u{1f919}\u2615\u{1f3c6}\u{1f92b}\u{1f448}\u{1f62e}\u{1f646}\u{1f37b}\u{1f343}\u{1f436}\u{1f481}\u{1f632}\u{1f33f}\u{1f9e1}\u{1f381}\u26a1\u{1f31e}\u{1f388}\u274c\u270a\u{1f44b}\u{1f630}\u{1f928}\u{1f636}\u{1f91d}\u{1f6b6}\u{1f4b0}\u{1f353}\u{1f4a2}\u{1f91f}\u{1f641}\u{1f6a8}\u{1f4a8}\u{1f92c}\u2708\u{1f380}\u{1f37a}\u{1f913}\u{1f619}\u{1f49f}\u{1f331}\u{1f616}\u{1f476}\u{1f974}\u25b6\u27a1\u2753\u{1f48e}\u{1f4b8}\u2b07\u{1f628}\u{1f31a}\u{1f98b}\u{1f637}\u{1f57a}\u26a0\u{1f645}\u{1f61f}\u{1f635}\u{1f44e}\u{1f932}\u{1f920}\u{1f927}\u{1f4cc}\u{1f535}\u{1f485}\u{1f9d0}\u{1f43e}\u{1f352}\u{1f617}\u{1f911}\u{1f30a}\u{1f92f}\u{1f437}\u260e\u{1f4a7}\u{1f62f}\u{1f486}\u{1f446}\u{1f3a4}\u{1f647}\u{1f351}\u2744\u{1f334}\u{1f4a3}\u{1f438}\u{1f48c}\u{1f4cd}\u{1f940}\u{1f922}\u{1f445}\u{1f4a1}\u{1f4a9}\u{1f450}\u{1f4f8}\u{1f47b}\u{1f910}\u{1f92e}\u{1f3bc}\u{1f975}\u{1f6a9}\u{1f34e}\u{1f34a}\u{1f47c}\u{1f48d}\u{1f4e3}\u{1f942}"),w6=eI.reduce((n,e,t)=>(n[t]=e,n),[]),_6=eI.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]),C6=zd({prefix:"\u{1f680}",name:"base256emoji",encode:function D6(n){return n.reduce((e,t)=>e+w6[t],"")},decode:function S6(n){const e=[];for(const t of n){const r=_6[t.codePointAt(0)];if(void 0===r)throw new Error(`Non-base256emoji character: ${t}`);e.push(r)}return new Uint8Array(e)}});var x6=Math.pow(2,31),N6=Math.pow(2,7),M6=Math.pow(2,14),O6=Math.pow(2,21),k6=Math.pow(2,28),L6=Math.pow(2,35),B6=Math.pow(2,42),F6=Math.pow(2,49),U6=Math.pow(2,56),V6=Math.pow(2,63),K6={encode:function nI(n,e,t){e=e||[];for(var r=t=t||0;n>=x6;)e[t++]=255&n|128,n/=128;for(;-128&n;)e[t++]=255&n|128,n>>>=7;return e[t]=0|n,nI.bytes=t-r+1,e},decode:function R0(n,r){var o,t=0,i=0,s=r=r||0,a=n.length;do{if(s>=a)throw R0.bytes=0,new RangeError("Could not decode varint");o=n[s++],t+=i<28?(127&o)<=128);return R0.bytes=s-r,t},encodingLength:function(n){return n[Wd.decode(n),Wd.decode.bytes],qd=(n,e,t=0)=>(Wd.encode(n,e,t),e),Yd=n=>Wd.encodingLength(n),Vc=(n,e)=>{const t=e.byteLength,r=Yd(n),i=r+Yd(t),s=new Uint8Array(i+t);return qd(n,s,0),qd(t,s,r),s.set(e,i),new N0(n,t,e,s)},Qd=n=>{const e=Uc(n),[t,r]=P0(e),[i,s]=P0(e.subarray(r)),o=e.subarray(r+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new N0(t,i,o,e)};class N0{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const iI=({name:n,code:e,encode:t})=>new z6(n,e,t);class z6{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Vc(this.code,t):t.then(r=>Vc(this.code,r))}throw Error("Unknown type, must be binary type")}}const sI=n=>function(){var e=$(function*(t){return new Uint8Array(yield crypto.subtle.digest(n,t))});return function(t){return e.apply(this,arguments)}}(),mi=iI({name:"sha2-256",code:18,encode:sI("SHA-256")}),G6=iI({name:"sha2-512",code:19,encode:sI("SHA-512")}),aI=Uc,Hc={code:0,name:"identity",encode:aI,digest:n=>Vc(0,aI(n))},q6="raw",Y6=85,Q6=n=>Uc(n),Z6=n=>Uc(n),X6=new TextEncoder,J6=new TextDecoder,eF="json",tF=512,nF=n=>X6.encode(JSON.stringify(n)),rF=n=>JSON.parse(J6.decode(n));class wr{constructor(e,t,r,i){this.code=t,this.version=e,this.multihash=r,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Xd,byteLength:Xd,code:Zd,version:Zd,multihash:Zd,bytes:Zd,_baseCache:Xd,asCID:Xd})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==vl)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==aF)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return wr.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=Vc(e,t);return wr.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&((n,e)=>n===e||n.code===e.code&&n.size===e.size&&((n,e)=>{if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t{const[N,B]=P0(e.subarray(t));return t+=B,N};let i=r(),s=vl;if(18===i?(i=0,t=0):1===i&&(s=r()),0!==i&&1!==i)throw new RangeError(`Invalid CID version ${i}`);const o=t,a=r(),u=r(),_=t+u;return{version:i,codec:s,multihashCode:a,digestSize:u,multihashSize:_-o,size:_}}static parse(e,t){const[r,i]=iF(e,t),s=wr.decode(i);return s._baseCache.set(r,e),s}}const iF=(n,e)=>{switch(n[0]){case"Q":return[ui.prefix,(e||ui).decode(`${ui.prefix}${n}`)];case ui.prefix:return[ui.prefix,(e||ui).decode(n)];case co.prefix:return[co.prefix,(e||co).decode(n)];default:if(null==e)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[n[0],e.decode(n)]}},sF=(n,e,t)=>{const{prefix:r}=t;if(r!==ui.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);const i=e.get(r);if(null==i){const s=t.encode(n).slice(1);return e.set(r,s),s}return i},oF=(n,e,t)=>{const{prefix:r}=t,i=e.get(r);if(null==i){const s=t.encode(n);return e.set(r,s),s}return i},vl=112,aF=18,cI=(n,e,t)=>{const r=Yd(n),i=r+Yd(e),s=new Uint8Array(i+t.byteLength);return qd(n,s,0),qd(e,s,r),s.set(t,i),s},uI=Symbol.for("@ipld/js-cid/CID"),Zd={writable:!1,configurable:!1,enumerable:!0},Xd={writable:!1,enumerable:!1,configurable:!1},uF=(n,e)=>{if(!n.test("0.0.0-dev"))throw new Error(e);console.warn(e)},lF="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n",El={...y,...l,...g,...w,...m,...h,...c,...f,...d,...b};function lI(n,e,t,r){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:r}}}const fI=lI("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>(new TextEncoder).encode(n.substring(1))),M0=lI("ascii","a",n=>{let e="a";for(let t=0;t{const e=Oc((n=n.substring(1)).length);for(let t=0;te)throw new Error("byte array longer than desired length");t=br([new Uint8Array(e-t.length),t])}return Lt(t,"base64url")}function gs(n){const e=function pF(n,e){let t=Ot(n,"base64urlpad");if(null!=e){if(t.length>e)throw new Error("byte array longer than desired length");t=br([new Uint8Array(e-t.length),t])}return t}(n);return new Un.jsbn.BigInteger(Lt(e,"base16"),16)}x(730);function mI(n){const e=n?.algorithm??"AES-GCM";let t=n?.keyLength??16;const r=n?.nonceLength??12,i=n?.digest??"SHA-256",s=n?.saltLength??16,o=n?.iterations??32767,a=Ls.get();function _(){return(_=$(function*(z,X){const J=a.getRandomValues(new Uint8Array(s)),oe=a.getRandomValues(new Uint8Array(r)),de={name:e,iv:oe};"string"==typeof X&&(X=Ot(X));const xe={name:"PBKDF2",salt:J,iterations:o,hash:{name:i}},ue=yield a.subtle.importKey("raw",X,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Te=yield a.subtle.deriveKey(xe,ue,{name:e,length:t},!0,["encrypt"]),Ke=yield a.subtle.encrypt(de,Te,z);return br([J,de.iv,new Uint8Array(Ke)])})).apply(this,arguments)}function N(){return(N=$(function*(z,X){const J=z.slice(0,s),oe=z.slice(s,s+r),de=z.slice(s+r),xe={name:e,iv:oe};"string"==typeof X&&(X=Ot(X));const ue={name:"PBKDF2",salt:J,iterations:o,hash:{name:i}},Te=yield a.subtle.importKey("raw",X,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Ke=yield a.subtle.deriveKey(ue,Te,{name:e,length:t},!0,["decrypt"]),Pe=yield a.subtle.decrypt(xe,Ke,de);return new Uint8Array(Pe)})).apply(this,arguments)}return t*=8,{encrypt:function u(z,X){return _.apply(this,arguments)},decrypt:function R(z,X){return N.apply(this,arguments)}}}function mF(n,e){return F0.apply(this,arguments)}function F0(){return(F0=$(function*(n,e){const t=Gd.decode(n);return yield mI().decrypt(t,e)})).apply(this,arguments)}Object.keys({"P-256":256,"P-384":384,"P-521":521}).join(" / "),x(8985);var vF=x(5856),EF=x.t(vF,2);const ln=BigInt(0),Yn=BigInt(1),Uo=BigInt(2),bl=BigInt(3),bF=BigInt(8),Mn=Object.freeze({a:ln,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Yn,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});function vI(n){const{a:e,b:t}=Mn,r=at(n*n),i=at(r*n);return at(i+e*n+t)}const Jd=Mn.a===ln;class U0 extends Error{constructor(e){super(e)}}class On{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof Tn))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new On(e.x,e.y,Yn)}static toAffineBatch(e){const t=function CF(n,e=Mn.P){const t=new Array(n.length),i=zc(n.reduce((s,o,a)=>o===ln?s:(t[a]=s,at(s*o,e)),Yn),e);return n.reduceRight((s,o,a)=>o===ln?s:(t[a]=at(s*t[a],e),at(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return On.toAffineBatch(e).map(On.fromAffine)}equals(e){if(!(e instanceof On))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,u=at(i*i),_=at(a*a),R=at(t*_),N=at(s*u),B=at(at(r*a)*_),z=at(at(o*i)*u);return R===N&&B===z}negate(){return new On(this.x,at(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,i=at(e*e),s=at(t*t),o=at(s*s),a=e+s,u=at(Uo*(at(a*a)-i-o)),_=at(bl*i),R=at(_*_),N=at(R-Uo*u),B=at(_*(u-N)-bF*o),z=at(Uo*t*r);return new On(N,B,z)}add(e){if(!(e instanceof On))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e;if(s===ln||o===ln)return this;if(t===ln||r===ln)return e;const u=at(i*i),_=at(a*a),R=at(t*_),N=at(s*u),B=at(at(r*a)*_),z=at(at(o*i)*u),X=at(N-R),J=at(z-B);if(X===ln)return J===ln?this.double():On.ZERO;const oe=at(X*X),de=at(X*oe),xe=at(R*oe),ue=at(J*J-de-Uo*xe),Te=at(J*(xe-ue)-B*de),Ke=at(i*a*X);return new On(ue,Te,Ke)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=On.ZERO;if("bigint"==typeof e&&e===ln)return t;let r=wI(e);if(r===Yn)return this;if(!Jd){let N=t,B=this;for(;r>ln;)r&Yn&&(N=N.add(B)),B=B.double(),r>>=Yn;return N}let{k1neg:i,k1:s,k2neg:o,k2:a}=DI(r),u=t,_=t,R=this;for(;s>ln||a>ln;)s&Yn&&(u=u.add(R)),a&Yn&&(_=_.add(R)),R=R.double(),s>>=Yn,a>>=Yn;return i&&(u=u.negate()),o&&(_=_.negate()),_=new On(at(_.x*Mn.beta),_.y,_.z),u.add(_)}precomputeWindow(e){const t=Jd?128/e+1:256/e+1,r=[];let i=this,s=i;for(let o=0;o>=N,X>u&&(X-=R,e+=Yn),0===X){let J=i[z];B%2&&(J=J.negate()),o=o.add(J)}else{let J=i[z+Math.abs(X)-1];X<0&&(J=J.negate()),s=s.add(J)}}return{p:s,f:o}}multiply(e,t){let i,s,r=wI(e);if(Jd){const{k1neg:o,k1:a,k2neg:u,k2:_}=DI(r);let{p:R,f:N}=this.wNAF(a,t),{p:B,f:z}=this.wNAF(_,t);o&&(R=R.negate()),u&&(B=B.negate()),B=new On(at(B.x*Mn.beta),B.y,B.z),i=R.add(B),s=N.add(z)}else{const{p:o,f:a}=this.wNAF(r,t);i=o,s=a}return On.normalizeZ([i,s])[0]}toAffine(e=zc(this.z)){const{x:t,y:r,z:i}=this,s=e,o=at(s*s),a=at(o*s),u=at(t*o),_=at(r*a);if(at(i*s)!==Yn)throw new Error("invZ was invalid");return new Tn(u,_)}}On.BASE=new On(Mn.Gx,Mn.Gy,Yn),On.ZERO=new On(ln,Yn,ln);const V0=new WeakMap;class Tn{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,V0.delete(this)}hasEvenY(){return this.y%Uo===ln}static fromCompressedHex(e){const t=32===e.length,r=vi(t?e:e.subarray(1));if(!th(r))throw new Error("Point is not on curve");let s=function SF(n){const{P:e}=Mn,t=BigInt(6),r=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),u=n*n*n%e,_=u*u*n%e,R=Gi(_,bl)*_%e,N=Gi(R,bl)*_%e,B=Gi(N,Uo)*u%e,z=Gi(B,r)*B%e,X=Gi(z,i)*z%e,J=Gi(X,o)*X%e,oe=Gi(J,a)*J%e,de=Gi(oe,o)*X%e,xe=Gi(de,bl)*_%e,ue=Gi(xe,s)*z%e,Te=Gi(ue,t)*u%e;return Gi(Te,Uo)}(vI(r));const o=(s&Yn)===Yn;t?o&&(s=at(-s)):1==(1&e[0])!==o&&(s=at(-s));const a=new Tn(r,s);return a.assertValidity(),a}static fromUncompressedHex(e){const t=vi(e.subarray(1,33)),r=vi(e.subarray(33,65)),i=new Tn(t,r);return i.assertValidity(),i}static fromHex(e){const t=Fs(e),r=t.length,i=t[0];if(32===r||33===r&&(2===i||3===i))return this.fromCompressedHex(t);if(65===r&&4===i)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(e){return Tn.BASE.multiply(_a(e))}static fromSignature(e,t,r){const i=SI(e=Fs(e)),{r:s,s:o}=TI(t);if(0!==r&&1!==r)throw new Error("Cannot recover signature: invalid recovery bit");const u=Tn.fromHex((1&r?"03":"02")+Vo(s)),{n:_}=Mn,R=zc(s,_),N=at(-i*R,_),B=at(o*R,_),z=Tn.BASE.multiplyAndAddUnsafe(u,N,B);if(!z)throw new Error("Cannot recover signature: point at infinify");return z.assertValidity(),z}toRawBytes(e=!1){return Ho(this.toHex(e))}toHex(e=!1){const t=Vo(this.x);return e?`${this.hasEvenY()?"02":"03"}${t}`:`04${t}${Vo(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!th(t)||!th(r))throw new Error(e);const i=at(r*r);if(at(i-vI(t))!==ln)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Tn(this.x,at(-this.y))}double(){return On.fromAffine(this).double().toAffine()}add(e){return On.fromAffine(this).add(On.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return On.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const i=On.fromAffine(this),s=t===ln||t===Yn||this!==Tn.BASE?i.multiplyUnsafe(t):i.multiply(t),o=On.fromAffine(e).multiplyUnsafe(r),a=s.add(o);return a.equals(On.ZERO)?void 0:a.toAffine()}}function EI(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function bI(n){if(n.length<2||2!==n[0])throw new Error(`Invalid signature integer tag: ${$c(n)}`);const e=n[1],t=n.subarray(2,e+2);if(!e||t.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===t[0]&&t[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:vi(t),left:n.subarray(e+2)}}Tn.BASE=new Tn(Mn.Gx,Mn.Gy),Tn.ZERO=new Tn(ln,ln);class uo{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${r}: Expected string or Uint8Array`);const i=t?$c(e):e;if(128!==i.length)throw new Error(`${r}: Expected 64-byte hex`);return new uo(eh(i.slice(0,64)),eh(i.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:i}=function wF(n){if(n.length<2||48!=n[0])throw new Error(`Invalid signature tag: ${$c(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:t}=bI(n.subarray(2)),{data:r,left:i}=bI(t);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${$c(i)}`);return{r:e,s:r}}(t?e:Ho(e));return new uo(r,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Wc(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Wc(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){return this.s>Mn.n>>Yn}normalizeS(){return this.hasHighS()?new uo(this.r,Mn.n-this.s):this}toDERRawBytes(e=!1){return Ho(this.toDERHex(e))}toDERHex(e=!1){const t=EI(wl(this.s));if(e)return t;const r=EI(wl(this.r)),i=wl(r.length/2),s=wl(t.length/2);return`30${wl(r.length/2+t.length/2+4)}02${i}${r}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Ho(this.toCompactHex())}toCompactHex(){return Vo(this.r)+Vo(this.s)}}function Kc(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function $c(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t0)return BigInt(n);if("bigint"==typeof n&&Wc(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function at(n,e=Mn.P){const t=n%e;return t>=ln?t:e+t}function Gi(n,e){const{P:t}=Mn;let r=n;for(;e-- >ln;)r*=r,r%=t;return r}function zc(n,e=Mn.P){if(n===ln||e<=ln)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=at(n,e),r=e,i=ln,s=Yn,o=Yn,a=ln;for(;t!==ln;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==Yn)throw new Error("invert: does not exist");return at(i,e)}const _I=(n,e)=>(n+e/Uo)/e,IF={a1:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),b1:-Yn*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a2:BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),b2:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),POW_2_128:BigInt("0x100000000000000000000000000000000")};function DI(n){const{n:e}=Mn,{a1:t,b1:r,a2:i,b2:s,POW_2_128:o}=IF,a=_I(s*n,e),u=_I(-r*n,e);let _=at(n-a*t-u*i,e),R=at(-a*r-u*s,e);const N=_>o,B=R>o;if(N&&(_=e-_),B&&(R=e-R),_>o||R>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:N,k1:_,k2neg:B,k2:R}}function SI(n){const{n:e}=Mn,r=8*n.length-256;let i=vi(n);return r>0&&(i>>=BigInt(r)),i>=e&&(i-=e),i}let Gc,_l;class CI{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return Yr.hmacSha256(this.k,...e)}hmacSync(...e){return _l(this.k,...e)}checkSync(){if("function"!=typeof _l)throw new U0("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}reseed(e=new Uint8Array){var t=this;return $(function*(){t.k=yield t.hmac(t.v,Uint8Array.from([0]),e),t.v=yield t.hmac(t.v),0!==e.length&&(t.k=yield t.hmac(t.v,Uint8Array.from([1]),e),t.v=yield t.hmac(t.v))})()}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}generate(){var e=this;return $(function*(){return e.incr(),e.v=yield e.hmac(e.v),e.v})()}generateSync(){return this.checkSync(),this.incr(),this.v=this.hmacSync(this.v),this.v}}function Wc(n){return ln0)e=BigInt(n);else if("string"==typeof n){if(64!==n.length)throw new Error("Expected 32 bytes of private key");e=eh(n)}else{if(!(n instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==n.length)throw new Error("Expected 32 bytes of private key");e=vi(n)}if(!Wc(e))throw new Error("Expected private key: 0 < key < n");return e}function H0(n){return n instanceof Tn?(n.assertValidity(),n):Tn.fromHex(n)}function TI(n){if(n instanceof uo)return n.assertValidity(),n;try{return uo.fromDER(n)}catch{return uo.fromCompact(n)}}function Dl(n,e=!1){return Tn.fromPrivateKey(n).toRawBytes(e)}function AI(n){const e=n instanceof Uint8Array,t="string"==typeof n,r=(e||t)&&n.length;return e?33===r||65===r:t?66===r||130===r:n instanceof Tn}function xI(n){return vi(n.length>32?n.slice(0,32):n)}function xF(n){const e=xI(n),t=at(e,Mn.n);return RI(t{if((n=Fs(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return jc(at(vi(n),Mn.n-Yn)+Yn)},randomBytes:(n=32)=>{if(Mi.web)return Mi.web.getRandomValues(new Uint8Array(n));if(Mi.node){const{randomBytes:e}=Mi.node;return Uint8Array.from(e(n))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Yr.hashToPrivateKey(Yr.randomBytes(40)),sha256:(n=$(function*(...e){if(Mi.web){const t=yield Mi.web.subtle.digest("SHA-256",Kc(...e));return new Uint8Array(t)}if(Mi.node){const{createHash:t}=Mi.node,r=t("sha256");return e.forEach(i=>r.update(i)),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")}),function(){return n.apply(this,arguments)}),hmacSha256:function(){var n=$(function*(e,...t){if(Mi.web){const r=yield Mi.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=Kc(...t),s=yield Mi.web.subtle.sign("HMAC",r,i);return new Uint8Array(s)}if(Mi.node){const{createHmac:r}=Mi.node,i=r("sha256",e);return t.forEach(s=>i.update(s)),Uint8Array.from(i.digest())}throw new Error("The environment doesn't have hmac-sha256 function")});return function(t){return n.apply(this,arguments)}}(),sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:function(){var n=$(function*(e,...t){let r=rh[e];if(void 0===r){const i=yield Yr.sha256(Uint8Array.from(e,s=>s.charCodeAt(0)));r=Kc(i,i),rh[e]=r}return Yr.sha256(r,...t)});return function(t){return n.apply(this,arguments)}}(),taggedHashSync:(n,...e)=>{if("function"!=typeof Gc)throw new U0("sha256Sync is undefined, you need to set it");let t=rh[n];if(void 0===t){const r=Gc(Uint8Array.from(n,i=>i.charCodeAt(0)));t=Kc(r,r),rh[n]=t}return Gc(t,...e)},precompute(n=8,e=Tn.BASE){const t=e===Tn.BASE?e:new Tn(e.x,e.y);return t._setWindowSize(n),t.multiply(bl),t}};var n;function ih(n){if(isNaN(n)||n<=0)throw ae(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return Yr.randomBytes(n)}function kF(n){const e=Un.asn1.fromDer(Lt(n,"ascii")),t=Un.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:Bs(t.n),e:Bs(t.e),d:Bs(t.d),p:Bs(t.p),q:Bs(t.q),dp:Bs(t.dP),dq:Bs(t.dQ),qi:Bs(t.qInv),alg:"RS256"}}function UI(n,e){return e.map(t=>gs(n[t]))}function HF(n){return z0.apply(this,arguments)}function z0(){return z0=$(function*(n){const e=yield Ls.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:n,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=yield HI(e);return{privateKey:t[0],publicKey:t[1]}}),z0.apply(this,arguments)}function VI(n){return G0.apply(this,arguments)}function G0(){return G0=$(function*(n){const t=[yield Ls.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),yield jF(n)],r=yield HI({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}),G0.apply(this,arguments)}function W0(){return W0=$(function*(n,e){const t=yield Ls.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),r=yield Ls.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,Uint8Array.from(e));return new Uint8Array(r,0,r.byteLength)}),W0.apply(this,arguments)}function q0(){return q0=$(function*(n,e,t){const r=yield Ls.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return yield Ls.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},r,e,t)}),q0.apply(this,arguments)}function HI(n){return Y0.apply(this,arguments)}function Y0(){return Y0=$(function*(n){if(null==n.privateKey||null==n.publicKey)throw ae(new Error("Private and public key are required"),"ERR_INVALID_PARAMETERS");return yield Promise.all([Ls.get().subtle.exportKey("jwk",n.privateKey),Ls.get().subtle.exportKey("jwk",n.publicKey)])}),Y0.apply(this,arguments)}function jF(n){return Q0.apply(this,arguments)}function Q0(){return Q0=$(function*(n){return yield Ls.get().subtle.importKey("jwk",{kty:n.kty,n:n.n,e:n.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}),Q0.apply(this,arguments)}function KI(n,e,t,r){const i=e?function VF(n){return Un.pki.setRsaPublicKey(...UI(n,["n","e"]))}(n):function UF(n){return Un.pki.setRsaPrivateKey(...UI(n,["n","e","d","p","q","dp","dq","qi"]))}(n);return Ot(r(Lt(Uint8Array.from(t),"ascii"),i),"ascii")}function Z0(n,e){return X0.apply(this,arguments)}function X0(){return X0=$(function*(n,e){const r=yield mI().encrypt(n,e);return Gd.encode(r)}),X0.apply(this,arguments)}Object.defineProperties(Yr,{sha256Sync:{configurable:!1,get:()=>Gc,set(n){Gc||(Gc=n)}},hmacSha256Sync:{configurable:!1,get:()=>_l,set(n){_l||(_l=n)}}}),x(5517);class J0{constructor(e){this._key=e}verify(e,t){var r=this;return $(function*(){return yield function $F(n,e,t){return q0.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function FF(n){if(null==n.n||null==n.e)throw ae(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Un.pki.publicKeyToAsn1({n:gs(n.n),e:gs(n.e)});return Ot(Un.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return Bc.encode({Type:nr.RSA,Data:this.marshal()}).subarray()}encrypt(e){return function zF(n,e){return KI(n,!0,e,(t,r)=>r.encrypt(t))}(this._key,e)}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class sh{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return ih(16)}sign(e){var t=this;return $(function*(){return yield function KF(n,e){return W0.apply(this,arguments)}(t._key,e)})()}get public(){if(null==this._publicKey)throw ae(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new J0(this._publicKey)}decrypt(e){return function GF(n,e){return KI(n,!1,e,(t,r)=>r.decrypt(t))}(this._key,e)}marshal(){return function LF(n){if(null==n.n||null==n.e||null==n.d||null==n.p||null==n.q||null==n.dp||null==n.dq||null==n.qi)throw ae(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Un.pki.privateKeyToAsn1({n:gs(n.n),e:gs(n.e),d:gs(n.d),p:gs(n.p),q:gs(n.q),dP:gs(n.dp),dQ:gs(n.dq),qInv:gs(n.qi)});return Ot(Un.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return Fc.encode({Type:nr.RSA,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return $(function*(){return Lt(yield e.public.hash(),"base58btc")})()}export(e,t="pkcs-8"){var r=this;return $(function*(){if("pkcs-8"===t){const i=new Un.util.ByteBuffer(r.marshal()),s=Un.asn1.fromDer(i),o=Un.pki.privateKeyFromAsn1(s);return Un.pki.encryptRsaPrivateKey(o,e,{algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"})}if("libp2p-key"===t)return yield Z0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function WF(n){return em.apply(this,arguments)}function em(){return em=$(function*(n){const e=kF(n),t=yield VI(e);return new sh(t.privateKey,t.publicKey)}),em.apply(this,arguments)}function qF(n){const e=function BF(n){const e=Un.asn1.fromDer(Lt(n,"ascii")),t=Un.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:Bs(t.n),e:Bs(t.e)}}(n);return new J0(e)}function YF(n){return tm.apply(this,arguments)}function tm(){return tm=$(function*(n){const e=yield VI(n);return new sh(e.privateKey,e.publicKey)}),tm.apply(this,arguments)}function QF(n){return nm.apply(this,arguments)}function nm(){return nm=$(function*(n){const e=yield HF(n);return new sh(e.privateKey,e.publicKey)}),nm.apply(this,arguments)}var ZF=x(7420),XF=x.t(ZF,2);const ar=BigInt(0),cn=BigInt(1),Yc=BigInt(2),$I=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),Vn=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:$I,n:$I,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),jI=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),Sl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),JF=(BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235")),e5=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),t5=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),n5=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class _n{constructor(e,t,r,i){this.x=e,this.y=t,this.z=r,this.t=i}static fromAffine(e){if(!(e instanceof rr))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(rr.ZERO)?_n.ZERO:new _n(e.x,e.y,cn,Oe(e.x*e.y))}static toAffineBatch(e){const t=function s5(n,e=Vn.P){const t=new Array(n.length),i=oh(n.reduce((s,o,a)=>o===ar?s:(t[a]=s,Oe(s*o,e)),cn),e);return n.reduceRight((s,o,a)=>o===ar?s:(t[a]=Oe(s*t[a],e),Oe(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){zI(e);const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,u=Oe(t*a),_=Oe(s*i),R=Oe(r*a),N=Oe(o*i);return u===_&&R===N}negate(){return new _n(Oe(-this.x),this.y,this.z,Oe(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:i}=Vn,s=Oe(e*e),o=Oe(t*t),a=Oe(Yc*Oe(r*r)),u=Oe(i*s),_=e+t,R=Oe(Oe(_*_)-s-o),N=u+o,B=N-a,z=u-o,X=Oe(R*B),J=Oe(N*z),oe=Oe(R*z),de=Oe(B*N);return new _n(X,J,de,oe)}add(e){zI(e);const{x:t,y:r,z:i,t:s}=this,{x:o,y:a,z:u,t:_}=e,R=Oe((r-t)*(a+o)),N=Oe((r+t)*(a-o)),B=Oe(N-R);if(B===ar)return this.double();const z=Oe(i*Yc*_),X=Oe(s*Yc*u),J=X+z,oe=N+R,de=X-z,xe=Oe(J*B),ue=Oe(oe*de),Te=Oe(J*de),Ke=Oe(B*oe);return new _n(xe,ue,Ke,Te)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,r=[];let i=this,s=i;for(let o=0;o>=N,X>u&&(X-=R,e+=cn),0===X){let J=i[z];B%2&&(J=J.negate()),o=o.add(J)}else{let J=i[z+Math.abs(X)-1];X<0&&(J=J.negate()),s=s.add(J)}}return _n.normalizeZ([s,o])[0]}multiply(e,t){return this.wNAF(Jc(e,Vn.l),t)}multiplyUnsafe(e){let t=Jc(e,Vn.l,!1);const r=_n.BASE,i=_n.ZERO;if(t===ar)return i;if(this.equals(i)||t===cn)return this;if(this.equals(r))return this.wNAF(t);let s=i,o=this;for(;t>ar;)t&cn&&(s=s.add(o)),o=o.double(),t>>=cn;return s}isSmallOrder(){return this.multiplyUnsafe(Vn.h).equals(_n.ZERO)}isTorsionFree(){return this.multiplyUnsafe(Vn.l).equals(_n.ZERO)}toAffine(e=oh(this.z)){const{x:t,y:r,z:i}=this,s=Oe(t*e),o=Oe(r*e);if(Oe(i*e)!==cn)throw new Error("invZ was invalid");return new rr(s,o)}fromRistrettoBytes(){im()}toRistrettoBytes(){im()}fromRistrettoHash(){im()}}function zI(n){if(!(n instanceof _n))throw new TypeError("ExtendedPoint expected")}function rm(n){if(!(n instanceof Wi))throw new TypeError("RistrettoPoint expected")}function im(){throw new Error("Legacy method: switch to RistrettoPoint")}_n.BASE=new _n(Vn.Gx,Vn.Gy,cn,Oe(Vn.Gx*Vn.Gy)),_n.ZERO=new _n(ar,cn,cn,ar);class Wi{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=Vn,r=Oe(Sl*e*e),i=Oe((r+cn)*t5);let s=BigInt(-1);const o=Oe((s-t*r)*Oe(r+t));let{isValid:a,value:u}=cm(i,o),_=Oe(u*e);$o(_)||(_=Oe(-_)),a||(u=_),a||(s=r);const R=Oe(s*(r-cn)*n5-o),N=u*u,B=Oe((u+u)*o),z=Oe(R*JF),X=Oe(cn-N),J=Oe(cn+N);return new _n(Oe(B*J),Oe(X*z),Oe(z*J),Oe(B*X))}static hashToCurve(e){const t=am((e=ms(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),i=am(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return new Wi(r.add(s))}static fromHex(e){e=ms(e,32);const{a:t,d:r}=Vn,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",s=am(e);if(!function o5(n,e){if(n.length!==e.length)return!1;for(let t=0;t=i)throw new Error("Expected 0 < hex < P");if(!t&&o>=jI)throw new Error("Expected 0 < hex < 2**256");const a=Oe(o*o),u=Oe(a-cn),_=Oe(r*a+cn);let{isValid:R,value:N}=cm(u,_);if(!R)throw new Error("Point.fromHex: invalid y coordinate");return 0!=(128&e[31])!=((N&cn)===cn)&&(N=Oe(-N)),new rr(N,o)}static fromPrivateKey(e){return $(function*(){return(yield Tl(e)).point})()}toRawBytes(){const e=Zc(this.y);return e[31]|=this.x&cn?128:0,e}toHex(){return Cl(this.toRawBytes())}toX25519(){const{y:e}=this;return Zc(Oe((cn+e)*oh(cn-e)))}isTorsionFree(){return _n.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new rr(Oe(-this.x),this.y)}add(e){return _n.fromAffine(this).add(_n.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return _n.fromAffine(this).multiply(e,this).toAffine()}}rr.BASE=new rr(Vn.Gx,Vn.Gy),rr.ZERO=new rr(ar,cn);class Qc{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=ms(e,64),r=rr.fromHex(t.slice(0,32),!1),i=Da(t.slice(32,64));return new Qc(r,i)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof rr))throw new Error("Expected Point instance");return Jc(t,Vn.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Zc(this.s),32),e}toHex(){return Cl(this.toRawBytes())}}function GI(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Expected Uint8Array list");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function Cl(n){if(!(n instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t=ar?t:e+t}function oh(n,e=Vn.P){if(n===ar||e<=ar)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Oe(n,e),r=e,i=ar,s=cn,o=cn,a=ar;for(;t!==ar;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==cn)throw new Error("invert: does not exist");return Oe(i,e)}function ys(n,e){const{P:t}=Vn;let r=n;for(;e-- >ar;)r*=r,r%=t;return r}function cm(n,e){const t=Oe(e*e*e),r=Oe(t*t*e);let s=Oe(n*t*function qI(n){const{P:e}=Vn,t=BigInt(5),r=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),u=n*n%e*n%e,_=ys(u,Yc)*u%e,R=ys(_,cn)*n%e,N=ys(R,t)*R%e,B=ys(N,r)*N%e,z=ys(B,i)*B%e,X=ys(z,s)*z%e,J=ys(X,o)*X%e,oe=ys(J,o)*X%e,de=ys(oe,r)*N%e;return{pow_p_5_8:ys(de,Yc)*n%e,b2:u}}(n*r).pow_p_5_8);const o=Oe(e*s*s),a=s,u=Oe(s*Sl),_=o===n,R=o===Oe(-n),N=o===Oe(-n*Sl);return _&&(s=a),(R||N)&&(s=u),$o(s)&&(s=Oe(-s)),{isValid:_||R,value:s}}function YI(n){return cm(cn,n)}function Xc(n){return Oe(Da(n),Vn.l)}function ms(n,e){const t=n instanceof Uint8Array?Uint8Array.from(n):om(n);if("number"==typeof e&&t.length!==e)throw new Error(`Expected ${e} bytes`);return t}function Jc(n,e,t=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof n&&Number.isSafeInteger(n)&&(n=BigInt(n)),"bigint"==typeof n&&n{if((n=ms(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Oe(Da(n),Vn.l-cn)+cn},randomBytes:(n=32)=>{if(jo.web)return jo.web.getRandomValues(new Uint8Array(n));if(jo.node){const{randomBytes:e}=jo.node;return new Uint8Array(e(n).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Sa.randomBytes(32),sha512:function(){var n=$(function*(...e){const t=GI(...e);if(jo.web){const r=yield jo.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(r)}if(jo.node)return Uint8Array.from(jo.node.createHash("sha512").update(t).digest());throw new Error("The environment doesn't have sha512 function")});return function(){return n.apply(this,arguments)}}(),precompute(n=8,e=rr.BASE){const t=e.equals(rr.BASE)?e:new rr(e.x,e.y);return t._setWindowSize(n),t.multiply(Yc),t},sha512Sync:void 0};function y5(){return ym.apply(this,arguments)}function ym(){return ym=$(function*(){const n=Sa.randomPrivateKey(),e=yield JI(n);return{privateKey:nT(n,e),publicKey:e}}),ym.apply(this,arguments)}function m5(n){return mm.apply(this,arguments)}function mm(){return mm=$(function*(n){if(32!==n.length)throw new TypeError('"seed" must be 32 bytes in length.');if(!(n instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const e=n,t=yield JI(e);return{privateKey:nT(e,t),publicKey:t}}),mm.apply(this,arguments)}function vm(){return vm=$(function*(n,e){const t=n.slice(0,32);return yield u5(e,t)}),vm.apply(this,arguments)}function Em(){return Em=$(function*(n,e,t){return yield f5(e,t,n)}),Em.apply(this,arguments)}function nT(n,e){const t=new Uint8Array(64);for(let r=0;r<32;r++)t[r]=n[r],t[32+r]=e[r];return t}Object.defineProperties(Sa,{sha512Sync:{configurable:!1,get:()=>Il,set(n){Il||(Il=n)}}});class bm{constructor(e){this._key=eu(e,32)}verify(e,t){var r=this;return $(function*(){return yield function E5(n,e,t){return Em.apply(this,arguments)}(r._key,t,e)})()}marshal(){return this._key}get bytes(){return Bc.encode({Type:nr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class xl{constructor(e,t){this._key=eu(e,64),this._publicKey=eu(t,32)}sign(e){var t=this;return $(function*(){return yield function v5(n,e){return vm.apply(this,arguments)}(t._key,e)})()}get public(){return new bm(this._publicKey)}marshal(){return this._key}get bytes(){return Fc.encode({Type:nr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return $(function*(){const t=yield Hc.digest(e.public.bytes);return ui.encode(t.bytes).substring(1)})()}export(e,t="libp2p-key"){var r=this;return $(function*(){if("libp2p-key"===t)return yield Z0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function b5(n){if(n.length>64){const r=(n=eu(n,96)).slice(0,64),i=n.slice(64,n.length);return new xl(r,i)}const e=(n=eu(n,64)).slice(0,64),t=n.slice(32);return new xl(e,t)}function w5(n){return n=eu(n,32),new bm(n)}function _5(){return wm.apply(this,arguments)}function wm(){return wm=$(function*(){const{privateKey:n,publicKey:e}=yield y5();return new xl(n,e)}),wm.apply(this,arguments)}function D5(n){return _m.apply(this,arguments)}function _m(){return _m=$(function*(n){const{privateKey:e,publicKey:t}=yield m5(n);return new xl(e,t)}),_m.apply(this,arguments)}function eu(n,e){if((n=Uint8Array.from(n??[])).length!==e)throw ae(new Error(`Key must be a Uint8Array of length ${e}, got ${n.length}`),"ERR_INVALID_KEY_TYPE");return n}function S5(){return Yr.randomPrivateKey()}function Dm(){return Dm=$(function*(n,e){const{digest:t}=yield mi.digest(e);try{return yield MI(t,n)}catch(r){throw ae(r,"ERR_INVALID_INPUT")}}),Dm.apply(this,arguments)}function Sm(){return Sm=$(function*(n,e,t){try{const{digest:r}=yield mi.digest(t);return PF(e,r,n)}catch(r){throw ae(r,"ERR_INVALID_INPUT")}}),Sm.apply(this,arguments)}function rT(n){try{Tn.fromHex(n)}catch(e){throw ae(e,"ERR_INVALID_PUBLIC_KEY")}}class Cm{constructor(e){rT(e),this._key=e}verify(e,t){var r=this;return $(function*(){return yield function I5(n,e,t){return Sm.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function T5(n){return Tn.fromHex(n).toRawBytes(!0)}(this._key)}get bytes(){return Bc.encode({Type:nr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class Im{constructor(e,t){this._key=e,this._publicKey=t??function x5(n){try{return Dl(n,!0)}catch(e){throw ae(e,"ERR_INVALID_PRIVATE_KEY")}}(e),function A5(n){try{Dl(n,!0)}catch(e){throw ae(e,"ERR_INVALID_PRIVATE_KEY")}}(this._key),rT(this._publicKey)}sign(e){var t=this;return $(function*(){return yield function C5(n,e){return Dm.apply(this,arguments)}(t._key,e)})()}get public(){return new Cm(this._publicKey)}marshal(){return this._key}get bytes(){return Fc.encode({Type:nr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return $(function*(){return Lt(yield e.public.hash(),"base58btc")})()}export(e,t="libp2p-key"){var r=this;return $(function*(){if("libp2p-key"===t)return yield Z0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function R5(n){return new Im(n)}function P5(n){return new Cm(n)}function N5(){return Tm.apply(this,arguments)}function Tm(){return Tm=$(function*(){const n=yield S5();return new Im(n)}),Tm.apply(this,arguments)}const lo={rsa:I,ed25519:A,secp256k1:P};function Am(n){const e=Object.keys(lo).join(" / ");return ae(new Error(`invalid or unsupported key type ${n}. Must be ${e}`),"ERR_UNSUPPORTED_KEY_TYPE")}function xm(n){if("rsa"===(n=n.toLowerCase())||"ed25519"===n||"secp256k1"===n)return lo[n];throw Am(n)}function iT(n,e){return Rm.apply(this,arguments)}function Rm(){return Rm=$(function*(n,e){return yield xm(n).generateKeyPair(e??2048)}),Rm.apply(this,arguments)}function Rl(n){const e=Bc.decode(n),t=e.Data;switch(e.Type){case nr.RSA:return lo.rsa.unmarshalRsaPublicKey(t);case nr.Ed25519:return lo.ed25519.unmarshalEd25519PublicKey(t);case nr.Secp256k1:return lo.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Am(e.Type)}}function sT(n,e){return xm(e=(e??"rsa").toLowerCase()),n.bytes}function Pl(n){return Nm.apply(this,arguments)}function Nm(){return Nm=$(function*(n){const e=Fc.decode(n),t=e.Data;switch(e.Type){case nr.RSA:return yield lo.rsa.unmarshalRsaPrivateKey(t);case nr.Ed25519:return lo.ed25519.unmarshalEd25519PrivateKey(t);case nr.Secp256k1:return lo.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw Am(e.Type)}}),Nm.apply(this,arguments)}function M5(n,e){return xm(e=(e??"rsa").toLowerCase()),n.bytes}function Mm(n,e){return Om.apply(this,arguments)}function Om(){return Om=$(function*(n,e){try{const i=yield mF(n,e);return yield Pl(i)}catch{}const t=Un.pki.decryptRsaPrivateKey(n,e);if(null===t)throw ae(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let r=Un.asn1.toDer(Un.pki.privateKeyToAsn1(t));return r=Ot(r.getBytes(),"ascii"),yield lo.rsa.unmarshalRsaPrivateKey(r)}),Om.apply(this,arguments)}const oT=Symbol.for("@libp2p/peer-id");function aT(n){return null!=n&&Boolean(n[oT])}const cT=Object.values(El).map(n=>n.decoder).reduce((n,e)=>n.or(e),El.identity.decoder);class lh{constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[oT](){return!0}toString(){return null==this.string&&(this.string=ui.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return wr.createV1(114,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return kr(this.multihash.bytes,e);if("string"==typeof e)return fr(e).equals(this);if(null!=e?.multihash?.bytes)return kr(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}}class Nl extends lh{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}}class Ml extends lh{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}}class Ol extends lh{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}}function Br(n){if("RSA"===n.type)return new Nl(n);if("Ed25519"===n.type)return new Ml(n);if("secp256k1"===n.type)return new Ol(n);throw ae(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function fr(n,e){if(e=e??cT,"1"===n.charAt(0)||"Q"===n.charAt(0)){const t=Qd(ui.decode(`z${n}`));return n.startsWith("12D")?new Ml({multihash:t}):n.startsWith("16U")?new Ol({multihash:t}):new Nl({multihash:t})}return tu(cT.decode(n))}function tu(n){try{const e=Qd(n);if(e.code===Hc.code){if(36===e.digest.length)return new Ml({multihash:e});if(37===e.digest.length)return new Ol({multihash:e})}if(e.code===mi.code)return new Nl({multihash:e})}catch{return function O5(n){if(null==n||null==n.multihash||null==n.version||1===n.version&&114!==n.code)throw new Error("Supplied PeerID CID is invalid");const e=n.multihash;if(e.code===mi.code)return new Nl({multihash:n.multihash});if(e.code===Hc.code){if(36===e.digest.length)return new Ml({multihash:n.multihash});if(37===e.digest.length)return new Ol({multihash:n.multihash})}throw new Error("Supplied PeerID CID is invalid")}(wr.decode(n))}throw new Error("Supplied PeerID CID is invalid")}function kl(n,e){return Bm.apply(this,arguments)}function Bm(){return Bm=$(function*(n,e){return 36===n.length?new Ml({multihash:Vc(Hc.code,n),privateKey:e}):37===n.length?new Ol({multihash:Vc(Hc.code,n),privateKey:e}):new Nl({multihash:yield mi.digest(n),publicKey:n,privateKey:e})}),Bm.apply(this,arguments)}var Fm;!function(n){let e;!function(t){let r;t.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.identityKey)throw new Error('Protocol error: required field "identityKey" was not found in object');if(s.uint32(10),s.bytes(i.identityKey),null==i.identitySig)throw new Error('Protocol error: required field "identitySig" was not found in object');if(s.uint32(18),s.bytes(i.identitySig),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(26),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0),data:new Uint8Array(0)},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.identityKey=i.bytes();break;case 2:o.identitySig=i.bytes();break;case 3:o.data=i.bytes();break;default:i.skipType(7&u)}}if(null==o.identityKey)throw new Error('Protocol error: value for required field "identityKey" was not found in protobuf');if(null==o.identitySig)throw new Error('Protocol error: value for required field "identitySig" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),t.encode=i=>qt(i,t.codec()),t.decode=i=>Wt(i,t.codec())}(e=n.NoiseHandshakePayload||(n.NoiseHandshakePayload={}))}(Fm||(Fm={}));const lT=Fm.NoiseHandshakePayload;function Um(){return Um=$(function*(n,e,t){const r=yield B5(n,hT(e)),i=t??new Uint8Array(0);if(null==n.publicKey)throw new Error("PublicKey was missing from local PeerId");return L5(n.publicKey,r,i)}),Um.apply(this,arguments)}function L5(n,e,t){return lT.encode({identityKey:n,identitySig:e,data:t??new Uint8Array(0)}).subarray()}function B5(n,e){return Vm.apply(this,arguments)}function Vm(){return Vm=$(function*(n,e){if(null==n.privateKey)throw new Error("PrivateKey was missing from PeerId");return yield(yield Pl(n.privateKey)).sign(e)}),Vm.apply(this,arguments)}function fT(n){return Hm.apply(this,arguments)}function Hm(){return Hm=$(function*(n){return yield kl(n.identityKey)}),Hm.apply(this,arguments)}function dT(n){return lT.decode(n)}function hT(n){const e=Ot("noise-libp2p-static-key:");return br([e,n],e.length+n.length)}function pT(n,e,t){return Km.apply(this,arguments)}function Km(){return Km=$(function*(n,e,t){const r=yield kl(e.identityKey);if(!r.equals(t))throw new Error("Peer ID doesn't match libp2p public key.");const i=hT(n);if(null==r.publicKey)throw new Error("PublicKey was missing from PeerId");if(null==e.identitySig)throw new Error("Signature was missing from message");if(!(yield Rl(r.publicKey).verify(i,e.identitySig)))throw new Error("Static key doesn't match to peer that signed payload!");return r}),Km.apply(this,arguments)}function fh(n){return!(!(n instanceof Uint8Array)||32!==n.length)}var _r=x(1455);function zt(n){return Object.assign(_r(n),{error:_r(`${n}:error`),trace:_r(`${n}:trace`)})}_r.formatters.b=n=>null==n?"undefined":ui.baseEncode(n),_r.formatters.t=n=>null==n?"undefined":co.baseEncode(n),_r.formatters.m=n=>null==n?"undefined":Gd.baseEncode(n),_r.formatters.p=n=>null==n?"undefined":n.toString(),_r.formatters.c=n=>null==n?"undefined":n.toString(),_r.formatters.k=n=>null==n?"undefined":n.toString();const Qr=zt("libp2p:noise");let qi;function gT(n){n?(qi(`LOCAL_PUBLIC_EPHEMERAL_KEY ${Lt(n.publicKey,"hex")}`),qi(`LOCAL_PRIVATE_EPHEMERAL_KEY ${Lt(n.privateKey,"hex")}`)):qi("Missing local ephemeral keys.")}function yT(n){qi(`REMOTE_EPHEMERAL_PUBLIC_KEY ${Lt(n,"hex")}`)}qi=PB?Qr:Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});class j5{constructor(e=0){this.n=e,this.bytes=new Uint8Array(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>4294967295)throw new Error("Cipherstate has reached maximum n, a new handshake must be performed")}}class G5 extends class z5{constructor(e){this.crypto=e}encryptWithAd(e,t,r){const i=this.encrypt(e.k,e.n,t,r);return e.n.increment(),i}decryptWithAd(e,t,r){const{plaintext:i,valid:s}=this.decrypt(e.k,e.n,t,r);return s&&e.n.increment(),{plaintext:i,valid:s}}hasKey(e){return!this.isEmptyKey(e.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(e){return kr(this.createEmptyKey(),e)}encrypt(e,t,r,i){return t.assertValue(),this.crypto.chaCha20Poly1305Encrypt(i,t.getBytes(),r,e)}encryptAndHash(e,t){let r;return r=this.hasKey(e.cs)?this.encryptWithAd(e.cs,e.h,t):t,this.mixHash(e,r),r}decrypt(e,t,r,i){t.assertValue();const s=this.crypto.chaCha20Poly1305Decrypt(i,t.getBytes(),r,e);return s?{plaintext:s,valid:!0}:{plaintext:new Uint8Array(0),valid:!1}}decryptAndHash(e,t){let r,i=!0;return this.hasKey(e.cs)?({plaintext:r,valid:i}=this.decryptWithAd(e.cs,e.h,t)):r=t,this.mixHash(e,t),{plaintext:r,valid:i}}dh(e,t){try{const r=this.crypto.generateX25519SharedKey(e,t);return 32===r.length?r:r.subarray(0,32)}catch(r){return Qr(r.message),new Uint8Array(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(br([e,t],e.length+t.length))}mixKey(e,t){const[r,i]=this.crypto.getHKDF(e.ck,t);e.cs=this.initializeKey(i),e.ck=r}initializeKey(e){return{k:e,n:new j5}}initializeSymmetric(e){const t=Ot(e,"utf-8"),r=this.hashProtocolName(t),i=r,s=this.createEmptyKey();return{cs:this.initializeKey(s),ck:i,h:r}}hashProtocolName(e){if(e.length<=32){const t=new Uint8Array(32);return t.set(e),t}return this.getHash(e,new Uint8Array(0))}split(e){const[t,r]=this.crypto.getHKDF(e.ck,new Uint8Array(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,new Uint8Array(0),t);return{ne:this.createEmptyKey(),ns:new Uint8Array(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,new Uint8Array(0),t.ciphertext)}}{initializeInitiator(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}initializeResponder(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}writeMessageA(e,t,r){const i=new Uint8Array(0);e.e=void 0!==r?r:this.crypto.generateX25519KeyPair();const s=e.e.publicKey;return this.mixHash(e.ss,s),{ne:s,ns:i,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=this.crypto.generateX25519KeyPair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const s=this.encryptAndHash(e.ss,e.s.publicKey);return this.mixKey(e.ss,this.dh(e.s.privateKey,e.re)),{ne:r,ns:s,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageC(e,t){const i=this.encryptAndHash(e.ss,e.s.publicKey);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const s=this.encryptAndHash(e.ss,t),a={ne:this.createEmptyKey(),ns:i,ciphertext:s},{cs1:u,cs2:_}=this.split(e.ss);return{h:e.ss.h,messageBuffer:a,cs1:u,cs2:_}}readMessageA(e,t){return fh(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(fh(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&fh(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:s,valid:i&&o}}readMessageC(e,t){const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);if(i&&fh(r)&&(e.rs=r),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:a,cs2:u}=this.split(e.ss);return{h:e.ss.h,plaintext:s,valid:i&&o,cs1:a,cs2:u}}initSession(e,t,r){const i=this.createEmptyKey(),s=new Uint8Array(32);let o;return o=e?this.initializeInitiator(t,r,s,i):this.initializeResponder(t,r,s,i),{hs:o,i:e,mc:0}}sendMessage(e,t,r){let i;if(0===e.mc)i=this.writeMessageA(e.hs,t,r);else if(1===e.mc)i=this.writeMessageB(e.hs,t);else if(2===e.mc){const{h:s,messageBuffer:o,cs1:a,cs2:u}=this.writeMessageC(e.hs,t);i=o,e.h=s,e.cs1=a,e.cs2=u}else{if(!(e.mc>2))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");i=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");i=this.writeMessageRegular(e.cs2,t)}}return e.mc++,i}recvMessage(e,t){let r=new Uint8Array(0),i=!1;if(0===e.mc)({plaintext:r,valid:i}=this.readMessageA(e.hs,t));else if(1===e.mc)({plaintext:r,valid:i}=this.readMessageB(e.hs,t));else if(2===e.mc){const{h:s,plaintext:o,valid:a,cs1:u,cs2:_}=this.readMessageC(e.hs,t);r=o,i=a,e.h=s,e.cs1=u,e.cs2=_}return e.mc++,{plaintext:r,valid:i}}}class W5{constructor(e,t,r,i,s,o,a,u){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=u??new G5(i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=new Uint8Array(0)}propose(){var e=this;return $(function*(){if(function F5(n){qi(`LOCAL_STATIC_PUBLIC_KEY ${Lt(n.publicKey,"hex")}`),qi(`LOCAL_STATIC_PRIVATE_KEY ${Lt(n.privateKey,"hex")}`)}(e.session.hs.s),e.isInitiator){Qr("Stage 0 - Initiator starting to send first message.");const t=e.xx.sendMessage(e.session,new Uint8Array(0));e.connection.writeLP(function kB(n){return br([n.ne,n.ciphertext],n.ne.length+n.ciphertext.length)}(t)),Qr("Stage 0 - Initiator finished sending first message."),gT(e.session.hs.e)}else{Qr("Stage 0 - Responder waiting to receive first message...");const t=function FB(n){if(n.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:n.subarray(0,32),ciphertext:n.subarray(32,n.length),ns:new Uint8Array(0)}}((yield e.connection.readLP()).subarray()),{valid:r}=e.xx.recvMessage(e.session,t);if(!r)throw new Lc("xx handshake stage 0 validation fail");Qr("Stage 0 - Responder received first message."),yT(e.session.hs.re)}})()}exchange(){var e=this;return $(function*(){if(e.isInitiator){Qr("Stage 1 - Initiator waiting to receive first message from responder...");const t=function UB(n){if(n.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:n.subarray(0,32),ns:n.subarray(32,80),ciphertext:n.subarray(80,n.length)}}((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Lc("xx handshake stage 1 validation fail");Qr("Stage 1 - Initiator received the message."),yT(e.session.hs.re),function U5(n){qi(`REMOTE_STATIC_PUBLIC_KEY ${Lt(n,"hex")}`)}(e.session.hs.rs),Qr("Initiator going to check remote's signature...");try{const s=dT(r);e.remotePeer=e.remotePeer||(yield fT(s)),yield pT(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new $d(`Error occurred while verifying signed payload: ${s.message}`)}Qr("All good with the signature!")}else{Qr("Stage 1 - Responder sending out first message with signed payload and static key.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function LB(n){return br([n.ne,n.ns,n.ciphertext],n.ne.length+n.ns.length+n.ciphertext.length)}(t)),Qr("Stage 1 - Responder sent the second handshake message with signed payload."),gT(e.session.hs.e)}})()}finish(){var e=this;return $(function*(){if(e.isInitiator){Qr("Stage 2 - Initiator sending third handshake message.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function BB(n){return br([n.ns,n.ciphertext],n.ns.length+n.ciphertext.length)}(t)),Qr("Stage 2 - Initiator sent message with signed payload.")}else{Qr("Stage 2 - Responder waiting for third handshake message...");const t=function VB(n){if(n.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:n.subarray(0,48),ciphertext:n.subarray(48,n.length)}}((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Lc("xx handshake stage 2 validation fail");Qr("Stage 2 - Responder received the message, finished handshake.");try{const s=dT(r);e.remotePeer=e.remotePeer||(yield fT(s)),yield pT(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new $d(`Error occurred while verifying signed payload: ${s.message}`)}}!function V5(n){n.cs1&&n.cs2?(qi(`CIPHER_STATE_1 ${n.cs1.n.getUint64()} ${Lt(n.cs1.k,"hex")}`),qi(`CIPHER_STATE_2 ${n.cs2.n.getUint64()} ${Lt(n.cs2.k,"hex")}`)):qi("Missing cipher state.")}(e.session)})()}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,new Uint8Array(0),e)}decrypt(e,t){const r=this.getCS(t,!1);return this.xx.decryptWithAd(r,new Uint8Array(0),e)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e,t=!0){if(!e.cs1||!e.cs2)throw new Lc("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteEarlyData(e){e&&(this.remoteEarlyData=e)}}class q5{constructor(e,t,r=dB,i){this.protocol="/noise",this.earlyData=t??new Uint8Array(0),this.crypto=r,this.staticKeys=e?this.crypto.generateX25519KeyPairFromSeed(e):this.crypto.generateX25519KeyPair(),this.prologue=i??new Uint8Array(0)}secureOutbound(e,t,r){var i=this;return $(function*(){const s=WC(t,{lengthEncoder:Hd,lengthDecoder:Kd,maxDataLength:gl}),o=yield i.performHandshake({connection:s,isInitiator:!0,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remoteEarlyData:o.remoteEarlyData,remotePeer:o.remotePeer}})()}secureInbound(e,t,r){var i=this;return $(function*(){const s=WC(t,{lengthEncoder:Hd,lengthDecoder:Kd,maxDataLength:gl}),o=yield i.performHandshake({connection:s,isInitiator:!1,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remoteEarlyData:o.remoteEarlyData,remotePeer:o.remotePeer}})()}performHandshake(e){var t=this;return $(function*(){const r=yield function k5(n,e,t){return Um.apply(this,arguments)}(e.localPeer,t.staticKeys.publicKey,t.earlyData);return yield t.performXXHandshake(e,r)})()}performXXHandshake(e,t){var r=this;return $(function*(){const{isInitiator:i,remotePeer:s,connection:o}=e,a=new W5(i,t,r.prologue,r.crypto,r.staticKeys,o,s);try{yield a.propose(),yield a.exchange(),yield a.finish()}catch(u){if(u instanceof Error)throw u.message=`Error occurred during XX handshake: ${u.message}`,u}return a})()}createSecureConnection(e,t){return $(function*(){const[r,i]=function AB(){const n=qC(),e=qC();return[{source:n.source,sink:e.sink},{source:e.source,sink:n.sink}]}(),s=e.unwrap();return yield qn(r,function NB(n){return function(){var e=hn(function*(t){var s,r=!1,i=!1;try{for(var a,o=Pt(t);r=!(a=yield lt(o.next())).done;r=!1){const u=a.value;for(let _=0;_u.length&&(R=u.length),yield n.encrypt(u.subarray(_,R),n.session)}}}catch(u){i=!0,s=u}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),ks({lengthEncoder:Hd}),s,ps({lengthDecoder:Kd}),function MB(n){return function(){var e=hn(function*(t){var s,r=!1,i=!1;try{for(var a,o=Pt(t);r=!(a=yield lt(o.next())).done;r=!1){const u=a.value;for(let _=0;_u.length&&(R=u.length);const{plaintext:N,valid:B}=yield lt(n.decrypt(u.subarray(_,R),n.session));if(!B)throw new Error("Failed to validate decrypted chunk");yield N}}}catch(u){i=!0,s=u}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),r),i})()}}function fo(n){return null!=n&&"function"==typeof n.start&&"function"==typeof n.stop}function Fr(n){return null!=n&&"function"==typeof n.init}class ho{constructor(e={}){this.started=!1,null!=e.peerId&&this.setPeerId(e.peerId),null!=e.addressManager&&this.setAddressManager(e.addressManager),null!=e.peerStore&&this.setPeerStore(e.peerStore),null!=e.upgrader&&this.setUpgrader(e.upgrader),null!=e.metrics&&this.setMetrics(e.metrics),null!=e.registrar&&this.setRegistrar(e.registrar),null!=e.connectionManager&&this.setConnectionManager(e.connectionManager),null!=e.transportManager&&this.setTransportManager(e.transportManager),null!=e.connectionGater&&this.setConnectionGater(e.connectionGater),null!=e.contentRouting&&this.setContentRouting(e.contentRouting),null!=e.peerRouting&&this.setPeerRouting(e.peerRouting),null!=e.datastore&&this.setDatastore(e.datastore),null!=e.connectionProtector&&this.setConnectionProtector(e.connectionProtector),null!=e.dht&&this.setDHT(e.dht),null!=e.pubsub&&this.setPubSub(e.pubsub)}isStarted(){return this.started}beforeStart(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}()))})()}start(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){yield r.start()});return function(r){return t.apply(this,arguments)}}())),e.started=!0})()}afterStart(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}()))})()}beforeStop(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}()))})()}stop(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){yield r.stop()});return function(r){return t.apply(this,arguments)}}())),e.started=!1})()}afterStop(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=$(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}()))})()}setPeerId(e){return this.peerId=e,e}getPeerId(){if(null==this.peerId)throw ae(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this.peerId}setMetrics(e){return this.metrics=e,Fr(e)&&e.init(this),e}getMetrics(){return this.metrics}setAddressManager(e){return this.addressManager=e,Fr(e)&&e.init(this),e}getAddressManager(){if(null==this.addressManager)throw ae(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this.addressManager}setPeerStore(e){return this.peerStore=e,Fr(e)&&e.init(this),e}getPeerStore(){if(null==this.peerStore)throw ae(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this.peerStore}setUpgrader(e){return this.upgrader=e,Fr(e)&&e.init(this),e}getUpgrader(){if(null==this.upgrader)throw ae(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this.upgrader}setRegistrar(e){return this.registrar=e,Fr(e)&&e.init(this),e}getRegistrar(){if(null==this.registrar)throw ae(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this.registrar}setConnectionManager(e){return this.connectionManager=e,Fr(e)&&e.init(this),e}getConnectionManager(){if(null==this.connectionManager)throw ae(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this.connectionManager}setTransportManager(e){return this.transportManager=e,Fr(e)&&e.init(this),e}getTransportManager(){if(null==this.transportManager)throw ae(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this.transportManager}setConnectionGater(e){return this.connectionGater=e,Fr(e)&&e.init(this),e}getConnectionGater(){if(null==this.connectionGater)throw ae(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this.connectionGater}setContentRouting(e){return this.contentRouting=e,Fr(e)&&e.init(this),e}getContentRouting(){if(null==this.contentRouting)throw ae(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this.contentRouting}setPeerRouting(e){return this.peerRouting=e,Fr(e)&&e.init(this),e}getPeerRouting(){if(null==this.peerRouting)throw ae(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this.peerRouting}setDatastore(e){return this.datastore=e,Fr(e)&&e.init(this),e}getDatastore(){if(null==this.datastore)throw ae(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this.datastore}setConnectionProtector(e){return this.connectionProtector=e,Fr(e)&&e.init(this),e}getConnectionProtector(){return this.connectionProtector}setDHT(e){return this.dht=e,Fr(e)&&e.init(this),e}getDHT(){if(null==this.dht)throw ae(new Error("dht not set"),"ERR_SERVICE_MISSING");return this.dht}setPubSub(e){return this.pubsub=e,Fr(e)&&e.init(this),e}getPubSub(){if(null==this.pubsub)throw ae(new Error("pubsub not set"),"ERR_SERVICE_MISSING");return this.pubsub}setDialer(e){return this.dialer=e,Fr(e)&&e.init(this),e}getDialer(){if(null==this.dialer)throw ae(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this.dialer}}class mT extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function vs(n,e,t){const r=t??{},i=function Y5(n){if(null!=n){if("function"==typeof n[Symbol.iterator])return n[Symbol.iterator]();if("function"==typeof n[Symbol.asyncIterator])return n[Symbol.asyncIterator]();if("function"==typeof n.next)return n}throw new Error("argument is not an iterator or iterable")}(n);function o(){return(o=hn(function*(){let a;const u=()=>{a?.()};for(e.addEventListener("abort",u);;){let _;try{if(e.aborted){const{abortMessage:N,abortCode:B}=r;throw new mT(N,B)}const R=new Promise((N,B)=>{a=()=>{const{abortMessage:z,abortCode:X}=r;B(new mT(z,X))}});_=yield lt(Promise.race([R,i.next()])),a=null}catch(R){e.removeEventListener("abort",u);const N="aborted"===R.type&&e.aborted;if(N&&null!=r.onAbort&&(yield lt(r.onAbort(n))),"function"==typeof i.return)try{const B=i.return();B instanceof Promise&&B.catch(z=>{null!=r.onReturnError&&r.onReturnError(z)})}catch(B){null!=r.onReturnError&&r.onReturnError(B)}if(N&&!0===r.returnOnAbort)return;throw R}if(!0===_.done)break;yield _.value}e.removeEventListener("abort",u)})).apply(this,arguments)}return function s(){return o.apply(this,arguments)}()}function Q5(n,e,t){return r=>n(vs(r,e,t))}function Go(n,e,t){return{sink:Q5(n.sink,e,{...t,onAbort:void 0}),source:vs(n.source,e,t)}}var dr=x(1732);function vT(n){return new Uint8Array(n)}var un=(()=>(function(n){n[n.NEW_STREAM=0]="NEW_STREAM",n[n.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",n[n.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",n[n.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",n[n.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",n[n.RESET_RECEIVER=5]="RESET_RECEIVER",n[n.RESET_INITIATOR=6]="RESET_INITIATOR"}(un||(un={})),un))();const zm=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),ET=Object.freeze({NEW_STREAM:un.NEW_STREAM,MESSAGE:un.MESSAGE_INITIATOR,CLOSE:un.CLOSE_INITIATOR,RESET:un.RESET_INITIATOR}),Z5=Object.freeze({MESSAGE:un.MESSAGE_RECEIVER,CLOSE:un.CLOSE_RECEIVER,RESET:un.RESET_RECEIVER}),bT=new class X5{constructor(){this._pool=vT(10240),this._poolOffset=0}write(e){const t=this._pool;let r=this._poolOffset;dr.encode(e.id<<3|e.type,t,r),r+=dr.encode.bytes,dr.encode(e.type!==un.NEW_STREAM&&e.type!==un.MESSAGE_INITIATOR&&e.type!==un.MESSAGE_RECEIVER||null==e.data?0:e.data.length,t,r),r+=dr.encode.bytes;const i=t.subarray(this._poolOffset,r);return 10240-r<100?(this._pool=vT(10240),this._poolOffset=0):this._poolOffset=r,e.type!==un.NEW_STREAM&&e.type!==un.MESSAGE_INITIATOR&&e.type!==un.MESSAGE_RECEIVER||null==e.data?[i]:[i,...e.data instanceof Uint8Array?[e.data]:e.data]}};function Wm(){return Wm=hn(function*(n){var r,e=!1,t=!1;try{for(var s,i=Pt(n);e=!(s=yield lt(i.next())).done;e=!1){const o=s.value;if(Array.isArray(o))for(const a of o)yield*Mr(Pt(bT.write(a)),lt);else yield*Mr(Pt(bT.write(o)),lt)}}catch(o){t=!0,r=o}finally{try{e&&null!=i.return&&(yield lt(i.return()))}finally{if(t)throw r}}}),Wm.apply(this,arguments)}class eU{constructor(){this._buffer=new qr,this._headerInfo=null}write(e){if(null==e||0===e.length)return[];this._buffer.append(e);const t=[];for(;0!==this._buffer.length;){if(null==this._headerInfo)try{this._headerInfo=this._decodeHeader(this._buffer)}catch{break}const{id:r,type:i,length:s,offset:o}=this._headerInfo;if(this._buffer.length-o>3,type:o,offset:r+s,length:i}}}function _T(n,e=0){let s,t=0,r=0,i=e;const o=n.length;do{if(i>=o||r>49)throw e=0,new RangeError("Could not decode varint");s=n.get(i++),t+=r<28?(127&s)<=128);return{value:t,offset:e=i-e}}function nU(n){return qm.apply(this,arguments)}function qm(){return qm=hn(function*(n){const e=new eU;var i,t=!1,r=!1;try{for(var o,s=Pt(n);t=!(o=yield lt(s.next())).done;t=!1){const u=e.write(o.value);u.length>0&&(yield u)}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield lt(s.return()))}finally{if(r)throw i}}}),qm.apply(this,arguments)}const DT=1<<20;var dh=x(772);const Es=zt("libp2p:mplex:stream"),Ym="ERR_STREAM_RESET";class cU extends Map{constructor(e){super();const{system:t,component:r,metric:i,metrics:s}=e;this.system=t??"libp2p",this.component=r,this.metric=i,this.metrics=s,this.updateComponentMetric()}set(e,t){return super.set(e,t),this.updateComponentMetric(),this}delete(e){const t=super.delete(e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metrics.updateComponentMetric({system:this.system,component:this.component,metric:this.metric,value:this.size})}}function Ll(n){const{system:e,component:t,metric:r,metrics:i}=n;let s;return s=null!=i?new cU({system:e,component:t,metric:r,metrics:i}):new Map,s}var uU=x(7813);const bs=zt("libp2p:mplex");function ST(n){const e={...n,type:`${zm[n.type]} (${n.type})`};return n.type===un.NEW_STREAM&&(e.data=Lt(n.data instanceof Uint8Array?n.data:n.data.subarray())),(n.type===un.MESSAGE_INITIATOR||n.type===un.MESSAGE_RECEIVER)&&(e.data=Lt(n.data instanceof Uint8Array?n.data:n.data.subarray(),"base16")),e}class pU{constructor(e,t){this.protocol="/mplex/6.7.0",t=t??{},this._streamId=0,this._streams={initiators:Ll({metrics:e.getMetrics(),component:"mplex",metric:"initiatorStreams"}),receivers:Ll({metrics:e.getMetrics(),component:"mplex",metric:"receiverStreams"})},this._init=t,this.sink=this._createSink();const r=this._createSource();this._source=r,this.source=r,this.closeController=new AbortController,this.rateLimiter=new uU.RateLimiterMemory({points:t.disconnectThreshold??5,duration:1})}init(e){}get streams(){const e=[];for(const t of this._streams.initiators.values())e.push(t);for(const t of this._streams.receivers.values())e.push(t);return e}newStream(e){if(this.closeController.signal.aborted)throw new Error("Muxer already closed");const t=this._streamId++;return e=null==e?t.toString():e.toString(),this._newStream({id:t,name:e,type:"initiator",registry:this._streams.initiators})}close(e){this.closeController.signal.aborted||(this.streams.forEach(null!=e?t=>t.abort(e):t=>t.close()),this.closeController.abort())}_newReceiverStream(e){const{id:t,name:r}=e;return this._newStream({id:t,name:r,type:"receiver",registry:this._streams.receivers})}_newStream(e){const{id:t,name:r,type:i,registry:s}=e;if(bs("new %s stream %s %s",i,t),"initiator"===i&&this._streams.initiators.size===(this._init.maxOutboundStreams??1024))throw ae(new Error("Too many outbound streams open"),"ERR_TOO_MANY_OUTBOUND_STREAMS");if(s.has(t))throw new Error(`${i} stream ${t} already exists!`);const u=function aU(n){const{id:e,name:t,send:r,onEnd:i,type:s="initiator",maxMsgSize:o=DT}=n,a=new AbortController,u=new AbortController,_=new AbortController,R="initiator"===s?ET:Z5,N="initiator"===s?`i${e}`:`r${e}`,B=`${t??e}`;let oe,z=!1,X=!1,J=!1;const de={open:Date.now()},ue=Pe=>{X||(X=!0,Es.trace("%s stream %s sink end - err: %o",s,B,Pe),null!=Pe&&null==oe&&(oe=Pe),z&&(de.close=Date.now(),i?.(oe)))},Te=kc({onEnd:Pe=>{z||(z=!0,Es.trace("%s stream %s source end - err: %o",s,B,Pe),null!=Pe&&null==oe&&(oe=Pe),X&&(Ke.stat.timeline.close=Date.now(),i?.(oe)))}}),Ke={close:()=>{Es.trace("%s stream %s close",s,B),Ke.closeRead(),Ke.closeWrite()},closeRead:()=>{Es.trace("%s stream %s closeRead",s,B),!z&&Te.end()},closeWrite:()=>{if(Es.trace("%s stream %s closeWrite",s,B),!X){_.abort();try{r({id:e,type:R.CLOSE})}catch(Pe){Es.trace("%s stream %s error sending close",s,t,Pe)}ue()}},abort:Pe=>{Es.trace("%s stream %s abort",s,B,Pe),Te.end(Pe),a.abort(),ue(Pe)},reset:()=>{const Pe=ae(new Error("stream reset"),Ym);u.abort(),Te.end(Pe),ue(Pe)},sink:(Pe=$(function*(bt){if(J)throw ae(new Error("sink already called on stream"),"ERR_DOUBLE_SINK");if(J=!0,X)throw ae(new Error("stream closed for writing"),"ERR_SINK_ENDED");bt=vs(bt,(0,dh.anySignal)([a.signal,u.signal,_.signal]));try{"initiator"===s&&r({id:e,type:ET.NEW_STREAM,data:new qr(Ot(B))});const Qn=new qr;var pn,yt=!1,Xt=!1;try{for(var Di,Gn=Pt(bt);yt=!(Di=yield Gn.next()).done;yt=!1)for(Qn.append(Di.value);0!==Qn.length;){if(Qn.length<=o){r({id:e,type:R.MESSAGE,data:Qn.sublist()}),Qn.consume(Qn.length);break}r({id:e,type:R.MESSAGE,data:Qn.sublist(0,o)}),Qn.consume(o)}}catch(Do){Xt=!0,pn=Do}finally{try{yt&&null!=Gn.return&&(yield Gn.return())}finally{if(Xt)throw pn}}}catch(Qn){if("aborted"===Qn.type&&"The operation was aborted"===Qn.message){if(_.signal.aborted)return;u.signal.aborted&&(Qn.message="stream reset",Qn.code=Ym),a.signal.aborted&&(Qn.message="stream aborted",Qn.code="ERR_STREAM_ABORT")}if(Qn.code===Ym)Es.trace("%s stream %s reset",s,t);else{Es.trace("%s stream %s error",s,t,Qn);try{r({id:e,type:R.RESET})}catch(Do){Es.trace("%s stream %s error sending reset",s,t,Do)}}return Te.end(Qn),void ue(Qn)}try{r({id:e,type:R.CLOSE})}catch(Qn){Es.trace("%s stream %s error sending close",s,t,Qn)}ue()}),function(yt){return Pe.apply(this,arguments)}),source:Te,sourcePush:Pe=>{Te.push(Pe)},sourceReadableLength:()=>Te.readableLength,stat:{direction:"initiator"===s?"outbound":"inbound",timeline:de},metadata:{},id:N};var Pe;return Ke}({id:t,name:r,send:_=>{bs.enabled&&bs.trace("%s stream %s send",i,t,ST(_)),this._source.push(_)},type:i,onEnd:()=>{bs("%s stream with id %s and protocol %s ended",i,t,u.stat.protocol),s.delete(t),null!=this._init.onStreamEnd&&this._init.onStreamEnd(u)},maxMsgSize:this._init.maxMsgSize});return s.set(t,u),u}_createSink(){var e=this;return function(){var r=$(function*(i){const s=[e.closeController.signal];null!=e._init.signal&&s.push(e._init.signal),i=vs(i,dh(s));try{yield qn(i,nU,function rU(n){const e=n??DT,t=r=>{if((r.type===un.NEW_STREAM||r.type===un.MESSAGE_INITIATOR||r.type===un.MESSAGE_RECEIVER)&&r.data.byteLength>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return r=>{return(i=hn(function*(){var u,o=!1,a=!1;try{for(var R,_=Pt(r);o=!(R=yield lt(_.next())).done;o=!1){const N=R.value;Array.isArray(N)?(N.forEach(t),yield*Mr(Pt(N),lt)):(t(N),yield N)}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield lt(_.return()))}finally{if(a)throw u}}}),function s(){return i.apply(this,arguments)})();var i}}(e._init.maxMsgSize),function(){var o=$(function*(a){var R,u=!1,_=!1;try{for(var B,N=Pt(a);u=!(B=yield N.next()).done;u=!1){const z=B.value;yield e._handleIncoming(z)}}catch(z){_=!0,R=z}finally{try{u&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()),e._source.end()}catch(o){bs("error in sink",o),e._source.end(o)}});return function(s){return r.apply(this,arguments)}}()}_createSource(){const t=function pB(n={}){return jC(t=>{let r;const i=[];for(;!t.isEmpty()&&(r=t.shift(),null!=r);){if(null!=r.error)throw r.error;!1===r.done&&i.push(r.value)}return null==r?{done:!0}:{done:!0===r.done,value:i}},n)}({objectMode:!0,onEnd:r=>{this.close(r)}});return Object.assign(function J5(n){return Wm.apply(this,arguments)}(t),{push:t.push,end:t.end,return:t.return})}_handleIncoming(e){var t=this;return $(function*(){const{id:r,type:i}=e;if(bs.enabled&&bs.trace("incoming message",ST(e)),e.type===un.NEW_STREAM){if(t._streams.receivers.size===(t._init.maxInboundStreams??1024)){bs("too many inbound streams open"),t._source.push({id:r,type:un.RESET_RECEIVER});try{yield t.rateLimiter.consume("new-stream",1)}catch{return bs("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),void t._source.end(new Error("Too many open streams"))}return}const u=t._newReceiverStream({id:r,name:Lt(e.data instanceof Uint8Array?e.data:e.data.subarray())});return void(null!=t._init.onIncomingStream&&t._init.onIncomingStream(u))}const o=(1==(1&i)?t._streams.initiators:t._streams.receivers).get(r);if(null==o)return void bs("missing stream %s for message type %s",r,zm[i]);const a=t._init.maxStreamBufferSize??4194304;switch(i){case un.MESSAGE_INITIATOR:case un.MESSAGE_RECEIVER:if(o.sourceReadableLength()>a){t._source.push({id:e.id,type:i===un.MESSAGE_INITIATOR?un.RESET_RECEIVER:un.RESET_INITIATOR});const u=ae(new Error("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers"),"ERR_STREAM_INPUT_BUFFER_FULL");return void o.abort(u)}o.sourcePush(e.data);break;case un.CLOSE_INITIATOR:case un.CLOSE_RECEIVER:o.closeRead();break;case un.RESET_INITIATOR:case un.RESET_RECEIVER:o.reset();break;default:bs("unknown message type %s",i)}})()}}class gU{constructor(e={}){this.protocol="/mplex/6.7.0",this.components=new ho,this._init=e}init(e){this.components=e}createStreamMuxer(e={}){return new pU(this.components,{...e,...this._init})}}const yU=WebSocket;var mU=x(3676);function CT(n){return n instanceof ArrayBuffer||"ArrayBuffer"===n?.constructor?.name&&"number"==typeof n?.byteLength}const vU=n=>{n.binaryType="arraybuffer";const e=function(){var s=$(function*(){return yield new Promise((o,a)=>{if(r)return o();if(null!=i)return a(i);const u=N=>{n.removeEventListener("open",_),n.removeEventListener("error",R),N()},_=()=>u(o),R=N=>{u(()=>a(N.error??new Error(`connect ECONNREFUSED ${n.url}`)))};n.addEventListener("open",_),n.addEventListener("error",R)})});return function(){return s.apply(this,arguments)}}(),t=hn(function*(){const s=new mU.zN(({push:N,stop:B,fail:z})=>{const X=oe=>{let de=null;"string"==typeof oe.data&&(de=Ot(oe.data)),CT(oe.data)&&(de=new Uint8Array(oe.data)),oe.data instanceof Uint8Array&&(de=oe.data),null!=de&&N(de)},J=oe=>z(oe.error??new Error("Socket error"));return n.addEventListener("message",X),n.addEventListener("error",J),n.addEventListener("close",B),()=>{n.removeEventListener("message",X),n.removeEventListener("error",J),n.removeEventListener("close",B)}},{highWaterMark:1/0});yield lt(e());var u,o=!1,a=!1;try{for(var R,_=Pt(s);o=!(R=yield lt(_.next())).done;o=!1){const N=R.value;yield CT(N)?new Uint8Array(N):N}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield lt(_.return()))}finally{if(a)throw u}}})();let i,r=1===n.readyState;return n.addEventListener("open",()=>{r=!0,i=null}),n.addEventListener("close",()=>{r=!1,i=null}),n.addEventListener("error",s=>{r||(i=s.error??new Error(`connect ECONNREFUSED ${n.url}`))}),Object.assign(t,{connected:e})},EU=n=>{if(n.readyState>=2)throw new Error("socket closed");if(1!==n.readyState)return new Promise((e,t)=>{function r(){n.removeEventListener("open",i),n.removeEventListener("error",s)}function i(){r(),e()}function s(o){r(),t(o.error??new Error(`connect ECONNREFUSED ${n.url}`))}n.addEventListener("open",i),n.addEventListener("error",s)})},bU=(n,e)=>((e=e??{}).closeOnEnd=!1!==e.closeOnEnd,function(){var r=$(function*(i){var a,s=!1,o=!1;try{for(var _,u=Pt(i);s=!(_=yield u.next()).done;s=!1){const R=_.value;try{yield EU(n)}catch(N){if("socket closed"===N.message)break;throw N}n.send(R)}}catch(R){o=!0,a=R}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(o)throw a}}if(null!=e.closeOnEnd&&n.readyState<=1)return yield new Promise((R,N)=>{n.addEventListener("close",B=>{if(B.wasClean||1006===B.code)R();else{const z=Object.assign(new Error("ws error"),{event:B});N(z)}}),setTimeout(()=>n.close())})});return function(s){return r.apply(this,arguments)}}()),wU=(n,e)=>{e=e??{};const t=vU(n);let r=e.remoteAddress,i=e.remotePort;if(null!=n.url)try{const o=new URL(n.url);r=o.hostname,i=parseInt(o.port,10)}catch{}if(null==r||null==i)throw new Error("Remote connection did not have address and/or port");return{sink:bU(n,e),source:t,connected:(o=$(function*(){return yield t.connected()}),function(){return o.apply(this,arguments)}),close:function(){var o=$(function*(){(n.readyState===n.CONNECTING||n.readyState===n.OPEN)&&(yield new Promise(a=>{n.addEventListener("close",()=>{a()}),n.close()}))});return function(){return o.apply(this,arguments)}}(),destroy:()=>{null!=n.terminate?n.terminate():n.close()},remoteAddress:r,remotePort:i,socket:n};var o};var _U=x(8596);const DU={http:"ws",https:"wss"};const IT="[a-fA-F\\d:]",Wo=n=>n&&n.includeBoundaries?`(?:(?<=\\s|^)(?=${IT})|(?<=${IT})(?=\\s|$))`:"",ws="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",Dr="[a-fA-F\\d]{1,4}",hh=`\n(?:\n(?:${Dr}:){7}(?:${Dr}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${Dr}:){6}(?:${ws}|:${Dr}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${Dr}:){5}(?::${ws}|(?::${Dr}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${Dr}:){4}(?:(?::${Dr}){0,1}:${ws}|(?::${Dr}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${Dr}:){3}(?:(?::${Dr}){0,2}:${ws}|(?::${Dr}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${Dr}:){2}(?:(?::${Dr}){0,3}:${ws}|(?::${Dr}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${Dr}:){1}(?:(?::${Dr}){0,4}:${ws}|(?::${Dr}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${Dr}){0,5}:${ws}|(?::${Dr}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),TU=new RegExp(`(?:^${ws}$)|(?:^${hh}$)`),AU=new RegExp(`^${ws}$`),xU=new RegExp(`^${hh}$`),Qm=n=>n&&n.exact?TU:new RegExp(`(?:${Wo(n)}${ws}${Wo(n)})|(?:${Wo(n)}${hh}${Wo(n)})`,"g");Qm.v4=n=>n&&n.exact?AU:new RegExp(`${Wo(n)}${ws}${Wo(n)}`,"g"),Qm.v6=n=>n&&n.exact?xU:new RegExp(`${Wo(n)}${hh}${Wo(n)}`,"g");const Zm=Qm,{toString:NU}=Object.prototype,TT={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Xm(n,e,{}={}){try{return function RU(n){const e=(...t)=>n(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${n.name||""})`,configurable:!0}),e}(()=>function OU(n,e={}){if(!function MU(n){return"[object RegExp]"===NU.call(n)}(n))throw new TypeError("Expected a RegExp instance");const t=Object.keys(TT).map(i=>("boolean"==typeof e[i]?e[i]:n[i])?TT[i]:"").join(""),r=new RegExp(e.source||n.source,t);return r.lastIndex="number"==typeof e.lastIndex?e.lastIndex:n.lastIndex,r}(n).test(e))()}catch(r){throw r}}const Jm={timeout:400};function ev(n){return Xm(Zm({exact:!0}),n.slice(0,45),Jm)}const PT=function LU(n){return Xm(Zm.v4({exact:!0}),n.slice(0,15),Jm)},BU=function RT(n){return Xm(Zm.v6({exact:!0}),n.slice(0,45),Jm)},NT=function(n){let t,e=0;if(n=n.trim(),PT(n))t=new Uint8Array(e+4),n.split(/\./g).forEach(r=>{t[e++]=255&parseInt(r,10)});else if(BU(n)){const r=n.split(":",8);let i;for(i=0;i0;i--)s.push("0");r.splice.apply(r,s)}for(t=new Uint8Array(e+16),i=0;i>8&255,t[e++]=255&s}}if(null==t)throw new Error(`invalid ip address "${n}"`);return t},_s=-1,ph={},tv={};function Sr(n){if("number"==typeof n){if(null!=tv[n])return tv[n];throw new Error(`no protocol with code: ${n}`)}if("string"==typeof n){if(null!=ph[n])return ph[n];throw new Error(`no protocol with name: ${n}`)}throw new Error("invalid protocol id type: "+typeof n)}function MT(n,e){switch(Sr(n).code){case 4:case 41:return function HU(n){const e=function(n,e=0,t){e=~~e,t=t??n.length-e;const r=[];let i="";const s=new DataView(n.buffer);if(4===t){for(let o=0;o65536)throw new Error("Port number is not in range(1, 65536)");const i=rv(r);return br([t,i],t.length+i.length)}(e);case 445:return function YU(n){const e=n.split(":");if(2!==e.length)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(56!==e[0].length)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);const t=co.decode(`b${e[0]}`),r=parseInt(e[1],10);if(r<1||r>65536)throw new Error("Port number is not in range(1, 65536)");const i=rv(r);return br([t,i],t.length+i.length)}(e);case 466:return function zU(n){const e=VU.decode(n),t=Uint8Array.from(dr.encode(e.length));return br([t,e],t.length+e.length)}(e);default:return Ot(e,"base16")}}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,_s,"ip6zone"],[53,_s,"dns",!0],[54,_s,"dns4",!0],[55,_s,"dns6",!0],[56,_s,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,_s,"unix",!1,!0],[421,_s,"ipfs"],[421,_s,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,_s,"garlic64"],[460,0,"quic"],[466,_s,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,_s,"memory"]].forEach(n=>{const e=function UU(n,e,t,r,i){return{code:n,size:e,name:t,resolvable:Boolean(r),path:Boolean(i)}}(...n);tv[e.code]=e,ph[e.name]=e});const nv=Object.values(El).map(n=>n.decoder),VU=function(){let n=nv[0].or(nv[1]);return nv.slice(2).forEach(e=>n=n.or(e)),n}();function rv(n){const e=new ArrayBuffer(2);return new DataView(e).setUint16(0,n),new Uint8Array(e)}function LT(n){return new DataView(n.buffer).getUint16(n.byteOffset)}function FT(n){return n.map(e=>{const t=yh(e);return null!=e[1]?[t.code,MT(t.code,e[1])]:[t.code]})}function UT(n){return sv(br(n.map(e=>{const t=yh(e);let r=Uint8Array.from(dr.encode(t.code));return e.length>1&&null!=e[1]&&(r=br([r,e[1]])),r})))}function VT(n,e){return n.size>0?n.size/8:0===n.size?0:dr.decode(e)+dr.decode.bytes}function gh(n){const e=[];let t=0;for(;tn.length)throw KT("Invalid address Uint8Array: "+Lt(n,"base16"));e.push([r,a])}return e}function iv(n){return function ZU(n){const e=[];return n.map(t=>{const r=yh(t);return e.push(r.name),t.length>1&&null!=t[1]&&e.push(t[1]),null}),ov(e.join("/"))}(FT(gh(n)))}function sv(n){const e=function HT(n){try{gh(n)}catch(e){return e}}(n);if(null!=e)throw e;return Uint8Array.from(n)}function ov(n){return"/"+n.trim().split("/").filter(e=>e).join("/")}function KT(n){return new Error("Error parsing address: "+n)}function yh(n){return Sr(n[0])}const tV=Symbol.for("nodejs.util.inspect.custom"),$T=[Sr("dns").code,Sr("dns4").code,Sr("dns6").code,Sr("dnsaddr").code],nV=[Sr("p2p").code,Sr("ipfs").code],jT=new Map,zT=Symbol.for("@multiformats/js-multiaddr/multiaddr");let mn=(()=>{class n{constructor(t){if(null==t&&(t=""),Object.defineProperty(this,zT,{value:!0}),t instanceof Uint8Array)this.bytes=sv(t);else if("string"==typeof t){if(t.length>0&&"/"!==t.charAt(0))throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=function eV(n){return function JU(n){const e=function QU(n){const e=[],t=n.split("/").slice(1);if(1===t.length&&""===t[0])return[];for(let r=0;r=t.length)throw KT("invalid address: "+n);if(!0===s.path){e.push([i,ov(t.slice(r).join("/"))]);break}e.push([i,t[r]])}else e.push([i])}return e}(n=ov(n)),t=function XU(n){return n.map(e=>{Array.isArray(e)||(e=[e]);const t=yh(e);return e.length>1?[t.code,OT(t.code,e[1])]:[t.code]})}(e);return UT(t)}(n)}(t)}else{if(!n.isMultiaddr(t))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=sv(t.bytes)}}toString(){return iv(this.bytes)}toJSON(){return this.toString()}toOptions(){const t=this.protoCodes(),r=this.toString().split("/").slice(1);let i,s;if(r.length>2)$T.includes(t[0])&&nV.includes(t[1])?(i=Sr("tcp").name,s=443):(i=Sr(r[2]).name,s=parseInt(r[3]));else{if(!$T.includes(t[0]))throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');i=Sr("tcp").name,s=443}return{family:41===t[0]||55===t[0]?6:4,host:r[1],transport:i,port:s}}protos(){return this.protoCodes().map(t=>Object.assign({},Sr(t)))}protoCodes(){const t=[],r=this.bytes;let i=0;for(;it.name)}tuples(){return gh(this.bytes)}stringTuples(){return FT(gh(this.bytes))}encapsulate(t){return t=new n(t),new n(this.toString()+t.toString())}decapsulate(t){const r=t.toString(),i=this.toString(),s=i.lastIndexOf(r);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new n(i.slice(0,s))}decapsulateCode(t){const r=this.tuples();for(let i=r.length-1;i>=0;i--)if(r[i][0]===t)return new n(UT(r.slice(0,i)));return this}getPeerId(){try{const r=this.stringTuples().filter(i=>i[0]===ph.ipfs.code).pop();if(null!=r?.[1]){const i=r[1];return Lt("Q"===i[0]||"1"===i[0]?ui.decode(`z${i}`):wr.parse(i).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(r=>!0===Sr(r[0]).path)[0][1],null==t&&(t=null)}catch{t=null}return t}equals(t){return kr(this.bytes,t.bytes)}resolve(t){var r=this;return $(function*(){const i=r.protos().find(a=>a.resolvable);if(null==i)return[r];const s=jT.get(i.name);if(null==s)throw ae(new Error(`no available resolver for ${i.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(yield s(r,t)).map(a=>new n(a))})()}nodeAddress(){const t=this.toOptions();if("tcp"!==t.transport&&"udp"!==t.transport)throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){const r=(t??this).protos();return!(2!==r.length||4!==r[0].code&&41!==r[0].code||6!==r[1].code&&273!==r[1].code)}static fromNodeAddress(t,r){if(null==t)throw new Error("requires node address object");if(null==r)throw new Error("requires transport protocol");let i;switch(t.family){case 4:i="ip4";break;case 6:i="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new n("/"+[i,t.address,r,t.port].join("/"))}static isName(t){return!!n.isMultiaddr(t)&&t.protos().some(r=>r.resolvable)}static isMultiaddr(t){return Boolean(t?.[zT])}[tV](){return""}inspect(){return""}}return n.resolvers=jT,n})();const mh=(n,e)=>e,sV={ip4:mh,ip6:(n,e,t,r)=>1===r.length&&"ip6"===r[0].protocol?e:`[${e}]`,tcp:(n,e,t,r,i)=>r.some(s=>["http","https","ws","wss"].includes(s.protocol))?`${n}:${e}`:((n,e,t,r)=>{if(null!=r&&!1===r.assumeHttp)return`tcp://${n}:${e}`;let i="tcp",s=`:${e}`;return"tcp"===t[t.length-1].protocol&&(i="443"===e?"https":"http",s="443"===e||"80"===e?"":s),`${i}://${n}${s}`})(n,e,r,i),udp:(n,e)=>`udp://${n}:${e}`,dnsaddr:mh,dns4:mh,dns6:mh,ipfs:(n,e)=>`${n}/ipfs/${e}`,p2p:(n,e)=>`${n}/p2p/${e}`,http:n=>`http://${n}`,https:n=>`https://${n}`,ws:n=>`ws://${n}`,wss:n=>`wss://${n}`,"p2p-websocket-star":n=>`${n}/p2p-websocket-star`,"p2p-webrtc-star":n=>`${n}/p2p-webrtc-star`,"p2p-webrtc-direct":n=>`${n}/p2p-webrtc-direct`};class nu extends Error{constructor(e="The operation was aborted"){super(e),this.code=nu.code,this.type=nu.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}}var aV=x(9456);const av="object"==typeof window&&"object"==typeof document&&9===document.nodeType,vh=aV(),Eh=av&&!vh,cV=vh&&!av,uV=vh&&av,lV=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&"node"===globalThis.process.release.name&&!vh,GT="function"==typeof importScripts&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,fV=(typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis,typeof navigator<"u"&&"ReactNative"===navigator.product);class yV extends Error{constructor(e){super(e),this.name="TimeoutError"}}class mV extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const YT=n=>void 0===globalThis.DOMException?new mV(n):new DOMException(n),QT=n=>{const e=void 0===n.reason?YT("This operation was aborted."):n.reason;return e instanceof Error?e:YT(e)},ZT=zt("libp2p:websockets:socket");const bV=It("dns4"),wV=It("dns6"),_V=It("dnsaddr"),Ca=Zr(It("dns"),_V,bV,wV),bh=Zr(It("ip4"),It("ip6")),Bl=Zr(en(bh,It("tcp")),en(Ca,It("tcp"))),XT=en(bh,It("udp")),DV=en(XT,It("utp")),SV=en(XT,It("quic")),ru=Zr(en(Bl,It("ws")),en(Ca,It("ws"))),Ia=Zr(en(Bl,It("wss")),en(Ca,It("wss"))),cv=Zr(en(Bl,It("http")),en(bh,It("http")),en(Ca,It("http"))),uv=Zr(en(Bl,It("https")),en(bh,It("https")),en(Ca,It("https"))),JT=Zr(en(ru,It("p2p-webrtc-star"),It("p2p")),en(Ia,It("p2p-webrtc-star"),It("p2p")),en(ru,It("p2p-webrtc-star")),en(Ia,It("p2p-webrtc-star"))),e2=(Zr(en(ru,It("p2p-websocket-star"),It("p2p")),en(Ia,It("p2p-websocket-star"),It("p2p")),en(ru,It("p2p-websocket-star")),en(Ia,It("p2p-websocket-star"))),Zr(en(cv,It("p2p-webrtc-direct"),It("p2p")),en(uv,It("p2p-webrtc-direct"),It("p2p")),en(cv,It("p2p-webrtc-direct")),en(uv,It("p2p-webrtc-direct")))),Fl=Zr(ru,Ia,cv,uv,JT,e2,Bl,DV,SV,Ca),qo=(Zr(en(Fl,It("p2p-stardust"),It("p2p")),en(Fl,It("p2p-stardust"))),Zr(en(Fl,It("p2p")),JT,e2,It("p2p"))),t2=Zr(en(qo,It("p2p-circuit"),qo),en(qo,It("p2p-circuit")),en(It("p2p-circuit"),qo),en(Fl,It("p2p-circuit")),en(It("p2p-circuit"),Fl),It("p2p-circuit")),n2=()=>Zr(en(t2,n2),t2),iu=n2();function r2(n){return function e(t){let r;try{r=new mn(t)}catch{return!1}const i=n(r.protoNames());return null!==i&&(!0===i||!1===i?i:0===i.length)}}function en(...n){function e(t){if(t.length(r="function"==typeof i?i().partialMatch(t):i.partialMatch(t),Array.isArray(r)&&(t=r),null===r)),r}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:r2(e),partialMatch:e}}function Zr(...n){function e(r){let i=null;return n.some(s=>{const o="function"==typeof s?s().partialMatch(r):s.partialMatch(r);return null!=o&&(i=o,!0)}),i}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:r2(e),partialMatch:e}}function It(n){const e=n;return{toString:function(){return e},matches:function t(i){let s;try{s=new mn(i)}catch{return!1}const o=s.protoNames();return 1===o.length&&o[0]===e},partialMatch:function r(i){return 0===i.length?null:i[0]===e?i.slice(1):null}}}function i2(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return ru.matches(t)||Ia.matches(t)})}Zr(en(iu,qo,iu),en(qo,iu),en(iu,qo),iu,qo);const lv=Symbol.for("@libp2p/transport"),Yo=zt("libp2p:websockets");class IV{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[lv](){return!0}dial(e,t){var r=this;return $(function*(){Yo("dialing %s",e),t=t??{};const s=function EV(n,e,t){const r={sink:i=>$(function*(){null!=t?.signal&&(i=vs(i,t.signal));try{yield n.sink(i)}catch(s){"aborted"!==s.type&&ZT.error(s)}})(),source:null!=(t=t??{}).signal?vs(n.source,t.signal):n.source,remoteAddr:e,timeline:{open:Date.now()},close:()=>$(function*(){const i=Date.now();try{yield function vV(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((u,_)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if(e.signal){const{signal:R}=e;R.aborted&&_(QT(R)),R.addEventListener("abort",()=>{_(QT(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{u(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new yV("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),$(function*(){try{u(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else u(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}(n.close(),{milliseconds:2e3})}catch{const{host:o,port:a}=r.remoteAddr.toOptions();ZT("timeout closing stream to %s:%s after %dms, destroying it manually",o,a,Date.now()-i),n.destroy()}finally{r.timeline.close=Date.now()}})()};return null!=n.socket.once&&n.socket.once("close",()=>{null==r.timeline.close&&(r.timeline.close=Date.now())}),r}(yield r._connect(e,t),e);Yo("new outbound connection %s",s.remoteAddr);const o=yield t.upgrader.upgradeOutbound(s);return Yo("outbound connection %s upgraded",s.remoteAddr),o})()}_connect(e,t){var r=this;return $(function*(){if(!0===t?.signal?.aborted)throw new nu;const i=e.toOptions();Yo("dialing %s:%s",i.host,i.port);const s=D0(),o=R=>{Yo.error("connection error:",R),s.reject(R)},a=function IU(n,e){e=e??{};const r=((n,e)=>(0,_U.relative)(n,e,DU,"ws"))(n,(typeof window>"u"?"":window.location).toString()),i=new yU(r,e.websocket);return wU(i,e)}(function oV(n,e){const t=new mn(n),r=n.toString().split("/").slice(1);return t.tuples().map(i=>({protocol:r.shift()??"",content:null!=i[1]?r.shift()??"":""})).reduce((i,s,o,a)=>{const u=sV[s.protocol];if(null==u)throw new Error(`Unsupported protocol ${s.protocol}`);return u(i,s.content,o,a,e)},"")}(e),r.init);if(null!=a.socket.on?a.socket.on("error",o):a.socket.onerror=o,null==t.signal)return yield Promise.race([a.connected(),s.promise]),Yo("connected %s",e),a;let u;const _=new Promise((R,N)=>{if(u=()=>{N(new nu),setTimeout(()=>{a.close().catch(B=>{Yo.error("error closing raw socket",B)})})},!0===t?.signal?.aborted)return u();t?.signal?.addEventListener("abort",u)});try{yield Promise.race([_,s.promise,a.connected()])}finally{null!=u&&t?.signal?.removeEventListener("abort",u)}return Yo("connected %s",e),a})()}createListener(e){return function dV(){throw new Error("WebSocket Servers can not be created in the browser!")}()}filter(e){return e=Array.isArray(e)?e:[e],null!=this.init?.filter?this.init?.filter(e):Eh||GT?function CV(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return Ia.matches(t)&&Ca.matches(t.decapsulateCode(6).decapsulateCode(478))})}(e):i2(e)}}var po,Ta=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};class Ei extends EventTarget{constructor(){super(...arguments),po.set(this,new Map)}listenerCount(e){const t=Ta(this,po,"f").get(e);return null==t?0:t.length}addEventListener(e,t,r){super.addEventListener(e,t,r);let i=Ta(this,po,"f").get(e);null==i&&(i=[],Ta(this,po,"f").set(e,i)),i.push({callback:t,once:(!0!==r&&!1!==r&&r?.once)??!1})}removeEventListener(e,t,r){super.removeEventListener(e.toString(),t??null,r);let i=Ta(this,po,"f").get(e);null!=i&&(i=i.filter(({callback:s})=>s!==t),Ta(this,po,"f").set(e,i))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=Ta(this,po,"f").get(e.type);return null==r||(r=r.filter(({once:i})=>!i),Ta(this,po,"f").set(e.type,r)),t}}po=new WeakMap;class TV extends Event{constructor(e,t){super(e,t),this.detail=t?.detail}}const nn=globalThis.CustomEvent??TV;var Ul=x(5357);const s2=(n,e)=>hn(function*(){const t=yield lt(Ul(n));yield*Mr(Pt(t.sort(e)),lt)})();var Qo=x(7414),Ds=x(6225),o2=x(0);const go="/",a2=(new TextEncoder).encode(go),wh=a2[0];class Ur{constructor(e,t){if("string"==typeof e)this._buf=Ot(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==wh)throw new Error("Invalid key")}toString(e="utf8"){return Lt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Ur(e.join(go))}static random(){return new Ur(((n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""))().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||"string"==typeof e?new Ur(e):"function"==typeof e.uint8Array?new Ur(e.uint8Array()):null}clean(){if((null==this._buf||0===this._buf.byteLength)&&(this._buf=a2),this._buf[0]!==wh){const e=new Uint8Array(this._buf.byteLength+1);e.fill(wh,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===wh;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let i=0;io)return!1}return t.lengtht.namespaces()))])}}function OV(n){return[].concat(...n)}class LV extends class AV{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,t,r){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}putMany(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(e);i=!(u=yield lt(a.next())).done;i=!1){const{key:_,value:R}=u.value;yield lt(r.put(_,R,t)),yield{key:_,value:R}}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}getMany(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(e);i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;yield r.get(_,t)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}deleteMany(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(e);i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;yield lt(r.delete(_,t)),yield _}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}batch(){var e=this;let t=[],r=[];return{put(i,s){t.push({key:i,value:s})},delete(i){r.push(i)},commit:(i=$(function*(s){yield Qo(e.putMany(t,s)),t=[],yield Qo(e.deleteMany(r,s)),r=[]}),function(o){return i.apply(this,arguments)})};var i}_all(e,t){return hn(function*(){throw new Error("._all is not implemented")})()}_allKeys(e,t){return hn(function*(){throw new Error("._allKeys is not implemented")})()}query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>s2(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=o2(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>s2(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=o2(r,e.limit)),r}}{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}put(e,t){var r=this;return $(function*(){r.data[e.toString()]=t})()}get(e){var t=this;return $(function*(){if(!(yield t.has(e)))throw function kV(n){return n=n||new Error("Not Found"),ae(n,"ERR_NOT_FOUND")}();return t.data[e.toString()]})()}has(e){var t=this;return $(function*(){return void 0!==t.data[e.toString()]})()}delete(e){var t=this;return $(function*(){delete t.data[e.toString()]})()}_all(){var e=this;return hn(function*(){yield*Mr(Pt(Object.entries(e.data).map(([t,r])=>({key:new Ur(t),value:r}))),lt)})()}_allKeys(){var e=this;return hn(function*(){yield*Mr(Pt(Object.entries(e.data).map(([t])=>new Ur(t))),lt)})()}}var Dn=(()=>(function(n){n.NOT_STARTED_YET="The libp2p node is not started yet",n.DHT_DISABLED="DHT is not available",n.PUBSUB_DISABLED="PubSub is not available",n.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",n.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",n.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",n.NOT_FOUND="Not found"}(Dn||(Dn={})),Dn))(),Ce=(()=>(function(n){n.DHT_DISABLED="ERR_DHT_DISABLED",n.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",n.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",n.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",n.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",n.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",n.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",n.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",n.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",n.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",n.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",n.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",n.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",n.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",n.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",n.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",n.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",n.ERR_DIALED_SELF="ERR_DIALED_SELF",n.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",n.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",n.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",n.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",n.ERR_INVALID_KEY="ERR_INVALID_KEY",n.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",n.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",n.ERR_INVALID_PEER="ERR_INVALID_PEER",n.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",n.ERR_NOT_FOUND="ERR_NOT_FOUND",n.ERR_TIMEOUT="ERR_TIMEOUT",n.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",n.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",n.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",n.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",n.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",n.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",n.ERR_FIND_SELF="ERR_FIND_SELF",n.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",n.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",n.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",n.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",n.ERR_INVALID_CMS="ERR_INVALID_CMS",n.ERR_MISSING_KEYS="ERR_MISSING_KEYS",n.ERR_NO_KEY="ERR_NO_KEY",n.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",n.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",n.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",n.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",n.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",n.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",n.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",n.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",n.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",n.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",n.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",n.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",n.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",n.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",n.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",n.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",n.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",n.ERR_INVALID_RECORD="ERR_INVALID_RECORD",n.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",n.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",n.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",n.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS"}(Ce||(Ce={})),Ce))(),fv=x(6930);function dv(n,e){return hv.apply(this,arguments)}function hv(){return hv=hn(function*(n,e){yield*Mr(Pt(fv(n,function(){var t=$(function*(r){return yield e.addressBook.add(r.id,r.multiaddrs),r});return function(r){return t.apply(this,arguments)}}())),lt)}),hv.apply(this,arguments)}function c2(n){const e=new Set;return Ds(n,t=>!e.has(t.id.toString())&&(e.add(t.id.toString()),!0))}function u2(n){return pv.apply(this,arguments)}function pv(){return pv=hn(function*(n,e=1){let t=0;var s,r=!1,i=!1;try{for(var a,o=Pt(n);r=!(a=yield lt(o.next())).done;r=!1){const u=a.value;t++,yield u}}catch(u){i=!0,s=u}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}if(thn(function*(){try{yield yield lt(s.findPeer(e,t))}catch(o){l2.error(o)}})())),s=>Ds(s,Boolean),s=>dv(s,r.components.getPeerStore()),function(){var s=$(function*(o){return yield Aa(o)});return function(o){return s.apply(this,arguments)}}());if(null!=i)return i;throw ae(new Error(Dn.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getClosestPeers(e,t){var r=this;return hn(function*(){if(0===r.routers.length)throw ae(new Error("No peer routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield*Mr(Pt(qn(Vd(...r.routers.map(i=>i.getClosestPeers(e,t))),i=>dv(i,r.components.getPeerStore()),i=>c2(i),i=>u2(i))),lt)})()}}class FV{constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started=!0})()}stop(){var e=this;return $(function*(){e.started=!1})()}findProviders(e,t={}){var r=this;return hn(function*(){if(0===r.routers.length)throw ae(new Error("No content this.routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield*Mr(Pt(qn(Vd(...r.routers.map(i=>i.findProviders(e,t))),i=>dv(i,r.components.getPeerStore()),i=>c2(i),i=>u2(i))),lt)})()}provide(e,t={}){var r=this;return $(function*(){if(0===r.routers.length)throw ae(new Error("No content routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield Promise.all(r.routers.map(function(){var i=$(function*(s){return yield s.provide(e,t)});return function(s){return i.apply(this,arguments)}}()))})()}put(e,t,r){var i=this;return $(function*(){if(!i.isStarted())throw ae(new Error(Dn.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);const s=i.components.getDHT();null!=s&&(yield Qo(s.put(e,t,r)))})()}get(e,t){var r=this;return $(function*(){if(!r.isStarted())throw ae(new Error(Dn.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);const i=r.components.getDHT();if(null!=i){var a,s=!1,o=!1;try{for(var _,u=Pt(i.get(e,t));s=!(_=yield u.next()).done;s=!1){const R=_.value;if("VALUE"===R.name)return R.value}}catch(R){o=!0,a=R}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(o)throw a}}}throw ae(new Error(Dn.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getMany(e,t,r){var i=this;return hn(function*(){if(!i.isStarted())throw ae(new Error(Dn.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);if(null==t||0===t)return;let s=0;const o=i.components.getDHT();if(null!=o){var _,a=!1,u=!1;try{for(var N,R=Pt(o.get(e,r));a=!(N=yield lt(R.next())).done;a=!1){const B=N.value;if("VALUE"===B.name&&(yield{from:B.from,val:B.value},s++,s===t))break}}catch(B){u=!0,_=B}finally{try{a&&null!=R.return&&(yield lt(R.return()))}finally{if(u)throw _}}}if(0===s)throw ae(new Error(Dn.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}}function Vl(n){if(aT(n))return{id:n,multiaddrs:[],protocols:[]};let e;return"string"==typeof n&&(n=new mn(n)),mn.isMultiaddr(n)&&(e=n,n=function UV(n){const e=n.getPeerId();if(null==e)throw ae(new Error(`${n.toString()} does not have a valid peer type`),Ce.ERR_INVALID_MULTIADDR);try{return fr(e)}catch{throw ae(new Error(`${n.toString()} is not a valid peer type`),Ce.ERR_INVALID_MULTIADDR)}}(n)),{id:n,multiaddrs:null!=e?[e]:[],protocols:[]}}const VV=n=>n;class HV extends Ei{constructor(e,t){super();const{listen:r=[],announce:i=[]}=t;this.components=e,this.listen=new Set(r.map(s=>s.toString())),this.announce=new Set(i.map(s=>s.toString())),this.observed=new Set,this.announceFilter=t.announceFilter??VV}getListenAddrs(){return Array.from(this.listen).map(e=>new mn(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>new mn(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>new mn(e))}addObservedAddr(e){let t=new mn(e);const r=t.getPeerId();null!=r&&fr(r).equals(this.components.getPeerId())&&(t=t.decapsulate(new mn(`/p2p/${this.components.getPeerId().toString()}`)));const i=t.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new nn("change:addresses")))}getAddresses(){let e=this.getAnnounceAddrs().map(r=>r.toString());0===e.length&&(e=this.components.getTransportManager().getAddrs().map(r=>r.toString())),e=e.concat(this.getObservedAddrs().map(r=>r.toString()));const t=new Set(e);return this.announceFilter(Array.from(t).map(r=>new mn(r))).map(r=>r.getPeerId()===this.components.getPeerId().toString()?r:r.encapsulate(`/p2p/${this.components.getPeerId().toString()}`))}}const Hl=x(7820),f2=zt("libp2p:connection-manager:latency-monitor:visibility-change-emitter");class $V extends Ei{constructor(){super(),this.hidden="hidden",this.visibilityChange="visibilityChange",null!=globalThis.document&&(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener())}_initializeVisibilityVarNames(){let e="hidden",t="visibilitychange";typeof globalThis.document.hidden<"u"?(e="hidden",t="visibilitychange"):typeof globalThis.document.mozHidden<"u"?(e="mozHidden",t="mozvisibilitychange"):typeof globalThis.document.msHidden<"u"?(e="msHidden",t="msvisibilitychange"):typeof globalThis.document.webkitHidden<"u"&&(e="webkitHidden",t="webkitvisibilitychange"),this.hidden=e,this.visibilityChange=t}_addVisibilityChangeListener(){typeof globalThis.document.addEventListener>"u"||typeof document[this.hidden]>"u"?f2("Checking page visibility requires a browser that supports the Page Visibility API."):globalThis.document.addEventListener(this.visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(void 0!==this.hidden&&void 0!==document[this.hidden])return null==document[this.hidden]}_handleVisibilityChange(){const e=!1===globalThis.document[this.hidden];f2(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new nn("visibilityChange",{detail:e}))}}const yo=zt("libp2p:connection-manager:latency-monitor");class jV extends Ei{constructor(e={}){super();const{latencyCheckIntervalMs:t,dataEmitIntervalMs:r,asyncTestFn:i,latencyRandomPercentage:s}=e;this.latencyCheckIntervalMs=t??500,this.latencyRandomPercentage=s??10,this.latencyCheckMultiply=this.latencyRandomPercentage/100*2*this.latencyCheckIntervalMs,this.latencyCheckSubtract=this.latencyCheckMultiply/2,this.dataEmitIntervalMs=null===r||0===r?void 0:r??5e3,yo("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),null!=this.dataEmitIntervalMs?yo("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):yo("Not emitting summaries"),this.asyncTestFn=i,null!=globalThis.process?.hrtime?(yo("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=o=>{const a=this.now(o);return 1e3*a[0]+a[1]/1e6}):typeof window<"u"&&null!=window.performance?.now?(yo("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(yo("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){(function zV(){return typeof globalThis.window<"u"})()&&(this.visibilityChangeEmitter=new $V,this.visibilityChangeEmitter.addEventListener("visibilityChange",e=>{const{detail:t}=e;t?this._startTimers():(this._emitSummary(),this._stopTimers())})),!0===this.visibilityChangeEmitter?.isVisible()&&this._startTimers()}stop(){this._stopTimers()}_startTimers(){null==this.checkLatencyID&&(this.checkLatency(),null!=this.dataEmitIntervalMs&&(this.emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),"function"==typeof this.emitIntervalID.unref&&this.emitIntervalID.unref()))}_stopTimers(){null!=this.checkLatencyID&&(clearTimeout(this.checkLatencyID),this.checkLatencyID=void 0),null!=this.emitIntervalID&&(clearInterval(this.emitIntervalID),this.emitIntervalID=void 0)}_emitSummary(){const e=this.getSummary();e.events>0&&this.dispatchEvent(new nn("data",{detail:e}))}getSummary(){const e={events:this.latencyData.events,minMs:this.latencyData.minMs,maxMs:this.latencyData.maxMs,avgMs:this.latencyData.events>0?this.latencyData.totalMs/this.latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this.latencyData.startTime)};return this.latencyData=this.initLatencyData(),yo.trace("Summary: %O",e),e}checkLatency(){const e=Math.random()*this.latencyCheckMultiply-this.latencyCheckSubtract,t={deltaOffset:Math.ceil(this.latencyCheckIntervalMs+e),startTime:this.now()},r=()=>{if(null==this.checkLatencyID)return;const i=this.getDeltaMS(t.startTime)-t.deltaOffset;this.checkLatency(),this.latencyData.events++,this.latencyData.minMs=Math.min(this.latencyData.minMs,i),this.latencyData.maxMs=Math.max(this.latencyData.maxMs,i),this.latencyData.totalMs+=i,yo.trace("MS: %s Data: %O",i,this.latencyData)};yo.trace("localData: %O",t),this.checkLatencyID=setTimeout(()=>{null!=this.asyncTestFn?(t.deltaOffset=0,t.startTime=this.now(),this.asyncTestFn(r)):(t.deltaOffset-=1,r())},t.deltaOffset),"function"==typeof this.checkLatencyID.unref&&this.checkLatencyID.unref()}initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}var Kl=x(2502);const h2="CLOSING",gv="CLOSED";var GV=x(8614);const p2=zt("libp2p:dialer:dial-request");class WV{constructor(e){const{addrs:t,dialAction:r,dialer:i}=e;this.addrs=t,this.dialer=i,this.dialAction=r}run(e={}){var t=this;return $(function*(){const r=t.dialer.getTokens(t.addrs.length);if(r.length<1)throw ae(new Error("No dial tokens available"),Ce.ERR_NO_DIAL_TOKENS);const i=new GV;for(const u of r)i.push(u).catch(_=>{p2.error(_)});const s=t.addrs.map(()=>{const u=new AbortController;try{(0,Vr.setMaxListeners)?.(1/0,u.signal)}catch{}return u});if(null!=e.signal)try{(0,Vr.setMaxListeners)?.(1/0,e.signal)}catch{}let o=0,a=!1;try{return yield Promise.any(t.addrs.map(function(){var u=$(function*(_,R){const N=yield i.shift();if(a)throw t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0]),ae(new Error("dialAction already succeeded"),Ce.ERR_ALREADY_SUCCEEDED);const B=s[R];if(null==B)throw ae(new Error("dialAction did not come with an AbortController"),Ce.ERR_INVALID_PARAMETERS);let z;try{const X=B.signal;z=yield t.dialAction(_,{...e,signal:null!=e.signal?(0,dh.anySignal)([X,e.signal]):X}),s[R]=void 0}finally{o++,t.addrs.length-o>=r.length?i.push(N).catch(X=>{p2.error(X)}):t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0])}if(null==z)throw ae(new Error("dialAction led to empty object"),Ce.ERR_TRANSPORT_DIAL_FAILED);return a=!0,z});return function(_,R){return u.apply(this,arguments)}}()))}finally{s.forEach(u=>{void 0!==u&&u.abort()}),r.forEach(u=>t.dialer.releaseToken(u))}})()}}var g2=x(4108);function y2(n){const{address:e}=n.nodeAddress();return Boolean(g2(e))}function yv(n,e){const t=y2(n.multiaddr),r=y2(e.multiaddr);return t&&!r?1:!t&&r||n.isCertified&&!e.isCertified?-1:!n.isCertified&&e.isCertified?1:0}var mv=x(4297);const Us=zt("libp2p:dialer"),b2="dialler";class JV{constructor(e={}){this.components=new ho,this.started=!1,this.addressSorter=e.addressSorter??yv,this.maxAddrsToDial=e.maxAddrsToDial??25,this.timeout=e.dialTimeout??3e4,this.maxDialsPerPeer=e.maxDialsPerPeer??4,this.tokens=[...new Array(e.maxParallelDials??100)].map((t,r)=>r),this.pendingDials=Ll({component:b2,metric:"pending-dials",metrics:e.metrics}),this.pendingDialTargets=Ll({component:b2,metric:"pending-dial-targets",metrics:e.metrics});for(const[t,r]of Object.entries(e.resolvers??{}))mn.resolvers.set(t,r)}init(e){this.components=e}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started=!0})()}stop(){var e=this;return $(function*(){e.started=!1;for(const t of e.pendingDials.values())try{t.controller.abort()}catch(r){Us.error(r)}e.pendingDials.clear();for(const t of e.pendingDialTargets.values())t.reject(new nu("Dialer was destroyed"));e.pendingDialTargets.clear()})()}dial(e,t={}){var r=this;return $(function*(){const{id:i,multiaddrs:s}=Vl(e);if(r.components.getPeerId().equals(i))throw ae(new Error("Tried to dial self"),Ce.ERR_DIALED_SELF);if(Us("check multiaddrs %p",i),null!=s&&s.length>0&&(Us("storing multiaddrs %p",i,s),yield r.components.getPeerStore().addressBook.add(i,s)),yield r.components.getConnectionGater().denyDialPeer(i))throw ae(new Error("The dial request is blocked by gater.allowDialPeer"),Ce.ERR_PEER_DIAL_INTERCEPTED);Us("creating dial target for %p",i);const o=yield r._createCancellableDialTarget(i,t);if(0===o.addrs.length)throw ae(new Error("The dial request has no valid addresses"),Ce.ERR_NO_VALID_ADDRESSES);const a=r.pendingDials.get(o.id)??r._createPendingDial(o,t);try{const u=yield a.promise;return Us("dial succeeded to %s",o.id),u}catch(u){throw Us("dial failed to %s",o.id,u),a.controller.signal.aborted&&(u.code=Ce.ERR_TIMEOUT),Us.error(u),u}finally{a.destroy()}})()}_createCancellableDialTarget(e,t){var r=this;return $(function*(){const i=`${parseInt(String(1e9*Math.random()),10).toString()}${Date.now()}`,s=new Promise((o,a)=>{r.pendingDialTargets.set(i,{resolve:o,reject:a})});try{return yield Promise.race([r._createDialTarget(e,t),s])}finally{r.pendingDialTargets.delete(i)}})()}_createDialTarget(e,t){var r=this;return $(function*(){const i=yield qn(yield r.components.getPeerStore().addressBook.get(e),a=>Ds(a,function(){var u=$(function*(_){return!(yield r.components.getConnectionGater().denyDialMultiaddr(e,_.multiaddr))});return function(_){return u.apply(this,arguments)}}()),a=>mv(a,r.addressSorter),a=>fv(a,u=>{const _=u.multiaddr;return e.toString()===_.getPeerId()?_:_.encapsulate(`/p2p/${e.toString()}`)}),function(){var a=$(function*(u){return yield Ul(u)});return function(u){return a.apply(this,arguments)}}()),s=[];for(const a of i)(yield r._resolve(a,t)).forEach(_=>s.push(_));const o=s.filter(a=>r.components.getTransportManager().transportForMultiaddr(a));if(o.length>r.maxAddrsToDial)throw yield r.components.getPeerStore().delete(e),ae(new Error("dial with more addresses than allowed"),Ce.ERR_TOO_MANY_ADDRESSES);return{id:e.toString(),addrs:o}})()}_createPendingDial(e,t={}){var r=this;const i=function(){var R=$(function*(N,B={}){if(!0===B.signal?.aborted)throw ae(new Error("already aborted"),Ce.ERR_ALREADY_ABORTED);return yield r.components.getTransportManager().dial(N,B)});return function(B){return R.apply(this,arguments)}}(),s=new WV({addrs:e.addrs,dialAction:i,dialer:this}),o=new bi.TimeoutController(this.timeout),a=[o.signal];null!=t.signal&&a.push(t.signal);const u=(0,dh.anySignal)(a);try{(0,Vr.setMaxListeners)?.(1/0,u)}catch{}const _={dialRequest:s,controller:o,promise:s.run({...t,signal:u}),destroy:()=>{o.clear(),this.pendingDials.delete(e.id)}};return this.pendingDials.set(e.id,_),_}getTokens(e){const t=Math.min(e,this.maxDialsPerPeer,this.tokens.length),r=this.tokens.splice(0,t);return Us("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.includes(e)||(Us("token %d released",e),this.tokens.push(e))}_resolve(e,t){var r=this;return $(function*(){if(!e.protoNames().includes("dnsaddr"))return[e];const s=yield r._resolveRecord(e,t);return(yield Promise.all(s.map(function(){var u=$(function*(_){return yield r._resolve(_,t)});return function(_){return u.apply(this,arguments)}}()))).flat().reduce((u,_)=>(null==u.find(R=>R.equals(_))&&u.push(_),u),[])})()}_resolveRecord(e,t){return $(function*(){try{return e=new mn(e.toString()),yield e.resolve(t)}catch(r){return Us.error(`multiaddr ${e.toString()} could not be resolved`,r),[]}})()}}function Dh(n,e){const t={[Symbol.iterator]:()=>t,next:()=>{const r=n.next(),i=r.value;return!0===r.done||null==i?{done:!0,value:void 0}:{done:!1,value:e(i)}}};return t}class e7{constructor(e){if(this.map=new Map,null!=e)for(const[t,r]of e.entries())this.map.set(t.toString(),r)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){this.map.delete(e.toString())}entries(){return Dh(this.map.entries(),e=>[fr(e[0]),e[1]])}forEach(e){this.map.forEach((t,r)=>{e(t,fr(r),this)})}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,t){this.map.set(e.toString(),t)}keys(){return Dh(this.map.keys(),e=>fr(e))}values(){return this.map.values()}get size(){return this.map.size}}class t7{constructor(e){if(this.set=new Set,null!=e)for(const t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return Dh(this.set.entries(),e=>{const t=fr(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{const r=fr(t);e(r,r,this)})}has(e){return this.set.has(e.toString())}values(){return Dh(this.set.values(),e=>fr(e))}}Symbol;const Xr=zt("libp2p:connection-manager"),r7={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4},Ev="libp2p",bv="connection-manager";class s7 extends Ei{constructor(e){if(super(),this.components=new ho,this.opts=Hl.call({ignoreUndefined:!0},r7,e),this.opts.maxConnections{const t={inbound:0,outbound:0};for(const r of this.connections.values())for(const i of r)"inbound"===i.stat.direction?t.inbound++:t.outbound++;return t}}),this.components.getMetrics()?.updateComponentMetric({system:Ev,component:bv,metric:"protocol-streams-total",label:"protocol",value:()=>{const t={};for(const r of this.connections.values())for(const i of r)for(const s of i.streams){const o=`${s.stat.direction} ${s.stat.protocol??"unnegotiated"}`;t[o]=(t[o]??0)+1}return t}}),this.components.getMetrics()?.updateComponentMetric({system:Ev,component:bv,metric:"protocol-streams-per-connection-90th-percentile",label:"protocol",value:()=>{const t={};for(const i of this.connections.values())for(const s of i){const o={};for(const a of s.streams){const u=`${a.stat.direction} ${a.stat.protocol??"unnegotiated"}`;o[u]=(o[u]??0)+1}for(const[a,u]of Object.entries(o))t[a]=t[a]??[],t[a].push(u)}const r={};for(let[i,s]of Object.entries(t)){s=s.sort((a,u)=>a-u);const o=Math.floor(.9*s.length);r[i]=s[o]}return r}})}isStarted(){return this.started}start(){var e=this;return $(function*(){null!=e.components.getMetrics()&&(e.timer=e.timer??Kl(e._checkMetrics,e.opts.pollInterval)),e.latencyMonitor.start(),e._onLatencyMeasure=e._onLatencyMeasure.bind(e),e.latencyMonitor.addEventListener("data",e._onLatencyMeasure),yield e.dialer.start(),e.started=!0,Xr("started")})()}afterStart(){var e=this;return $(function*(){e.components.getUpgrader().addEventListener("connection",e.onConnect),e.components.getUpgrader().addEventListener("connectionEnd",e.onDisconnect),Promise.resolve().then($(function*(){const t=[];for(const r of yield e.components.getPeerStore().all())(yield e.components.getPeerStore().getTags(r.id)).filter(o=>"keep-alive"===o.name).length>0&&t.push(r.id);e.connectOnStartupController?.clear(),e.connectOnStartupController=new bi.TimeoutController(e.startupReconnectTimeout);try{(0,Vr.setMaxListeners)?.(1/0,e.connectOnStartupController.signal)}catch{}yield Promise.all(t.map(function(){var r=$(function*(i){yield e.openConnection(i,{signal:e.connectOnStartupController?.signal}).catch(s=>{Xr.error(s)})});return function(i){return r.apply(this,arguments)}}()))})).catch(t=>{Xr.error(t)}).finally(()=>{e.connectOnStartupController?.clear()})})()}beforeStop(){var e=this;return $(function*(){e.connectOnStartupController?.abort(),e.components.getUpgrader().removeEventListener("connection",e.onConnect),e.components.getUpgrader().removeEventListener("connectionEnd",e.onDisconnect)})()}stop(){var e=this;return $(function*(){e.timer?.clear(),e.latencyMonitor.removeEventListener("data",e._onLatencyMeasure),e.latencyMonitor.stop(),yield e.dialer.stop(),e.started=!1,yield e._close(),Xr("stopped")})()}_close(){var e=this;return $(function*(){const t=[];for(const r of e.connections.values())for(const i of r)t.push($(function*(){try{yield i.close()}catch(s){Xr.error(s)}})());Xr("closing %d connections",t.length),yield Promise.all(t),e.connections.clear()})()}_checkMetrics(){var e=this;return $(function*(){const t=e.components.getMetrics();if(null!=t)try{const r=t.getGlobal().getMovingAverages(),i=r.dataReceived[e.opts.movingAverageInterval].movingAverage;yield e._checkMaxLimit("maxReceivedData",i);const s=r.dataSent[e.opts.movingAverageInterval].movingAverage;yield e._checkMaxLimit("maxSentData",s);const o=i+s;yield e._checkMaxLimit("maxData",o),Xr.trace("metrics update",o)}finally{e.timer=Kl(e._checkMetrics,e.opts.pollInterval)}})()}onConnect(e){this._onConnect(e).catch(t=>{Xr.error(t)})}_onConnect(e){var t=this;return $(function*(){const{detail:r}=e;if(!t.started)return void(yield r.close());const i=r.remotePeer,s=i.toString(),o=t.connections.get(s);null!=o?o.push(r):t.connections.set(s,[r]),null!=i.publicKey&&(yield t.components.getPeerStore().keyBook.set(i,i.publicKey));const a=t.getConnections().length,u=a-t.opts.maxConnections;yield t._checkMaxLimit("maxConnections",a,u),t.dispatchEvent(new nn("peer:connect",{detail:r}))})()}onDisconnect(e){const{detail:t}=e;if(!this.started)return;const r=t.remotePeer.toString();let i=this.connections.get(r);null!=i&&i.length>1?(i=i.filter(s=>s.id!==t.id),this.connections.set(r,i)):null!=i&&(this.connections.delete(r),this.dispatchEvent(new nn("peer:disconnect",{detail:t})),this.components.getMetrics()?.onPeerDisconnected(t.remotePeer))}getConnections(e){if(null!=e)return this.connections.get(e.toString())??[];let t=[];for(const r of this.connections.values())t=t.concat(r);return t}openConnection(e,t={}){var r=this;return $(function*(){Xr("dial to %p",e);const i=r.getConnections(e);if(i.length>0)return Xr("had an existing connection to %p",e),i[0];let s;if(null==t?.signal){s=new bi.TimeoutController(r.dialTimeout),t.signal=s.signal;try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}}try{const o=yield r.dialer.dial(e,t);let a=r.connections.get(e.toString());null==a&&(a=[],r.connections.set(e.toString(),a));let u=!1;for(const _ of a)_.id===o.id&&(u=!0);return u||a.push(o),o}finally{s?.clear()}})()}closeConnections(e){var t=this;return $(function*(){const r=t.connections.get(e.toString())??[];yield Promise.all(r.map(function(){var i=$(function*(s){return yield s.close()});return function(s){return i.apply(this,arguments)}}()))})()}getAll(e){if(!aT(e))throw ae(new Error("peerId must be an instance of peer-id"),Ce.ERR_INVALID_PARAMETERS);const t=e.toString(),r=this.connections.get(t);return null!=r?r.filter(i=>"OPEN"===i.stat.status):[]}_onLatencyMeasure(e){const{detail:t}=e;this._checkMaxLimit("maxEventLoopDelay",t.avgMs,1).catch(r=>{Xr.error(r)})}_checkMaxLimit(e,t,r=1){var i=this;return $(function*(){const s=i.opts[e];Xr.trace("checking limit of %s. current value: %d of %d",e,t,s),t>s&&(Xr("%s: limit exceeded: %p, %d/%d, pruning %d connection(s)",i.components.getPeerId(),e,t,s,r),yield i._maybePruneConnections(r))})()}_maybePruneConnections(e){var t=this;return $(function*(){const r=t.getConnections();if(r.length<=t.opts.minConnections||e<1)return;const i=new e7;for(const a of r){const u=a.remotePeer;if(i.has(u))continue;const _=yield t.components.getPeerStore().getTags(u);i.set(u,_.reduce((R,N)=>R+N.value,0))}const s=r.sort((a,u)=>{const _=i.get(a.remotePeer)??0,R=i.get(u.remotePeer)??0;return _>R?1:_{Zo.error("could start autodial",t)}),Zo("started")):Zo("not enabled")})()}stop(){var e=this;return $(function*(){e.options.enabled?(e.running=!1,null!=e.autoDialTimeout&&e.autoDialTimeout.clear(),Zo("stopped")):Zo("not enabled")})()}_autoDial(){var e=this;return $(function*(){null!=e.autoDialTimeout&&e.autoDialTimeout.clear();const t=e.options.minConnections;if(e.components.getConnectionManager().getConnections().length>=t)return void(e.autoDialTimeout=Kl(e._autoDial,e.options.autoDialInterval));const r=yield e.components.getPeerStore().all(),i=yield qn(r.sort(()=>Math.random()>.5?1:-1),s=>Ds(s,o=>!o.id.equals(e.components.getPeerId())),s=>mv(s,(o,a)=>a.protocols.length>o.protocols.length||null!=a.id.publicKey&&null==o.id.publicKey?1:-1),function(){var s=$(function*(o){return yield Ul(o)});return function(o){return s.apply(this,arguments)}}());for(let s=0;e.running&&sFo(t)}(e=n.Status||(n.Status={})),function(a){a.HOP="HOP",a.STOP="STOP",a.STATUS="STATUS",a.CAN_HOP="CAN_HOP"}(r=n.Type||(n.Type={})),function(a){a[a.HOP=1]="HOP",a[a.STOP=2]="STOP",a[a.STATUS=3]="STATUS",a[a.CAN_HOP=4]="CAN_HOP"}(i||(i={})),function(a){a.codec=()=>Fo(i)}(r=n.Type||(n.Type={})),function(a){let u;a.codec=()=>(null==u&&(u=Yt((_,R,N={})=>{if(!1!==N.lengthDelimited&&R.fork(),null==_.id)throw new Error('Protocol error: required field "id" was not found in object');if(R.uint32(10),R.bytes(_.id),null==_.addrs)throw new Error('Protocol error: required field "addrs" was not found in object');for(const B of _.addrs)R.uint32(18),R.bytes(B);!1!==N.lengthDelimited&&R.ldelim()},(_,R)=>{const N={},B=null==R?_.len:_.pos+R;for(;_.pos>>3){case 1:N.id=_.bytes();break;case 2:N.addrs=N.addrs??[],N.addrs.push(_.bytes());break;default:_.skipType(7&z)}}if(N.addrs=N.addrs??[],null==N.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');if(null==N.addrs)throw new Error('Protocol error: value for required field "addrs" was not found in protobuf');return N})),u),a.encode=_=>qt(_,a.codec()),a.decode=_=>Wt(_,a.codec())}(s=n.Peer||(n.Peer={})),n.codec=()=>(null==o&&(o=Yt((a,u,_={})=>{!1!==_.lengthDelimited&&u.fork(),null!=a.type&&(u.uint32(8),n.Type.codec().encode(a.type,u)),null!=a.srcPeer&&(u.uint32(18),n.Peer.codec().encode(a.srcPeer,u)),null!=a.dstPeer&&(u.uint32(26),n.Peer.codec().encode(a.dstPeer,u)),null!=a.code&&(u.uint32(32),n.Status.codec().encode(a.code,u)),!1!==_.lengthDelimited&&u.ldelim()},(a,u)=>{const _={},R=null==u?a.len:a.pos+u;for(;a.pos>>3){case 1:_.type=n.Type.codec().decode(a);break;case 2:_.srcPeer=n.Peer.codec().decode(a,a.uint32());break;case 3:_.dstPeer=n.Peer.codec().decode(a,a.uint32());break;case 4:_.code=n.Status.codec().decode(a);break;default:a.skipType(7&N)}}return _})),o),n.encode=a=>qt(a,n.codec()),n.decode=a=>Wt(a,n.codec())}(rn||(rn={}));const c7=zt("libp2p:stream:converter");function w2(n,e={}){const{stream:t,remoteAddr:r}=n,{sink:i,source:s}=t,o=hn(function*(){var B,R=!1,N=!1;try{for(var X,z=Pt(s);R=!(X=yield lt(z.next())).done;R=!1){const J=X.value;yield*Mr(Pt(J),lt)}}catch(J){N=!0,B=J}finally{try{R&&null!=z.return&&(yield lt(z.return()))}finally{if(N)throw B}}})(),a={sink:R=>$(function*(){null!=e.signal&&(R=vs(R,e.signal));try{yield i(R),yield u()}catch(N){"aborted"!==N.type&&c7(N)}})(),source:null!=e.signal?vs(o,e.signal):o,remoteAddr:r,timeline:{open:Date.now(),close:void 0},close:()=>$(function*(){yield i(hn(function*(){yield new Uint8Array(0)})()),yield u()})()};function u(){return _.apply(this,arguments)}function _(){return(_=$(function*(){return null==a.timeline.close&&(a.timeline.close=Date.now()),yield Promise.resolve()})).apply(this,arguments)}return a}const $l="/libp2p/circuit/relay/0.1.0";function _2(n,e){n.write({type:rn.Type.STATUS,code:e})}function D2(n,e){try{null!=n.dstPeer?.addrs&&n.dstPeer.addrs.forEach(t=>new mn(t))}catch(t){throw _2(e,n.type===rn.Type.HOP?rn.Status.HOP_DST_MULTIADDR_INVALID:rn.Status.STOP_DST_MULTIADDR_INVALID),t}try{null!=n.srcPeer?.addrs&&n.srcPeer.addrs.forEach(t=>new mn(t))}catch(t){throw _2(e,n.type===rn.Type.HOP?rn.Status.HOP_SRC_MULTIADDR_INVALID:rn.Status.STOP_SRC_MULTIADDR_INVALID),t}}const jl=zt("libp2p:circuit:stream-handler");class Sh{constructor(e){const{stream:t,maxLength:r=4096}=e;this.stream=t,this.shake=Fd(this.stream),this.decoder=ps.fromReader(this.shake.reader,{maxDataLength:r})}read(){var e=this;return $(function*(){const t=yield e.decoder.next();if(null!=t.value){const r=rn.decode(t.value);return jl("read message type",r.type),r}jl("read received no value, closing stream"),e.close()})()}write(e){jl("write message type %s",e.type),this.shake.write(ks.single(rn.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){jl("closing the stream"),this.rest().sink([]).catch(e=>{jl.error(e)})}}const zl=zt("libp2p:circuit:stop");function f7(n){return wv.apply(this,arguments)}function wv(){return wv=$(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream($l,{signal:r});zl("starting stop request to %p",e.remotePeer);const s=new Sh({stream:i});s.write(t);const o=yield s.read();if(null!=o)return o.code===rn.Status.SUCCESS?(zl("stop request to %p was successful",e.remotePeer),s.rest()):(zl("stop request failed with code %d",o.code),void s.close());s.close()}),wv.apply(this,arguments)}const Yi=zt("libp2p:circuit:hop");function _v(){return _v=$(function*(n){const{connection:e,request:t,streamHandler:r,circuit:i,connectionManager:s}=n;if(!i.hopEnabled())return Yi("HOP request received but we are not acting as a relay"),r.end({type:rn.Type.STATUS,code:rn.Status.HOP_CANT_SPEAK_RELAY});try{D2(t,r)}catch(N){return void Yi.error("invalid hop request via peer %p %o",e.remotePeer,N)}if(null==t.dstPeer)return void Yi("HOP request received but we do not receive a dstPeer");const o=tu(t.dstPeer.id),a=s.getConnections(o);if(0===a.length&&!i.hopActive())return Yi("HOP request received but we are not connected to the destination peer"),r.end({type:rn.Type.STATUS,code:rn.Status.HOP_NO_CONN_TO_DST});if(0===a.length)return Yi("did not have connection to remote peer"),r.end({type:rn.Type.STATUS,code:rn.Status.HOP_NO_CONN_TO_DST});const u={type:rn.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer};let _;try{Yi("performing STOP request");const N=yield f7({connection:a[0],request:u});if(null==N)throw new Error("Could not stop");_=N}catch(N){return void Yi.error(N)}Yi("hop request from %p is valid",e.remotePeer),r.write({type:rn.Type.STATUS,code:rn.Status.SUCCESS});const R=r.rest();return Yi("creating related connections"),yield qn(R,_,R)}),_v.apply(this,arguments)}function Dv(){return Dv=$(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream($l,{signal:r}),s=new Sh({stream:i});s.write(t);const o=yield s.read();if(null==o)throw ae(new Error("HOP request had no response"),Ce.ERR_HOP_REQUEST_FAILED);if(o.code===rn.Status.SUCCESS)return Yi("hop request was successful"),s.rest();throw Yi("hop request failed with code %d, closing stream",o.code),s.close(),ae(new Error(`HOP request failed with code "${o.code??"unknown"}"`),Ce.ERR_HOP_REQUEST_FAILED)}),Dv.apply(this,arguments)}function Sv(){return Sv=$(function*(n){const{connection:e,signal:t}=n,r=yield e.newStream($l,{signal:t}),i=new Sh({stream:r});i.write({type:rn.Type.CAN_HOP});const s=yield i.read();return yield i.close(),!(null==s||s.code!==rn.Status.SUCCESS)}),Sv.apply(this,arguments)}const Qi=zt("libp2p:circuit");class y7{constructor(e){this.components=new ho,this._init=e}init(e){this.components=e,this.components.getRegistrar().handle($l,t=>{this._onProtocol(t).catch(r=>{Qi.error(r)})}).catch(t=>{Qi.error(t)})}hopEnabled(){return!0}hopActive(){return!0}get[lv](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}_onProtocol(e){var t=this;return $(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t._init.hop.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=Go(i,s.signal),a=new Sh({stream:{...i,...o}}),u=yield a.read();if(null==u)return Qi("request was invalid, could not read from stream"),a.write({type:rn.Type.STATUS,code:rn.Status.MALFORMED_MESSAGE}),void a.close();let _;switch(u.type){case rn.Type.CAN_HOP:Qi("received CAN_HOP request from %p",r.remotePeer),yield function g7(n){const{connection:e,streamHandler:t,circuit:r}=n,i=r.hopEnabled();Yi("can hop (%s) request from %p",i,e.remotePeer),t.end({type:rn.Type.STATUS,code:i?rn.Status.SUCCESS:rn.Status.HOP_CANT_SPEAK_RELAY})}({circuit:t,connection:r,streamHandler:a});break;case rn.Type.HOP:Qi("received HOP request from %p",r.remotePeer),yield function d7(n){return _v.apply(this,arguments)}({connection:r,request:u,streamHandler:a,circuit:t,connectionManager:t.components.getConnectionManager()});break;case rn.Type.STOP:Qi("received STOP request from %p",r.remotePeer),_=yield function l7(n){const{connection:e,request:t,streamHandler:r}=n;try{D2(t,r)}catch(i){return void zl.error("invalid stop request via peer %p %o",e.remotePeer,i)}return zl("stop request is valid"),r.write({type:rn.Type.STATUS,code:rn.Status.SUCCESS}),r.rest()}({connection:r,request:u,streamHandler:a});break;default:return Qi("Request of type %s not supported",u.type),a.write({type:rn.Type.STATUS,code:rn.Status.MALFORMED_MESSAGE}),void a.close()}if(null!=_){const B=w2({stream:_,remoteAddr:r.remoteAddr.encapsulate("/p2p-circuit").encapsulate(new mn(u.dstPeer?.addrs[0])),localAddr:new mn(u.srcPeer?.addrs[0])}),z=u.type===rn.Type.HOP?"relay":"inbound";Qi("new %s connection %s",z,B.remoteAddr);const X=yield t.components.getUpgrader().upgradeInbound(B);Qi("%s connection %s upgraded",z,B.remoteAddr),null!=t.handler&&t.handler(X)}}finally{s.clear()}})()}dial(e,t={}){var r=this;return $(function*(){const i=e.toString().split("/p2p-circuit"),s=new mn(i[0]),o=new mn(i[i.length-1]),a=s.getPeerId(),u=o.getPeerId();if(null==a||null==u){const X="Circuit relay dial failed as addresses did not have peer id";throw Qi.error(X),ae(new Error(X),Ce.ERR_RELAYED_DIAL)}const _=fr(a),R=fr(u);let N=!1,z=r.components.getConnectionManager().getConnections(_)[0];null==z&&(yield r.components.getPeerStore().addressBook.add(_,[s]),z=yield r.components.getConnectionManager().openConnection(_,t),N=!0);try{const X=yield function h7(n){return Dv.apply(this,arguments)}({...t,connection:z,request:{type:rn.Type.HOP,srcPeer:{id:r.components.getPeerId().toBytes(),addrs:r.components.getAddressManager().getAddresses().map(de=>de.bytes)},dstPeer:{id:R.toBytes(),addrs:[new mn(o).bytes]}}}),J=s.encapsulate(`/p2p-circuit/p2p/${r.components.getPeerId().toString()}`),oe=w2({stream:X,remoteAddr:e,localAddr:J});return Qi("new outbound connection %s",oe.remoteAddr),yield r.components.getUpgrader().upgradeOutbound(oe)}catch(X){throw Qi.error("Circuit relay dial failed",X),N&&(yield z.close()),X}})()}createListener(e){return this.handler=e.handler,function u7(n){const e=new Map;function r(){return(r=$(function*(o){const a=o.toString().split("/p2p-circuit").find(z=>""!==z),u=new mn(a),_=u.getPeerId();if(null==_)throw new Error("Could not determine relay peer from multiaddr");const R=fr(_);yield n.peerStore.addressBook.add(R,[u]);const N=yield n.connectionManager.openConnection(R),B=N.remoteAddr.encapsulate("/p2p-circuit");e.set(N.remotePeer.toString(),B),s.dispatchEvent(new nn("listening"))})).apply(this,arguments)}const s=Object.assign(new Ei,{close:(o=$(function*(){return yield Promise.resolve()}),function(){return o.apply(this,arguments)}),listen:function t(o){return r.apply(this,arguments)},getAddrs:function i(){const o=[];for(const a of e.values())o.push(a);return o}});var o;return n.connectionManager.addEventListener("peer:disconnect",o=>{const{detail:a}=o;e.delete(a.remotePeer.toString())&&s.dispatchEvent(new nn("close"))}),s}({connectionManager:this.components.getConnectionManager(),peerStore:this.components.getPeerStore()})}filter(e){return(e=Array.isArray(e)?e:[e]).filter(t=>iu.matches(t))}}function S2(n){return Cv.apply(this,arguments)}function Cv(){return Cv=$(function*(n){const e=(new TextEncoder).encode(n),t=yield mi.digest(e);return wr.createV0(t)}),Cv.apply(this,arguments)}const I2="hop_relay",A2="/libp2p/relay",Gl=zt("libp2p:auto-relay"),b7=()=>{};class w7{constructor(e,t){this.components=e,this.addressSorter=t.addressSorter??yv,this.maxListeners=t.maxListeners??1,this.listenRelays=new Set,this.onError=t.onError??b7,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this.components.getPeerStore().addEventListener("change:protocols",r=>{this._onProtocolChange(r).catch(i=>{Gl.error(i)})}),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onPeerDisconnected)}_onProtocolChange(e){var t=this;return $(function*(){const{peerId:r,protocols:i}=e.detail,s=r.toString();if(null!=i.find(a=>a===$l)){if(!t.listenRelays.has(s))try{const a=t.components.getConnectionManager().getConnections(r);if(0===a.length)return;const u=a[0];if(u.remoteAddr.protoCodes().includes(290))return void Gl(`relayed connection to ${s} will not be used to hop on`);(yield function p7(n){return Sv.apply(this,arguments)}({connection:u}))&&(yield t.components.getPeerStore().metadataBook.setValue(r,I2,Ot("true")),yield t._addListenRelay(u,s))}catch(a){t.onError(a)}}else t.listenRelays.has(s)&&(yield t._removeListenRelay(s))})()}_onPeerDisconnected(e){const i=e.detail.remotePeer.toString();!this.listenRelays.has(i)||this._removeListenRelay(i).catch(s=>{Gl.error(s)})}_addListenRelay(e,t){var r=this;return $(function*(){try{if(r.listenRelays.size>=r.maxListeners)return;const i=yield qn(yield r.components.getPeerStore().addressBook.get(e.remotePeer),o=>mv(o,r.addressSorter),function(){var o=$(function*(a){return yield Ul(a)});return function(a){return o.apply(this,arguments)}}());(yield Promise.all(i.map(function(){var o=$(function*(a){try{let u=a.multiaddr;return null==u.getPeerId()&&(u=u.encapsulate(`/p2p/${e.remotePeer.toString()}`)),u=u.encapsulate("/p2p-circuit"),yield r.components.getTransportManager().listen([u]),!0}catch(u){Gl.error("error listening on circuit address",u),r.onError(u)}return!1});return function(a){return o.apply(this,arguments)}}()))).includes(!0)&&r.listenRelays.add(t)}catch(i){r.onError(i),r.listenRelays.delete(t)}})()}_removeListenRelay(e){var t=this;return $(function*(){t.listenRelays.delete(e)&&(yield t._listenOnAvailableHopRelays([e]))})()}_listenOnAvailableHopRelays(e=[]){var t=this;return $(function*(){if(t.listenRelays.size>=t.maxListeners)return;const r=[],i=yield t.components.getPeerStore().all();for(const{id:R,metadata:N}of i){const B=R.toString();if(t.listenRelays.has(B)||e.includes(B))continue;const z=N.get(I2);if(null==z||"true"!==Lt(z))continue;const X=t.components.getConnectionManager().getConnections(R);if(0!==X.length){if(yield t._addListenRelay(X[0],B),t.listenRelays.size>=t.maxListeners)return}else r.push(R)}for(const R of r)if(yield t._tryToListenOnRelay(R),t.listenRelays.size>=t.maxListeners)return;try{const R=yield S2(A2);var a,s=!1,o=!1;try{for(var _,u=Pt(t.components.getContentRouting().findProviders(R));s=!(_=yield u.next()).done;s=!1){const N=_.value;if(0===N.multiaddrs.length)continue;const B=N.id;if(yield t.components.getPeerStore().addressBook.add(B,N.multiaddrs),yield t._tryToListenOnRelay(B),t.listenRelays.size>=t.maxListeners)return}}catch(N){o=!0,a=N}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(o)throw a}}}catch(R){t.onError(R)}})()}_tryToListenOnRelay(e){var t=this;return $(function*(){try{const r=yield t.components.getConnectionManager().openConnection(e);yield t._addListenRelay(r,e.toString())}catch(r){Gl.error("Could not use %p as relay",e,r),t.onError(r,`could not connect and listen on known hop relay ${e.toString()}`)}})()}}const x2=zt("libp2p:relay");class _7{constructor(e,t){this.components=e,this.autoRelay=!1!==t.autoRelay?.enabled?new w7(e,{addressSorter:t.addressSorter,...t.autoRelay}):void 0,this.started=!1,this.init=t,this._advertiseService=this._advertiseService.bind(this)}isStarted(){return this.started}start(){var e=this;return $(function*(){!1!==e.init.hop.enabled&&!1!==e.init.advertise.enabled&&(e.timeout=(0,_h.setDelayedInterval)(e._advertiseService,e.init.advertise.ttl,e.init.advertise.bootDelay)),e.started=!0})()}stop(){var e=this;return $(function*(){null!=e.timeout&&(0,_h.clearDelayedInterval)(e.timeout),e.started=!1})()}_advertiseService(){var e=this;return $(function*(){try{const t=yield S2(A2);yield e.components.getContentRouting().provide(t)}catch(t){t.code===Ce.ERR_NO_ROUTERS_AVAILABLE?(x2.error("a content router, such as a DHT, must be provided in order to advertise the relay service",t),yield e.stop()):x2.error(t)}})()}}var D7=x(9014);x(422),x(5911);const R2=Un.pki;function Iv(){return Iv=$(function*(n,e){const t=n.map(e);return n[(yield Promise.all(t)).findIndex(s=>s)]}),Iv.apply(this,arguments)}const I7=zt("libp2p:keychain:cms"),Tv=new WeakMap;class T7{constructor(e,t){if(null==e)throw ae(new Error("keychain is required"),Ce.ERR_KEYCHAIN_REQUIRED);this.keychain=e,Tv.set(this,{dek:t})}encrypt(e,t){var r=this;return $(function*(){if(!(t instanceof Uint8Array))throw ae(new Error("Plain data must be a Uint8Array"),Ce.ERR_INVALID_PARAMETERS);const i=yield r.keychain.findKeyByName(e),s=yield r.keychain.getPrivateKey(e),o=Tv.get(r);if(null==o)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const u=Un.pki.decryptRsaPrivateKey(s,o.dek),_=yield((n,e)=>{const t=R2.rsa.setPublicKey(e.n,e.e),r=R2.createCertificate();r.publicKey=t,r.serialNumber="01",r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+10);const i=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:n.id}];return r.setSubject(i),r.setIssuer(i),r.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),r.sign(e),r})(i,u),R=Un.pkcs7.createEnvelopedData();return R.addRecipient(_),R.content=Un.util.createBuffer(t),R.encrypt(),Ot(Un.asn1.toDer(R.toAsn1()).getBytes(),"ascii")})()}decrypt(e){var t=this;return $(function*(){if(!(e instanceof Uint8Array))throw ae(new Error("CMS data is required"),Ce.ERR_INVALID_PARAMETERS);let r;try{const N=Un.util.createBuffer(Lt(e,"ascii")),B=Un.asn1.fromDer(N);r=Un.pkcs7.messageFromAsn1(B)}catch(N){throw I7.error(N),ae(new Error("Invalid CMS"),Ce.ERR_INVALID_CMS)}const i=r.recipients.filter(N=>N.issuer.find(B=>"O"===B.shortName&&"ipfs"===B.value)).filter(N=>N.issuer.find(B=>"CN"===B.shortName)).map(N=>({recipient:N,keyId:N.issuer.find(B=>"CN"===B.shortName).value})),s=yield function C7(n,e){return Iv.apply(this,arguments)}(i,function(){var N=$(function*(B){try{if(null!=(yield t.keychain.findKeyById(B.keyId)))return!0}catch{return!1}return!1});return function(B){return N.apply(this,arguments)}}());if(null==s){const N=i.map(B=>B.keyId);throw ae(new Error(`Decryption needs one of the key(s): ${N.join(", ")}`),Ce.ERR_MISSING_KEYS,{missingKeys:N})}const o=yield t.keychain.findKeyById(s.keyId);if(null==o)throw ae(new Error("No key available to decrypto"),Ce.ERR_NO_KEY);const a=yield t.keychain.getPrivateKey(o.name),u=Tv.get(t);if(null==u)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const R=Un.pki.decryptRsaPrivateKey(a,u.dek);return r.decrypt(s.recipient,R),Ot(r.content.getBytes(),"ascii")})()}}x(1298);var A7=x(7949);const N2={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function M2(n,e,t,r,i){if("sha1"!==i&&"sha2-256"!==i&&"sha2-512"!==i){const a=Object.keys(N2).join(" / ");throw ae(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}const o=A7(n,e,t,r,N2[i]);return hF.encode64(o,null)}const Ch=zt("libp2p:keychain"),Xo=new WeakMap,xv={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function mo(n){return null!=n&&"string"==typeof n&&n===D7(n.trim())&&n.length>0}function Ln(){return Rv.apply(this,arguments)}function Rv(){return(Rv=$(function*(){const t=800*Math.random()+200;yield new Promise(r=>setTimeout(r,t))})).apply(this,arguments)}function Vs(n){return new Ur("/pkcs8/"+n)}function Jo(n){return new Ur("/info/"+n)}class k2{constructor(e,t){if(this.components=e,this.init=Hl(xv,t),null!=this.init.pass&&this.init.pass?.length<20)throw new Error("pass must be least 20 characters");if(null!=this.init.dek?.keyLength&&this.init.dek.keyLength<14)throw new Error("dek.keyLength must be least 14 bytes");if(null!=this.init.dek?.salt?.length&&this.init.dek.salt.length<16)throw new Error("dek.saltLength must be least 16 bytes");if(null!=this.init.dek?.iterationCount&&this.init.dek.iterationCount<1e3)throw new Error("dek.iterationCount must be least 1000");const r=null!=this.init.pass&&null!=this.init.dek?.salt?M2(this.init.pass,this.init.dek?.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";Xo.set(this,{dek:r})}get cms(){const e=Xo.get(this);if(null==e)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);return new T7(this,e.dek)}static generateOptions(){const e=Object.assign({},xv),t=3*Math.ceil(16/3);return e.dek.salt=Lt(ih(t),"base64"),e}static get options(){return xv}createKey(e,t,r=2048){var i=this;return $(function*(){if(!mo(e)||"self"===e)throw yield Ln(),ae(new Error("Invalid key name"),Ce.ERR_INVALID_KEY_NAME);if("string"!=typeof t)throw yield Ln(),ae(new Error("Invalid key type"),Ce.ERR_INVALID_KEY_TYPE);const s=Vs(e);if(yield i.components.getDatastore().has(s))throw yield Ln(),ae(new Error("Key name already exists"),Ce.ERR_KEY_ALREADY_EXISTS);if("rsa"===t.toLowerCase()&&(!Number.isSafeInteger(r)||r<2048))throw yield Ln(),ae(new Error("Invalid RSA key size"),Ce.ERR_INVALID_KEY_SIZE);let a;try{const u=yield iT(t,r),_=yield u.id(),R=Xo.get(i);if(null==R)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const N=R.dek,B=yield u.export(N);a={name:e,id:_};const z=i.components.getDatastore().batch();z.put(s,Ot(B)),z.put(Jo(e),Ot(JSON.stringify(a))),yield z.commit()}catch(u){throw yield Ln(),u}return a})()}listKeys(){var e=this;return $(function*(){const t={prefix:"/info/"},r=[];var o,i=!1,s=!1;try{for(var u,a=Pt(e.components.getDatastore().query(t));i=!(u=yield a.next()).done;i=!1)r.push(JSON.parse(Lt(u.value.value)))}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}return r})()}findKeyById(e){var t=this;return $(function*(){try{return(yield t.listKeys()).find(i=>i.id===e)}catch(r){throw yield Ln(),r}})()}findKeyByName(e){var t=this;return $(function*(){if(!mo(e))throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);const r=Jo(e);try{const i=yield t.components.getDatastore().get(r);return JSON.parse(Lt(i))}catch(i){throw yield Ln(),Ch.error(i),ae(new Error(`Key '${e}' does not exist.`),Ce.ERR_KEY_NOT_FOUND)}})()}removeKey(e){var t=this;return $(function*(){if(!mo(e)||"self"===e)throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);const r=Vs(e),i=yield t.findKeyByName(e),s=t.components.getDatastore().batch();return s.delete(r),s.delete(Jo(e)),yield s.commit(),i})()}renameKey(e,t){var r=this;return $(function*(){if(!mo(e)||"self"===e)throw yield Ln(),ae(new Error(`Invalid old key name '${e}'`),Ce.ERR_OLD_KEY_NAME_INVALID);if(!mo(t)||"self"===t)throw yield Ln(),ae(new Error(`Invalid new key name '${t}'`),Ce.ERR_NEW_KEY_NAME_INVALID);const i=Vs(e),s=Vs(t),o=Jo(e),a=Jo(t);if(yield r.components.getDatastore().has(s))throw yield Ln(),ae(new Error(`Key '${t}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);try{const _=yield r.components.getDatastore().get(i),R=yield r.components.getDatastore().get(o),N=JSON.parse(Lt(R));N.name=t;const B=r.components.getDatastore().batch();return B.put(s,_),B.put(a,Ot(JSON.stringify(N))),B.delete(i),B.delete(o),yield B.commit(),N}catch(_){throw yield Ln(),_}})()}exportKey(e,t){var r=this;return $(function*(){if(!mo(e))throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t)throw yield Ln(),ae(new Error("Password is required"),Ce.ERR_PASSWORD_REQUIRED);const i=Vs(e);try{const o=Lt(yield r.components.getDatastore().get(i)),a=Xo.get(r);if(null==a)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const u=a.dek;return yield(yield Mm(o,u)).export(t)}catch(s){throw yield Ln(),s}})()}importKey(e,t,r){var i=this;return $(function*(){if(!mo(e)||"self"===e)throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t)throw yield Ln(),ae(new Error("PEM encoded key is required"),Ce.ERR_PEM_REQUIRED);const s=Vs(e);if(yield i.components.getDatastore().has(s))throw yield Ln(),ae(new Error(`Key '${e}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);let a,u;try{a=yield Mm(t,r)}catch{throw yield Ln(),ae(new Error("Cannot read the key, most likely the password is wrong"),Ce.ERR_CANNOT_READ_KEY)}try{u=yield a.id();const N=Xo.get(i);if(null==N)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const B=N.dek;t=yield a.export(B)}catch(N){throw yield Ln(),N}const _={name:e,id:u},R=i.components.getDatastore().batch();return R.put(s,Ot(t)),R.put(Jo(e),Ot(JSON.stringify(_))),yield R.commit(),_})()}importPeer(e,t){var r=this;return $(function*(){try{if(!mo(e))throw ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t||null==t.privateKey)throw ae(new Error("Peer.privKey is required"),Ce.ERR_MISSING_PRIVATE_KEY);const i=yield Pl(t.privateKey),s=Vs(e);if(yield r.components.getDatastore().has(s))throw yield Ln(),ae(new Error(`Key '${e}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);const a=Xo.get(r);if(null==a)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const u=a.dek,_=yield i.export(u),R={name:e,id:t.toString()},N=r.components.getDatastore().batch();return N.put(s,Ot(_)),N.put(Jo(e),Ot(JSON.stringify(R))),yield N.commit(),R}catch(i){throw yield Ln(),i}})()}getPrivateKey(e){var t=this;return $(function*(){if(!mo(e))throw yield Ln(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);try{const r=Vs(e);return Lt(yield t.components.getDatastore().get(r))}catch(r){throw yield Ln(),Ch.error(r),ae(new Error(`Key '${e}' does not exist.`),Ce.ERR_KEY_NOT_FOUND)}})()}rotateKeychainPass(e,t){var r=this;return $(function*(){if("string"!=typeof e)throw yield Ln(),ae(new Error(`Invalid old pass type '${typeof e}'`),Ce.ERR_INVALID_OLD_PASS_TYPE);if("string"!=typeof t)throw yield Ln(),ae(new Error(`Invalid new pass type '${typeof t}'`),Ce.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw yield Ln(),ae(new Error(`Invalid pass length ${t.length}`),Ce.ERR_INVALID_PASS_LENGTH);Ch("recreating keychain");const i=Xo.get(r);if(null==i)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const s=i.dek;r.init.pass=t;const o=null!=t&&null!=r.init.dek?.salt?M2(t,r.init.dek.salt,r.init.dek?.iterationCount,r.init.dek?.keyLength,r.init.dek?.hash):"";Xo.set(r,{dek:o});const a=yield r.listKeys();for(const u of a){const R=Lt(yield r.components.getDatastore().get(Vs(u.name))),N=yield Mm(R,s),B=o.toString(),z=yield N.export(B),X=r.components.getDatastore().batch(),J={name:u.name,id:u.id};X.put(Vs(u.name),Ot(z)),X.put(Jo(u.name),Ot(JSON.stringify(J))),yield X.commit()}Ch("keychain reconstructed")})()}}var Pv=x(1349),R7=x(5550);class P7{constructor(e){if("number"!=typeof e)throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");this.timespan=e,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(e,t){return 1-Math.exp(-(e-t)/this.timespan)}push(e,t){if(null!=this.previousTime){const r=this.alpha(e,this.previousTime),i=t-this.movingAverage,s=r*i;this.movingAverage=r*t+(1-r)*this.movingAverage,this.variance=(1-r)*(this.variance+i*s),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+r*i}else this.movingAverage=t;this.previousTime=e}}function L2(n){return new P7(n)}class Nv extends Ei{constructor(e){super(),this.enabled=e.enabled,this.queue=[],this.stats={dataReceived:0n,dataSent:0n},this.frequencyLastTime=Date.now(),this.frequencyAccumulators={},this.movingAverages={dataReceived:[],dataSent:[]},this.computeThrottleMaxQueueSize=e.computeThrottleMaxQueueSize,this.computeThrottleTimeout=e.computeThrottleTimeout,this._update=this._update.bind(this),this.movingAverageIntervals=e.movingAverageIntervals;for(let t=0;t0&&this._resetComputeTimeout()}stop(){null!=this.timeout&&(this.timeout.clear(),this.timeout=null)}getSnapshot(){return Object.assign({},this.stats)}getMovingAverages(){return Object.assign({},this.movingAverages)}push(e,t){this.queue.push([e,t,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this.timeout=Kl(this._update,this._nextTimeout())}_nextTimeout(){return Math.max(this.computeThrottleTimeout*(1-this.queue.length/this.computeThrottleMaxQueueSize),0)}_update(){if(this.timeout=null,this.queue.length>0){let e=["",0,0];for(e of this.queue)this._applyOp(e);this.queue=[],e.length>2&&""!==e[0]&&this._updateFrequency(e[2]),this.dispatchEvent(new nn("update",{detail:this.stats}))}}_updateFrequency(e){const t=e-this.frequencyLastTime;this._updateFrequencyFor("dataReceived",t,e),this._updateFrequencyFor("dataSent",t,e),this.frequencyLastTime=e}_updateFrequencyFor(e,t,r){const i=this.frequencyAccumulators[e]??0;this.frequencyAccumulators[e]=0;const o=i/(t??1)*1e3;let a=this.movingAverages[e];null==a&&(a=this.movingAverages[e]=[]);const u=this.movingAverageIntervals;for(let _=0;_s:s})}forPeer(e){const t=e.toString();return this.peerStats.get(t)??this.oldPeers.get(t)}getProtocols(){return Array.from(this.protocolStats.keys())}forProtocol(e){return this.protocolStats.get(e)}onPeerDisconnected(e){const t=e.toString(),r=this.peerStats.get(t);null!=r&&(r.stop(),this.peerStats.delete(t),this.oldPeers.set(t,r))}_onMessage(e){if(!this.running)return;const{remotePeer:t,protocol:r,direction:i,dataLength:s}=e,o=M7[i];let a=this.forPeer(t);if(null==a){const u=new Nv(this.statsInit);this.peerStats.set(t.toString(),u),a=u}if(a.push(o,s),this.globalStats.push(o,s),null!=r){let u=this.forProtocol(r);if(null==u){const _=new Nv(this.statsInit);this.protocolStats.set(r,_),u=_}u.push(o,s)}}updatePlaceholder(e,t){if(!this.running)return;const r=e.toString(),i=this.peerStats.get(r)??this.oldPeers.get(r),s=t.toString(),o=this.peerStats.get(s)??this.oldPeers.get(s);let a=i;null!=o&&(a=function k7(n,e){return n.stop(),e.stop(),n.queue=[...n.queue,...e.queue],n}(o,a),this.oldPeers.remove(s)),this.peerStats.delete(e.toString()),this.peerStats.set(s,a),a.start()}trackStream(e){var t=this;const{stream:r,remotePeer:i,protocol:s}=e;if(!this.running)return;r.source=Pv(r.source,u=>this._onMessage({remotePeer:i,protocol:s,direction:"in",dataLength:u.byteLength}));const a=r.sink;r.sink=function(){var u=$(function*(_){return yield qn(_,R=>Pv(R,N=>{t._onMessage({remotePeer:i,protocol:s,direction:"out",dataLength:N.byteLength})}),a)});return function(_){return u.apply(this,arguments)}}()}}function Mv(n){return Ov.apply(this,arguments)}function Ov(){return Ov=$(function*(n){try{return{status:"fulfilled",value:yield n,isFulfilled:!0,isRejected:!1}}catch(e){return{status:"rejected",reason:e,isFulfilled:!1,isRejected:!0}}}),Ov.apply(this,arguments)}class L7{constructor(e){ob(this,"value"),ob(this,"next"),this.value=e}}class B7{constructor(){pp(this,zs,void 0),pp(this,Va,void 0),pp(this,Ha,void 0),this.clear()}enqueue(e){const t=new L7(e);aa(this,zs)?(aa(this,Va).next=t,So(this,Va,t)):(So(this,zs,t),So(this,Va,t)),ab(this,Ha)._++}dequeue(){const e=aa(this,zs);if(e)return So(this,zs,aa(this,zs).next),ab(this,Ha)._--,e.value}clear(){So(this,zs,void 0),So(this,Va,void 0),So(this,Ha,0)}get size(){return aa(this,Ha)}*[Symbol.iterator](){let e=aa(this,zs);for(;e;)yield e.value,e=e.next}}function F7(n){if(!Number.isInteger(n)&&n!==Number.POSITIVE_INFINITY||!(n>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const e=new B7;let t=0;const i=function(){var a=$(function*(u,_,R){t++;const N=$(function*(){return u(...R)})();_(N);try{yield N}catch{}t--,e.size>0&&e.dequeue()()});return function(_,R,N){return a.apply(this,arguments)}}(),o=(a,...u)=>new Promise(_=>{((a,u,_)=>{e.enqueue(i.bind(void 0,a,u,_)),$(function*(){yield Promise.resolve(),t0&&e.dequeue()()})()})(a,_,u)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}function U7(n){return kv.apply(this,arguments)}function kv(){return kv=$(function*(n,e={}){const{concurrency:t=Number.POSITIVE_INFINITY}=e,r=F7(t);return Promise.all(n.map(i=>Mv(i&&"function"==typeof i.then?i:"function"==typeof i?r(()=>i()):Promise.resolve(i))))}),kv.apply(this,arguments)}zs=new WeakMap,Va=new WeakMap,Ha=new WeakMap;const Ra=zt("libp2p:transports");class V7 extends Ei{constructor(e,t={}){super(),this.components=e,this.started=!1,this.transports=new Map,this.listeners=Ll({component:"transport-manager",metric:"listeners",metrics:this.components.getMetrics()}),this.faultTolerance=t.faultTolerance??Pa.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw ae(new Error("Transport must have a valid tag"),Ce.ERR_INVALID_KEY);if(this.transports.has(t))throw ae(new Error("There is already a transport with this tag"),Ce.ERR_DUPLICATE_TRANSPORT);Ra("adding transport %s",t),this.transports.set(t,e),this.listeners.has(t)||this.listeners.set(t,[])}isStarted(){return this.started}start(){var e=this;return $(function*(){const t=e.components.getAddressManager().getListenAddrs();yield e.listen(t),e.started=!0})()}stop(){var e=this;return $(function*(){const t=[];for(const[r,i]of e.listeners)for(Ra("closing listeners for %s",r);i.length>0;){const s=i.pop();null!=s&&t.push(s.close())}yield Promise.all(t),Ra("all listeners closed");for(const r of e.listeners.keys())e.listeners.set(r,[]);e.started=!1})()}dial(e,t){var r=this;return $(function*(){const i=r.transportForMultiaddr(e);if(null==i)throw ae(new Error(`No transport available for address ${String(e)}`),Ce.ERR_TRANSPORT_UNAVAILABLE);try{return yield i.dial(e,{...t,upgrader:r.components.getUpgrader()})}catch(s){throw null==s.code&&(s.code=Ce.ERR_TRANSPORT_DIAL_FAILED),s}})()}getAddrs(){let e=[];for(const t of this.listeners.values())for(const r of t)e=[...e,...r.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}transportForMultiaddr(e){for(const t of this.transports.values())if(t.filter([e]).length>0)return t}listen(e){var t=this;return $(function*(){if(null==e||0===e.length)return void Ra("no addresses were provided for listening, this node is dial only");const r=[];for(const[i,s]of t.transports.entries()){const o=s.filter(e),a=[];for(const R of o){Ra("creating listener for %s on %s",i,R);const N=s.createListener({upgrader:t.components.getUpgrader()});let B=t.listeners.get(i);null==B&&(B=[],t.listeners.set(i,B)),B.push(N),N.addEventListener("listening",()=>{t.dispatchEvent(new nn("listener:listening",{detail:N}))}),N.addEventListener("close",()=>{t.dispatchEvent(new nn("listener:close",{detail:N}))}),a.push(N.listen(R))}if(0!==a.length){if(null==(yield U7(a)).find(R=>R.isFulfilled)&&t.faultTolerance!==Pa.NO_FATAL)throw ae(new Error(`Transport (${i}) could not listen on any available address`),Ce.ERR_NO_VALID_ADDRESSES)}else r.push(i)}if(r.length===t.transports.size){const i=`no valid addresses were provided for transports [${r.join(", ")}]`;if(t.faultTolerance===Pa.FATAL_ALL)throw ae(new Error(i),Ce.ERR_NO_VALID_ADDRESSES);Ra(`libp2p in dial mode only: ${i}`)}})()}remove(e){var t=this;return $(function*(){Ra("removing %s",e);for(const r of t.listeners.get(e)??[])yield r.close();t.transports.delete(e),t.listeners.delete(e)})()}removeAll(){var e=this;return $(function*(){const t=[];for(const r of e.transports.keys())t.push(e.remove(r));yield Promise.all(t)})()}}var Pa=(()=>(function(n){n[n.FATAL_ALL=0]="FATAL_ALL",n[n.NO_FATAL=1]="NO_FATAL"}(Pa||(Pa={})),Pa))();const su="/multistream/1.0.0",B2=Ot("\n");function Lv(n){const e=new qr(n,B2);return ks.single(e)}function Wl(n,e,t={}){const r=Lv(e);n.push(!0===t.writeBytes?r.subarray():r)}function H7(n,e,t={}){const r=new qr;for(const i of e)r.append(Lv(i));n.push(!0===t.writeBytes?r.subarray():r)}function K7(n,e){return Bv.apply(this,arguments)}function Bv(){return Bv=$(function*(n,e){let t=1;const r={[Symbol.asyncIterator]:()=>r,next:(a=$(function*(){return yield n.next(t)}),function(){return a.apply(this,arguments)})};var a;let i=r;null!=e?.signal&&(i=vs(r,e.signal));const o=yield qn(i,ps({onLength:a=>{t=a}}),function(){var a=$(function*(u){return yield Aa(u)});return function(u){return a.apply(this,arguments)}}());if(null==o)throw ae(new Error("no buffer returned"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(o.get(o.byteLength-1)!==B2[0])throw ae(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.sublist(0,-1)}),Bv.apply(this,arguments)}function Ih(n,e){return Fv.apply(this,arguments)}function Fv(){return Fv=$(function*(n,e){return Lt((yield K7(n,e)).subarray())}),Fv.apply(this,arguments)}const ql=zt("libp2p:mss:select");function Uv(n,e){return Vv.apply(this,arguments)}function Vv(){return Vv=$(function*(n,e,t={}){e=Array.isArray(e)?[...e]:[e];const{reader:r,writer:i,rest:s,stream:o}=Fd(n),a=e.shift();if(null==a)throw new Error("At least one protocol must be specified");ql('select: write ["%s", "%s"]',su,a),H7(i,[Ot(su),Ot(a)],t);let R=yield Ih(r,t);if(ql('select: read "%s"',R),R===su&&(R=yield Ih(r,t),ql('select: read "%s"',R)),R===a)return s(),{stream:o,protocol:a};for(const N of e){ql('select: write "%s"',N),Wl(i,Ot(N),t);const B=yield Ih(r,t);if(ql('select: read "%s" for "%s"',B,N),B===N)return s(),{stream:o,protocol:N}}throw s(),ae(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}),Vv.apply(this,arguments)}const Yl=zt("libp2p:mss:handle");function Hv(n,e,t){return Kv.apply(this,arguments)}function Kv(){return Kv=$(function*(n,e,t){e=Array.isArray(e)?e:[e];const{writer:r,reader:i,rest:s,stream:o}=Fd(n);for(;;){const a=yield Ih(i,t);if(Yl('read "%s"',a),a!==su){if(e.includes(a))return Wl(r,Ot(a),t),Yl('respond with "%s" for "%s"',a,a),s(),{stream:o,protocol:a};"ls"!==a?(Wl(r,Ot("na"),t),Yl('respond with "na" for "%s"',a)):(Wl(r,new qr(...e.map(u=>Lv(Ot(u)))),t),Yl('respond with "%s" for %s',e,a))}else Yl('respond with "%s" for "%s"',su,a),Wl(r,Ot(su),t)}}),Kv.apply(this,arguments)}var F2=x(344);const U2=Symbol.for("@libp2p/connection"),$7=zt("libp2p:connection");class j7{constructor(e){const{remoteAddr:t,remotePeer:r,newStream:i,close:s,getStreams:o,stat:a}=e;this.id=`${parseInt(String(1e9*Math.random())).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=r,this.stat={...a,status:"OPEN"},this._newStream=i,this._close=s,this._getStreams=o,this.tags=[],this._closing=!1}get[Symbol.toStringTag](){return"Connection"}get[U2](){return!0}get streams(){return this._getStreams()}newStream(e,t){var r=this;return $(function*(){if(r.stat.status===h2)throw ae(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(r.stat.status===gv)throw ae(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);const i=yield r._newStream(e,t);return i.stat.direction="outbound",i})()}addStream(e){e.stat.direction="inbound"}removeStream(e){}close(){var e=this;return $(function*(){if(e.stat.status!==gv&&!e._closing){e.stat.status=h2;try{e.streams.forEach(t=>t.close())}catch(t){$7.error(t)}e._closing=!0,yield e._close(),e._closing=!1,e.stat.timeline.close=Date.now(),e.stat.status=gv}})()}}const $v=Symbol.for("@libp2p/topology"),V2=zt("libp2p:registrar");class W7{constructor(e){this.topologies=new Map,this.handlers=new Map,this.components=e,this._onDisconnect=this._onDisconnect.bind(this),this._onProtocolChange=this._onProtocolChange.bind(this),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onDisconnect),this.components.getPeerStore().addEventListener("change:protocols",this._onProtocolChange)}getProtocols(){return Array.from(new Set([...this.topologies.keys(),...this.handlers.keys()])).sort()}getHandler(e){const t=this.handlers.get(e);if(null==t)throw ae(new Error(`No handler registered for protocol ${e}`),Ce.ERR_NO_HANDLER_FOR_PROTOCOL);return t}getTopologies(e){const t=this.topologies.get(e);return null==t?[]:[...t.values()]}handle(e,t,r){var i=this;return $(function*(){if(i.handlers.has(e))throw ae(new Error(`Handler already registered for protocol ${e}`),Ce.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const s=Hl.bind({ignoreUndefined:!0})({maxInboundStreams:32,maxOutboundStreams:64},r);i.handlers.set(e,{handler:t,options:s}),yield i.components.getPeerStore().protoBook.add(i.components.getPeerId(),[e])})()}unhandle(e){var t=this;return $(function*(){const r=Array.isArray(e)?e:[e];r.forEach(i=>{t.handlers.delete(i)}),yield t.components.getPeerStore().protoBook.remove(t.components.getPeerId(),r)})()}register(e,t){var r=this;return $(function*(){if(!function G7(n){return null!=n&&Boolean(n[$v])}(t))throw V2.error("topology must be an instance of interfaces/topology"),ae(new Error("topology must be an instance of interfaces/topology"),Ce.ERR_INVALID_PARAMETERS);const i=`${(1e9*Math.random()).toString(36)}${Date.now()}`;let s=r.topologies.get(e);return null==s&&(s=new Map,r.topologies.set(e,s)),s.set(i,t),yield t.setRegistrar(r),i})()}unregister(e){for(const[t,r]of this.topologies.entries())r.has(e)&&(r.delete(e),0===r.size&&this.topologies.delete(t))}_onDisconnect(e){const t=e.detail;this.components.getPeerStore().protoBook.get(t.remotePeer).then(r=>{for(const i of r){const s=this.topologies.get(i);if(null!=s)for(const o of s.values())o.onDisconnect(t.remotePeer)}}).catch(r=>{V2.error(r)})}_onProtocolChange(e){const{peerId:t,protocols:r,oldProtocols:i}=e.detail,s=i.filter(a=>!r.includes(a)),o=r.filter(a=>!i.includes(a));for(const a of s){const u=this.topologies.get(a);if(null!=u)for(const _ of u.values())_.onDisconnect(t)}for(const a of o){const u=this.topologies.get(a);if(null!=u)for(const _ of u.values()){const R=this.components.getConnectionManager().getConnections(t)[0];null!=R&&_.onConnect(t,R)}}}}const zn=zt("libp2p:upgrader");function $2(n,e,t){let r=0;return t.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===n&&r++}),r}class Q7 extends Ei{constructor(e,t){super(),this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(r=>{this.connectionEncryption.set(r.protocol,r)}),this.muxers=new Map,t.muxers.forEach(r=>{this.muxers.set(r.protocol,r)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout}upgradeInbound(e){var t=this;return $(function*(){let r,i,s,o,a,u,_;const R=t.components.getMetrics(),N=new bi.TimeoutController(t.inboundUpgradeTimeout);try{(0,Vr.setMaxListeners)?.(1/0,N.signal)}catch{}try{const B=Go(e,N.signal);if(e.source=B.source,e.sink=B.sink,yield t.components.getConnectionGater().denyInboundConnection(e))throw ae(new Error("The multiaddr connection is blocked by gater.acceptConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(null!=R){({setTarget:u,proxy:_}=F2());const J=`${(1e9*Math.random()).toString(36)}${Date.now()}`;u({toString:()=>J}),R.trackStream({stream:e,remotePeer:_})}zn("starting the inbound connection upgrade");let z=e;const X=t.components.getConnectionProtector();null!=X&&(zn("protecting the inbound connection"),z=yield X.protect(e));try{if(({conn:r,remotePeer:i,protocol:a}=yield t._encryptInbound(z)),yield t.components.getConnectionGater().denyInboundEncryptedConnection(i,{...z,...r}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const J=yield t._multiplexInbound({...z,...r},t.muxers);o=J.muxerFactory,s=J.stream}else s=r}catch(J){throw zn.error("Failed to upgrade inbound connection",J),yield e.close(J),J}if(yield t.components.getConnectionGater().denyInboundUpgradedConnection(i,{...z,...r}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);return null!=R&&(R.updatePlaceholder(_,i),u(i)),zn("Successfully upgraded inbound connection"),t._createConnection({cryptoProtocol:a,direction:"inbound",maConn:e,upgradedConn:s,muxerFactory:o,remotePeer:i})}finally{N.clear()}})()}upgradeOutbound(e){var t=this;return $(function*(){const r=e.remoteAddr.getPeerId();if(null==r)throw ae(new Error("outbound connection must have a peer id"),Ce.ERR_INVALID_MULTIADDR);const i=fr(r);if(yield t.components.getConnectionGater().denyOutboundConnection(i,e))throw ae(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),Ce.ERR_CONNECTION_INTERCEPTED);let s,o,a,u,_,R,N;const B=t.components.getMetrics();if(null!=B){({setTarget:R,proxy:N}=F2());const J=`${(1e9*Math.random()).toString(36)}${Date.now()}`;R({toB58String:()=>J}),B.trackStream({stream:e,remotePeer:N})}zn("Starting the outbound connection upgrade");let z=e;const X=t.components.getConnectionProtector();null!=X&&(z=yield X.protect(e));try{if(({conn:s,remotePeer:o,protocol:u}=yield t._encryptOutbound(z,i)),yield t.components.getConnectionGater().denyOutboundEncryptedConnection(o,{...z,...s}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const J=yield t._multiplexOutbound({...z,...s},t.muxers);_=J.muxerFactory,a=J.stream}else a=s}catch(J){throw zn.error("Failed to upgrade outbound connection",J),yield e.close(J),J}if(yield t.components.getConnectionGater().denyOutboundUpgradedConnection(o,{...z,...s}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);return null!=B&&(B.updatePlaceholder(N,o),R(o)),zn("Successfully upgraded outbound connection"),t._createConnection({cryptoProtocol:u,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:_,remotePeer:o})})()}_createConnection(e){var t=this;const{cryptoProtocol:r,direction:i,maConn:s,upgradedConn:o,remotePeer:a,muxerFactory:u}=e;let _,R,N;null!=u&&(_=u.createStreamMuxer({direction:i,onIncomingStream:X=>{null!=N&&Promise.resolve().then($(function*(){const J=t.components.getRegistrar().getProtocols(),{stream:oe,protocol:de}=yield Hv(X,J);if(zn("%s: incoming stream opened on %s",i,de),t.components.getMetrics()?.trackStream({stream:oe,remotePeer:a,protocol:de}),null==N)return;const ue=function q7(n,e){try{const{options:t}=e.getHandler(n);return t.maxInboundStreams}catch(t){if(t.code!==Ce.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 32}(de,t.components.getRegistrar());$2(de,"inbound",N)!==ue?(X.stat.protocol=de,t.components.getPeerStore().protoBook.add(a,[de]).catch(Ke=>zn.error(Ke)),N.addStream(X),t._onStream({connection:N,stream:{...X,...oe},protocol:de})):X.abort(ae(new Error(`Too many inbound protocol streams for protocol "${de}" - limit ${ue}`),Ce.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS))})).catch(J=>{zn.error(J),null==X.stat.timeline.close&&X.close()})},onStreamEnd:X=>{N?.removeStream(X.id)}}),Fr(_)&&_.init(this.components),R=function(){var X=$(function*(J,oe={}){if(null==_)throw ae(new Error("Stream is not multiplexed"),Ce.ERR_MUXER_UNAVAILABLE);zn("%s: starting new stream on %s",i,J);const de=_.newStream(),xe=t.components.getMetrics();let ue;try{if(null==oe.signal){zn("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",J),ue=new bi.TimeoutController(3e4),oe.signal=ue.signal;try{(0,Vr.setMaxListeners)?.(1/0,ue.signal)}catch{}}const{stream:Te,protocol:Ke}=yield Uv(de,J,oe);xe?.trackStream({stream:Te,remotePeer:a,protocol:Ke});const Pe=function Y7(n,e){try{const{options:t}=e.getHandler(n);return t.maxOutboundStreams}catch(t){if(t.code!==Ce.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 64}(Ke,t.components.getRegistrar());if($2(Ke,"outbound",N)===Pe){const yt=ae(new Error(`Too many outbound protocol streams for protocol "${Ke}" - limit ${Pe}`),Ce.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw de.abort(yt),yt}return de.stat.protocol=Ke,t.components.getPeerStore().protoBook.add(a,[Ke]).catch(yt=>zn.error(yt)),{...de,...Te,stat:{...de.stat,protocol:Ke}}}catch(Te){throw zn.error("could not create new stream",Te),null==de.stat.timeline.close&&de.close(),null!=Te.code?Te:ae(Te,Ce.ERR_UNSUPPORTED_PROTOCOL)}finally{ue?.clear()}});return function(oe){return X.apply(this,arguments)}}(),qn(o,_,o).catch(zn.error));const B=s.timeline;s.timeline=new Proxy(B,{set:(...X)=>(null!=N&&"close"===X[1]&&null!=X[2]&&null==B.close&&$(function*(){try{"OPEN"===N.stat.status&&(yield N.close())}catch(J){zn.error(J)}finally{t.dispatchEvent(new nn("connectionEnd",{detail:N}))}})().catch(J=>{zn.error(J)}),Reflect.set(...X))}),s.timeline.upgraded=Date.now();const z=()=>{throw ae(new Error("connection is not multiplexed"),Ce.ERR_CONNECTION_NOT_MULTIPLEXED)};return N=function z7(n){return new j7(n)}({remoteAddr:s.remoteAddr,remotePeer:a,stat:{status:"OPEN",direction:i,timeline:s.timeline,multiplexer:_?.protocol,encryption:r},newStream:R??z,getStreams:()=>null!=_?_.streams:z(),close:(X=$(function*(){yield s.close(),_?.close()}),function(){return X.apply(this,arguments)})}),this.dispatchEvent(new nn("connection",{detail:N})),N;var X}_onStream(e){const{connection:t,stream:r,protocol:i}=e,{handler:s}=this.components.getRegistrar().getHandler(i);s({connection:t,stream:r})}_encryptInbound(e){var t=this;return $(function*(){const r=Array.from(t.connectionEncryption.keys());zn("handling inbound crypto protocol selection",r);try{const{stream:i,protocol:s}=yield Hv(e,r,{writeBytes:!0}),o=t.connectionEncryption.get(s);if(null==o)throw new Error(`no crypto module found for ${s}`);return zn("encrypting inbound connection..."),{...yield o.secureInbound(t.components.getPeerId(),i),protocol:s}}catch(i){throw ae(i,Ce.ERR_ENCRYPTION_FAILED)}})()}_encryptOutbound(e,t){var r=this;return $(function*(){const i=Array.from(r.connectionEncryption.keys());zn("selecting outbound crypto protocol",i);try{const{stream:s,protocol:o}=yield Uv(e,i,{writeBytes:!0}),a=r.connectionEncryption.get(o);if(null==a)throw new Error(`no crypto module found for ${o}`);return zn("encrypting outbound connection to %p",t),{...yield a.secureOutbound(r.components.getPeerId(),s,t),protocol:o}}catch(s){throw ae(s,Ce.ERR_ENCRYPTION_FAILED)}})()}_multiplexOutbound(e,t){return $(function*(){const r=Array.from(t.keys());zn("outbound selecting muxer %s",r);try{const{stream:i,protocol:s}=yield Uv(e,r,{writeBytes:!0});return zn("%s selected as muxer protocol",s),{stream:i,muxerFactory:t.get(s)}}catch(i){throw zn.error("error multiplexing outbound stream",i),ae(i,Ce.ERR_MUXER_UNAVAILABLE)}})()}_multiplexInbound(e,t){return $(function*(){const r=Array.from(t.keys());zn("inbound handling muxers %s",r);try{const{stream:i,protocol:s}=yield Hv(e,r,{writeBytes:!0});return{stream:i,muxerFactory:t.get(s)}}catch(i){throw zn.error("error multiplexing inbound stream",i),ae(i,Ce.ERR_MUXER_UNAVAILABLE)}})()}}var Na;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.protocolVersion&&(r.uint32(42),r.string(t.protocolVersion)),null!=t.agentVersion&&(r.uint32(50),r.string(t.agentVersion)),null!=t.publicKey&&(r.uint32(10),r.bytes(t.publicKey)),null==t.listenAddrs)throw new Error('Protocol error: required field "listenAddrs" was not found in object');for(const s of t.listenAddrs)r.uint32(18),r.bytes(s);if(null!=t.observedAddr&&(r.uint32(34),r.bytes(t.observedAddr)),null==t.protocols)throw new Error('Protocol error: required field "protocols" was not found in object');for(const s of t.protocols)r.uint32(26),r.string(s);null!=t.signedPeerRecord&&(r.uint32(66),r.bytes(t.signedPeerRecord)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 5:i.protocolVersion=t.string();break;case 6:i.agentVersion=t.string();break;case 1:i.publicKey=t.bytes();break;case 2:i.listenAddrs=i.listenAddrs??[],i.listenAddrs.push(t.bytes());break;case 4:i.observedAddr=t.bytes();break;case 3:i.protocols=i.protocols??[],i.protocols.push(t.string());break;case 8:i.signedPeerRecord=t.bytes();break;default:t.skipType(7&o)}}if(i.listenAddrs=i.listenAddrs??[],i.protocols=i.protocols??[],null==i.listenAddrs)throw new Error('Protocol error: value for required field "listenAddrs" was not found in protobuf');if(null==i.protocols)throw new Error('Protocol error: value for required field "protocols" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Na||(Na={}));var Th;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.publicKey)throw new Error('Protocol error: required field "publicKey" was not found in object');if(r.uint32(10),r.bytes(t.publicKey),null==t.payloadType)throw new Error('Protocol error: required field "payloadType" was not found in object');if(r.uint32(18),r.bytes(t.payloadType),null==t.payload)throw new Error('Protocol error: required field "payload" was not found in object');if(r.uint32(26),r.bytes(t.payload),null==t.signature)throw new Error('Protocol error: required field "signature" was not found in object');r.uint32(42),r.bytes(t.signature),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.publicKey=t.bytes();break;case 2:i.payloadType=t.bytes();break;case 3:i.payload=t.bytes();break;case 5:i.signature=t.bytes();break;default:t.skipType(7&o)}}if(null==i.publicKey)throw new Error('Protocol error: value for required field "publicKey" was not found in protobuf');if(null==i.payloadType)throw new Error('Protocol error: value for required field "payloadType" was not found in protobuf');if(null==i.payload)throw new Error('Protocol error: value for required field "payload" was not found in protobuf');if(null==i.signature)throw new Error('Protocol error: value for required field "signature" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Th||(Th={}));class wi{constructor(e){const{peerId:t,payloadType:r,payload:i,signature:s}=e;this.peerId=t,this.payloadType=r,this.payload=i,this.signature=s}marshal(){if(null==this.peerId.publicKey)throw new Error("Missing public key");return null==this.marshaled&&(this.marshaled=Th.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return kr(this.marshal(),e.marshal())}validate(e){var t=this;return $(function*(){const r=j2(e,t.payloadType,t.payload);if(null==t.peerId.publicKey)throw new Error("Missing public key");return yield Rl(t.peerId.publicKey).verify(r.subarray(),t.signature)})()}}wi.createFromProtobuf=function(){var n=$(function*(e){const t=Th.decode(e),r=yield kl(t.publicKey);return new wi({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})});return function(e){return n.apply(this,arguments)}}(),wi.seal=function(){var n=$(function*(e,t){if(null==t.privateKey)throw new Error("Missing private key");const r=e.domain,i=e.codec,s=e.marshal(),o=j2(r,i,s),u=yield(yield Pl(t.privateKey)).sign(o.subarray());return new wi({peerId:t,payloadType:i,payload:s,signature:u})});return function(e,t){return n.apply(this,arguments)}}(),wi.openAndCertify=function(){var n=$(function*(e,t){const r=yield wi.createFromProtobuf(e);if(!(yield r.validate(t)))throw ae(new Error("envelope signature is not valid for the given domain"),"ERR_SIGNATURE_NOT_VALID");return r});return function(e,t){return n.apply(this,arguments)}}();const j2=(n,e,t)=>{const r=Ot(n),i=Ni.encode(r.byteLength),s=Ni.encode(e.length),o=Ni.encode(t.length);return new qr(i,r,s,e,o,t)};var Ah;!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Yt((s,o,a={})=>{if(!1!==a.lengthDelimited&&o.fork(),null==s.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');o.uint32(10),o.bytes(s.multiaddr),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={multiaddr:new Uint8Array(0)},u=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.multiaddr=s.bytes():s.skipType(7&_)}if(null==a.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return a})),i),r.encode=s=>qt(s,r.codec()),r.decode=s=>Wt(s,r.codec())}(e=n.AddressInfo||(n.AddressInfo={})),n.codec=()=>(null==t&&(t=Yt((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null==r.peerId)throw new Error('Protocol error: required field "peerId" was not found in object');if(i.uint32(10),i.bytes(r.peerId),null==r.seq)throw new Error('Protocol error: required field "seq" was not found in object');if(i.uint32(16),i.uint64(r.seq),null==r.addresses)throw new Error('Protocol error: required field "addresses" was not found in object');for(const o of r.addresses)i.uint32(26),n.AddressInfo.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={peerId:new Uint8Array(0),seq:0n,addresses:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.peerId=r.bytes();break;case 2:s.seq=r.uint64();break;case 3:s.addresses.push(n.AddressInfo.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}if(null==s.peerId)throw new Error('Protocol error: value for required field "peerId" was not found in protobuf');if(null==s.seq)throw new Error('Protocol error: value for required field "seq" was not found in protobuf');return s})),t),n.encode=r=>qt(r,n.codec()),n.decode=r=>Wt(r,n.codec())}(Ah||(Ah={}));const t9=Uint8Array.from([3,1]);let ou=(()=>{class n{constructor(t){this.domain=n.DOMAIN,this.codec=n.CODEC;const{peerId:r,multiaddrs:i,seqNumber:s}=t;this.peerId=r,this.multiaddrs=i??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=Ah.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!!(t instanceof n&&this.peerId.equals(t.peerId)&&this.seqNumber===t.seqNumber&&function J7(n,e){const t=(r,i)=>r.toString().localeCompare(i.toString());return n.length===e.length&&e.sort(t)&&n.sort(t).every((r,i)=>e[i].equals(r))}(this.multiaddrs,t.multiaddrs))}}return n.createFromProtobuf=e=>{const t=Ah.decode(e),r=tu(t.peerId),i=(t.addresses??[]).map(o=>new mn(o.multiaddr));return new n({peerId:r,multiaddrs:i,seqNumber:t.seq})},n.DOMAIN="libp2p-peer-record",n.CODEC=t9,n})();const G2="js-libp2p/0.0.0",Hn=zt("libp2p:identify");class jv{constructor(e,t){this.components=e,this.started=!1,this.init=t,this.identifyProtocolStr=`/${t.protocolPrefix}/id/1.0.0`,this.identifyPushProtocolStr=`/${t.protocolPrefix}/id/push/1.0.0`,this.host={protocolVersion:`${t.protocolPrefix}/0.1.0`,...t.host},this.components.getConnectionManager().addEventListener("peer:connect",r=>{this.identify(r.detail).catch(Hn.error)}),this.components.getPeerStore().addEventListener("change:multiaddrs",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Hn.error(s))}),this.components.getPeerStore().addEventListener("change:protocols",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Hn.error(s))})}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started||(yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"AgentVersion",Ot(e.host.agentVersion)),yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"ProtocolVersion",Ot(e.host.protocolVersion)),yield e.components.getRegistrar().handle(e.identifyProtocolStr,t=>{e._handleIdentify(t).catch(r=>{Hn.error(r)})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),yield e.components.getRegistrar().handle(e.identifyPushProtocolStr,t=>{e._handlePush(t).catch(r=>{Hn.error(r)})},{maxInboundStreams:e.init.maxPushIncomingStreams,maxOutboundStreams:e.init.maxPushOutgoingStreams}),e.started=!0)})()}stop(){var e=this;return $(function*(){yield e.components.getRegistrar().unhandle(e.identifyProtocolStr),yield e.components.getRegistrar().unhandle(e.identifyPushProtocolStr),e.started=!1})()}push(e){var t=this;return $(function*(){const r=yield t.components.getPeerStore().addressBook.getRawEnvelope(t.components.getPeerId()),i=t.components.getAddressManager().getAddresses().map(a=>a.bytes),s=yield t.components.getPeerStore().protoBook.get(t.components.getPeerId()),o=e.map(function(){var a=$(function*(u){let _;const R=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,R.signal)}catch{}try{_=yield u.newStream([t.identifyPushProtocolStr],{signal:R.signal});const N=Go(_,R.signal);yield qn([Na.encode({listenAddrs:i,signedPeerRecord:r,protocols:s})],ks(),N,Qo)}catch(N){Hn.error("could not push identify update to peer",N)}finally{_?.close(),R.clear()}});return function(u){return a.apply(this,arguments)}}());yield Promise.all(o)})()}pushToPeerStore(){var e=this;return $(function*(){if(!e.isStarted())return;const t=[];for(const r of e.components.getConnectionManager().getConnections()){const i=r.remotePeer;!(yield e.components.getPeerStore().get(i)).protocols.includes(e.identifyPushProtocolStr)||t.push(r)}yield e.push(t)})()}_identify(e,t={}){var r=this;return $(function*(){let i,o,s=t.signal;if(null==s){i=new bi.TimeoutController(r.init.timeout),s=i.signal;try{(0,Vr.setMaxListeners)?.(1/0,i.signal)}catch{}}try{o=yield e.newStream([r.identifyProtocolStr],{signal:s});const a=Go(o,s),u=yield qn([],a,ps({maxDataLength:r.init.maxIdentifyMessageSize??8192}),function(){var _=$(function*(R){return yield Aa(R)});return function(R){return _.apply(this,arguments)}}());if(null==u)throw ae(new Error("No data could be retrieved"),Ce.ERR_CONNECTION_ENDED);try{return Na.decode(u)}catch(_){throw ae(_,Ce.ERR_INVALID_MESSAGE)}}finally{i?.clear(),o?.close()}})()}identify(e,t={}){var r=this;return $(function*(){const i=yield r._identify(e,t),{publicKey:s,listenAddrs:o,protocols:a,observedAddr:u,signedPeerRecord:_,agentVersion:R,protocolVersion:N}=i;if(null==s)throw ae(new Error("public key was missing from identify message"),Ce.ERR_MISSING_PUBLIC_KEY);const B=yield kl(s);if(!e.remotePeer.equals(B))throw ae(new Error("identified peer does not match the expected peer"),Ce.ERR_INVALID_PEER);if(r.components.getPeerId().equals(B))throw ae(new Error("identified peer is our own peer id?"),Ce.ERR_INVALID_PEER);const z=jv.getCleanMultiaddr(u);if(null!=_){Hn("received signed peer record from %p",B);try{const X=yield wi.openAndCertify(_,ou.DOMAIN);if(!X.peerId.equals(B))throw ae(new Error("identified peer does not match the expected peer"),Ce.ERR_INVALID_PEER);if(yield r.components.getPeerStore().addressBook.consumePeerRecord(X))return yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",Ot(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",Ot(N))),void Hn("identify completed for peer %p and protocols %o",B,a)}catch(X){Hn("received invalid envelope, discard it and fallback to listenAddrs is available",X)}}else Hn("no signed peer record received from %p",B);Hn("falling back to legacy addresses from %p",B);try{yield r.components.getPeerStore().addressBook.set(B,o.map(X=>new mn(X)))}catch(X){Hn.error("received invalid addrs",X)}yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",Ot(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",Ot(N))),Hn("identify completed for peer %p and protocols %o",B,a),Hn("received observed address of %s",z?.toString())})()}_handleIdentify(e){var t=this;return $(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=t.components.getPeerId().publicKey??new Uint8Array(0),a=yield t.components.getPeerStore().get(t.components.getPeerId()),u=t.components.getAddressManager().getAddresses().map(B=>B.decapsulateCode(Sr("p2p").code));let _=a.peerRecordEnvelope;if(u.length>0&&null==_){const B=new ou({peerId:t.components.getPeerId(),multiaddrs:u}),z=yield wi.seal(B,t.components.getPeerId());yield t.components.getPeerStore().addressBook.consumePeerRecord(z),_=z.marshal().subarray()}const R=Na.encode({protocolVersion:t.host.protocolVersion,agentVersion:t.host.agentVersion,publicKey:o,listenAddrs:u.map(B=>B.bytes),signedPeerRecord:_,observedAddr:r.remoteAddr.bytes,protocols:a.protocols}),N=Go(i,s.signal);yield qn([R],ks(),N,Qo)}catch(o){Hn.error("could not respond to identify request",o)}finally{i.close(),s.clear()}})()}_handlePush(e){var t=this;return $(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}let o;try{const u=Go(i,s.signal),_=yield qn([],u,ps({maxDataLength:t.init.maxIdentifyMessageSize??8192}),function(){var R=$(function*(N){return yield Aa(N)});return function(N){return R.apply(this,arguments)}}());null!=_&&(o=Na.decode(_))}catch(u){return Hn.error("received invalid message",u)}finally{i.close(),s.clear()}if(null==o)return Hn.error("received invalid message");const a=r.remotePeer;if(t.components.getPeerId().equals(a))Hn("received push from ourselves?");else{if(Hn("received push from %p",a),null!=o.signedPeerRecord){Hn("received signedPeerRecord in push");try{const u=yield wi.openAndCertify(o.signedPeerRecord,ou.DOMAIN);if(yield t.components.getPeerStore().addressBook.consumePeerRecord(u))return Hn("consumed signedPeerRecord sent in push"),void(yield t.components.getPeerStore().protoBook.set(a,o.protocols));Hn("failed to consume signedPeerRecord sent in push")}catch(u){Hn("received invalid envelope, discard it and fallback to listenAddrs is available",u)}}else Hn("did not receive signedPeerRecord in push");try{yield t.components.getPeerStore().addressBook.set(a,o.listenAddrs.map(u=>new mn(u)))}catch(u){Hn.error("received invalid addrs",u)}try{yield t.components.getPeerStore().protoBook.set(a,o.protocols)}catch(u){Hn.error("received invalid protocols",u)}Hn("handled push from %p",a)}})()}static getCleanMultiaddr(e){if(null!=e&&e.length>0)try{return new mn(e)}catch{}}}var xh,Hs;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.identifier)throw new Error('Protocol error: required field "identifier" was not found in object');r.uint32(10),r.string(t.identifier),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.identifier=t.string():t.skipType(7&o)}if(null==i.identifier)throw new Error('Protocol error: value for required field "identifier" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(xh||(xh={})),function(n){let e;var i;let t,r;(i=e=n.StatusCode||(n.StatusCode={})).OK="OK",i.NOT_FOUND="NOT_FOUND",i.ERROR="ERROR",function(i){i[i.OK=0]="OK",i[i.NOT_FOUND=1]="NOT_FOUND",i[i.ERROR=2]="ERROR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.StatusCode||(n.StatusCode={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.status)throw new Error('Protocol error: required field "status" was not found in object');if(s.uint32(8),n.StatusCode.codec().encode(i.status,s),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(18),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.status=n.StatusCode.codec().decode(i);break;case 2:o.data=i.bytes();break;default:i.skipType(7&u)}}if(null==o.status)throw new Error('Protocol error: value for required field "status" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(Hs||(Hs={}));const q2=zt("libp2p:fetch");class d9{constructor(e,t){this.started=!1,this.components=e,this.protocol=`/${t.protocolPrefix??"libp2p"}/fetch/0.0.1`,this.lookupFunctions=new Map,this.handleMessage=this.handleMessage.bind(this),this.init=t}start(){var e=this;return $(function*(){yield e.components.getRegistrar().handle(e.protocol,t=>{e.handleMessage(t).catch(r=>{q2.error(r)}).finally(()=>{t.stream.close()})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return $(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}fetch(e,t,r={}){var i=this;return $(function*(){q2("dialing %s to %p",i.protocol,e);const s=yield i.components.getConnectionManager().openConnection(e,r);let o,u,a=r.signal;if(null==a){o=new bi.TimeoutController(i.init.timeout),a=o.signal;try{(0,Vr.setMaxListeners)?.(1/0,o.signal)}catch{}}try{u=yield s.newStream([i.protocol],{signal:a});const _=Go(u,a);return(yield qn([xh.encode({identifier:t})],ks(),_,ps(),function(){var N=$(function*(B){const z=yield Aa(B);if(null==z)throw ae(new Error("No data received"),Ce.ERR_INVALID_MESSAGE);const X=Hs.decode(z);switch(X.status){case Hs.StatusCode.OK:return X.data;case Hs.StatusCode.NOT_FOUND:return null;case Hs.StatusCode.ERROR:{const J=(new TextDecoder).decode(X.data);throw ae(new Error("Error in fetch protocol response: "+J),Ce.ERR_INVALID_PARAMETERS)}default:throw ae(new Error("Unknown response status"),Ce.ERR_INVALID_MESSAGE)}});return function(B){return N.apply(this,arguments)}}()))??null}finally{o?.clear(),u?.close()}})()}handleMessage(e){var t=this;return $(function*(){const{stream:r}=e,i=t;yield qn(r,ps(),function(){var s=hn(function*(o){const a=yield lt(Aa(o));if(null==a)throw ae(new Error("No data received"),Ce.ERR_INVALID_MESSAGE);const u=xh.decode(a);let _;const R=i._getLookupFunction(u.identifier);if(null!=R){const N=yield lt(R(u.identifier));_=null!=N?{status:Hs.StatusCode.OK,data:N}:{status:Hs.StatusCode.NOT_FOUND,data:new Uint8Array(0)}}else{const N=(new TextEncoder).encode("No lookup function registered for key: "+u.identifier);_={status:Hs.StatusCode.ERROR,data:N}}yield Hs.encode(_)});return function(o){return s.apply(this,arguments)}}(),ks(),r)})()}_getLookupFunction(e){for(const t of this.lookupFunctions.keys())if(e.startsWith(t))return this.lookupFunctions.get(t)}registerLookupFunction(e,t){if(this.lookupFunctions.has(e))throw ae(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),Ce.ERR_KEY_ALREADY_EXISTS);this.lookupFunctions.set(e,t)}unregisterLookupFunction(e,t){null!=t&&this.lookupFunctions.get(e)!==t||this.lookupFunctions.delete(e)}}const Y2=zt("libp2p:ping");class y9{constructor(e,t){this.components=e,this.started=!1,this.protocol=`/${t.protocolPrefix}/ping/1.0.0`,this.init=t}start(){var e=this;return $(function*(){yield e.components.getRegistrar().handle(e.protocol,e.handleMessage,{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return $(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}handleMessage(e){const{stream:t}=e;qn(t,t).catch(r=>{Y2.error(r)})}ping(e,t={}){var r=this;return $(function*(){Y2("dialing %s to %p",r.protocol,e);const i=Date.now(),s=ih(32),o=yield r.components.getConnectionManager().openConnection(e,t);let a,_,u=t.signal;if(null==u){a=new bi.TimeoutController(r.init.timeout),u=a.signal;try{(0,Vr.setMaxListeners)?.(1/0,a.signal)}catch{}}try{_=yield o.newStream([r.protocol],{signal:u});const R=Go(_,u),N=yield qn([s],R,function(){var z=$(function*(X){return yield Aa(X)});return function(X){return z.apply(this,arguments)}}()),B=Date.now();if(null==N||!kr(s,N.subarray()))throw ae(new Error("Received wrong ping ack"),Ce.ERR_WRONG_PING_ACK);return B-i}finally{a?.clear(),_?.close()}})()}}function zv(){return(zv=$(function*(){throw new Error("Not supported in browsers")})).apply(this,arguments)}function E9(n){const{address:e}=n.nodeAddress();return function v9(n){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(n)||/^::1$/.test(n)}(e)}const Wv=zt("libp2p:nat");function b9(n=1024,e=65535){return Math.floor(Math.random()*(e-n+1)+n)}class w9{constructor(e,t){if(this.components=e,this.started=!1,this.enabled=t.enabled,this.externalAddress=t.externalAddress,this.localAddress=t.localAddress,this.description=t.description??`libp2p@0.0.0 ${this.components.getPeerId().toString()}`,this.ttl=t.ttl??7200,this.keepAlive=t.keepAlive??!0,this.gateway=t.gateway,this.ttl<7200)throw ae(new Error("NatManager ttl should be at least 7200 seconds"),Ce.ERR_INVALID_PARAMETERS)}isStarted(){return this.started}start(){}afterStart(){Eh||!this.enabled||this.started||(this.started=!0,this._start().catch(e=>{Wv.error(e)}))}_start(){var e=this;return $(function*(){const t=e.components.getTransportManager().getAddrs();for(const r of t){const{family:i,host:s,port:o,transport:a}=r.toOptions();if(!r.isThinWaistAddress()||"tcp"!==a||E9(r)||4!==i)continue;const u=yield e._getClient(),_=e.externalAddress??(yield u.externalIp());if(g2(_))throw new Error(`${_} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);const R=b9();Wv(`opening uPnP connection from ${_}:${R} to ${s}:${o}`),yield u.map({publicPort:R,localPort:o,localAddress:e.localAddress,protocol:"TCP"===a.toUpperCase()?"TCP":"UDP"}),e.components.getAddressManager().addObservedAddr(mn.fromNodeAddress({family:4,address:_,port:R},a))}})()}_getClient(){var e=this;return $(function*(){return null!=e.client||(e.client=yield function m9(){return zv.apply(this,arguments)}({description:e.description,ttl:e.ttl,keepAlive:e.keepAlive,gateway:e.gateway})),e.client})()}stop(){var e=this;return $(function*(){if(!Eh&&null!=e.client)try{yield e.client.close(),e.client=void 0}catch(t){Wv.error(t)}})()}}const _9=zt("libp2p:peer-record-updater");class D9{constructor(e){this.components=e,this.started=!1,this.update=this.update.bind(this)}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started=!0,e.components.getTransportManager().addEventListener("listener:listening",e.update),e.components.getTransportManager().addEventListener("listener:close",e.update),e.components.getAddressManager().addEventListener("change:addresses",e.update)})()}stop(){var e=this;return $(function*(){e.started=!1,e.components.getTransportManager().removeEventListener("listener:listening",e.update),e.components.getTransportManager().removeEventListener("listener:close",e.update),e.components.getAddressManager().removeEventListener("change:addresses",e.update)})()}update(){var e=this;Promise.resolve().then($(function*(){const t=new ou({peerId:e.components.getPeerId(),multiaddrs:e.components.getAddressManager().getAddresses().map(i=>i.decapsulateCode(Sr("p2p").code))}),r=yield wi.seal(t,e.components.getPeerId());yield e.components.getPeerStore().addressBook.consumePeerRecord(r)})).catch(t=>{_9.error("Could not update self peer record: %o",t)})}}class S9{constructor(e){this.dht=e}findPeer(e,t={}){var r=this;return $(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.findPeer(e,t));i=!(u=yield a.next()).done;i=!1){const _=u.value;if("FINAL_PEER"===_.name)return _.peer}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw ae(new Error(Dn.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getClosestPeers(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.getClosestPeers(e,t));i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;"PEER_RESPONSE"===_.name&&(yield*Mr(Pt(_.closer),lt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}}const Bn=zt("libp2p:peer-store:address-book"),Rh="change:multiaddrs";function C9(){return Yv.apply(this,arguments)}function Yv(){return(Yv=$(function*(){return!0})).apply(this,arguments)}class I9{constructor(e,t,r){this.dispatchEvent=e,this.store=t,this.addressFilter=r??C9}consumePeerRecord(e){var t=this;return $(function*(){Bn.trace("consumePeerRecord await write lock");const r=yield t.store.lock.writeLock();let i,s,o;Bn.trace("consumePeerRecord got write lock");try{let a;try{a=ou.createFromProtobuf(e.payload)}catch{return Bn.error("invalid peer record received"),!1}i=a.peerId;const u=a.multiaddrs;if(!i.equals(e.peerId))return Bn("signing key does not match PeerId in the PeerRecord"),!1;if(null==u||0===u.length)return!1;if((yield t.store.has(i))&&(s=yield t.store.load(i),null!=s.peerRecordEnvelope)){const R=yield wi.createFromProtobuf(s.peerRecordEnvelope),N=ou.createFromProtobuf(R.payload);if(N.seqNumber>=a.seqNumber)return Bn("sequence number was lower or equal to existing sequence number - stored: %d received: %d",N.seqNumber,a.seqNumber),!1}const _=yield Qv(i,u,t.addressFilter,!0);o=yield t.store.patchOrCreate(i,{addresses:_,peerRecordEnvelope:e.marshal().subarray()}),Bn("stored provided peer record for %p",a.peerId)}finally{Bn.trace("consumePeerRecord release write lock"),r()}return t.dispatchEvent(new nn(Rh,{detail:{peerId:i,multiaddrs:o.addresses.map(({multiaddr:a})=>a),oldMultiaddrs:null==s?[]:s.addresses.map(({multiaddr:a})=>a)}})),!0})()}getRawEnvelope(e){var t=this;return $(function*(){Bn.trace("getRawEnvelope await read lock");const r=yield t.store.lock.readLock();Bn.trace("getRawEnvelope got read lock");try{return(yield t.store.load(e)).peerRecordEnvelope}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Bn.trace("getRawEnvelope release read lock"),r()}})()}getPeerRecord(e){var t=this;return $(function*(){const r=yield t.getRawEnvelope(e);if(null!=r)return yield wi.createFromProtobuf(r)})()}get(e){var t=this;return $(function*(){e=Br(e),Bn.trace("get wait for read lock");const r=yield t.store.lock.readLock();Bn.trace("get got read lock");try{return(yield t.store.load(e)).addresses}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Bn.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Bn.error("multiaddrs must be an array of Multiaddrs"),ae(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Bn.trace("set await write lock");const i=yield r.store.lock.writeLock();Bn.trace("set got write lock");let o,a,s=!1;try{const u=yield Qv(e,t,r.addressFilter);if(0===u.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...u.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length&&u.length===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.patchOrCreate(e,{addresses:u}),Bn("set multiaddrs for %p",e)}finally{Bn.trace("set multiaddrs for %p",e),Bn("set release write lock"),i()}r.dispatchEvent(new nn(Rh,{detail:{peerId:e,multiaddrs:a.addresses.map(u=>u.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:u})=>u)}})),s||r.dispatchEvent(new nn("peer",{detail:{id:e,multiaddrs:a.addresses.map(u=>u.multiaddr),protocols:a.protocols}}))})()}add(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Bn.error("multiaddrs must be an array of Multiaddrs"),ae(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Bn.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o,a;Bn.trace("add got write lock");try{const u=yield Qv(e,t,r.addressFilter);if(0===u.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...u.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.mergeOrCreate(e,{addresses:u}),Bn("added multiaddrs for %p",e)}finally{Bn.trace("set release write lock"),i()}r.dispatchEvent(new nn(Rh,{detail:{peerId:e,multiaddrs:a.addresses.map(u=>u.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:u})=>u)}})),!0===s&&r.dispatchEvent(new nn("peer",{detail:{id:e,multiaddrs:a.addresses.map(u=>u.multiaddr),protocols:a.protocols}}))})()}delete(e){var t=this;return $(function*(){e=Br(e),Bn.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Bn.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{addresses:[]})}finally{Bn.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new nn(Rh,{detail:{peerId:e,multiaddrs:[],oldMultiaddrs:null==i?[]:i.addresses.map(({multiaddr:s})=>s)}}))})()}}function Qv(n,e,t){return Zv.apply(this,arguments)}function Zv(){return Zv=$(function*(n,e,t,r=!1){return yield qn(e,i=>Pv(i,s=>{if(!mn.isMultiaddr(s))throw Bn.error("multiaddr must be an instance of Multiaddr"),ae(new Error("multiaddr must be an instance of Multiaddr"),"ERR_INVALID_PARAMETERS")}),i=>Ds(i,function(){var s=$(function*(o){return yield t(n,o)});return function(o){return s.apply(this,arguments)}}()),i=>fv(i,s=>({multiaddr:new mn(s.toString()),isCertified:r})),function(){var i=$(function*(s){return yield Ul(s)});return function(s){return i.apply(this,arguments)}}())}),Zv.apply(this,arguments)}const Ks=zt("libp2p:peer-store:key-book"),Q2="change:pubkey";class T9{constructor(e,t){this.dispatchEvent=e,this.store=t}set(e,t){var r=this;return $(function*(){if(e=Br(e),!(t instanceof Uint8Array))throw Ks.error("publicKey must be an instance of Uint8Array to store data"),ae(new Error("publicKey must be an instance of PublicKey"),"ERR_INVALID_PARAMETERS");Ks.trace("set await write lock");const i=yield r.store.lock.writeLock();Ks.trace("set got write lock");let o,s=!1;try{try{if(o=yield r.store.load(e),null!=o.pubKey&&kr(o.pubKey,t))return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}yield r.store.patchOrCreate(e,{pubKey:t}),s=!0}finally{Ks.trace("set release write lock"),i()}s&&r.dispatchEvent(new nn(Q2,{detail:{peerId:e,publicKey:t,oldPublicKey:o?.pubKey}}))})()}get(e){var t=this;return $(function*(){e=Br(e),Ks.trace("get await write lock");const r=yield t.store.lock.readLock();Ks.trace("get got write lock");try{return(yield t.store.load(e)).pubKey}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Ks("get release write lock"),r()}})()}delete(e){var t=this;return $(function*(){e=Br(e),Ks.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Ks.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{pubKey:void 0})}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}finally{Ks.trace("delete release write lock"),r()}t.dispatchEvent(new nn(Q2,{detail:{peerId:e,publicKey:void 0,oldPublicKey:i?.pubKey}}))})()}}const Cr=zt("libp2p:peer-store:metadata-book"),Ph="change:metadata";class A9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return $(function*(){e=Br(e),Cr.trace("get await read lock");const r=yield t.store.lock.readLock();Cr.trace("get got read lock");try{return(yield t.store.load(e)).metadata}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Cr.trace("get release read lock"),r()}return new Map})()}getValue(e,t){var r=this;return $(function*(){e=Br(e),Cr.trace("getValue await read lock");const i=yield r.store.lock.readLock();Cr.trace("getValue got read lock");try{return(yield r.store.load(e)).metadata.get(t)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}finally{Cr.trace("getValue release write lock"),i()}})()}set(e,t){var r=this;return $(function*(){if(e=Br(e),!(t instanceof Map))throw Cr.error("valid metadata must be provided to store data"),ae(new Error("valid metadata must be provided"),"ERR_INVALID_PARAMETERS");Cr.trace("set await write lock");const i=yield r.store.lock.writeLock();let s;Cr.trace("set got write lock");try{try{s=yield r.store.load(e)}catch(o){if("ERR_NOT_FOUND"!==o.code)throw o}yield r.store.mergeOrCreate(e,{metadata:t})}finally{Cr.trace("set release write lock"),i()}r.dispatchEvent(new nn(Ph,{detail:{peerId:e,metadata:t,oldMetadata:null==s?new Map:s.metadata}}))})()}setValue(e,t,r){var i=this;return $(function*(){if(e=Br(e),"string"!=typeof t||!(r instanceof Uint8Array))throw Cr.error("valid key and value must be provided to store data"),ae(new Error("valid key and value must be provided"),"ERR_INVALID_PARAMETERS");Cr.trace("setValue await write lock");const s=yield i.store.lock.writeLock();let o,a;Cr.trace("setValue got write lock");try{try{o=yield i.store.load(e);const u=o.metadata.get(t);if(null!=u&&kr(r,u))return}catch(u){if("ERR_NOT_FOUND"!==u.code)throw u}a=yield i.store.mergeOrCreate(e,{metadata:new Map([[t,r]])})}finally{Cr.trace("setValue release write lock"),s()}i.dispatchEvent(new nn(Ph,{detail:{peerId:e,metadata:a.metadata,oldMetadata:null==o?new Map:o.metadata}}))})()}delete(e){var t=this;return $(function*(){e=Br(e),Cr.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Cr.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}null!=i&&(yield t.store.patch(e,{metadata:new Map}))}finally{Cr.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new nn(Ph,{detail:{peerId:e,metadata:new Map,oldMetadata:i.metadata}}))})()}deleteValue(e,t){var r=this;return $(function*(){e=Br(e),Cr.trace("deleteValue await write lock");const i=yield r.store.lock.writeLock();let s,o;Cr.trace("deleteValue got write lock");try{o=yield r.store.load(e),s=o.metadata,s.delete(t),yield r.store.patch(e,{metadata:s})}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}finally{Cr.trace("deleteValue release write lock"),i()}null!=s&&r.dispatchEvent(new nn(Ph,{detail:{peerId:e,metadata:s,oldMetadata:null==o?new Map:o.metadata}}))})()}}const Ir=zt("libp2p:peer-store:proto-book"),Nh="change:protocols";class x9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return $(function*(){Ir.trace("get wait for read lock");const r=yield t.store.lock.readLock();Ir.trace("get got read lock");try{return(yield t.store.load(e)).protocols}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Ir.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("set await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("set got write lock");try{try{if(s=yield r.store.load(e),new Set([...t]).size===s.protocols.length)return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.patchOrCreate(e,{protocols:t}),Ir("stored provided protocols for %p",e)}finally{Ir.trace("set release write lock"),i()}r.dispatchEvent(new nn(Nh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}add(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("add got write lock");try{try{if(s=yield r.store.load(e),new Set([...s.protocols,...t]).size===s.protocols.length)return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.mergeOrCreate(e,{protocols:t}),Ir("added provided protocols for %p",e)}finally{Ir.trace("add release write lock"),i()}r.dispatchEvent(new nn(Nh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}remove(e,t){var r=this;return $(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("remove await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("remove got write lock");try{try{s=yield r.store.load(e);const a=new Set(s.protocols);for(const u of t)a.delete(u);if(s.protocols.length===a.size)return;t=Array.from(a)}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.patchOrCreate(e,{protocols:t})}finally{Ir.trace("remove release write lock"),i()}r.dispatchEvent(new nn(Nh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}delete(e){var t=this;return $(function*(){e=Br(e),Ir.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Ir.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{protocols:[]})}finally{Ir.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new nn(Nh,{detail:{peerId:e,protocols:[],oldProtocols:i.protocols}}))})()}}var Mh,Oh,kh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.addresses)throw new Error('Protocol error: required field "addresses" was not found in object');for(const s of t.addresses)r.uint32(10),Oh.codec().encode(s,r);if(null==t.protocols)throw new Error('Protocol error: required field "protocols" was not found in object');for(const s of t.protocols)r.uint32(18),r.string(s);if(null==t.metadata)throw new Error('Protocol error: required field "metadata" was not found in object');for(const s of t.metadata)r.uint32(26),kh.codec().encode(s,r);null!=t.pubKey&&(r.uint32(34),r.bytes(t.pubKey)),null!=t.peerRecordEnvelope&&(r.uint32(42),r.bytes(t.peerRecordEnvelope)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={addresses:[],protocols:[],metadata:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.addresses.push(Oh.codec().decode(t,t.uint32()));break;case 2:i.protocols.push(t.string());break;case 3:i.metadata.push(kh.codec().decode(t,t.uint32()));break;case 4:i.pubKey=t.bytes();break;case 5:i.peerRecordEnvelope=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Mh||(Mh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');r.uint32(10),r.bytes(t.multiaddr),null!=t.isCertified&&(r.uint32(16),r.bool(t.isCertified)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={multiaddr:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.multiaddr=t.bytes();break;case 2:i.isCertified=t.bool();break;default:t.skipType(7&o)}}if(null==i.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Oh||(Oh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.key)throw new Error('Protocol error: required field "key" was not found in object');if(r.uint32(10),r.string(t.key),null==t.value)throw new Error('Protocol error: required field "value" was not found in object');r.uint32(18),r.bytes(t.value),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={key:"",value:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.key=t.string();break;case 2:i.value=t.bytes();break;default:t.skipType(7&o)}}if(null==i.key)throw new Error('Protocol error: value for required field "key" was not found in protobuf');if(null==i.value)throw new Error('Protocol error: value for required field "value" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(kh||(kh={}));var R9=x(2005);class Z2 extends Error{constructor(e){super(e),this.name="TimeoutError"}}class P9 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const X2=n=>void 0===globalThis.DOMException?new P9(n):new DOMException(n),J2=n=>{const e=void 0===n.reason?X2("This operation was aborted."):n.reason;return e instanceof Error?e:X2(e)};function eA(n,e,t,r){let i;const s=new Promise((o,a)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:u}=r;u.aborted&&a(J2(u)),u.addEventListener("abort",()=>{a(J2(u))})}i=r.customTimers.setTimeout.call(void 0,()=>{if("function"==typeof t){try{o(t())}catch(R){a(R)}return}const _=t instanceof Error?t:new Z2("string"==typeof t?t:`Promise timed out after ${e} milliseconds`);"function"==typeof n.cancel&&n.cancel(),a(_)},e),$(function*(){try{o(yield n)}catch(u){a(u)}finally{r.customTimers.clearTimeout.call(void 0,i)}})()}else o(n)});return s.clear=()=>{clearTimeout(i),i=void 0},s}var vo,Ma=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};class M9{constructor(){vo.set(this,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&Ma(this,vo,"f")[this.size-1].priority>=t.priority)return void Ma(this,vo,"f").push(r);const i=function N9(n,e,t){let r=0,i=n.length;for(;i>0;){const s=Math.trunc(i/2);let o=r+s;t(n[o],e)<=0?(r=++o,i-=s+1):i=s}return r}(Ma(this,vo,"f"),r,(s,o)=>o.priority-s.priority);Ma(this,vo,"f").splice(i,0,r)}dequeue(){return Ma(this,vo,"f").shift()?.run}filter(e){return Ma(this,vo,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Ma(this,vo,"f").length}}vo=new WeakMap;var hr,Ql,Zl,ea,Lh,Xl,Bh,Ss,Jl,Oi,Fh,ki,ef,ta,Uh,tA,nA,rA,iA,sA,oA,Vh,Xv,Jv,Hh,Kh,ir=function(n,e,t,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?n!==e||!i:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(n,t):i?i.value=t:e.set(n,t),t},gt=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};const O9=new Z2;class k9 extends Error{}class aA extends R9{constructor(e){var t,r,i,s;if(super(),hr.add(this),Ql.set(this,void 0),Zl.set(this,void 0),ea.set(this,0),Lh.set(this,void 0),Xl.set(this,void 0),Bh.set(this,0),Ss.set(this,void 0),Jl.set(this,void 0),Oi.set(this,void 0),Fh.set(this,void 0),ki.set(this,0),ef.set(this,void 0),ta.set(this,void 0),Uh.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:M9,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(s=null===(i=e.interval)||void 0===i?void 0:i.toString())&&void 0!==s?s:""}\` (${typeof e.interval})`);ir(this,Ql,e.carryoverConcurrencyCount,"f"),ir(this,Zl,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,"f"),ir(this,Lh,e.intervalCap,"f"),ir(this,Xl,e.interval,"f"),ir(this,Oi,new e.queueClass,"f"),ir(this,Fh,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,ir(this,Uh,!0===e.throwOnTimeout,"f"),ir(this,ta,!1===e.autoStart,"f")}get concurrency(){return gt(this,ef,"f")}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);ir(this,ef,e,"f"),gt(this,hr,"m",Hh).call(this)}add(e,t={}){var r=this;return $(function*(){return new Promise((i,s)=>{const o=function(){var a=$(function*(){var u,_,R;ir(r,ki,(_=gt(r,ki,"f"),++_),"f"),ir(r,ea,(R=gt(r,ea,"f"),++R),"f");try{if(null!==(u=t.signal)&&void 0!==u&&u.aborted)return void s(new k9("The task was aborted."));const B=yield void 0===r.timeout&&void 0===t.timeout?e({signal:t.signal}):eA(Promise.resolve(e({signal:t.signal})),void 0===t.timeout?r.timeout:t.timeout,()=>{(void 0===t.throwOnTimeout?gt(r,Uh,"f"):t.throwOnTimeout)&&s(O9)});i(B),r.emit("completed",B)}catch(N){s(N),r.emit("error",N)}gt(r,hr,"m",rA).call(r)});return function(){return a.apply(this,arguments)}}();gt(r,Oi,"f").enqueue(o,t),gt(r,hr,"m",Vh).call(r),r.emit("add")})})()}addAll(e,t){var r=this;return $(function*(){return Promise.all(e.map(function(){var i=$(function*(s){return r.add(s,t)});return function(s){return i.apply(this,arguments)}}()))})()}start(){return gt(this,ta,"f")?(ir(this,ta,!1,"f"),gt(this,hr,"m",Hh).call(this),this):this}pause(){ir(this,ta,!0,"f")}clear(){ir(this,Oi,new(gt(this,Fh,"f")),"f")}onEmpty(){var e=this;return $(function*(){0!==gt(e,Oi,"f").size&&(yield gt(e,hr,"m",Kh).call(e,"empty"))})()}onSizeLessThan(e){var t=this;return $(function*(){gt(t,Oi,"f").sizegt(t,Oi,"f").size{gt(this,hr,"m",sA).call(this)},t),"f"),!0;ir(this,ea,gt(this,Ql,"f")?gt(this,ki,"f"):0,"f")}return!1},Vh=function(){if(0===gt(this,Oi,"f").size)return gt(this,Ss,"f")&&clearInterval(gt(this,Ss,"f")),ir(this,Ss,void 0,"f"),gt(this,hr,"m",iA).call(this),!1;if(!gt(this,ta,"f")){const e=!gt(this,hr,"a",oA);if(gt(this,hr,"a",tA)&>(this,hr,"a",nA)){const t=gt(this,Oi,"f").dequeue();return!!t&&(this.emit("active"),t(),e&>(this,hr,"m",Xv).call(this),!0)}}return!1},Xv=function(){gt(this,Zl,"f")||void 0!==gt(this,Ss,"f")||(ir(this,Ss,setInterval(()=>{gt(this,hr,"m",Jv).call(this)},gt(this,Xl,"f")),"f"),ir(this,Bh,Date.now()+gt(this,Xl,"f"),"f"))},Jv=function(){0===gt(this,ea,"f")&&0===gt(this,ki,"f")&>(this,Ss,"f")&&(clearInterval(gt(this,Ss,"f")),ir(this,Ss,void 0,"f")),ir(this,ea,gt(this,Ql,"f")?gt(this,ki,"f"):0,"f"),gt(this,hr,"m",Hh).call(this)},Hh=function(){for(;gt(this,hr,"m",Vh).call(this););},Kh=function(){var n=$(function*(t,r){return new Promise(i=>{const s=()=>{r&&!r()||(this.off(t,s),i())};this.on(t,s)})});return function e(t,r){return n.apply(this,arguments)}}();class L9 extends Error{constructor(e){super(e),this.name="TimeoutError"}}class B9 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const cA=n=>void 0===globalThis.DOMException?new B9(n):new DOMException(n),uA=n=>{const e=void 0===n.reason?cA("This operation was aborted."):n.reason;return e instanceof Error?e:cA(e)};function F9(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((u,_)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if(e.signal){const{signal:R}=e;R.aborted&&_(uA(R)),R.addEventListener("abort",()=>{_(uA(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{u(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new L9("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),$(function*(){try{u(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else u(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}const lA="lock:worker:request-read",fA="lock:worker:release-read",dA="lock:master:grant-read",hA="lock:worker:request-write",pA="lock:worker:release-write",gA="lock:master:grant-write",na={},au=n=>{n.addEventListener("message",e=>{au.dispatchEvent("message",n,e)}),null!=n.port&&n.port.addEventListener("message",e=>{au.dispatchEvent("message",n,e)})};au.addEventListener=(n,e)=>{null==na[n]&&(na[n]=[]),na[n].push(e)},au.removeEventListener=(n,e)=>{null!=na[n]&&(na[n]=na[n].filter(t=>t===e))},au.dispatchEvent=function(n,e,t){null!=na[n]&&na[n].forEach(r=>r(e,t))};const yA=au,mA=(n,e,t,r,i)=>(s,o)=>{if(o.data.type!==t)return;const a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};var u;n.dispatchEvent(new MessageEvent(e,{data:{name:a.name,handler:(u=$(function*(){return s.postMessage({type:i,name:a.name,identifier:a.identifier}),yield new Promise(_=>{const R=N=>{null!=N&&null!=N.data&&N.data.type===r&&N.data.identifier===a.identifier&&(s.removeEventListener("message",R),_())};s.addEventListener("message",R)})}),function(){return u.apply(this,arguments)})}}))},vA=(n,e,t,r)=>$(function*(){const i=((n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""))();return globalThis.postMessage({type:e,identifier:i,name:n}),yield new Promise(s=>{const o=a=>{null!=a&&null!=a.data&&a.data.type===t&&a.data.identifier===i&&(globalThis.removeEventListener("message",o),s(()=>{globalThis.postMessage({type:r,identifier:i,name:n})}))};globalThis.addEventListener("message",o)})}),K9={singleProcess:!1},Oa={};let ra;function eE(n,e){return tE.apply(this,arguments)}function tE(){return tE=$(function*(n,e){let t;const r=new Promise(i=>{t=i});return n.add($(function*(){return yield F9($(function*(){return yield new Promise(i=>{t(()=>{i()})})})(),{milliseconds:e.timeout})})),yield r}),tE.apply(this,arguments)}const z9={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};const EA=zt("libp2p:peer-store:store"),bA="/peers/";class W9{constructor(){this.components=new ho,this.lock=function G9(n){const e=Object.assign({},z9,n);return null==ra&&(ra=(n=>{if(n=Object.assign({},K9,n),Boolean(globalThis.document)||n.singleProcess){const t=new EventTarget;return yA.addEventListener("message",mA(t,"requestReadLock",lA,fA,dA)),yA.addEventListener("message",mA(t,"requestWriteLock",hA,pA,gA)),t}return{isWorker:!0,readLock:t=>vA(t,lA,dA,fA),writeLock:t=>vA(t,hA,gA,pA)}})(e),!0!==ra.isWorker&&(ra.addEventListener("requestReadLock",t=>{null!=Oa[t.data.name]&&Oa[t.data.name].readLock().then(function(){var r=$(function*(i){return yield t.data.handler().finally(()=>i())});return function(i){return r.apply(this,arguments)}}())}),ra.addEventListener("requestWriteLock",function(){var t=$(function*(r){null!=Oa[r.data.name]&&Oa[r.data.name].writeLock().then(function(){var i=$(function*(s){return yield r.data.handler().finally(()=>s())});return function(s){return i.apply(this,arguments)}}())});return function(r){return t.apply(this,arguments)}}()))),null==Oa[e.name]&&(Oa[e.name]=((n,e)=>{if(!0===ra.isWorker)return{readLock:ra.readLock(n,e),writeLock:ra.writeLock(n,e)};const t=new aA({concurrency:1});let r;return{readLock:()=>$(function*(){if(null!=r)return yield eE(r,e);r=new aA({concurrency:e.concurrency,autoStart:!1});const i=r,s=eE(r,e);return t.add($(function*(){return i.start(),yield i.onIdle().then(()=>{r===i&&(r=null)})})),yield s})(),writeLock:()=>$(function*(){return r=null,yield eE(t,e)})()}})(e.name,e)),Oa[e.name]}({name:"peer-store",singleProcess:!0})}init(e){this.components=e}_peerIdToDatastoreKey(e){if(null==e.type)throw EA.error("peerId must be an instance of peer-id to store data"),ae(new Error("peerId must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");const t=e.toCID().toString();return new Ur(`${bA}${t}`)}has(e){var t=this;return $(function*(){return yield t.components.getDatastore().has(t._peerIdToDatastoreKey(e))})()}delete(e){var t=this;return $(function*(){yield t.components.getDatastore().delete(t._peerIdToDatastoreKey(e))})()}load(e){var t=this;return $(function*(){const r=yield t.components.getDatastore().get(t._peerIdToDatastoreKey(e)),i=Mh.decode(r),s=new Map;for(const o of i.metadata)s.set(o.key,o.value);return{...i,id:e,addresses:i.addresses.map(({multiaddr:o,isCertified:a})=>({multiaddr:new mn(o),isCertified:a??!1})),metadata:s,pubKey:i.pubKey??void 0,peerRecordEnvelope:i.peerRecordEnvelope??void 0}})()}save(e){var t=this;return $(function*(){if(null!=e.pubKey&&null!=e.id.publicKey&&!kr(e.pubKey,e.id.publicKey))throw EA.error("peer publicKey bytes do not match peer id publicKey bytes"),ae(new Error("publicKey bytes do not match peer id publicKey bytes"),"ERR_INVALID_PARAMETERS");const r=new Set,i=e.addresses.filter(a=>!r.has(a.multiaddr.toString())&&(r.add(a.multiaddr.toString()),!0)).sort((a,u)=>a.multiaddr.toString().localeCompare(u.multiaddr.toString())).map(({multiaddr:a,isCertified:u})=>({multiaddr:a.bytes,isCertified:u})),s=[];[...e.metadata.keys()].sort().forEach(a=>{const u=e.metadata.get(a);null!=u&&s.push({key:a,value:u})});const o=Mh.encode({addresses:i,protocols:e.protocols.sort(),pubKey:e.pubKey,metadata:s,peerRecordEnvelope:e.peerRecordEnvelope});return yield t.components.getDatastore().put(t._peerIdToDatastoreKey(e.id),o.subarray()),yield t.load(e.id)})()}patch(e,t){var r=this;return $(function*(){const i=yield r.load(e);return yield r._patch(e,t,i)})()}patchOrCreate(e,t){var r=this;return $(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._patch(e,t,i)})()}_patch(e,t,r){var i=this;return $(function*(){return yield i.save({...r,...t,id:e})})()}merge(e,t){var r=this;return $(function*(){const i=yield r.load(e);return yield r._merge(e,t,i)})()}mergeOrCreate(e,t){var r=this;return $(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._merge(e,t,i)})()}_merge(e,t,r){var i=this;return $(function*(){const s=new Map;return r.addresses.forEach(o=>{s.set(o.multiaddr.toString(),o.isCertified)}),(t.addresses??[]).forEach(o=>{const a=o.multiaddr.toString(),_=Boolean(s.get(a))||o.isCertified;s.set(a,_)}),yield i.save({id:e,addresses:Array.from(s.entries()).map(([o,a])=>({multiaddr:new mn(o),isCertified:a})),protocols:Array.from(new Set([...r.protocols??[],...t.protocols??[]])),metadata:new Map([...r.metadata?.entries()??[],...t.metadata?.entries()??[]]),pubKey:t.pubKey??r?.pubKey,peerRecordEnvelope:t.peerRecordEnvelope??r?.peerRecordEnvelope})})()}all(){var e=this;return hn(function*(){var i,t=!1,r=!1;try{for(var o,s=Pt(e.components.getDatastore().queryKeys({prefix:bA}));t=!(o=yield lt(s.next())).done;t=!1){const u=o.value.toString().split("/")[2],_=co.decode(u);yield e.load(tu(_))}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield lt(s.return()))}finally{if(r)throw i}}})()}}var ia,$h;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.tags)throw new Error('Protocol error: required field "tags" was not found in object');for(const s of t.tags)r.uint32(10),$h.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={tags:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.tags.push($h.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ia||(ia={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.name)throw new Error('Protocol error: required field "name" was not found in object');r.uint32(10),r.string(t.name),null!=t.value&&(r.uint32(16),r.uint32(t.value)),null!=t.expiry&&(r.uint32(24),r.uint64(t.expiry)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={name:""},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.name=t.string();break;case 2:i.value=t.uint32();break;case 3:i.expiry=t.uint64();break;default:t.skipType(7&o)}}if(null==i.name)throw new Error('Protocol error: value for required field "name" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}($h||($h={}));const Zi=zt("libp2p:peer-store");class q9 extends Ei{constructor(e={}){super(),this.components=new ho,this.store=new W9,this.addressBook=new I9(this.dispatchEvent.bind(this),this.store,e.addressFilter),this.keyBook=new T9(this.dispatchEvent.bind(this),this.store),this.metadataBook=new A9(this.dispatchEvent.bind(this),this.store),this.protoBook=new x9(this.dispatchEvent.bind(this),this.store)}init(e){this.components=e,this.store.init(e)}forEach(e){var t=this;return $(function*(){Zi.trace("getPeers await read lock");const r=yield t.store.lock.readLock();Zi.trace("getPeers got read lock");try{var o,i=!1,s=!1;try{for(var u,a=Pt(t.store.all());i=!(u=yield a.next()).done;i=!1){const _=u.value;_.id.equals(t.components.getPeerId())||e(_)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}}finally{Zi.trace("getPeers release read lock"),r()}})()}all(){var e=this;return $(function*(){const t=[];return yield e.forEach(r=>{t.push(r)}),t})()}delete(e){var t=this;return $(function*(){Zi.trace("delete await write lock");const r=yield t.store.lock.writeLock();Zi.trace("delete got write lock");try{yield t.store.delete(e)}finally{Zi.trace("delete release write lock"),r()}})()}get(e){var t=this;return $(function*(){Zi.trace("get await read lock");const r=yield t.store.lock.readLock();Zi.trace("get got read lock");try{return yield t.store.load(e)}finally{Zi.trace("get release read lock"),r()}})()}has(e){var t=this;return $(function*(){Zi.trace("has await read lock");const r=yield t.store.lock.readLock();Zi.trace("has got read lock");try{return yield t.store.has(e)}finally{Zi.trace("has release read lock"),r()}})()}tagPeer(e,t,r={}){var i=this;return $(function*(){const s=r.value??0,o=Math.round(s),a=r.ttl??void 0;if(o!==s||o<0||o>100)throw ae(new Error("Tag value must be between 0-100"),"ERR_TAG_VALUE_OUT_OF_BOUNDS");const u=yield i.metadataBook.getValue(e,"tags");let _=[];null!=u&&(_=ia.decode(u).tags);for(const R of _)if(R.name===t)throw ae(new Error("Peer already tagged"),"ERR_DUPLICATE_TAG");_.push({name:t,value:o,expiry:null==a?void 0:BigInt(Date.now()+a)}),yield i.metadataBook.setValue(e,"tags",ia.encode({tags:_}).subarray())})()}unTagPeer(e,t){var r=this;return $(function*(){const i=yield r.metadataBook.getValue(e,"tags");let s=[];null!=i&&(s=ia.decode(i).tags),s=s.filter(o=>o.name!==t),yield r.metadataBook.setValue(e,"tags",ia.encode({tags:s}).subarray())})()}getTags(e){var t=this;return $(function*(){const r=yield t.metadataBook.getValue(e,"tags");let i=[];null!=r&&(i=ia.decode(r).tags);const s=BigInt(Date.now()),o=i.filter(a=>null==a.expiry||a.expiry>s);return o.length!==i.length&&(yield t.metadataBook.setValue(e,"tags",ia.encode({tags:o}).subarray())),o.map(a=>({name:a.name,value:a.value??0}))})()}}class Y9{constructor(e){this.dht=e}provide(e){var t=this;return $(function*(){yield Qo(t.dht.provide(e))})()}findProviders(e,t={}){var r=this;return hn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.findProviders(e,t));i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;"PROVIDER"===_.name&&(yield*Mr(Pt(_.providers),lt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}put(e,t,r){var i=this;return $(function*(){yield Qo(i.dht.put(e,t,r))})()}get(e,t){var r=this;return $(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.get(e,t));i=!(u=yield a.next()).done;i=!1){const _=u.value;if("VALUE"===_.name)return _.value}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw ae(new Error("Not found"),"ERR_NOT_FOUND")})()}}const wA=zt("libp2p:dialer:auto-dialer");class Q9{constructor(e,t){this.components=e,this.enabled=t.enabled,this.minConnections=t.minConnections,this.dialTimeout=t.dialTimeout}handle(e){const{detail:t}=e;if(this.enabled&&0===this.components.getConnectionManager().getConnections(t.id).length&&(this.minConnections??0)>this.components.getConnectionManager().getConnections().length){wA("auto-dialing discovered peer %p with timeout %d",t.id,this.dialTimeout);const o=new bi.TimeoutController(this.dialTimeout);try{(0,Vr.setMaxListeners)?.(1/0,o.signal)}catch{}this.components.getConnectionManager().openConnection(t.id,{signal:o.signal}).catch(a=>{wA.error("could not connect to discovered peer %p with %o",t.id,a)}).finally(()=>{o.clear()})}}}var _A=x(4033);const Z9=globalThis.fetch,X9=globalThis.Headers;function nE(n,e,t){return`${n}?name=${e}&type=${t}`}function J9(n,e){return rE.apply(this,arguments)}function rE(){return rE=$(function*(n,e){return yield(yield Z9(n,{headers:new X9({accept:"application/dns-json"}),signal:e})).json()}),rE.apply(this,arguments)}function cu(n,e){return`${e}_${n}`}globalThis,globalThis;const iE=Object.assign(_r("dns-over-http-resolver"),{error:_r("dns-over-http-resolver:error")}),tH=class eH{constructor(e={}){this._cache=new _A({max:e?.maxCache??100}),this._TXTcache=new _A({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??J9,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>e.abort())}getServers(){return this._servers}_getShuffledServers(){const e=[...this._servers];for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),i=e[t];e[t]=e[r],e[r]=i}return e}setServers(e){this._servers=e}resolve(e,t="A"){var r=this;return $(function*(){switch(t){case"A":return yield r.resolve4(e);case"AAAA":return yield r.resolve6(e);case"TXT":return yield r.resolveTxt(e);default:throw new Error(`${t} is not supported`)}})()}resolve4(e){var t=this;return $(function*(){const i=t._cache.get(cu(e,"A"));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const u=yield t._request(nE(o,e,"A"),a.signal),_=u.Answer.map(N=>N.data),R=Math.min(...u.Answer.map(N=>N.TTL));return t._cache.set(cu(e,"A"),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),iE.error(`${o} could not resolve ${e} record A`)}finally{t._abortControllers=t._abortControllers.filter(u=>u!==a)}}throw s?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record A`)})()}resolve6(e){var t=this;return $(function*(){const r="AAAA",i=t._cache.get(cu(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const u=yield t._request(nE(o,e,r),a.signal),_=u.Answer.map(N=>N.data),R=Math.min(...u.Answer.map(N=>N.TTL));return t._cache.set(cu(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),iE.error(`${o} could not resolve ${e} record AAAA`)}finally{t._abortControllers=t._abortControllers.filter(u=>u!==a)}}throw s?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record AAAA`)})()}resolveTxt(e){var t=this;return $(function*(){const r="TXT",i=t._TXTcache.get(cu(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const u=yield t._request(nE(o,e,r),a.signal),_=u.Answer.map(N=>[N.data.replace(/['"]+/g,"")]),R=Math.min(...u.Answer.map(N=>N.TTL));return t._TXTcache.set(cu(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),iE.error(`${o} could not resolve ${e} record TXT`)}finally{t._abortControllers=t._abortControllers.filter(u=>u!==a)}}throw s?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record TXT`)})()}clearCache(){this._cache.clear(),this._TXTcache.clear()}},{code:nH}=Sr("dnsaddr");function sE(){return sE=$(function*(n,e={}){const t=new tH;null!=e.signal&&e.signal.addEventListener("abort",()=>{t.cancel()});const r=n.getPeerId(),[,i]=n.stringTuples().find(([a])=>a===nH)??[];if(null==i)throw new Error("No hostname found in multiaddr");let o=(yield t.resolveTxt(`_dnsaddr.${i}`)).flat().map(a=>a.split("=")[1]);return null!=r&&(o=o.filter(a=>a.includes(r))),o}),sE.apply(this,arguments)}const iH={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:n=>n},connectionManager:{maxConnections:300,minConnections:50,autoDial:!0,autoDialInterval:1e4,maxParallelDials:100,maxDialsPerPeer:4,dialTimeout:3e4,inboundUpgradeTimeout:3e4,resolvers:{dnsaddr:function rH(n){return sE.apply(this,arguments)}},addressSorter:yv},connectionGater:{},transportManager:{faultTolerance:Pa.FATAL_ALL},metrics:{enabled:!1,computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},nat:{enabled:!0,ttl:7200,keepAlive:!0},relay:{enabled:!0,advertise:{bootDelay:9e5,enabled:!1,ttl:18e5},hop:{enabled:!1,active:!1,timeout:3e4},autoRelay:{enabled:!1,maxListeners:2}},identify:{protocolPrefix:"ipfs",host:{agentVersion:G2},timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1},ping:{protocolPrefix:"ipfs",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4},fetch:{protocolPrefix:"libp2p",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4}};function sH(n){const e=Hl(iH,n);if(null==e.transports||e.transports.length<1)throw ae(new Error(Dn.ERR_TRANSPORTS_REQUIRED),Ce.ERR_TRANSPORTS_REQUIRED);if(null==e.connectionEncryption||0===e.connectionEncryption.length)throw ae(new Error(Dn.CONN_ENCRYPTION_REQUIRED),Ce.CONN_ENCRYPTION_REQUIRED);if(null===e.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw ae(new Error(Dn.ERR_PROTECTOR_REQUIRED),Ce.ERR_PROTECTOR_REQUIRED);return e.identify.host.agentVersion===G2&&(lV||cV?e.identify.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(Eh||GT||uV||fV)&&(e.identify.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`)),e}var DA;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.id)throw new Error('Protocol error: required field "id" was not found in object');r.uint32(10),r.bytes(t.id),null!=t.pubKey&&(r.uint32(18),r.bytes(t.pubKey)),null!=t.privKey&&(r.uint32(26),r.bytes(t.privKey)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={id:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.id=t.bytes();break;case 2:i.pubKey=t.bytes();break;case 3:i.privKey=t.bytes();break;default:t.skipType(7&o)}}if(null==i.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(DA||(DA={}));const oH=function(){var n=$(function*(){const e=yield iT("Ed25519"),t=yield function SA(n){return aE.apply(this,arguments)}(e);if("Ed25519"===t.type)return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)});return function(){return n.apply(this,arguments)}}();function aE(){return aE=$(function*(n){return yield kl(sT(n.public),M5(n))}),aE.apply(this,arguments)}const fE=Symbol.for("@libp2p/peer-discovery");class cH extends Ei{get[fE](){return!0}get[Symbol.toStringTag](){return"@libp2p/dummy-dht"}get wan(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}get lan(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}get(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}findProviders(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}findPeer(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}getClosestPeers(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}provide(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}put(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)}getMode(){return $(function*(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)})()}setMode(){return $(function*(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)})()}refreshRoutingTable(){return $(function*(){throw ae(new Error(Dn.DHT_DISABLED),Ce.DHT_DISABLED)})()}}class uH extends Ei{isStarted(){return!1}start(){}stop(){}get globalSignaturePolicy(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}get multicodecs(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getPeers(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getTopics(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}subscribe(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}unsubscribe(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getSubscribers(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}publish(){return $(function*(){throw ae(new Error(Dn.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)})()}}const Eo=zt("libp2p");class lH extends Ei{constructor(e){var o;super(),this.initializables=[],this.started=!1,this.peerId=e.peerId,this.components=new ho({peerId:e.peerId,datastore:e.datastore??new LV,connectionGater:{denyDialPeer:(o=$(function*(){return yield Promise.resolve(!1)}),function(){return o.apply(this,arguments)}),denyDialMultiaddr:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundEncryptedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundEncryptedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundUpgradedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundUpgradedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),filterMultiaddrForPeer:function(){var o=$(function*(){return yield Promise.resolve(!0)});return function(){return o.apply(this,arguments)}}(),...e.connectionGater}}),this.components.setPeerStore(new q9({addressFilter:this.components.getConnectionGater().filterMultiaddrForPeer,...e.peerStore})),this.services=[this.components],e.metrics.enabled&&(this.metrics=this.components.setMetrics(new O7(e.metrics))),this.peerStore=this.components.getPeerStore(),this.peerStore.addEventListener("peer",o=>{const{detail:a}=o;this.dispatchEvent(new nn("peer:discovery",{detail:a}))}),null!=e.connectionProtector&&this.components.setConnectionProtector(e.connectionProtector),this.components.setUpgrader(new Q7(this.components,{connectionEncryption:(e.connectionEncryption??[]).map(o=>this.configureComponent(o)),muxers:(e.streamMuxers??[]).map(o=>this.configureComponent(o)),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout})),this.connectionManager=this.components.setConnectionManager(new s7(e.connectionManager)),this.registrar=this.components.setRegistrar(new W7(this.components)),this.components.setTransportManager(new V7(this.components,e.transportManager)),this.components.setAddressManager(new HV(this.components,e.addresses)),this.configureComponent(new D9(this.components)),this.configureComponent(new a7(this.components,{enabled:e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,autoDialInterval:e.connectionManager.autoDialInterval}));const t=k2.generateOptions();this.keychain=this.configureComponent(new k2(this.components,{...t,...e.keychain})),this.services.push(new w9(this.components,e.nat)),e.transports.forEach(o=>{this.components.getTransportManager().add(this.configureComponent(o))}),null!=e.streamMuxers&&e.streamMuxers.length>0&&(this.identifyService=new jv(this.components,{...e.identify}),this.configureComponent(this.identifyService)),this.dht=null!=e.dht?this.components.setDHT(e.dht):new cH,this.pubsub=null!=e.pubsub?this.components.setPubSub(e.pubsub):new uH;const r=(e.peerRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&(r.push(this.configureComponent(new S9(this.dht))),this.dht.addEventListener("peer",o=>{this.onDiscoveryPeer(o)})),this.peerRouting=this.components.setPeerRouting(this.configureComponent(new BV(this.components,{...e.peerRouting,routers:r})));const i=(e.contentRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&i.push(this.configureComponent(new Y9(this.dht))),this.contentRouting=this.components.setContentRouting(this.configureComponent(new FV(this.components,{routers:i}))),e.relay.enabled&&(this.components.getTransportManager().add(this.configureComponent(new y7(e.relay))),this.configureComponent(new _7(this.components,{addressSorter:e.connectionManager.addressSorter,...e.relay}))),this.fetchService=this.configureComponent(new d9(this.components,{...e.fetch})),this.pingService=this.configureComponent(new y9(this.components,{...e.ping}));const s=this.configureComponent(new Q9(this.components,{enabled:!1!==e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,dialTimeout:e.connectionManager.dialTimeout??3e4}));this.addEventListener("peer:discovery",o=>{!this.isStarted()||s.handle(o)});for(const o of e.peerDiscovery??[])this.configureComponent(o),o.addEventListener("peer",a=>{this.onDiscoveryPeer(a)})}configureComponent(e){return fo(e)&&this.services.push(e),Fr(e)&&this.initializables.push(e),e}start(){var e=this;return $(function*(){if(!e.started){e.started=!0,Eo("libp2p is starting");try{e.initializables.forEach(t=>{t.init(e.components)}),yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.start())),yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has started")}catch(t){throw Eo.error("An error occurred starting libp2p",t),yield e.stop(),t}}})()}stop(){var e=this;return $(function*(){!e.started||(Eo("libp2p is stopping"),e.started=!1,yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.stop())),yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has stopped"))})()}loadKeychain(){var e=this;return $(function*(){if(null!=e.keychain)try{yield e.keychain.findKeyByName("self")}catch{yield e.keychain.importPeer("self",e.peerId)}})()}isStarted(){return this.started}getConnections(e){return this.components.getConnectionManager().getConnections(e)}getPeers(){const e=new t7;for(const t of this.components.getConnectionManager().getConnections())e.add(t.remotePeer);return Array.from(e)}dial(e,t={}){var r=this;return $(function*(){const{id:i,multiaddrs:s}=Vl(e);return yield r.components.getPeerStore().addressBook.add(i,s),yield r.components.getConnectionManager().openConnection(i,t)})()}dialProtocol(e,t,r={}){var i=this;return $(function*(){if(null==t)throw ae(new Error("no protocols were provided to open a stream"),Ce.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw ae(new Error("no protocols were provided to open a stream"),Ce.ERR_INVALID_PROTOCOLS_FOR_STREAM);return yield(yield i.dial(e,r)).newStream(t,r)})()}getMultiaddrs(){return this.components.getAddressManager().getAddresses()}hangUp(e){var t=this;return $(function*(){const{id:r}=Vl(e);yield t.components.getConnectionManager().closeConnections(r)})()}getPublicKey(e,t={}){var r=this;return $(function*(){if(Eo("getPublicKey %p",e),null!=e.publicKey)return e.publicKey;const i=yield r.peerStore.get(e);if(null!=i.pubKey)return i.pubKey;if(null==r.dht)throw ae(new Error("Public key was not in the peer store and the DHT is not enabled"),Ce.ERR_NO_ROUTERS_AVAILABLE);const s=br([Ot("/pk/"),e.multihash.digest]);var u,o=!1,a=!1;try{for(var R,_=Pt(r.dht.get(s,t));o=!(R=yield _.next()).done;o=!1){const N=R.value;if("VALUE"===N.name){const B=Rl(N.value);return yield r.peerStore.keyBook.set(e,N.value),B.bytes}}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw u}}throw ae(new Error(`Node not responding with its public key: ${e.toString()}`),Ce.ERR_INVALID_RECORD)})()}fetch(e,t,r={}){var i=this;return $(function*(){const{id:s,multiaddrs:o}=Vl(e);return null!=o&&(yield i.components.getPeerStore().addressBook.add(s,o)),yield i.fetchService.fetch(s,t,r)})()}ping(e,t={}){var r=this;return $(function*(){const{id:i,multiaddrs:s}=Vl(e);return s.length>0&&(yield r.components.getPeerStore().addressBook.add(i,s)),yield r.pingService.ping(i,t)})()}handle(e,t,r){var i=this;return $(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var s=$(function*(o){yield i.components.getRegistrar().handle(o,t,r)});return function(o){return s.apply(this,arguments)}}()))})()}unhandle(e){var t=this;return $(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var r=$(function*(i){yield t.components.getRegistrar().unhandle(i)});return function(i){return r.apply(this,arguments)}}()))})()}onDiscoveryPeer(e){const{detail:t}=e;t.id.toString()!==this.peerId.toString()?(t.multiaddrs.length>0&&this.components.getPeerStore().addressBook.add(t.id,t.multiaddrs).catch(r=>Eo.error(r)),t.protocols.length>0&&this.components.getPeerStore().protoBook.set(t.id,t.protocols).catch(r=>Eo.error(r)),this.dispatchEvent(new nn("peer:discovery",{detail:t}))):Eo.error(new Error(Ce.ERR_DISCOVERED_SELF))}}function fH(n){return dE.apply(this,arguments)}function dE(){return dE=$(function*(n){return null==n.peerId&&(n.peerId=yield oH()),new lH(sH(n))}),dE.apply(this,arguments)}function dH(n){return hE.apply(this,arguments)}function hE(){return hE=$(function*(n){return yield fH(n)}),hE.apply(this,arguments)}function IA(n,e){return n.length<=e||n.length<=1?n:function pH(n){if(n.length<=1)return n;for(let t=0;t{class n extends Ei{constructor(t,r){super(),this.interval=r?.interval??n.DefaultInterval;const i=r?.maxPeers??t?.length,s=t.map(o=>"string"==typeof o?new mn(o):o);this.peers=function hH(n){return n.map(e=>{const t=e.getPeerId();return{id:t?fr(t):null,multiaddrs:[e.decapsulateCode(421)],protocols:[]}}).filter(e=>null!==e.id)}(IA(s,i)),TA("Use provided list of peers (reduced to maxPeers)",this.peers.map(o=>o.toString()))}start(){this._startTimer()}_startTimer(){if(this.peers){if(TA("Starting to emit static peers."),null!=this.timer)return;this.timer=setInterval(()=>this._returnPeers(),this.interval),this._returnPeers()}}_returnPeers(){null!=this.timer&&this.peers.forEach(t=>{this.dispatchEvent(new nn("peer",{detail:t}))})}stop(){null!=this.timer&&clearInterval(this.timer),this.timer=void 0}get[fE](){return!0}get[Symbol.toStringTag](){return"@waku/peer-discovery-static-list"}}return n.DefaultInterval=200,n})();var uu=(()=>(function(n){n.Prod="prod",n.Test="test"}(uu||(uu={})),uu))();const pE_fleets={"wakuv2.prod":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.prod":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD","node-01.do-ams3.wakuv2.prod":"/dns4/node-01.do-ams3.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmL5okWopX7NqZWBUKVqW8iUxCEmd5GMHLVPwCgzYzQv3e","node-01.gc-us-central1-a.wakuv2.prod":"/dns4/node-01.gc-us-central1-a.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA"}},"wakuv2.test":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.test":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm","node-01.do-ams3.wakuv2.test":"/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ","node-01.gc-us-central1-a.wakuv2.test":"/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS"}}};function lu(n){return"string"==typeof n?Ot(n.replace(/^0x/i,"").toLowerCase(),"base16"):n}function Cs(n,e){const t=e??n.reduce((s,o)=>s+o.length,0),r=new Uint8Array(t);let i=0;for(const s of n)r.set(s,i),i+=s.length;return r}var jh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(jh||(jh={}));var bH=x(6577),wH=x(4237);const fu_algorithm={name:"AES-GCM",length:128},zh={node:bH,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0};function Xi(){if(zh.web)return zh.web.subtle;if(zh.node)return zh.node.webcrypto.subtle;throw new Error("The environment doesn't have Crypto Subtle API (if in the browser, be sure to use to be in a secure context, ie, https)")}const du=Yr.randomBytes,gE=Yr.sha256;function _H(n,e){return yE.apply(this,arguments)}function yE(){return yE=$(function*(n,e){const[t,r]=yield MI(n,e,{recovered:!0,der:!1});return Cs([t,new Uint8Array([r])],t.length+1)}),yE.apply(this,arguments)}function mE(n){return new Uint8Array(wH.keccak256.arrayBuffer(n))}function AA(n,e){let t=1,r=0,i=Promise.resolve(new Uint8Array);for(;r>24,t>>16,t>>8,t]),o=Cs([s,n],s.length+n.length),a=gE(o);i=i.then(u=>a.then(_=>{const R=new Uint8Array(_);return Cs([u,R],u.length+R.length)})),r+=32,t+=1}return i}function DH(n,e,t){return Xi().importKey("raw",e,"AES-CTR",!1,["encrypt"]).then(r=>Xi().encrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function SH(n,e,t){return Xi().importKey("raw",e,"AES-CTR",!1,["decrypt"]).then(r=>Xi().decrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function CH(n,e){const t={name:"HMAC",hash:{name:"SHA-256"}};return Xi().importKey("raw",n,t,!1,["sign"]).then(r=>Xi().sign(t,r,e)).then(r=>new Uint8Array(r))}function IH(n,e,t){const r={name:"HMAC",hash:{name:"SHA-256"}};return Xi().importKey("raw",n,r,!1,["verify"]).then(s=>Xi().verify(r,s,t,e))}function xA(n,e){if(32!==n.length)throw new Error(`Bad private key, it should be 32 bytes but it's actually ${n.length} bytes long`);if(65!==e.length)throw new Error(`Bad public key, it should be 65 bytes but it's actually ${e.length} bytes long`);if(4!==e[0])throw new Error("Bad public key, a valid public key would begin with 4");{const t=function AF(n,e,t=!1){if(AI(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!AI(e))throw new TypeError("getSharedSecret: second arg must be public key");const r=H0(e);return r.assertValidity(),r.multiply(_a(n)).toRawBytes(t)}(n,e,!0);return new Uint8Array(lu(t).slice(1))}}function TH(n,e){return vE.apply(this,arguments)}function vE(){return vE=$(function*(n,e){const t=du(32),r=yield xA(t,n),i=yield AA(r,32),s=du(16),o=i.slice(0,16),a=yield DH(s,o,e),u=Cs([s,a],s.length+a.length),_=yield gE(i.slice(16)),R=yield CH(_,u),N=Dl(t,!1);return Cs([N,u,R],N.length+u.length+R.length)}),vE.apply(this,arguments)}function AH(n,e){return bE.apply(this,arguments)}function bE(){return bE=$(function*(n,e){if(e.length<=113)throw new Error("Invalid Ciphertext. Data is too small. It should ba at least 113 bytes");if(4!==e[0])throw new Error(`Not a valid ciphertext. It should begin with 4 but actually begin with ${e[0]}`);{const t=e.slice(0,65),r=e.length-113,i=e.slice(65,81),s=e.slice(65,81+r),o=s.slice(16),a=e.slice(81+r),u=xA(n,t),_=yield AA(u,32),[R,N]=yield gE(_.slice(16)).then(B=>[_.slice(0,16),B]);if(!(yield IH(N,s,a)))throw new Error("Incorrect MAC");return SH(i,R,o)}}),bE.apply(this,arguments)}function xH(n,e,t){return wE.apply(this,arguments)}function wE(){return wE=$(function*(n,e,t){return Xi().importKey("raw",e,fu_algorithm,!1,["encrypt"]).then(r=>Xi().encrypt({iv:n,...fu_algorithm},r,t)).then(r=>new Uint8Array(r))}),wE.apply(this,arguments)}function RH(n,e,t){return _E.apply(this,arguments)}function _E(){return _E=$(function*(n,e,t){return Xi().importKey("raw",e,fu_algorithm,!1,["decrypt"]).then(r=>Xi().decrypt({iv:n,...fu_algorithm},r,t)).then(r=>new Uint8Array(r))}),_E.apply(this,arguments)}function PH(){return du(12)}function PA(n,e){return CE.apply(this,arguments)}function CE(){return CE=$(function*(n,e){let t=new Uint8Array([0]);t=VH(t,n),t=Cs([t,n]);let r=1+OA(n)+n.length;e&&(r+=65);const s=256-r%256,o=du(s);if(!HH(o,s))throw new Error("failed to generate random padding of size "+s);let a;if(t=Cs([t,o]),e){t[0]|=4;const u=mE(t),_=yield _H(u,e);t=Cs([t,_]),a={signature:_,publicKey:Dl(e,!1)}}return{payload:t,sig:a}}),CE.apply(this,arguments)}function IE(){return IE=$(function*(n,e){return TH(lu(e),n)}),IE.apply(this,arguments)}function NA(n,e){return TE.apply(this,arguments)}function TE(){return TE=$(function*(n,e){return AH(e,n)}),TE.apply(this,arguments)}function AE(){return AE=$(function*(n,e){const t=PH();return Cs([yield xH(t,lu(e),n),t])}),AE.apply(this,arguments)}function MA(n,e){return xE.apply(this,arguments)}function xE(){return xE=$(function*(n,e){const t=n.length-12,r=n.slice(0,t);return RH(n.slice(t),lu(e),r)}),xE.apply(this,arguments)}function VH(n,e){const t=OA(e);let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e.length,!0),r=r.slice(0,t),(n=Cs([n,r]))[0]|=t,n}function OA(n){let e=1;for(let t=n.length;t>=256;t/=256)e++;return e}function HH(n,e){return n.length===e&&(e<=3||-1!==n.findIndex(t=>0!==t))}const sa=_r("waku:message"),kA=BigInt(1e6);var Gh,Wh,LA,qh,tf=(()=>(function(n){n.Asymmetric="asymmetric",n.Symmetric="symmetric"}(tf||(tf={})),tf))();class oa{constructor(e,t,r){this.proto=e,this._signaturePublicKey=t,this._signature=r}static fromUtf8String(e,t,r){return $(function*(){const i=(n=>Ot(n,"utf8"))(e);return oa.fromBytes(i,t,r)})()}static fromBytes(e,t,r){return $(function*(){const{timestamp:i,encPublicKey:s,symKey:o,sigPrivKey:a}=Object.assign({timestamp:new Date},r||{});let R,u=e,_=0;if(s&&o)throw"Pass either `encPublicKey` or `symKey`, not both.";if(s){const N=yield PA(u,a);u=yield function FH(n,e){return IE.apply(this,arguments)}(N.payload,s),R=N.sig,_=1}else if(o){const N=yield PA(u,a);u=yield function UH(n,e){return AE.apply(this,arguments)}(N.payload,o),R=N.sig,_=1}return new oa({payload:u,timestampDeprecated:i.valueOf()/1e3,timestamp:BigInt(i.valueOf())*kA,version:_,contentTopic:t},R?.publicKey,R?.signature)})()}static decode(e,t){return $(function*(){const r=jh.decode(e);return oa.decodeProto(r,t)})()}static decodeProto(e,t){return $(function*(){const r=e.payload;let i,s;if(1===e.version&&r){if(void 0===t)return void sa("Payload is encrypted but no private keys have been provided.");const o=yield Promise.all(t.map(function(){var N=$(function*({key:B,method:z,contentTopics:X}){if(!X||e.contentTopic&&X.includes(e.contentTopic))switch(z){case tf.Asymmetric:try{return yield NA(r,B)}catch(J){return void sa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",J)}case tf.Symmetric:try{return yield MA(r,B)}catch(J){return void sa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",J)}default:try{return yield MA(r,B)}catch(J){sa("Failed to decrypt message using symmetric encryption",J);try{return yield NA(r,B)}catch(oe){return void sa("Failed to decrypt message using asymmetric encryption",oe)}}}});return function(B){return N.apply(this,arguments)}}())),u=o.filter(N=>!!N);if(0===u.length)return void sa("Failed to decrypt payload.");const _=u[0],R=yield function OH(n){const e=function kH(n){return 3&new DataView(n.buffer).getUint8(0)}(n);if(0===e)return;const t=function LH(n,e){let t=n.slice(1,1+e);return e<4&&(t=Cs([t,new Uint8Array(4-e)],4)),new DataView(t.buffer).getInt32(0,!0)}(n,e),r=1+e,i=n.slice(r,r+t),s=function BH(n){return 4==(4&new DataView(n.buffer).getUint8(0))}(n);let o;if(s){const a=function KH(n){return n.slice(n.length-65,n.length)}(n),u=function $H(n,e){return mE(e?n.slice(0,n.length-65):n)}(n,s),_=function jH(n,e){const r=new DataView(e.slice(64).buffer).getUint8(0);return function TF(n,e,t,r=!1){return Tn.fromSignature(n,e,t).toRawBytes(r)}(n,uo.fromCompact(e.slice(0,64)),r,!1)}(u,a);o={signature:a,publicKey:_}}return{payload:i,sig:o}}(_);if(!R)return void sa("Failed to decode payload.");Object.assign(e,{payload:R.payload}),i=R.sig?.publicKey,s=R.sig?.signature}return new oa(e,i,s)})()}encode(){return jh.encode(this.proto)}get payloadAsUtf8(){if(!this.payload)return"";try{return(n=>Lt(this.payload,"utf8"))()}catch(e){return sa("Could not decode byte as UTF-8",e),""}}get payload(){if(this.proto.payload)return new Uint8Array(this.proto.payload)}get contentTopic(){return this.proto.contentTopic}get version(){return this.proto.version??0}get timestamp(){try{if(this.proto.timestamp)return new Date(Number(this.proto.timestamp/kA));if(this.proto.timestampDeprecated)return new Date(1e3*this.proto.timestampDeprecated)}catch{return}}get signaturePublicKey(){return this._signaturePublicKey}get signature(){return this._signature}}!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Yt((s,o,a={})=>{!1!==a.lengthDelimited&&o.fork(),null!=s.contentTopic&&(o.uint32(10),o.string(s.contentTopic)),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={},u=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.contentTopic=s.string():s.skipType(7&_)}return a})),i),r.encode=s=>qt(s,r.codec()),r.decode=s=>Wt(s,r.codec())}(e=n.ContentFilter||(n.ContentFilter={})),n.codec=()=>(null==t&&(t=Yt((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null!=r.subscribe&&(i.uint32(8),i.bool(r.subscribe)),null!=r.topic&&(i.uint32(18),i.string(r.topic)),null==r.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const o of r.contentFilters)i.uint32(26),n.ContentFilter.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={contentFilters:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.subscribe=r.bool();break;case 2:s.topic=r.string();break;case 3:s.contentFilters.push(n.ContentFilter.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}return s})),t),n.encode=r=>qt(r,n.codec()),n.decode=r=>Wt(r,n.codec())}(Gh||(Gh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const s of t.messages)r.uint32(10),qh.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={messages:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.messages.push(qh.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Wh||(Wh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),Gh.codec().encode(t.request,r)),null!=t.push&&(r.uint32(26),Wh.codec().encode(t.push,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=Gh.codec().decode(t,t.uint32());break;case 3:i.push=Wh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(LA||(LA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(qh||(qh={}));const nf="/vac/waku/filter/2.0.0-beta1";var Yh,Qh,BA,Zh;_r("waku:filter"),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(10),r.string(t.pubSubTopic)),null!=t.message&&(r.uint32(18),Zh.codec().encode(t.message,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.pubSubTopic=t.string();break;case 2:i.message=Zh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Yh||(Yh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.isSuccess&&(r.uint32(8),r.bool(t.isSuccess)),null!=t.info&&(r.uint32(18),r.string(t.info)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.isSuccess=t.bool();break;case 2:i.info=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Qh||(Qh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),Yh.codec().encode(t.request,r)),null!=t.response&&(r.uint32(26),Qh.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=Yh.codec().decode(t,t.uint32());break;case 3:i.response=Qh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(BA||(BA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Zh||(Zh={})),_r("waku:light-push");const rf="/vac/waku/lightpush/2.0.0-beta1",ka=["/vac/waku/relay/2.0.0-beta2","/vac/waku/relay/2.0.0"];var Xh,hu,Jh,ep,sf,FA,tp;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(16),r.sint64(t.receivedTime)),null!=t.senderTime&&(r.uint32(24),r.sint64(t.senderTime)),null!=t.pubsubTopic&&(r.uint32(34),r.string(t.pubsubTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.sint64();break;case 3:i.senderTime=t.sint64();break;case 4:i.pubsubTopic=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Xh||(Xh={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),Xh.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=Xh.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(hu||(hu={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Jh||(Jh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),Jh.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),hu.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(40),r.sint64(t.startTime)),null!=t.endTime&&(r.uint32(48),r.sint64(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(Jh.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=hu.codec().decode(t,t.uint32());break;case 5:i.startTime=t.sint64();break;case 6:i.endTime=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ep||(ep={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),tp.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),hu.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(tp.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=hu.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(sf||(sf={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),ep.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),sf.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=ep.codec().decode(t,t.uint32());break;case 3:i.response=sf.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(FA||(FA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(tp||(tp={}));var np,pu,rp,ip,sp,UA,op,of=(()=>(function(n){n.V2Beta3="/vac/waku/store/2.0.0-beta3",n.V2Beta4="/vac/waku/store/2.0.0-beta4"}(of||(of={})),of))();!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(17),r.double(t.receivedTime)),null!=t.senderTime&&(r.uint32(25),r.double(t.senderTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.double();break;case 3:i.senderTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(np||(np={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),np.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=np.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(pu||(pu={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(rp||(rp={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),rp.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),pu.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(41),r.double(t.startTime)),null!=t.endTime&&(r.uint32(49),r.double(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(rp.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=pu.codec().decode(t,t.uint32());break;case 5:i.startTime=t.double();break;case 6:i.endTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ip||(ip={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),op.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),pu.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(op.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=pu.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(sp||(sp={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),ip.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),sp.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=ip.codec().decode(t,t.uint32());break;case 3:i.response=sp.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(UA||(UA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(op||(op={})),BigInt(1e6),_r("waku:store");const KA=_r("waku:waku");var Jr=(()=>(function(n){n.Relay="relay",n.Store="store",n.LightPush="lightpush",n.Filter="filter"}(Jr||(Jr={})),Jr))();class JH{constructor(e,t,r,i,s){this.libp2p=t,this.store=r,this.filter=s,this.lightPush=i,function eK(n){if(n)try{return n.multicodecs.includes(ka[ka.length-1])}catch{}return!1}(t.pubsub)&&(this.relay=t.pubsub),this.pingKeepAliveTimers={},this.relayKeepAliveTimers={};const o=e.pingKeepAlive||0,a=this.relay?e.relayKeepAlive||300:0;t.connectionManager.addEventListener("peer:connect",u=>{this.startKeepAlive(u.detail.remotePeer,o,a)}),t.connectionManager.addEventListener("peer:disconnect",u=>{this.stopKeepAlive(u.detail.remotePeer)}),e?.decryptionKeys?.forEach(u=>{this.addDecryptionKey(u)})}dial(e,t){var r=this;return $(function*(){const i=t??[Jr.Relay],s=[];if(i.includes(Jr.Relay)&&ka.forEach(o=>s.push(o)),i.includes(Jr.Store))for(const o of Object.values(of))s.push(o);return i.includes(Jr.LightPush)&&s.push(rf),i.includes(Jr.Filter)&&s.push(nf),r.libp2p.dialProtocol(e,s)})()}addPeerToAddressBook(e,t){var r=this;return $(function*(){let i;i="string"==typeof e?fr(e):e;const s=t.map(o=>"string"==typeof o?function rV(n){return new mn(n)}(o):o);yield r.libp2p.peerStore.addressBook.set(i,s)})()}start(){var e=this;return $(function*(){yield e.libp2p.start()})()}stop(){var e=this;return $(function*(){e.stopAllKeepAlives(),yield e.libp2p.stop()})()}isStarted(){return this.libp2p.isStarted()}addDecryptionKey(e,t){this.relay&&this.relay.addDecryptionKey(e,t),this.store&&this.store.addDecryptionKey(e,t),this.filter&&this.filter.addDecryptionKey(e,t)}deleteDecryptionKey(e){this.relay&&this.relay.deleteDecryptionKey(e),this.store&&this.store.deleteDecryptionKey(e),this.filter&&this.filter.deleteDecryptionKey(e)}getLocalMultiaddrWithID(){const e=this.libp2p.getMultiaddrs().find(t=>t.toString().match(/127\.0\.0\.1/));if(!e||""===e.toString())throw"Not listening on localhost";return e+"/p2p/"+this.libp2p.peerId.toString()}startKeepAlive(e,t,r){this.stopKeepAlive(e);const i=e.toString();0!==t&&(this.pingKeepAliveTimers[i]=setInterval(()=>{this.libp2p.ping(e).catch(o=>{KA(`Ping failed (${i})`,o)})},1e3*t));const s=this.relay;s&&0!==r&&(this.relayKeepAliveTimers[i]=setInterval(()=>{KA("Sending Waku Relay ping message"),oa.fromBytes(new Uint8Array,"/relay-ping/1/ping/null").then(o=>s.send(o))},1e3*r))}stopKeepAlive(e){const t=e.toString();this.pingKeepAliveTimers[t]&&(clearInterval(this.pingKeepAliveTimers[t]),delete this.pingKeepAliveTimers[t]),this.relayKeepAliveTimers[t]&&(clearInterval(this.relayKeepAliveTimers[t]),delete this.relayKeepAliveTimers[t])}stopAllKeepAlives(){for(const e of[...Object.values(this.pingKeepAliveTimers),...Object.values(this.relayKeepAliveTimers)])clearInterval(e);this.pingKeepAliveTimers={},this.relayKeepAliveTimers={}}}const $A=()=>{};class tK{constructor(e){this.min=e.min??0,this.max=e.max??1/0,this.peers=new Set,this.onConnect=e.onConnect??$A,this.onDisconnect=e.onDisconnect??$A}get[Symbol.toStringTag](){return $v.toString()}get[$v](){return!0}setRegistrar(e){var t=this;return $(function*(){t.registrar=e})()}disconnect(e){this.onDisconnect(e)}}class rK{constructor(e,t,r){this.gossip=e,this.msgs=new Map,this.history=[],this.msgIdToStrFn=r;for(let i=0;i{const s=this.msgs.get(i.msgIdStr);if(s&&s.validated&&e.has(i.topic)){let o=t.get(i.topic);o||(o=[],t.set(i.topic,o)),o.push(i.msgId)}});return t}validate(e){const t=this.msgs.get(e);if(!t)return null;const{message:r,originatingPeers:i}=t;return t.validated=!0,t.originatingPeers=new Set,{message:r,originatingPeers:i}}shift(){this.history[this.history.length-1].forEach(t=>{this.msgs.delete(t.msgIdStr)}),this.history.pop(),this.history.unshift([])}remove(e){const t=this.msgs.get(e);return t?(this.msgs.delete(e),t):null}}var iK=x(8479);const{RPC:cp}=iK,jA="/floodsub/1.0.0",zA="/meshsub/1.0.0",OE="/meshsub/1.1.0",yu=5e3;function bo(n=[],e){return{subscriptions:[],messages:n,control:e?{graft:e.graft||[],prune:e.prune||[],ihave:e.ihave||[],iwant:e.iwant||[]}:void 0}}function wo(n){if(n.length<=1)return n;for(let t=0;t(function(n){n.StrictSign="StrictSign",n.StrictNoSign="StrictNoSign"}(fp||(fp={})),fp))(),Ba=(()=>(function(n){n[n.Signing=0]="Signing",n[n.Anonymous=1]="Anonymous"}(Ba||(Ba={})),Ba))(),js=(()=>(function(n){n.Accept="accept",n.Ignore="ignore",n.Reject="reject"}(js||(js={})),js))(),Ji=(()=>(function(n){n.Error="error",n.Ignore="ignore",n.Reject="reject",n.Blacklisted="blacklisted"}(Ji||(Ji={})),Ji))(),li=(()=>(function(n){n.InvalidSignature="invalid_signature",n.InvalidSeqno="invalid_seqno",n.InvalidPeerId="invalid_peerid",n.SignaturePresent="signature_present",n.SeqnoPresent="seqno_present",n.FromPresent="from_present",n.TransformFailed="transform_failed"}(li||(li={})),li))(),es=(()=>(function(n){n.duplicate="duplicate",n.invalid="invalid",n.valid="valid"}(es||(es={})),es))();function WA(n){switch(n){case js.Ignore:return Ji.Ignore;case js.Reject:return Ji.Reject}}function LE(){return LE=$(function*(n,e){switch(n){case up:{if(!e)throw Error("Must provide PeerId");if(null==e.privateKey)throw Error("Cannot sign message, no private key present");if(null==e.publicKey)throw Error("Cannot sign message, no public key present");const t=yield Pl(e.privateKey);return{type:Ba.Signing,author:e,key:e.publicKey,privateKey:t}}case kE:return{type:Ba.Anonymous};default:throw new Error(`Unknown signature policy "${n}"`)}}),LE.apply(this,arguments)}const Kn="ERR_INVALID_PEER_SCORE_PARAMS",BK={topics:{},topicScoreCap:10,appSpecificScore:()=>0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyThreshold:0,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},FK={topicWeight:.5,timeInMeshWeight:1,timeInMeshQuantum:1,timeInMeshCap:3600,firstMessageDeliveriesWeight:1,firstMessageDeliveriesDecay:.5,firstMessageDeliveriesCap:2e3,meshMessageDeliveriesWeight:-1,meshMessageDeliveriesDecay:.5,meshMessageDeliveriesCap:100,meshMessageDeliveriesThreshold:20,meshMessageDeliveriesWindow:10,meshMessageDeliveriesActivation:5e3,meshFailurePenaltyWeight:-1,meshFailurePenaltyDecay:.5,invalidMessageDeliveriesWeight:-1,invalidMessageDeliveriesDecay:.3};function UK(n={}){return{...BK,...n,topics:n.topics?Object.entries(n.topics).reduce((e,[t,r])=>(e[t]=function VK(n={}){return{...FK,...n}}(r),e),{}):{}}}function KK(n){if(n.topicWeight<0)throw ae(new Error("invalid topic weight; must be >= 0"),Kn);if(0===n.timeInMeshQuantum)throw ae(new Error("invalid TimeInMeshQuantum; must be non zero"),Kn);if(n.timeInMeshWeight<0)throw ae(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),Kn);if(0!==n.timeInMeshWeight&&n.timeInMeshQuantum<=0)throw ae(new Error("invalid TimeInMeshQuantum; must be positive"),Kn);if(0!==n.timeInMeshWeight&&n.timeInMeshCap<=0)throw ae(new Error("invalid TimeInMeshCap; must be positive"),Kn);if(n.firstMessageDeliveriesWeight<0)throw ae(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),Kn);if(0!==n.firstMessageDeliveriesWeight&&(n.firstMessageDeliveriesDecay<=0||n.firstMessageDeliveriesDecay>=1))throw ae(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),Kn);if(0!==n.firstMessageDeliveriesWeight&&n.firstMessageDeliveriesCap<=0)throw ae(new Error("invalid FirstMessageDeliveriesCap; must be positive"),Kn);if(n.meshMessageDeliveriesWeight>0)throw ae(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.meshMessageDeliveriesWeight&&(n.meshMessageDeliveriesDecay<=0||n.meshMessageDeliveriesDecay>=1))throw ae(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesCap<=0)throw ae(new Error("invalid MeshMessageDeliveriesCap; must be positive"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesThreshold<=0)throw ae(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),Kn);if(n.meshMessageDeliveriesWindow<0)throw ae(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesActivation<1e3)throw ae(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),Kn);if(n.meshFailurePenaltyWeight>0)throw ae(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.meshFailurePenaltyWeight&&(n.meshFailurePenaltyDecay<=0||n.meshFailurePenaltyDecay>=1))throw ae(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),Kn);if(n.invalidMessageDeliveriesWeight>0)throw ae(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),Kn);if(n.invalidMessageDeliveriesDecay<=0||n.invalidMessageDeliveriesDecay>=1)throw ae(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),Kn)}const $K={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function jK(n={}){return{...$K,...n}}function zK(n,e,t,r){let i=0;if(Object.entries(e.topics).forEach(([o,a])=>{const u=t.topics[o];if(void 0===u)return;let _=0;if(a.inMesh){let z=a.meshTime/u.timeInMeshQuantum;z>u.timeInMeshCap&&(z=u.timeInMeshCap),_+=z*u.timeInMeshWeight}let R=a.firstMessageDeliveries;if(R>u.firstMessageDeliveriesCap&&(R=u.firstMessageDeliveriesCap),_+=R*u.firstMessageDeliveriesWeight,a.meshMessageDeliveriesActive&&a.meshMessageDeliveries0&&i>t.topicScoreCap&&(i=t.topicScoreCap),i+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(o=>{if(t.IPColocationFactorWhitelist.has(o))return;const a=r.get(o),u=a?a.size:0;if(u>t.IPColocationFactorThreshold){const _=u-t.IPColocationFactorThreshold;i+=_*_*t.IPColocationFactorWeight}}),e.behaviourPenalty>t.behaviourPenaltyThreshold){const o=e.behaviourPenalty-t.behaviourPenaltyThreshold;i+=o*o*t.behaviourPenaltyWeight}return i}var GK=x(1807),fi=(()=>(function(n){n[n.unknown=0]="unknown",n[n.valid=1]="valid",n[n.invalid=2]="invalid",n[n.ignored=3]="ignored"}(fi||(fi={})),fi))();class WK{constructor(){this.records=new Map,this.queue=new GK}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:fi.unknown,firstSeen:Date.now(),validated:0,peers:new Set},this.records.set(e,t);const r={msgId:e,expire:Date.now()+12e4};return this.queue.push(r),t}gc(){const e=Date.now();let t=this.queue.peekFront();for(;t&&t.expire0)throw ae(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.IPColocationFactorWeight&&n.IPColocationFactorThreshold<1)throw ae(new Error("invalid IPColocationFactorThreshold; must be at least 1"),Kn);if(n.behaviourPenaltyWeight>0)throw ae(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.behaviourPenaltyWeight&&(n.behaviourPenaltyDecay<=0||n.behaviourPenaltyDecay>=1))throw ae(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),Kn);if(n.decayInterval<1e3)throw ae(new Error("invalid DecayInterval; must be at least 1s"),Kn);if(n.decayToZero<=0||n.decayToZero>=1)throw ae(new Error("invalid DecayToZero; must be between 0 and 1"),Kn)}(e),this.scoreCacheValidityMs=r.scoreCacheValidityMs,this.computeScore=r.computeScore??zK}init(e){this.components=e}get size(){return this.peerStats.size}start(){this._backgroundInterval?mu("Peer score already running"):(this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),mu("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),mu("stopped")):mu("Peer score already stopped")}background(){this.refreshScores(),this.updateIPs(),this.deliveryRecords.gc()}dumpPeerScoreStats(){return Object.fromEntries(Array.from(this.peerStats.entries()).map(([e,t])=>[e,t]))}refreshScores(){const e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach((r,i)=>{r.connected?(Object.entries(r.topics).forEach(([s,o])=>{const a=this.params.topics[s];void 0!==a&&(o.firstMessageDeliveries*=a.firstMessageDeliveriesDecay,o.firstMessageDeliveriesa.meshMessageDeliveriesActivation&&(o.meshMessageDeliveriesActive=!0)))}),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenaltyr.expire&&(this.removeIPs(i,r.ips),this.peerStats.delete(i),this.scoreCache.delete(i))})}score(e){this.metrics?.scoreFnCalls.inc();const t=this.peerStats.get(e);if(!t)return 0;const r=Date.now(),i=this.scoreCache.get(e);if(i&&i.cacheUntil>r)return i.score;this.metrics?.scoreFnRuns.inc();const s=this.computeScore(e,t,this.params,this.peerIPs),o=r+this.scoreCacheValidityMs;return i?(this.metrics?.scoreCachedDelta.observe(Math.abs(s-i.score)),i.score=s,i.cacheUntil=o):this.scoreCache.set(e,{score:s,cacheUntil:o}),s}addPenalty(e,t,r){const i=this.peerStats.get(e);i&&(i.behaviourPenalty+=t,this.metrics?.onScorePenalty(r))}addPeer(e){const t={connected:!0,expire:0,topics:{},ips:[],behaviourPenalty:0};this.peerStats.set(e,t);const r=this.getIPs(e);this.setIPs(e,r,t.ips),t.ips=r}removePeer(e){const t=this.peerStats.get(e);if(t){if(this.score(e)>0)return this.removeIPs(e,t.ips),void this.peerStats.delete(e);Object.entries(t.topics).forEach(([r,i])=>{i.firstMessageDeliveries=0;const s=this.params.topics[r].meshMessageDeliveriesThreshold;if(i.inMesh&&i.meshMessageDeliveriesActive&&i.meshMessageDeliveries{o!==e.toString()&&this.markDuplicateMessageDelivery(o,r)})):mu("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,s-i.firstSeen,fi[i.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,i){switch(i){case Ji.Error:return void this.markInvalidMessageDelivery(e,r);case Ji.Blacklisted:return}const s=this.deliveryRecords.ensureRecord(t);if(s.status===fi.unknown)return i===Ji.Ignore?(s.status=fi.ignored,void s.peers.clear()):(s.status=fi.invalid,this.markInvalidMessageDelivery(e,r),s.peers.forEach(o=>{this.markInvalidMessageDelivery(o,r)}),void s.peers.clear());mu("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-s.firstSeen,fi[s.status])}duplicateMessage(e,t,r){const i=this.deliveryRecords.ensureRecord(t);if(!i.peers.has(e))switch(i.status){case fi.unknown:i.peers.add(e);break;case fi.valid:i.peers.add(e),this.markDuplicateMessageDelivery(e,r,i.validated);break;case fi.invalid:this.markInvalidMessageDelivery(e,r)}}markInvalidMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);i&&(i.invalidMessageDeliveries+=1)}}markFirstMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);if(i){let s=this.params.topics[t].firstMessageDeliveriesCap;i.firstMessageDeliveries=Math.min(s,i.firstMessageDeliveries+1),i.inMesh&&(s=this.params.topics[t].meshMessageDeliveriesCap,i.meshMessageDeliveries=Math.min(s,i.meshMessageDeliveries+1))}}}markDuplicateMessageDelivery(e,t,r){const i=this.peerStats.get(e);if(i){const s=void 0!==r?Date.now():0,o=this.getPtopicStats(i,t);if(o&&o.inMesh){const a=this.params.topics[t];if(void 0!==r){const _=s-r,R=_>a.meshMessageDeliveriesWindow;if(this.metrics?.onDuplicateMsgDelivery(t,_,R),R)return}o.meshMessageDeliveries=Math.min(a.meshMessageDeliveriesCap,o.meshMessageDeliveries+1)}}}getIPs(e){return this.components.getConnectionManager().getConnections(fr(e)).map(t=>t.remoteAddr.toOptions().host)}setIPs(e,t,r){e:for(const i of t){for(const o of r)if(i===o)continue e;let s=this.peerIPs.get(i);s||(s=new Set,this.peerIPs.set(i,s)),s.add(e)}e:for(const i of r){for(const o of t)if(i===o)continue e;const s=this.peerIPs.get(i);!s||(s.delete(e),s.size||this.peerIPs.delete(i))}}removeIPs(e,t){t.forEach(r=>{const i=this.peerIPs.get(r);!i||(i.delete(e),i.size||this.peerIPs.delete(r))})}updateIPs(){this.peerStats.forEach((e,t)=>{const r=this.getIPs(t);this.setIPs(t,r,e.ips),e.ips=r})}getPtopicStats(e,t){let r=e.topics[t];return void 0!==r?r:void 0!==this.params.topics[t]?(r={inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e.topics[t]=r,r):null}}class YK{constructor(e,t,r){this.gossipsubIWantFollowupMs=e,this.msgIdToStrFn=t,this.metrics=r,this.promises=new Map,this.requestMsByMsg=new Map,this.requestMsByMsgExpire=10*e}get size(){return this.promises.size}get requestMsByMsgSize(){return this.requestMsByMsg.size}addPromise(e,t){const r=Math.floor(Math.random()*t.length),s=this.msgIdToStrFn(t[r]);let o=this.promises.get(s);o||(o=new Map,this.promises.set(s,o));const a=Date.now();o.has(e)||(o.set(e,a+this.gossipsubIWantFollowupMs),this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(s)||this.requestMsByMsg.set(s,a)))}getBrokenPromises(){const e=Date.now(),t=new Map;let r=0;return this.promises.forEach((i,s)=>{i.forEach((o,a)=>{o=Date.now()?t.value:void 0}clear(){this.entries.clear()}}var _o=(()=>(function(n){n.Fanout="fanout",n.Random="random",n.Subscribed="subscribed",n.Outbound="outbound",n.NotEnough="not_enough",n.Opportunistic="opportunistic"}(_o||(_o={})),_o))(),Fa=(()=>(function(n){n.Dc="disconnected",n.BadScore="bad_score",n.Prune="prune",n.Unsub="unsubscribed",n.Excess="excess"}(Fa||(Fa={})),Fa))(),vu=(()=>(function(n){n.GraftBackoff="graft_backoff",n.BrokenPromise="broken_promise",n.MessageDeficit="message_deficit",n.IPColocation="IP_colocation"}(vu||(vu={})),vu))(),Eu=(()=>(function(n){n.LowScore="low_score",n.MaxIhave="max_ihave",n.MaxIasked="max_iasked"}(Eu||(Eu={})),Eu))(),Ua=(()=>(function(n){n.graylist="graylist",n.publish="publish",n.gossip="gossip",n.mesh="mesh"}(Ua||(Ua={})),Ua))();const qA=Ot("libp2p-pubsub:");function FE(){return FE=$(function*(n,e,t,r){switch(n.type){case Ba.Signing:{const i={from:n.author.toBytes(),data:r,seqno:ih(8),topic:e,signature:void 0,key:void 0},s=br([qA,cp.Message.encode(i).finish()]);return i.signature=yield n.privateKey.sign(s),i.key=n.key,{raw:i,msg:{type:"signed",from:n.author,data:t,sequenceNumber:BigInt(`0x${Lt(i.seqno,"base16")}`),topic:e,signature:i.signature,key:i.key}}}case Ba.Anonymous:return{raw:{from:void 0,data:r,seqno:void 0,topic:e,signature:void 0,key:void 0},msg:{type:"unsigned",data:t,topic:e}}}}),FE.apply(this,arguments)}function UE(){return UE=$(function*(n,e){switch(n){case kE:return null!=e.signature?{valid:!1,error:li.SignaturePresent}:null!=e.seqno?{valid:!1,error:li.SeqnoPresent}:null!=e.key?{valid:!1,error:li.FromPresent}:{valid:!0,message:{type:"unsigned",topic:e.topic,data:e.data??new Uint8Array(0)}};case up:{if(null==e.seqno)return{valid:!1,error:li.InvalidSeqno};if(8!==e.seqno.length)return{valid:!1,error:li.InvalidSeqno};if(null==e.signature)return{valid:!1,error:li.InvalidSignature};if(null==e.from)return{valid:!1,error:li.InvalidPeerId};let t,r;try{t=tu(e.from)}catch{return{valid:!1,error:li.InvalidPeerId}}if(e.key){if(r=Rl(e.key),void 0!==t.publicKey&&!kr(r.bytes,t.publicKey))return{valid:!1,error:li.InvalidPeerId}}else{if(null==t.publicKey)return{valid:!1,error:li.InvalidPeerId};r=Rl(t.publicKey)}const s=br([qA,cp.Message.encode({from:e.from,data:e.data,seqno:e.seqno,topic:e.topic,signature:void 0,key:void 0}).finish()]);return(yield r.verify(s,e.signature))?{valid:!0,message:{type:"signed",from:t,data:e.data??new Uint8Array(0),sequenceNumber:BigInt(`0x${Lt(e.seqno,"base16")}`),topic:e.topic,signature:e.signature,key:e.key??sT(r)}}:{valid:!1,error:li.InvalidSignature}}}}),UE.apply(this,arguments)}function n$(n){if("signed"!==n.type)throw new Error("expected signed message type");if(null==n.sequenceNumber)throw Error("missing seqno field");return((n,e)=>{const t=Ot(e.toString(16).padStart(16,"0"),"base16"),r=new Uint8Array(n.length+t.length);return r.set(n,0),r.set(t,n.length),r})(n.from.toBytes(),n.sequenceNumber)}function r$(n){return VE.apply(this,arguments)}function VE(){return VE=$(function*(n){return yield mi.encode(n.data)}),VE.apply(this,arguments)}function i$(n,e,t,r,i){let s=0;const o=new Map;if(Object.entries(e.topics).forEach(([B,z])=>{const X=i.get(B)??"unknown",J=t.topics[B];if(void 0===J)return;let oe=o.get(X);oe||(oe={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},o.set(X,oe));let de=0,xe=0,ue=0,Te=0,Ke=0;z.inMesh&&(de+=Math.max(z.meshTime/J.timeInMeshQuantum,J.timeInMeshCap)*J.timeInMeshWeight);let Pe=z.firstMessageDeliveries;if(Pe>J.firstMessageDeliveriesCap&&(Pe=J.firstMessageDeliveriesCap),xe+=Pe*J.firstMessageDeliveriesWeight,z.meshMessageDeliveriesActive&&z.meshMessageDeliveries0&&s>t.topicScoreCap){s=t.topicScoreCap;const B=t.topicScoreCap/s;for(const z of o.values())z.p1w*=B,z.p2w*=B,z.p3w*=B,z.p3bw*=B,z.p4w*=B}let a=0,u=0,_=0;return a+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(B=>{if(t.IPColocationFactorWhitelist.has(B))return;const z=r.get(B),X=z?z.size:0;if(X>t.IPColocationFactorThreshold){const J=X-t.IPColocationFactorThreshold;u+=J*J*t.IPColocationFactorWeight}}),_+=e.behaviourPenalty*e.behaviourPenalty*t.behaviourPenaltyWeight,s+=a+u+_,{byTopic:o,p5w:a,p6w:u,p7w:_,score:s}}function HE(n,e,t=(()=>!0)){const r=new Set;if(e<=0)return r;for(const i of n){if(r.size>=e)break;t(i)&&(r.add(i),n.delete(i))}return r}class a${constructor(e,t,r){this.rawStream=e,this.pushable=kc({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=r.maxBufferSize??1/0,qn(vs(this.pushable,this.closeController.signal,{returnOnAbort:!0}),ks(),this.rawStream).catch(t)}get protocol(){return this.rawStream.stat.protocol}push(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);this.pushable.push(e)}close(){this.closeController.abort(),this.pushable.return(),this.rawStream.close()}}class c${constructor(e){this.rawStream=e,this.closeController=new AbortController,this.source=vs(qn(this.rawStream,ps()),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}}var _i=(()=>(function(n){n[n.started=0]="started",n[n.stopped=1]="stopped"}(_i||(_i={})),_i))();class YA extends Ei{constructor(e={}){super(),this.multicodecs=[OE,zA],this.peers=new Set,this.streamsInbound=new Map,this.streamsOutbound=new Map,this.outboundInflightQueue=kc({objectMode:!0}),this.direct=new Set,this.floodsubPeers=new Set,this.acceptFromWhitelist=new Map,this.topics=new Map,this.subscriptions=new Set,this.mesh=new Map,this.fanout=new Map,this.fanoutLastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.topicValidators=new Map,this.heartbeatTicks=0,this.components=new ho,this.directPeerInitial=null,this.status={code:_i.stopped},this.heartbeatTimer=null,this.runHeartbeat=()=>{const r=this.metrics?.heartbeatDuration.startTimer();this.heartbeat().catch(i=>{this.log("Error running heartbeat",i)}).finally(()=>{if(r?.(),this.status.code===_i.started){clearTimeout(this.status.heartbeatTimeout);let i=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;i<.25*this.opts.heartbeatInterval&&(i+=this.opts.heartbeatInterval,this.metrics?.heartbeatSkipped.inc()),this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,i)}})};const t={fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:6,Dlo:4,Dhi:12,Dscore:4,Dout:2,Dlazy:6,heartbeatInterval:1e3,fanoutTTL:6e4,mcacheLength:5,mcacheGossip:3,seenTTL:12e4,gossipsubIWantFollowupMs:3e3,prunePeers:16,pruneBackoff:6e4,graftFloodThreshold:1e4,opportunisticGraftPeers:2,opportunisticGraftTicks:60,directConnectTicks:300,...e,scoreParams:UK(e.scoreParams),scoreThresholds:jK(e.scoreThresholds)};if(this.globalSignaturePolicy=t.globalSignaturePolicy??up,t.fallbackToFloodsub&&this.multicodecs.push(jA),this.log=zt(t.debugName??"libp2p:gossipsub"),this.opts=t,this.direct=new Set(t.directPeers.map(r=>r.id.toString())),this.seenCache=new BE({validityMs:t.seenTTL}),this.publishedMessageIds=new BE({validityMs:t.seenTTL}),e.msgIdFn)this.msgIdFn=e.msgIdFn;else switch(this.globalSignaturePolicy){case up:this.msgIdFn=n$;break;case kE:this.msgIdFn=r$}if(e.fastMsgIdFn&&(this.fastMsgIdFn=e.fastMsgIdFn,this.fastMsgIdCache=new BE({validityMs:t.seenTTL})),this.msgIdToStrFn=e.msgIdToStrFn??kK,this.mcache=e.messageCache||new rK(t.mcacheGossip,t.mcacheLength,this.msgIdToStrFn),e.dataTransform&&(this.dataTransform=e.dataTransform),e.metricsRegister){if(!e.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");const r=Math.max(...Object.values(t.scoreParams.topics).map(s=>s.meshMessageDeliveriesWindow),1e3),i=function QK(n,e,t){return{protocolsEnabled:n.gauge({name:"gossipsub_protocol",help:"Status of enabled protocols",labelNames:["protocol"]}),topicSubscriptionStatus:n.gauge({name:"gossipsub_topic_subscription_status",help:"Status of our subscription to this topic",labelNames:["topicStr"]}),topicPeersCount:n.gauge({name:"gossipsub_topic_peer_count",help:"Number of peers subscribed to each topic",labelNames:["topicStr"]}),meshPeerCounts:n.gauge({name:"gossipsub_mesh_peer_count",help:"Number of peers in our mesh",labelNames:["topicStr"]}),meshPeerInclusionEvents:n.gauge({name:"gossipsub_mesh_peer_inclusion_events_total",help:"Number of times we include peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),meshPeerChurnEvents:n.gauge({name:"gossipsub_peer_churn_events_total",help:"Number of times we remove peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),peersPerProtocol:n.gauge({name:"gossipsub_peers_per_protocol_count",help:"Peers connected for each topic",labelNames:["protocol"]}),heartbeatDuration:n.histogram({name:"gossipsub_heartbeat_duration_seconds",help:"The time it takes to complete one iteration of the heartbeat",buckets:[.01,.1,1]}),heartbeatSkipped:n.gauge({name:"gossipsub_heartbeat_skipped",help:"Heartbeat run took longer than heartbeat interval so next is skipped"}),asyncValidationResult:n.gauge({name:"gossipsub_async_validation_result_total",help:"Message validation result for each topic",labelNames:["topic","acceptance"]}),asyncValidationMcacheHit:n.gauge({name:"gossipsub_async_validation_mcache_hit_total",help:"Async validation result reported by the user layer",labelNames:["hit"]}),rpcRecvBytes:n.gauge({name:"gossipsub_rpc_recv_bytes_total",help:"RPC recv"}),rpcRecvCount:n.gauge({name:"gossipsub_rpc_recv_count_total",help:"RPC recv"}),rpcRecvSubscription:n.gauge({name:"gossipsub_rpc_recv_subscription_total",help:"RPC recv"}),rpcRecvMessage:n.gauge({name:"gossipsub_rpc_recv_message_total",help:"RPC recv"}),rpcRecvControl:n.gauge({name:"gossipsub_rpc_recv_control_total",help:"RPC recv"}),rpcRecvIHave:n.gauge({name:"gossipsub_rpc_recv_ihave_total",help:"RPC recv"}),rpcRecvIWant:n.gauge({name:"gossipsub_rpc_recv_iwant_total",help:"RPC recv"}),rpcRecvGraft:n.gauge({name:"gossipsub_rpc_recv_graft_total",help:"RPC recv"}),rpcRecvPrune:n.gauge({name:"gossipsub_rpc_recv_prune_total",help:"RPC recv"}),rpcRecvNotAccepted:n.gauge({name:"gossipsub_rpc_rcv_not_accepted_total",help:"Total count of RPC dropped because acceptFrom() == false"}),rpcSentBytes:n.gauge({name:"gossipsub_rpc_sent_bytes_total",help:"RPC sent"}),rpcSentCount:n.gauge({name:"gossipsub_rpc_sent_count_total",help:"RPC sent"}),rpcSentSubscription:n.gauge({name:"gossipsub_rpc_sent_subscription_total",help:"RPC sent"}),rpcSentMessage:n.gauge({name:"gossipsub_rpc_sent_message_total",help:"RPC sent"}),rpcSentControl:n.gauge({name:"gossipsub_rpc_sent_control_total",help:"RPC sent"}),rpcSentIHave:n.gauge({name:"gossipsub_rpc_sent_ihave_total",help:"RPC sent"}),rpcSentIWant:n.gauge({name:"gossipsub_rpc_sent_iwant_total",help:"RPC sent"}),rpcSentGraft:n.gauge({name:"gossipsub_rpc_sent_graft_total",help:"RPC sent"}),rpcSentPrune:n.gauge({name:"gossipsub_rpc_sent_prune_total",help:"RPC sent"}),msgPublishCount:n.gauge({name:"gossipsub_msg_publish_count_total",help:"Total count of msg published by topic",labelNames:["topic"]}),msgPublishPeers:n.gauge({name:"gossipsub_msg_publish_peers_total",help:"Total count of peers that we publish a msg to",labelNames:["topic"]}),msgPublishPeersByGroup:n.gauge({name:"gossipsub_msg_publish_peers_by_group",help:"Total count of peers (by group) that we publish a msg to",labelNames:["topic","peerGroup"]}),msgPublishBytes:n.gauge({name:"gossipsub_msg_publish_bytes_total",help:"Total count of msg publish data.length bytes",labelNames:["topic"]}),msgForwardCount:n.gauge({name:"gossipsub_msg_forward_count_total",help:"Total count of msg forwarded by topic",labelNames:["topic"]}),msgForwardPeers:n.gauge({name:"gossipsub_msg_forward_peers_total",help:"Total count of peers that we forward a msg to",labelNames:["topic"]}),msgReceivedPreValidation:n.gauge({name:"gossipsub_msg_received_prevalidation_total",help:"Total count of recv msgs before any validation",labelNames:["topic"]}),msgReceivedStatus:n.gauge({name:"gossipsub_msg_received_status_total",help:"Tracks distribution of recv msgs by duplicate, invalid, valid",labelNames:["topic","status"]}),msgReceivedInvalid:n.gauge({name:"gossipsub_msg_received_invalid_total",help:"Tracks specific reason of invalid",labelNames:["topic","error"]}),duplicateMsgDeliveryDelay:n.histogram({name:"gossisub_duplicate_msg_delivery_delay_seconds",help:"Time since the 1st duplicated message validated",labelNames:["topic"],buckets:[.25*t.maxMeshMessageDeliveriesWindowSec,.5*t.maxMeshMessageDeliveriesWindowSec,1*t.maxMeshMessageDeliveriesWindowSec,2*t.maxMeshMessageDeliveriesWindowSec,4*t.maxMeshMessageDeliveriesWindowSec]}),duplicateMsgLateDelivery:n.gauge({name:"gossisub_duplicate_msg_late_delivery_total",help:"Total count of late duplicate message delivery by topic, which triggers P3 penalty",labelNames:["topic"]}),scoreFnCalls:n.gauge({name:"gossipsub_score_fn_calls_total",help:"Total times score() is called"}),scoreFnRuns:n.gauge({name:"gossipsub_score_fn_runs_total",help:"Total times score() call actually computed computeScore(), no cache"}),scoreCachedDelta:n.histogram({name:"gossipsub_score_cache_delta",help:"Delta of score between cached values that expired",buckets:[10,100,1e3]}),peersByScoreThreshold:n.gauge({name:"gossipsub_peers_by_score_threshold_count",help:"Current count of peers by score threshold",labelNames:["threshold"]}),score:n.avgMinMax({name:"gossipsub_score",help:"Avg min max of gossip scores",labelNames:["topic","p"]}),scoreWeights:n.avgMinMax({name:"gossipsub_score_weights",help:"Separate score weights",labelNames:["topic","p"]}),scorePerMesh:n.avgMinMax({name:"gossipsub_score_per_mesh",help:"Histogram of the scores for each mesh topic",labelNames:["topic"]}),scoringPenalties:n.gauge({name:"gossipsub_scoring_penalties_total",help:"A counter of the kind of penalties being applied to peers",labelNames:["penalty"]}),behaviourPenalty:n.histogram({name:"gossipsub_peer_stat_behaviour_penalty",help:"Current peer stat behaviour_penalty at each scrape",buckets:[.25*t.behaviourPenaltyThreshold,.5*t.behaviourPenaltyThreshold,1*t.behaviourPenaltyThreshold,2*t.behaviourPenaltyThreshold,4*t.behaviourPenaltyThreshold]}),ihaveRcvIgnored:n.gauge({name:"gossipsub_ihave_rcv_ignored_total",help:"Total received IHAVE messages that we ignore for some reason",labelNames:["reason"]}),ihaveRcvMsgids:n.gauge({name:"gossipsub_ihave_rcv_msgids_total",help:"Total received IHAVE messages by topic",labelNames:["topic"]}),ihaveRcvNotSeenMsgids:n.gauge({name:"gossipsub_ihave_rcv_not_seen_msgids_total",help:"Total messages per topic we do not have, not actual requests",labelNames:["topic"]}),iwantRcvMsgids:n.gauge({name:"gossipsub_iwant_rcv_msgids_total",help:"Total received IWANT messages by topic",labelNames:["topic"]}),iwantRcvDonthaveMsgids:n.gauge({name:"gossipsub_iwant_rcv_dont_have_msgids_total",help:"Total requested messageIDs that we do not have"}),iwantPromiseStarted:n.gauge({name:"gossipsub_iwant_promise_sent_total",help:"Total count of started IWANT promises"}),iwantPromiseResolved:n.gauge({name:"gossipsub_iwant_promise_resolved_total",help:"Total count of resolved IWANT promises"}),iwantPromiseResolvedPeers:n.gauge({name:"gossipsub_iwant_promise_resolved_peers",help:"Total count of peers we have asked IWANT promises that are resolved"}),iwantPromiseBroken:n.gauge({name:"gossipsub_iwant_promise_broken",help:"Total count of broken IWANT promises"}),iwantPromiseDeliveryTime:n.histogram({name:"gossipsub_iwant_promise_delivery_seconds",help:"Histogram of delivery time of resolved IWANT promises",buckets:[.5*t.gossipPromiseExpireSec,1*t.gossipPromiseExpireSec,2*t.gossipPromiseExpireSec,4*t.gossipPromiseExpireSec]}),cacheSize:n.gauge({name:"gossipsub_cache_size",help:"Unbounded cache sizes",labelNames:["cache"]}),mcacheSize:n.gauge({name:"gossipsub_mcache_size",help:"Current mcache msg count"}),topicStrToLabel:e,toTopic(r){return this.topicStrToLabel.get(r)??r},onJoin(r){this.topicSubscriptionStatus.set({topicStr:r},1),this.meshPeerCounts.set({topicStr:r},0)},onLeave(r){this.topicSubscriptionStatus.set({topicStr:r},0),this.meshPeerCounts.set({topicStr:r},0)},onAddToMesh(r,i,s){const o=this.toTopic(r);this.meshPeerInclusionEvents.inc({topic:o,reason:i},s)},onRemoveFromMesh(r,i,s){const o=this.toTopic(r);this.meshPeerChurnEvents.inc({topic:o,reason:i},s)},onReportValidationMcacheHit(r){this.asyncValidationMcacheHit.inc({hit:r?"hit":"miss"})},onReportValidation(r,i){const s=this.toTopic(r);this.asyncValidationResult.inc({topic:s,acceptance:i})},onScorePenalty(r){this.scoringPenalties.inc({penalty:r},1)},onIhaveRcv(r,i,s){const o=this.toTopic(r);this.ihaveRcvMsgids.inc({topic:o},i),this.ihaveRcvNotSeenMsgids.inc({topic:o},s)},onIwantRcv(r,i){for(const[s,o]of r){const a=this.toTopic(s);this.iwantRcvMsgids.inc({topic:a},o)}this.iwantRcvDonthaveMsgids.inc(i)},onForwardMsg(r,i){const s=this.toTopic(r);this.msgForwardCount.inc({topic:s},1),this.msgForwardPeers.inc({topic:s},i)},onPublishMsg(r,i,s,o){const a=this.toTopic(r);this.msgPublishCount.inc({topic:a},1),this.msgPublishBytes.inc({topic:a},s*o),this.msgPublishPeers.inc({topic:a},s),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"direct"},i.direct),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"floodsub"},i.floodsub),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"mesh"},i.mesh),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"fanout"},i.fanout)},onMsgRecvPreValidation(r){const i=this.toTopic(r);this.msgReceivedPreValidation.inc({topic:i},1)},onMsgRecvResult(r,i){const s=this.toTopic(r);this.msgReceivedStatus.inc({topic:s,status:i})},onMsgRecvInvalid(r,i){const s=this.toTopic(r);this.msgReceivedInvalid.inc({topic:s,error:i.reason===Ji.Error?i.error:i.reason},1)},onDuplicateMsgDelivery(r,i,s){if(this.duplicateMsgDeliveryDelay.observe(i/1e3),s){const o=this.toTopic(r);this.duplicateMsgLateDelivery.inc({topic:o},1)}},onRpcRecv(r,i){this.rpcRecvBytes.inc(i),this.rpcRecvCount.inc(1),r.subscriptions&&this.rpcRecvSubscription.inc(r.subscriptions.length),r.messages&&this.rpcRecvMessage.inc(r.messages.length),r.control&&(this.rpcRecvControl.inc(1),r.control.ihave&&this.rpcRecvIHave.inc(r.control.ihave.length),r.control.iwant&&this.rpcRecvIWant.inc(r.control.iwant.length),r.control.graft&&this.rpcRecvGraft.inc(r.control.graft.length),r.control.prune&&this.rpcRecvPrune.inc(r.control.prune.length))},onRpcSent(r,i){if(this.rpcSentBytes.inc(i),this.rpcSentCount.inc(1),r.subscriptions&&this.rpcSentSubscription.inc(r.subscriptions.length),r.messages&&this.rpcSentMessage.inc(r.messages.length),r.control){const s=r.control.ihave?.length??0,o=r.control.iwant?.length??0,a=r.control.graft?.length??0,u=r.control.prune?.length??0;s>0&&this.rpcSentIHave.inc(s),o>0&&this.rpcSentIWant.inc(o),a>0&&this.rpcSentGraft.inc(a),u>0&&this.rpcSentPrune.inc(u),(s>0||o>0||a>0||u>0)&&this.rpcSentControl.inc(1)}},registerScores(r,i){let s=0,o=0,a=0,u=0;for(const _ of r)_>=i.graylistThreshold&&s++,_>=i.publishThreshold&&o++,_>=i.gossipThreshold&&a++,_>=0&&u++;this.peersByScoreThreshold.set({threshold:Ua.graylist},s),this.peersByScoreThreshold.set({threshold:Ua.publish},o),this.peersByScoreThreshold.set({threshold:Ua.gossip},a),this.peersByScoreThreshold.set({threshold:Ua.mesh},u),this.score.set(r)},registerScoreWeights(r){for(const[i,s]of r.byTopic)this.scoreWeights.set({topic:i,p:"p1"},s.p1w),this.scoreWeights.set({topic:i,p:"p2"},s.p2w),this.scoreWeights.set({topic:i,p:"p3"},s.p3w),this.scoreWeights.set({topic:i,p:"p3b"},s.p3bw),this.scoreWeights.set({topic:i,p:"p4"},s.p4w);this.scoreWeights.set({p:"p5"},r.p5w),this.scoreWeights.set({p:"p6"},r.p6w),this.scoreWeights.set({p:"p7"},r.p7w)},registerScorePerMesh(r,i){const s=new Map;r.forEach((o,a)=>{const u=this.topicStrToLabel.get(a)??"unknown";let _=s.get(u);_||(_=new Set,s.set(u,_)),o.forEach(R=>_?.add(R))});for(const[o,a]of s){const u=[];a.forEach(_=>{u.push(i.get(_)??0)}),this.scorePerMesh.set({topic:o},u)}}}}(e.metricsRegister,e.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:t.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:r/1e3});i.mcacheSize.addCollect(()=>this.onScrapeMetrics(i));for(const s of this.multicodecs)i.protocolsEnabled.set({protocol:s},1);this.metrics=i}else this.metrics=null;this.gossipTracer=new YK(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new qK(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:t.heartbeatInterval}),this.maxInboundStreams=e.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams}getPeers(){return[...this.peers.keys()].map(e=>fr(e))}isStarted(){return this.status.code===_i.started}init(e){var t=this;return $(function*(){t.components=e,t.score.init(e)})()}start(){var e=this;return $(function*(){if(e.isStarted())return;e.log("starting"),e.publishConfig=yield function LK(n,e){return LE.apply(this,arguments)}(e.globalSignaturePolicy,e.components.getPeerId()),e.outboundInflightQueue=kc({objectMode:!0}),qn(e.outboundInflightQueue,function(){var o=$(function*(a){var R,u=!1,_=!1;try{for(var B,N=Pt(a);u=!(B=yield N.next()).done;u=!1){const{peerId:z,connection:X}=B.value;yield e.createOutboundStream(z,X)}}catch(z){_=!0,R=z}finally{try{u&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()).catch(o=>e.log.error("outbound inflight queue error",o)),yield Promise.all(e.opts.directPeers.map(function(){var o=$(function*(a){yield e.components.getPeerStore().addressBook.add(a.id,a.addrs)});return function(a){return o.apply(this,arguments)}}()));const t=e.components.getRegistrar();yield Promise.all(e.multicodecs.map(o=>t.handle(o,e.onIncomingStream.bind(e),{maxInboundStreams:e.maxInboundStreams,maxOutboundStreams:e.maxOutboundStreams})));const r=function nK(n){return new tK(n)}({onConnect:e.onPeerConnected.bind(e),onDisconnect:e.onPeerDisconnected.bind(e)}),i=yield Promise.all(e.multicodecs.map(o=>t.register(o,r))),s=setTimeout(e.runHeartbeat,100);e.status={code:_i.started,registrarTopologyIds:i,heartbeatTimeout:s,hearbeatStartMs:Date.now()+100},e.score.start(),e.directPeerInitial=setTimeout(()=>{Promise.resolve().then($(function*(){yield Promise.all(Array.from(e.direct).map(function(){var o=$(function*(a){return yield e.connect(a)});return function(a){return o.apply(this,arguments)}}()))})).catch(o=>{e.log(o)})},1e3),e.log("started")})()}stop(){var e=this;return $(function*(){if(e.log("stopping"),e.status.code!==_i.started)return;const{registrarTopologyIds:t}=e.status;e.status={code:_i.stopped};const r=e.components.getRegistrar();t.forEach(i=>r.unregister(i)),e.outboundInflightQueue.end();for(const i of e.streamsOutbound.values())i.close();e.streamsOutbound.clear();for(const i of e.streamsInbound.values())i.close();e.streamsInbound.clear(),e.peers.clear(),e.subscriptions.clear(),e.heartbeatTimer&&(e.heartbeatTimer.cancel(),e.heartbeatTimer=null),e.score.stop(),e.mesh.clear(),e.fanout.clear(),e.fanoutLastpub.clear(),e.gossip.clear(),e.control.clear(),e.peerhave.clear(),e.iasked.clear(),e.backoff.clear(),e.outbound.clear(),e.gossipTracer.clear(),e.seenCache.clear(),e.fastMsgIdCache&&e.fastMsgIdCache.clear(),e.directPeerInitial&&clearTimeout(e.directPeerInitial),e.log("stopped")})()}dumpPeerScoreStats(){return this.score.dumpPeerScoreStats()}onIncomingStream({stream:e,connection:t}){if(!this.isStarted())return;const r=t.remotePeer;this.addPeer(r,t.stat.direction),this.createInboundStream(r,e),this.outboundInflightQueue.push({peerId:r,connection:t})}onPeerConnected(e,t){!this.isStarted()||(this.addPeer(e,t.stat.direction),this.outboundInflightQueue.push({peerId:e,connection:t}))}onPeerDisconnected(e){this.log("connection ended %p",e),this.removePeer(e)}createOutboundStream(e,t){var r=this;return $(function*(){if(!r.isStarted())return;const i=e.toString();if(r.peers.has(i)&&!r.streamsOutbound.has(i))try{const s=new a$(yield t.newStream(r.multicodecs),a=>r.log.error("outbound pipe error",a),{maxBufferSize:r.opts.maxOutboundBufferSize});r.log("create outbound stream %p",e),r.streamsOutbound.set(i,s);const o=s.protocol;o===jA&&r.floodsubPeers.add(i),r.metrics?.peersPerProtocol.inc({protocol:o},1),r.subscriptions.size>0&&(r.log("send subscriptions to",i),r.sendSubscriptions(i,Array.from(r.subscriptions),!0))}catch(s){r.log.error("createOutboundStream error",s)}})()}createInboundStream(e,t){var r=this;return $(function*(){if(!r.isStarted())return;const i=e.toString();if(!r.peers.has(i))return;const s=r.streamsInbound.get(i);void 0!==s&&(r.log("replacing existing inbound steam %s",i),s.close()),r.log("create inbound stream %s",i);const o=new c$(t);r.streamsInbound.set(i,o),r.pipePeerReadStream(e,o.source).catch(a=>r.log(a))})()}addPeer(e,t){const r=e.toString();this.peers.has(r)||(this.log("new peer %p",e),this.peers.add(r),this.score.addPeer(r),this.outbound.has(r)||this.outbound.set(r,"outbound"===t))}removePeer(e){const t=e.toString();if(!this.peers.has(t))return;this.log("delete peer %p",e),this.peers.delete(t);const r=this.streamsOutbound.get(t),i=this.streamsInbound.get(t);r&&this.metrics?.peersPerProtocol.inc({protocol:r.protocol},-1),r?.close(),i?.close(),this.streamsOutbound.delete(t),this.streamsInbound.delete(t);for(const s of this.topics.values())s.delete(t);for(const[s,o]of this.mesh)!0===o.delete(t)&&this.metrics?.onRemoveFromMesh(s,Fa.Dc,1);for(const s of this.fanout.values())s.delete(t);this.floodsubPeers.delete(t),this.gossip.delete(t),this.control.delete(t),this.outbound.delete(t),this.score.removePeer(t),this.acceptFromWhitelist.delete(t)}get started(){return this.status.code===_i.started}getMeshPeers(e){const t=this.mesh.get(e);return t?Array.from(t):[]}getSubscribers(e){const t=this.topics.get(e);return(t?Array.from(t):[]).map(r=>fr(r))}getTopics(){return Array.from(this.subscriptions)}pipePeerReadStream(e,t){var r=this;return $(function*(){try{yield qn(t,function(){var i=$(function*(s){var u,o=!1,a=!1;try{for(var R,_=Pt(s);o=!(R=yield _.next()).done;o=!1){const N=R.value;try{const B=N.subarray(),z=cp.decode(B);r.metrics?.onRpcRecv(z,B.length),r.opts.awaitRpcHandler?yield r.handleReceivedRpc(e,z):r.handleReceivedRpc(e,z).catch(X=>r.log(X))}catch(B){r.log(B)}}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw u}}});return function(s){return i.apply(this,arguments)}}())}catch(i){r.log.error(i),r.onPeerDisconnected(e)}})()}handleReceivedRpc(e,t){var r=this;return $(function*(){if(!r.acceptFrom(e.toString()))return r.log("received message from unacceptable peer %p",e),void r.metrics?.rpcRecvNotAccepted.inc();if(r.log("rpc from %p",e),t.subscriptions&&t.subscriptions.length>0&&(t.subscriptions.forEach(i=>{r.handleReceivedSubscription(e,i)}),r.dispatchEvent(new nn("subscription-change",{detail:{peerId:e,subscriptions:t.subscriptions.filter(i=>null!==i.topic).map(i=>({topic:i.topic??"",subscribe:Boolean(i.subscribe)}))}}))),t.messages)for(const i of t.messages){const s=r.handleReceivedMessage(e,i).catch(o=>r.log(o));r.opts.awaitRpcMessageHandler&&(yield s)}t.control&&(yield r.handleControlMessage(e.toString(),t.control))})()}handleReceivedSubscription(e,t){if(null==t.topic)return;this.log("subscription update from %p topic %s",e,t.topic);let r=this.topics.get(t.topic);null==r&&(r=new Set,this.topics.set(t.topic,r)),t.subscribe?r.add(e.toString()):r.delete(e.toString())}handleReceivedMessage(e,t){var r=()=>super.dispatchEvent,i=this;return $(function*(){i.metrics?.onMsgRecvPreValidation(t.topic);const s=yield i.validateReceivedMessage(e,t);switch(i.metrics?.onMsgRecvResult(t.topic,s.code),s.code){case es.duplicate:return i.score.duplicateMessage(e.toString(),s.msgIdStr,t.topic),void i.mcache.observeDuplicate(s.msgIdStr,e.toString());case es.invalid:if(s.msgIdStr){const o=s.msgIdStr;i.score.rejectMessage(e.toString(),o,t.topic,s.reason),i.gossipTracer.rejectMessage(o,s.reason)}else i.score.rejectInvalidMessage(e.toString(),t.topic);return void i.metrics?.onMsgRecvInvalid(t.topic,s);case es.valid:i.score.validateMessage(s.messageId.msgIdStr),i.gossipTracer.deliverMessage(s.messageId.msgIdStr),i.mcache.put(s.messageId,t,!i.opts.asyncValidation),i.subscriptions.has(t.topic)&&(!i.components.getPeerId().equals(e)||i.opts.emitSelf)&&(r().call(i,new nn("gossipsub:message",{detail:{propagationSource:e,msgId:s.messageId.msgIdStr,msg:s.msg}})),r().call(i,new nn("message",{detail:s.msg}))),i.opts.asyncValidation||i.forwardMessage(s.messageId.msgIdStr,t,e.toString())}})()}validateReceivedMessage(e,t){var r=this;return $(function*(){const i=r.fastMsgIdFn?.(t),s=i?r.fastMsgIdCache?.get(i):void 0;if(s)return{code:es.duplicate,msgIdStr:s};const o=yield function XK(n,e){return UE.apply(this,arguments)}(r.globalSignaturePolicy,t);if(!o.valid)return{code:es.invalid,reason:Ji.Error,error:o.error};const a=o.message;try{r.dataTransform&&(a.data=r.dataTransform.inboundTransform(t.topic,a.data))}catch(B){return r.log("Invalid message, transform failed",B),{code:es.invalid,reason:Ji.Error,error:li.TransformFailed}}const u=yield r.msgIdFn(a),_=r.msgIdToStrFn(u),R={msgId:u,msgIdStr:_};if(i&&r.fastMsgIdCache?.put(i,_),r.seenCache.has(_))return{code:es.duplicate,msgIdStr:_};r.seenCache.put(_);const N=r.topicValidators.get(t.topic);if(null!=N){let B;try{B=yield N(a.topic,a,e)}catch(z){const X=z.code;"ERR_TOPIC_VALIDATOR_IGNORE"===X&&(B=js.Ignore),B="ERR_TOPIC_VALIDATOR_REJECT"===X?js.Reject:js.Ignore}if(B!==js.Accept)return{code:es.invalid,reason:WA(B),msgIdStr:_}}return{code:es.valid,messageId:R,msg:a}})()}getScore(e){return this.score.score(e)}sendSubscriptions(e,t,r){this.sendRpc(e,{subscriptions:t.map(i=>({topic:i,subscribe:r})),messages:[]})}handleControlMessage(e,t){var r=this;return $(function*(){if(void 0===t)return;const i=t.ihave?r.handleIHave(e,t.ihave):[],s=t.iwant?r.handleIWant(e,t.iwant):[],o=t.graft?yield r.handleGraft(e,t.graft):[];t.prune&&(yield r.handlePrune(e,t.prune)),(i.length||s.length||o.length)&&r.sendRpc(e,bo(s,{iwant:i,prune:o}))})()}acceptFrom(e){if(this.direct.has(e))return!0;const t=Date.now(),r=this.acceptFromWhitelist.get(e);if(r&&r.messagesAccepted<128&&r.acceptUntil>=t)return r.messagesAccepted+=1,!0;const i=this.score.score(e);return i>=0?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+1e3}):this.acceptFromWhitelist.delete(e),i>=this.opts.scoreThresholds.graylistThreshold}handleIHave(e,t){if(!t.length)return[];const r=this.score.score(e);if(r10)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,i),this.metrics?.ihaveRcvIgnored.inc({reason:Eu.MaxIhave}),[];const s=this.iasked.get(e)??0;if(s>=yu)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,s),this.metrics?.ihaveRcvIgnored.inc({reason:Eu.MaxIasked}),[];const o=new Map;if(t.forEach(({topicID:_,messageIDs:R})=>{if(!_||!R||!this.mesh.has(_))return;let N=0;R.forEach(B=>{const z=this.msgIdToStrFn(B);this.seenCache.has(z)||(o.set(z,B),N++)}),this.metrics?.onIhaveRcv(_,R.length,N)}),!o.size)return[];let a=o.size;a+s>yu&&(a=yu-s),this.log("IHAVE: Asking for %d out of %d messages from %s",a,o.size,e);let u=Array.from(o.values());return wo(u),u=u.slice(0,a),this.iasked.set(e,s+a),this.gossipTracer.addPromise(e,u),[{messageIDs:u}]}handleIWant(e,t){if(!t.length)return[];const r=this.score.score(e);if(r{a&&a.forEach(u=>{const _=this.msgIdToStrFn(u),R=this.mcache.getWithIWantCount(_,e);null!=R?(s.set(R.msg.topic,1+(s.get(R.msg.topic)??0)),R.count>3?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,u):i.set(_,R.msg)):o++})}),this.metrics?.onIwantRcv(s,o),i.size?(this.log("IWANT: Sending %d messages to %s",i.size,e),Array.from(i.values())):(this.log("IWANT: Could not provide any wanted messages to %s",e),[])}handleGraft(e,t){var r=this;return $(function*(){const i=[],s=r.score.score(e),o=Date.now();let a=r.opts.doPX;return t.forEach(({topicID:u})=>{if(!u)return;const _=r.mesh.get(u);if(!_)return void(a=!1);if(_.has(e))return;if(r.direct.has(e))return r.log("GRAFT: ignoring request from direct peer %s",e),i.push(u),void(a=!1);const R=r.backoff.get(u)?.get(e);return"number"==typeof R&&o=r.opts.Dhi&&!r.outbound.get(e)?(i.push(u),void r.addBackoff(e,u)):(r.log("GRAFT: Add mesh link from %s in %s",e,u),r.score.graft(e,u),_.add(e),void r.metrics?.onAddToMesh(u,_o.Subscribed,1))}),i.length?yield Promise.all(i.map(u=>r.makePrune(e,u,a))):[]})()}handlePrune(e,t){var r=this;return $(function*(){const i=r.score.score(e);for(const{topicID:s,backoff:o,peers:a}of t){if(null==s)continue;const u=r.mesh.get(s);if(!u)return;if(r.log("PRUNE: Remove mesh link to %s in %s",e,s),r.score.prune(e,s),u.has(e)&&(u.delete(e),r.metrics?.onRemoveFromMesh(s,Fa.Unsub,1)),"number"==typeof o&&o>0?r.doAddBackoff(e,s,1e3*o):r.addBackoff(e,s),a&&a.length){if(i{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",t,e),this.score.addPenalty(t,e,vu.BrokenPromise)})}clearBackoff(){if(this.heartbeatTicks%15!=0)return;const e=Date.now();this.backoff.forEach((t,r)=>{t.forEach((i,s)=>{i{e.streamsOutbound.has(r)||t.push(r)}),yield Promise.all(t.map(function(){var r=$(function*(i){return yield e.connect(i)});return function(i){return r.apply(this,arguments)}}()))})()}pxConnect(e){var t=this;return $(function*(){e.length>t.opts.prunePeers&&(wo(e),e=e.slice(0,t.opts.prunePeers));const r=[];yield Promise.all(e.map(function(){var i=$(function*(s){if(!s.peerID)return;const o=tu(s.peerID).toString();if(!t.peers.has(o)){if(!s.signedPeerRecord)return void r.push(o);try{const a=yield wi.openAndCertify(s.signedPeerRecord,"libp2p-peer-record"),u=a.peerId;if(!a.peerId.equals(o))return void t.log("bogus peer record obtained through px: peer ID %p doesn't match expected peer %p",u,o);if(!(yield t.components.getPeerStore().addressBook.consumePeerRecord(a)))return void t.log("bogus peer record obtained through px: could not add peer record to address book");r.push(o)}catch{t.log("bogus peer record obtained through px: invalid signature or not a peer record")}}});return function(s){return i.apply(this,arguments)}}())),r.length&&(yield Promise.all(r.map(function(){var i=$(function*(s){return yield t.connect(s)});return function(s){return i.apply(this,arguments)}}())))})()}connect(e){var t=this;return $(function*(){t.log("Initiating connection with %s",e);const r=fr(e),i=yield t.components.getConnectionManager().openConnection(r);for(const s of t.multicodecs)for(const o of t.components.getRegistrar().getTopologies(s))o.onConnect(r,i)})()}subscribe(e){if(this.status.code!==_i.started)throw new Error("Pubsub has not started");if(!this.subscriptions.has(e)){this.subscriptions.add(e);for(const t of this.peers.keys())this.sendSubscriptions(t,[e],!0)}this.join(e)}unsubscribe(e){if(this.status.code!==_i.started)throw new Error("Pubsub is not started");const t=this.subscriptions.delete(e);if(this.log("unsubscribe from %s - am subscribed %s",e,t),t)for(const r of this.peers.keys())this.sendSubscriptions(r,[e],!1);this.leave(e).catch(r=>{this.log(r)})}join(e){if(this.status.code!==_i.started)throw new Error("Gossipsub has not started");if(this.mesh.has(e))return;this.log("JOIN %s",e),this.metrics?.onJoin(e);const t=new Set,r=this.fanout.get(e);if(r&&(this.fanout.delete(e),this.fanoutLastpub.delete(e),r.forEach(i=>{!this.direct.has(i)&&this.score.score(i)>=0&&t.add(i)}),this.metrics?.onAddToMesh(e,_o.Fanout,t.size)),t.size!t.has(o)&&!this.direct.has(o)&&this.score.score(o)>=0).forEach(o=>{t.add(o)}),this.metrics?.onAddToMesh(e,_o.Random,t.size-i)}this.mesh.set(e,t),t.forEach(i=>{this.log("JOIN: Add mesh link to %s in %s",i,e),this.sendGraft(i,e)})}leave(e){var t=this;return $(function*(){if(t.status.code!==_i.started)throw new Error("Gossipsub has not started");t.log("LEAVE %s",e),t.metrics?.onLeave(e);const r=t.mesh.get(e);r&&(yield Promise.all(Array.from(r).map(function(){var i=$(function*(s){return t.log("LEAVE: Remove mesh link to %s in %s",s,e),yield t.sendPrune(s,e)});return function(s){return i.apply(this,arguments)}}())),t.mesh.delete(e))})()}selectPeersToForward(e,t,r){const i=new Set,s=this.topics.get(e);s&&(this.direct.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&i.add(a)}),this.floodsubPeers.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&this.score.score(a)>=this.opts.scoreThresholds.publishThreshold&&i.add(a)}));const o=this.mesh.get(e);return o&&o.size>0&&o.forEach(a=>{t!==a&&!r?.has(a)&&i.add(a)}),i}selectPeersToPublish(e){const t=new Set,r={direct:0,floodsub:0,mesh:0,fanout:0},i=this.topics.get(e);if(i)if(this.opts.floodPublish)i.forEach(s=>{this.direct.has(s)?(t.add(s),r.direct++):this.score.score(s)>=this.opts.scoreThresholds.publishThreshold&&(t.add(s),r.floodsub++)});else{this.direct.forEach(o=>{i.has(o)&&(t.add(o),r.direct++)}),this.floodsubPeers.forEach(o=>{i.has(o)&&this.score.score(o)>=this.opts.scoreThresholds.publishThreshold&&(t.add(o),r.floodsub++)});const s=this.mesh.get(e);if(s&&s.size>0)s.forEach(o=>{t.add(o),r.mesh++});else{const o=this.fanout.get(e);if(o&&o.size>0)o.forEach(a=>{t.add(a),r.fanout++});else{const a=this.getRandomGossipPeers(e,this.opts.D,u=>this.score.score(u)>=this.opts.scoreThresholds.publishThreshold);a.size>0&&(this.fanout.set(e,a),a.forEach(u=>{t.add(u),r.fanout++}))}this.fanoutLastpub.set(e,Date.now())}}return{tosend:t,tosendCount:r}}forwardMessage(e,t,r,i){r&&this.score.deliverMessage(r,e,t.topic);const s=this.selectPeersToForward(t.topic,r,i),o=bo([t]);s.forEach(a=>{this.sendRpc(a,o)}),this.metrics?.onForwardMsg(t.topic,s.size)}publish(e,t){var r=()=>super.dispatchEvent,i=this;return $(function*(){const s=i.dataTransform?i.dataTransform.outboundTransform(e,t):t;if(null==i.publishConfig)throw Error("PublishError.Uninitialized");const{raw:o,msg:a}=yield function ZK(n,e,t,r){return FE.apply(this,arguments)}(i.publishConfig,e,t,s),u=yield i.msgIdFn(a),_=i.msgIdToStrFn(u);if(i.seenCache.has(_))throw Error("PublishError.Duplicate");const{tosend:R,tosendCount:N}=i.selectPeersToPublish(e),B=!0===i.opts.emitSelf&&i.subscriptions.has(e);if(0===R.size&&!i.opts.allowPublishToZeroPeers&&!B)throw Error("PublishError.InsufficientPeers");i.seenCache.put(_),i.mcache.put({msgId:u,msgIdStr:_},o,!0),i.publishedMessageIds.put(_);const z=bo([o]);for(const X of R)i.sendRpc(X,z)||R.delete(X);return i.metrics?.onPublishMsg(e,N,R.size,null!=o.data?o.data.length:0),B&&(R.add(i.components.getPeerId().toString()),r().call(i,new nn("gossipsub:message",{detail:{propagationSource:i.components.getPeerId(),msgId:_,msg:a}})),r().call(i,new nn("message",{detail:a}))),{recipients:Array.from(R.values()).map(X=>fr(X))}})()}reportMessageValidationResult(e,t,r){if(r===js.Accept){const i=this.mcache.validate(e);if(this.metrics?.onReportValidationMcacheHit(null!==i),null!=i){const{message:s,originatingPeers:o}=i;this.score.deliverMessage(t.toString(),e,s.topic),this.forwardMessage(e,i.message,t.toString(),o),this.metrics?.onReportValidation(s.topic,r)}}else{const i=this.mcache.remove(e);if(this.metrics?.onReportValidationMcacheHit(null!==i),i){const s=WA(r),{message:o,originatingPeers:a}=i;this.score.rejectMessage(t.toString(),e,o.topic,s);for(const u of a)this.score.rejectMessage(u,e,o.topic,s);this.metrics?.onReportValidation(o.topic,r)}}}sendGraft(e,t){const i=bo([],{graft:[{topicID:t}]});this.sendRpc(e,i)}sendPrune(e,t){var r=this;return $(function*(){const s=bo([],{prune:[yield r.makePrune(e,t,r.opts.doPX)]});r.sendRpc(e,s)})()}sendRpc(e,t){const r=this.streamsOutbound.get(e);if(!r)return this.log(`Cannot send RPC to ${e} as there is no open stream to it available`),!1;const i=this.control.get(e);i&&(this.piggybackControl(e,t,i),this.control.delete(e));const s=this.gossip.get(e);s&&(this.piggybackGossip(e,t,s),this.gossip.delete(e));const o=cp.encode(t).finish();try{r.push(o)}catch(a){return this.log.error(`Cannot send rpc to ${e}`,a),i&&this.control.set(e,i),s&&this.gossip.set(e,s),!1}return this.metrics?.onRpcSent(t,o.length),!0}piggybackControl(e,t,r){const i=(r.graft||[]).filter(({topicID:o})=>(o&&this.mesh.get(o)||new Set).has(e)),s=(r.prune||[]).filter(({topicID:o})=>!(o&&this.mesh.get(o)||new Set).has(e));!i.length&&!s.length||(t.control?(t.control.graft=t.control.graft&&t.control.graft.concat(i),t.control.prune=t.control.prune&&t.control.prune.concat(s)):t.control={graft:i,prune:s,ihave:[],iwant:[]})}piggybackGossip(e,t,r){t.control||(t.control={ihave:[],iwant:[],graft:[],prune:[]}),t.control.ihave=r}sendGraftPrune(e,t,r){var i=this;return $(function*(){const s=i.opts.doPX;for(const[o,a]of e){const u=a.map(B=>({topicID:B}));let _=[];const R=t.get(o);R&&(_=yield Promise.all(R.map(function(){var B=$(function*(z){return yield i.makePrune(o,z,s&&!r.get(o))});return function(z){return B.apply(this,arguments)}}())),t.delete(o));const N=bo([],{graft:u,prune:_});i.sendRpc(o,N)}for(const[o,a]of t){const u=yield Promise.all(a.map(function(){var R=$(function*(N){return yield i.makePrune(o,N,s&&!r.get(o))});return function(N){return R.apply(this,arguments)}}())),_=bo([],{prune:u});i.sendRpc(o,_)}})()}emitGossip(e){const t=this.mcache.getGossipIDs(new Set(e.keys()));for(const[r,i]of e)this.doEmitGossip(r,i,t.get(r)??[])}doEmitGossip(e,t,r){if(!r.length||(wo(r),r.length>yu&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length),!t.size))return;let i=this.opts.Dlazy;const s=.25*t.size;let o=t;s>i&&(i=s),i>o.size?i=o.size:o=wo(Array.from(o)).slice(0,i),o.forEach(a=>{let u=r;r.length>yu&&(u=wo(u.slice()).slice(0,yu)),this.pushGossip(a,{topicID:e,messageIDs:u})})}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,bo([],{ihave:t}));for(const[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,bo([],{graft:t.graft,prune:t.prune}))}pushGossip(e,t){this.log("Add gossip to %s",e);const r=this.gossip.get(e)||[];this.gossip.set(e,r.concat(t))}makePrune(e,t,r){var i=this;return $(function*(){if(i.score.prune(e,t),i.streamsOutbound.get(e).protocol===zA)return{topicID:t,peers:[]};const s=i.opts.pruneBackoff/1e3;if(!r)return{topicID:t,peers:[],backoff:s};const o=i.getRandomGossipPeers(t,i.opts.prunePeers,u=>u!==e&&i.score.score(u)>=0),a=yield Promise.all(Array.from(o).map(function(){var u=$(function*(_){const R=fr(_);return{peerID:R.toBytes(),signedPeerRecord:yield i.components.getPeerStore().addressBook.getRawEnvelope(R)}});return function(_){return u.apply(this,arguments)}}()));return{topicID:t,peers:a,backoff:s}})()}heartbeat(){var e=this;return $(function*(){const{D:t,Dlo:r,Dhi:i,Dscore:s,Dout:o,fanoutTTL:a}=e.opts;e.heartbeatTicks++;const u=new Map,_=J=>{let oe=u.get(J);return void 0===oe&&(oe=e.score.score(J),u.set(J,oe)),oe},R=new Map,N=new Map,B=new Map;e.clearBackoff(),e.peerhave.clear(),e.metrics?.cacheSize.set({cache:"iasked"},e.iasked.size),e.iasked.clear(),e.applyIwantPenalties(),e.heartbeatTicks%e.opts.directConnectTicks==0&&(yield e.directConnect()),e.fastMsgIdCache?.prune(),e.seenCache.prune(),e.gossipTracer.prune(),e.publishedMessageIds.prune();const z=new Map;e.mesh.forEach((J,oe)=>{const de=e.topics.get(oe),xe=new Set,ue=new Set;if(z.set(oe,ue),de){const Pe=wo(Array.from(de)),bt=e.backoff.get(oe);for(const yt of Pe){const Xt=e.streamsOutbound.get(yt);if(Xt&&e.multicodecs.includes(Xt.protocol)&&!J.has(yt)&&!e.direct.has(yt)){const pn=_(yt);(!bt||!bt.has(yt))&&pn>=0&&xe.add(yt),pn>=e.opts.scoreThresholds.gossipThreshold&&ue.add(yt)}}}const Te=(Pe,bt)=>{e.log("HEARTBEAT: Remove mesh link to %s in %s",Pe,oe),e.addBackoff(Pe,oe),J.delete(Pe),_(Pe)>=e.opts.scoreThresholds.gossipThreshold&&ue.add(Pe),e.metrics?.onRemoveFromMesh(oe,bt,1);const yt=N.get(Pe);yt?yt.push(oe):N.set(Pe,[oe])},Ke=(Pe,bt)=>{e.log("HEARTBEAT: Add mesh link to %s in %s",Pe,oe),e.score.graft(Pe,oe),J.add(Pe),ue.delete(Pe),e.metrics?.onAddToMesh(oe,bt,1);const yt=R.get(Pe);yt?yt.push(oe):R.set(Pe,[oe])};if(J.forEach(Pe=>{const bt=_(Pe);bt<0&&(e.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",Pe,bt,oe),Te(Pe,Fa.BadScore),B.set(Pe,!0))}),J.size!0)}(xe,t-J.size).forEach(yt=>{Ke(yt,_o.NotEnough)}),J.size>i){let Pe=Array.from(J);Pe.sort((yt,Xt)=>_(Xt)-_(yt)),Pe=Pe.slice(0,s).concat(wo(Pe.slice(s)));let bt=0;if(Pe.slice(0,t).forEach(yt=>{e.outbound.get(yt)&&bt++}),bt{const Gn=Pe[pn];for(let Di=pn;Di>0;Di--)Pe[Di]=Pe[Di-1];Pe[0]=Gn};if(bt>0){let pn=bt;for(let Gn=1;Gn0;Gn++)e.outbound.get(Pe[Gn])&&(yt(Gn),pn--)}let Xt=t-bt;for(let pn=t;pn0;pn++)e.outbound.get(Pe[pn])&&(yt(pn),Xt--)}Pe.slice(t).forEach(yt=>{Te(yt,Fa.Excess)})}if(J.size>=r){let Pe=0;J.forEach(bt=>{e.outbound.get(bt)&&Pe++}),Pe!0===e.outbound.get(Xt)).forEach(Xt=>{Ke(Xt,_o.Outbound)})}if(e.heartbeatTicks%e.opts.opportunisticGraftTicks==0&&J.size>1){const Pe=Array.from(J).sort((Xt,pn)=>_(Xt)-_(pn)),bt=Math.floor(J.size/2),yt=_(Pe[bt]);if(yt_(Gn)>yt);for(const Gn of pn)e.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",Gn,oe),Ke(Gn,_o.Opportunistic)}}});const X=Date.now();e.fanoutLastpub.forEach((J,oe)=>{J+a{const de=e.topics.get(oe);J.forEach(Ke=>{(!de.has(Ke)||_(Ke)=e.opts.scoreThresholds.publishThreshold&&ue.push(Pe),yt>=e.opts.scoreThresholds.gossipThreshold&&Te.add(Pe)}}}J.size{J.add(Pe),Te?.delete(Pe)})}),e.emitGossip(z),yield e.sendGraftPrune(R,N,B),e.flush(),e.mcache.shift(),e.dispatchEvent(new nn("gossipsub:heartbeat"))})()}getRandomGossipPeers(e,t,r=(()=>!0)){const i=this.topics.get(e);if(!i)return new Set;let s=[];return i.forEach(o=>{const a=this.streamsOutbound.get(o);!a||this.multicodecs.includes(a.protocol)&&r(o)&&s.push(o)}),s=wo(s),t>0&&s.length>t&&(s=s.slice(0,t)),new Set(s)}onScrapeMetrics(e){e.mcacheSize.set(this.mcache.size),e.cacheSize.set({cache:"direct"},this.direct.size),e.cacheSize.set({cache:"seenCache"},this.seenCache.size),e.cacheSize.set({cache:"fastMsgIdCache"},this.fastMsgIdCache?.size??0),e.cacheSize.set({cache:"publishedMessageIds"},this.publishedMessageIds.size),e.cacheSize.set({cache:"mcache"},this.mcache.size),e.cacheSize.set({cache:"score"},this.score.size),e.cacheSize.set({cache:"gossipTracer.promises"},this.gossipTracer.size),e.cacheSize.set({cache:"gossipTracer.requests"},this.gossipTracer.requestMsByMsgSize),e.cacheSize.set({cache:"topics"},this.topics.size),e.cacheSize.set({cache:"subscriptions"},this.subscriptions.size),e.cacheSize.set({cache:"mesh"},this.mesh.size),e.cacheSize.set({cache:"fanout"},this.fanout.size),e.cacheSize.set({cache:"peers"},this.peers.size),e.cacheSize.set({cache:"streamsOutbound"},this.streamsOutbound.size),e.cacheSize.set({cache:"streamsInbound"},this.streamsInbound.size),e.cacheSize.set({cache:"acceptFromWhitelist"},this.acceptFromWhitelist.size),e.cacheSize.set({cache:"gossip"},this.gossip.size),e.cacheSize.set({cache:"control"},this.control.size),e.cacheSize.set({cache:"peerhave"},this.peerhave.size),e.cacheSize.set({cache:"outbound"},this.outbound.size);let t=0;for(const o of this.backoff.values())t+=o.size;e.cacheSize.set({cache:"backoff"},t);for(const[o,a]of this.topics)e.topicPeersCount.set({topicStr:o},a.size);for(const[o,a]of this.mesh)e.meshPeerCounts.set({topicStr:o},a.size);const r=[],i=new Map;e.behaviourPenalty.reset();for(const o of this.peers.keys()){const a=this.score.score(o);r.push(a),i.set(o,a),e.behaviourPenalty.observe(this.score.peerStats.get(o)?.behaviourPenalty??0)}e.registerScores(r,this.opts.scoreThresholds),e.registerScorePerMesh(this.mesh,i);const s=function s$(n,e,t,r,i){const s={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]};for(const o of n){const a=e.get(o);if(a){const u=i$(o,a,t,r,i);for(const[_,R]of u.byTopic){let N=s.byTopic.get(_);N||(N={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},s.byTopic.set(_,N)),N.p1w.push(R.p1w),N.p2w.push(R.p2w),N.p3w.push(R.p3w),N.p3bw.push(R.p3bw),N.p4w.push(R.p4w)}s.p5w.push(u.p5w),s.p6w.push(u.p6w),s.p7w.push(u.p7w),s.score.push(u.score)}else s.p5w.push(0),s.p6w.push(0),s.p7w.push(0),s.score.push(0)}return s}(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(s)}}YA.multicodec=OE;const KE=_r("waku:relay");class $E extends YA{constructor(e){super(e=Object.assign(e??{},{globalSignaturePolicy:fp.StrictNoSign,fallbackToFloodsub:!1})),this.multicodecs=ka,this.observers={},this.decryptionKeys=new Map,this.pubSubTopic=e?.pubSubTopic??"/waku/2/default-waku/proto",e?.decryptionKeys?.forEach(t=>{this.addDecryptionKey(t)})}start(){var e=()=>super.start,t=this;return $(function*(){yield e().call(t),t.subscribe(t.pubSubTopic)})()}send(e){var t=this;return $(function*(){const r=e.encode();yield t.publish(t.pubSubTopic,r)})()}addDecryptionKey(e,t){this.decryptionKeys.set(lu(e),t??{})}deleteDecryptionKey(e){this.decryptionKeys.delete(lu(e))}addObserver(e,t=[]){0===t.length?(this.observers[""]||(this.observers[""]=new Set),this.observers[""].add(e)):t.forEach(r=>{this.observers[r]||(this.observers[r]=new Set),this.observers[r].add(e)})}deleteObserver(e,t=[]){0===t.length?this.observers[""]&&this.observers[""].delete(e):t.forEach(r=>{this.observers[r]&&this.observers[r].delete(e)})}subscribe(e){this.addEventListener("gossipsub:message",t=>{if(t.detail.msg.topic===e){const r=Array.from(this.decryptionKeys).map(([i,{method:s,contentTopics:o}])=>({key:i,method:s,contentTopics:o}));KE(`Message received on ${e}`),oa.decode(t.detail.msg.data,r).then(i=>{i?(this.observers[""]&&this.observers[""].forEach(s=>{s(i)}),i.contentTopic&&this.observers[i.contentTopic]&&this.observers[i.contentTopic].forEach(s=>{s(i)})):KE("Failed to decode Waku Message")}).catch(i=>{KE("Failed to decode Waku Message",i)})}}),super.subscribe(e)}getMeshPeers(e){return super.getMeshPeers(e??this.pubSubTopic)}}function zE(){return zE=$(function*(n){const e=n?.libp2p??{},t=e.peerDiscovery??[];n?.defaultBootstrap&&(t.push(dp()),Object.assign(e,{peerDiscovery:t}));const r=yield hp(new $E(n),e);return new JH(n??{},r)}),zE.apply(this,arguments)}function dp(){return new gH(function mH(n=uu.Prod,e=1){if(e<=0)return[];let t;switch(n){case uu.Prod:t=pE_fleets["wakuv2.prod"]["waku-websocket"];break;case uu.Test:t=pE_fleets["wakuv2.test"]["waku-websocket"];break;default:t=pE_fleets["wakuv2.prod"]["waku-websocket"]}return t=Object.values(t),t=t.map(r=>new mn(r)),IA(t,e)}())}function hp(n,e){return qE.apply(this,arguments)}function qE(){return qE=$(function*(n,e){return dH(Object.assign({transports:[new IV({filter:i2})],streamMuxers:[new gU],connectionEncryption:[new q5]},n?{pubsub:n}:{},e??{}))}),qE.apply(this,arguments)}$E.multicodec=ka[0],$E.multicodec=ka[ka.length-1];function f$(n,e,t){"function"==typeof t&&(t={filter:t});const r=function l$(n,e,t){let r;const i=new Promise((s,o)=>{if(!((t={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...t}).count>=0)||t.count!==Number.POSITIVE_INFINITY&&!Number.isInteger(t.count))throw new TypeError("The `count` option should be at least 0 or more");const a=[e].flat(),u=[],{addListener:_,removeListener:R}=(n=>{const e=n.on||n.addListener||n.addEventListener,t=n.off||n.removeListener||n.removeEventListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(n),removeListener:t.bind(n)}})(n),N=(...z)=>{const X=t.multiArgs?z:z[0];t.filter&&!t.filter(X)||(u.push(X),t.count===u.length&&(r(),s(u)))},B=z=>{r(),o(z)};r=()=>{for(const z of a)R(z,N);for(const z of t.rejectionEvents)R(z,B)};for(const z of a)_(z,N);for(const z of t.rejectionEvents)_(z,B);t.resolveImmediately&&s(u)});if(i.cancel=r,"number"==typeof t.timeout){const s=eA(i,t.timeout);return s.cancel=r,s}return i}(n,e,t={...t,count:1,resolveImmediately:!1}),i=r.then(s=>s[0]);return i.cancel=r.cancel,i}const ZA=_r("waku:wait-for-remote-peer");function YE(){return YE=$(function*(n,e,t){if(e=e??y$(n),!n.isStarted())return Promise.reject("Waku node is not started");const r=[];if(e.includes(Jr.Relay)){if(!n.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");r.push(h$(n.relay))}if(e.includes(Jr.Store)){if(!n.store)throw new Error("Cannot wait for Store peer: protocol not mounted");r.push(QE(n.store,Object.values(of)))}if(e.includes(Jr.LightPush)){if(!n.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");r.push(QE(n.lightPush,[rf]))}if(e.includes(Jr.Filter)){if(!n.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");r.push(QE(n.filter,[nf]))}t?yield g$(Promise.all(r),t,"Timed out waiting for a remote peer."):yield Promise.all(r)}),YE.apply(this,arguments)}function QE(n,e){return ZE.apply(this,arguments)}function ZE(){return ZE=$(function*(n,e){const t=yield n.peers();t.length?ZA(`${e} peer found: `,t[0].id.toString()):yield new Promise(r=>{const i=s=>{for(const o of e)if(s.detail.protocols.includes(o)){ZA("Resolving for",o,s.detail.protocols),n.libp2p.peerStore.removeEventListener("change:protocols",i),r();break}};n.libp2p.peerStore.addEventListener("change:protocols",i)})}),ZE.apply(this,arguments)}function h$(n){return XE.apply(this,arguments)}function XE(){return XE=$(function*(n){let e=n.getMeshPeers();for(;0==e.length;)yield f$(n,"gossipsub:heartbeat"),e=n.getMeshPeers()}),XE.apply(this,arguments)}const p$=(n,e)=>new Promise((t,r)=>setTimeout(()=>r(e),n));function g$(n,e,t){return JE.apply(this,arguments)}function JE(){return JE=$(function*(n,e,t){yield Promise.race([n,p$(e,t)])}),JE.apply(this,arguments)}function y$(n){const e=[];return n.relay&&e.push(Jr.Relay),n.filter&&e.push(Jr.Filter),n.store&&e.push(Jr.Store),n.lightPush&&e.push(Jr.LightPush),e}let XA=(()=>{class n{constructor(){this.wakuSubject=new pr,this.waku=this.wakuSubject.asObservable(),this.wakuStatusSubject=new lB(""),this.wakuStatus=this.wakuStatusSubject.asObservable()}init(){(function u$(n){return zE.apply(this,arguments)})({defaultBootstrap:!0}).then(t=>{t.start().then(()=>{this.wakuSubject.next(t),this.wakuStatusSubject.next("Connecting..."),function d$(n,e,t){return YE.apply(this,arguments)}(t).then(()=>{this.wakuStatusSubject.next("Connected")})})})}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Wn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function v$(n,e){if(1&n&&(eo(0,"li")(1,"span"),Tc(2),to()()),2&n){const t=e.$implicit;Gu(2),yy("",t.timestamp," ",t.text,"")}}_r("waku:enr");const rb=new(T0().Type)("ChatMessage").add(new(T0().Field)("timestamp",1,"uint32")).add(new(T0().Field)("text",2,"string"));let E$=(()=>{class n{constructor(t){this.wakuService=t,this.contentTopic="/relay-angular-chat/1/chat/proto",this.messages=[],this.messageCount=0,this.processIncomingMessages=r=>{if(!r.payload)return;const{text:i,timestamp:s}=rb.decode(r.payload),o=new Date;o.setTime(Number(s)),this.messages.push({text:i,timestamp:o})}}ngOnInit(){this.wakuService.wakuStatus.subscribe(t=>{this.wakuStatus=t}),this.wakuService.waku.subscribe(t=>{this.waku=t,this.waku.relay.addObserver(this.processIncomingMessages,[this.contentTopic])}),window.onbeforeunload=()=>this.ngOnDestroy()}ngOnDestroy(){this.waku.relay.deleteObserver(this.processIncomingMessages,[this.contentTopic])}sendMessage(){const t=(new Date).getTime(),r=rb.create({timestamp:t,text:`Here is a message #${this.messageCount}`}),i=rb.encode(r).finish();oa.fromBytes(i,this.contentTopic).then(s=>{this.waku.relay.send(s).then(()=>{console.log(`Message #${this.messageCount} sent`),this.messageCount+=1})})}}return n.\u0275fac=function(t){return new(t||n)(Zt(XA))},n.\u0275cmp=hf({type:n,selectors:[["app-messages"]],decls:6,vars:2,consts:[[3,"disabled","click"],[1,"messages"],[4,"ngFor","ngForOf"]],template:function(t,r){1&t&&(eo(0,"button",0),dy("click",function(){return r.sendMessage()}),Tc(1,"Send Message"),to(),eo(2,"h2"),Tc(3,"Messages"),to(),eo(4,"ul",1),function g1(n,e,t,r,i,s,o,a){const u=Ue(),_=dn(),R=n+22,N=_.firstCreatePass?function YM(n,e,t,r,i,s,o,a,u){const _=e.consts,R=gc(e,n,4,o||null,Ao(_,a));Zg(e,t,R,Ao(_,u)),Df(e,R);const N=R.tViews=Qg(2,R,r,i,s,e.directiveRegistry,e.pipeRegistry,null,e.schemas,_);return null!==e.queries&&(e.queries.template(e,R),N.queries=e.queries.embeddedTView(R)),R}(R,_,u,e,t,r,i,s,o):_.data[R];Ts(N,!1);const B=u[11].createComment("");Wf(_,u,B,N),jr(B,u),td(u,u[R]=Q_(B,u,B,N)),vf(N)&&qg(_,u,N),null!=o&&Yg(u,N,a)}(5,v$,3,2,"li",2),to()),2&t&&(od("disabled","Connected"!==r.wakuStatus),Gu(5),od("ngForOf",r.messages))},dependencies:[lC]}),n})(),b$=(()=>{class n{constructor(t){this.wakuService=t,this.title="relay-angular-chat"}ngOnInit(){this.wakuService.init(),this.wakuService.wakuStatus.subscribe(t=>{this.wakuStatus=t})}}return n.\u0275fac=function(t){return new(t||n)(Zt(XA))},n.\u0275cmp=hf({type:n,selectors:[["app-root"]],decls:5,vars:2,template:function(t,r){1&t&&(eo(0,"h1"),Tc(1),to(),eo(2,"p"),Tc(3),to(),cy(4,"app-messages")),2&t&&(Gu(1),gy(r.title),Gu(2),cd("Waku node's status: ",r.wakuStatus,""))},dependencies:[E$],styles:["h1[_ngcontent-%COMP%]{color:#369;font-family:Arial,Helvetica,sans-serif;font-size:250%}h2[_ngcontent-%COMP%], h3[_ngcontent-%COMP%]{color:#444;font-family:Arial,Helvetica,sans-serif;font-weight:lighter}body[_ngcontent-%COMP%]{margin:2em}body[_ngcontent-%COMP%], input[type=text][_ngcontent-%COMP%], button[_ngcontent-%COMP%]{color:#333;font-family:Cambria,Georgia,serif}*[_ngcontent-%COMP%]{font-family:Arial,Helvetica,sans-serif}"]}),n})(),w$=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=_u({type:n,bootstrap:[b$]}),n.\u0275inj=Ka({imports:[eB]}),n})();x(8583),function SL(){KS=!1}(),J4().bootstrapModule(w$).catch(n=>console.error(n))},1280:Y=>{"use strict";Y.exports=function U(x,y){for(var l=new Array(arguments.length-1),g=0,w=2,m=!0;w{"use strict";var x=U;x.length=function(h){var c=h.length;if(!c)return 0;for(var f=0;--c%4>1&&"="===h.charAt(c);)++f;return Math.ceil(3*h.length)/4-f};for(var y=new Array(64),l=new Array(123),g=0;g<64;)l[y[g]=g<26?g+65:g<52?g+71:g<62?g-4:g-59|43]=g++;x.encode=function(h,c,f){for(var v,d=null,b=[],S=0,E=0;c>2],v=(3&p)<<4,E=1;break;case 1:b[S++]=y[v|p>>4],v=(15&p)<<2,E=2;break;case 2:b[S++]=y[v|p>>6],b[S++]=y[63&p],E=0}S>8191&&((d||(d=[])).push(String.fromCharCode.apply(String,b)),S=0)}return E&&(b[S++]=y[v],b[S++]=61,1===E&&(b[S++]=61)),d?(S&&d.push(String.fromCharCode.apply(String,b.slice(0,S))),d.join("")):String.fromCharCode.apply(String,b.slice(0,S))};var w="invalid encoding";x.decode=function(h,c,f){for(var S,d=f,b=0,E=0;E1)break;if(void 0===(v=l[v]))throw Error(w);switch(b){case 0:S=v,b=1;break;case 1:c[f++]=S<<2|(48&v)>>4,S=v,b=2;break;case 2:c[f++]=(15&S)<<4|(60&v)>>2,S=v,b=3;break;case 3:c[f++]=(3&S)<<6|v,b=0}}if(1===b)throw Error(w);return f-d},x.test=function(h){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(h)}},9749:Y=>{"use strict";function U(x,y){"string"==typeof x&&(y=x,x=void 0);var l=[];function g(m){if("string"!=typeof m){var h=w();if(U.verbose&&console.log("codegen: "+h),h="return "+h,m){for(var c=Object.keys(m),f=new Array(c.length+1),d=new Array(c.length),b=0;b{"use strict";function U(){this._listeners={}}Y.exports=U,U.prototype.on=function(y,l,g){return(this._listeners[y]||(this._listeners[y]=[])).push({fn:l,ctx:g||this}),this},U.prototype.off=function(y,l){if(void 0===y)this._listeners={};else if(void 0===l)this._listeners[y]=[];else for(var g=this._listeners[y],w=0;w{"use strict";Y.exports=w;var y=x(1280),g=x(716)("fs");function w(m,h,c){return"function"==typeof h?(c=h,h={}):h||(h={}),c?!h.xhr&&g&&g.readFile?g.readFile(m,function(d,b){return d&&typeof XMLHttpRequest<"u"?w.xhr(m,h,c):d?c(d):c(null,h.binary?b:b.toString("utf8"))}):w.xhr(m,h,c):y(w,this,m,h)}w.xhr=function(h,c,f){var d=new XMLHttpRequest;d.onreadystatechange=function(){if(4===d.readyState){if(0!==d.status&&200!==d.status)return f(Error("status "+d.status));if(c.binary){var S=d.response;if(!S){S=[];for(var E=0;E{"use strict";function U(w){return typeof Float32Array<"u"?function(){var m=new Float32Array([-0]),h=new Uint8Array(m.buffer),c=128===h[3];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3]}function d(E,v,p){m[0]=E,v[p]=h[3],v[p+1]=h[2],v[p+2]=h[1],v[p+3]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],m[0]}function S(E,v){return h[3]=E[v],h[2]=E[v+1],h[1]=E[v+2],h[0]=E[v+3],m[0]}w.writeFloatLE=c?f:d,w.writeFloatBE=c?d:f,w.readFloatLE=c?b:S,w.readFloatBE=c?S:b}():function(){function m(c,f,d,b){var S=f<0?1:0;if(S&&(f=-f),0===f)c(1/f>0?0:2147483648,d,b);else if(isNaN(f))c(2143289344,d,b);else if(f>34028234663852886e22)c((S<<31|2139095040)>>>0,d,b);else if(f<11754943508222875e-54)c((S<<31|Math.round(f/1401298464324817e-60))>>>0,d,b);else{var E=Math.floor(Math.log(f)/Math.LN2);c((S<<31|E+127<<23|8388607&Math.round(f*Math.pow(2,-E)*8388608))>>>0,d,b)}}function h(c,f,d){var b=c(f,d),S=2*(b>>31)+1,E=b>>>23&255,v=8388607&b;return 255===E?v?NaN:S*(1/0):0===E?1401298464324817e-60*S*v:S*Math.pow(2,E-150)*(v+8388608)}w.writeFloatLE=m.bind(null,x),w.writeFloatBE=m.bind(null,y),w.readFloatLE=h.bind(null,l),w.readFloatBE=h.bind(null,g)}(),typeof Float64Array<"u"?function(){var m=new Float64Array([-0]),h=new Uint8Array(m.buffer),c=128===h[7];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3],v[p+4]=h[4],v[p+5]=h[5],v[p+6]=h[6],v[p+7]=h[7]}function d(E,v,p){m[0]=E,v[p]=h[7],v[p+1]=h[6],v[p+2]=h[5],v[p+3]=h[4],v[p+4]=h[3],v[p+5]=h[2],v[p+6]=h[1],v[p+7]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],h[4]=E[v+4],h[5]=E[v+5],h[6]=E[v+6],h[7]=E[v+7],m[0]}function S(E,v){return h[7]=E[v],h[6]=E[v+1],h[5]=E[v+2],h[4]=E[v+3],h[3]=E[v+4],h[2]=E[v+5],h[1]=E[v+6],h[0]=E[v+7],m[0]}w.writeDoubleLE=c?f:d,w.writeDoubleBE=c?d:f,w.readDoubleLE=c?b:S,w.readDoubleBE=c?S:b}():function(){function m(c,f,d,b,S,E){var v=b<0?1:0;if(v&&(b=-b),0===b)c(0,S,E+f),c(1/b>0?0:2147483648,S,E+d);else if(isNaN(b))c(0,S,E+f),c(2146959360,S,E+d);else if(b>17976931348623157e292)c(0,S,E+f),c((v<<31|2146435072)>>>0,S,E+d);else{var p;if(b<22250738585072014e-324)c((p=b/5e-324)>>>0,S,E+f),c((v<<31|p/4294967296)>>>0,S,E+d);else{var I=Math.floor(Math.log(b)/Math.LN2);1024===I&&(I=1023),c(4503599627370496*(p=b*Math.pow(2,-I))>>>0,S,E+f),c((v<<31|I+1023<<20|1048576*p&1048575)>>>0,S,E+d)}}}function h(c,f,d,b,S){var E=c(b,S+f),v=c(b,S+d),p=2*(v>>31)+1,I=v>>>20&2047,A=4294967296*(1048575&v)+E;return 2047===I?A?NaN:p*(1/0):0===I?5e-324*p*A:p*Math.pow(2,I-1075)*(A+4503599627370496)}w.writeDoubleLE=m.bind(null,x,0,4),w.writeDoubleBE=m.bind(null,y,4,0),w.readDoubleLE=h.bind(null,l,0,4),w.readDoubleBE=h.bind(null,g,4,0)}(),w}function x(w,m,h){m[h]=255&w,m[h+1]=w>>>8&255,m[h+2]=w>>>16&255,m[h+3]=w>>>24}function y(w,m,h){m[h]=w>>>24,m[h+1]=w>>>16&255,m[h+2]=w>>>8&255,m[h+3]=255&w}function l(w,m){return(w[m]|w[m+1]<<8|w[m+2]<<16|w[m+3]<<24)>>>0}function g(w,m){return(w[m]<<24|w[m+1]<<16|w[m+2]<<8|w[m+3])>>>0}Y.exports=U(U)},716:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(Y){}return null}module.exports=inquire},1311:(Y,U)=>{"use strict";var x=U,y=x.isAbsolute=function(w){return/^(?:\/|\w+:)/.test(w)},l=x.normalize=function(w){var m=(w=w.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),h=y(w),c="";h&&(c=m.shift()+"/");for(var f=0;f0&&".."!==m[f-1]?m.splice(--f,2):h?m.splice(f,1):++f:"."===m[f]?m.splice(f,1):++f;return c+m.join("/")};x.resolve=function(w,m,h){return h||(m=l(m)),y(m)?m:(h||(w=l(w)),(w=w.replace(/(?:\/|^)[^/]+$/,"")).length?l(w+"/"+m):m)}},4479:Y=>{"use strict";Y.exports=function U(x,y,l){var g=l||8192,w=g>>>1,m=null,h=g;return function(f){if(f<1||f>w)return x(f);h+f>g&&(m=x(g),h=0);var d=y.call(m,h,h+=f);return 7&h&&(h=1+(7|h)),d}}},7768:(Y,U)=>{"use strict";var x=U;x.length=function(l){for(var g=0,w=0,m=0;m191&&d<224?c[f++]=(31&d)<<6|63&l[g++]:d>239&&d<365?(d=((7&d)<<18|(63&l[g++])<<12|(63&l[g++])<<6|63&l[g++])-65536,c[f++]=55296+(d>>10),c[f++]=56320+(1023&d)):c[f++]=(15&d)<<12|(63&l[g++])<<6|63&l[g++],f>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,c)),f=0);return h?(f&&h.push(String.fromCharCode.apply(String,c.slice(0,f))),h.join("")):String.fromCharCode.apply(String,c.slice(0,f))},x.write=function(l,g,w){for(var h,c,m=w,f=0;f>6|192,g[w++]=63&h|128):55296==(64512&h)&&56320==(64512&(c=l.charCodeAt(f+1)))?(++f,g[w++]=(h=65536+((1023&h)<<10)+(1023&c))>>18|240,g[w++]=h>>12&63|128,g[w++]=h>>6&63|128,g[w++]=63&h|128):(g[w++]=h>>12|224,g[w++]=h>>6&63|128,g[w++]=63&h|128);return w-m}},4502:(Y,U,x)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(8046);function h(Z,q,ne){return void 0===q&&(q=new Uint8Array(2)),void 0===ne&&(ne=0),q[ne+0]=Z>>>8,q[ne+1]=Z>>>0,q}function c(Z,q,ne){return void 0===q&&(q=new Uint8Array(2)),void 0===ne&&(ne=0),q[ne+0]=Z>>>0,q[ne+1]=Z>>>8,q}function f(Z,q){return void 0===q&&(q=0),Z[q]<<24|Z[q+1]<<16|Z[q+2]<<8|Z[q+3]}function d(Z,q){return void 0===q&&(q=0),(Z[q]<<24|Z[q+1]<<16|Z[q+2]<<8|Z[q+3])>>>0}function b(Z,q){return void 0===q&&(q=0),Z[q+3]<<24|Z[q+2]<<16|Z[q+1]<<8|Z[q]}function S(Z,q){return void 0===q&&(q=0),(Z[q+3]<<24|Z[q+2]<<16|Z[q+1]<<8|Z[q])>>>0}function E(Z,q,ne){return void 0===q&&(q=new Uint8Array(4)),void 0===ne&&(ne=0),q[ne+0]=Z>>>24,q[ne+1]=Z>>>16,q[ne+2]=Z>>>8,q[ne+3]=Z>>>0,q}function v(Z,q,ne){return void 0===q&&(q=new Uint8Array(4)),void 0===ne&&(ne=0),q[ne+0]=Z>>>0,q[ne+1]=Z>>>8,q[ne+2]=Z>>>16,q[ne+3]=Z>>>24,q}function D(Z,q,ne){return void 0===q&&(q=new Uint8Array(8)),void 0===ne&&(ne=0),E(Z/4294967296>>>0,q,ne),E(Z>>>0,q,ne+4),q}function T(Z,q,ne){return void 0===q&&(q=new Uint8Array(8)),void 0===ne&&(ne=0),v(Z>>>0,q,ne),v(Z/4294967296>>>0,q,ne+4),q}U.readInt16BE=function l(Z,q){return void 0===q&&(q=0),(Z[q+0]<<8|Z[q+1])<<16>>16},U.readUint16BE=function g(Z,q){return void 0===q&&(q=0),(Z[q+0]<<8|Z[q+1])>>>0},U.readInt16LE=function w(Z,q){return void 0===q&&(q=0),(Z[q+1]<<8|Z[q])<<16>>16},U.readUint16LE=function m(Z,q){return void 0===q&&(q=0),(Z[q+1]<<8|Z[q])>>>0},U.writeUint16BE=h,U.writeInt16BE=h,U.writeUint16LE=c,U.writeInt16LE=c,U.readInt32BE=f,U.readUint32BE=d,U.readInt32LE=b,U.readUint32LE=S,U.writeUint32BE=E,U.writeInt32BE=E,U.writeUint32LE=v,U.writeInt32LE=v,U.readInt64BE=function p(Z,q){void 0===q&&(q=0);var ne=f(Z,q),se=f(Z,q+4);return 4294967296*ne+se-4294967296*(se>>31)},U.readUint64BE=function I(Z,q){return void 0===q&&(q=0),4294967296*d(Z,q)+d(Z,q+4)},U.readInt64LE=function A(Z,q){void 0===q&&(q=0);var ne=b(Z,q);return 4294967296*b(Z,q+4)+ne-4294967296*(ne>>31)},U.readUint64LE=function P(Z,q){void 0===q&&(q=0);var ne=S(Z,q);return 4294967296*S(Z,q+4)+ne},U.writeUint64BE=D,U.writeInt64BE=D,U.writeUint64LE=T,U.writeInt64LE=T,U.readUintBE=function M(Z,q,ne){if(void 0===ne&&(ne=0),Z%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(Z/8>q.length-ne)throw new Error("readUintBE: array is too short for the given bitLength");for(var se=0,he=1,pe=Z/8+ne-1;pe>=ne;pe--)se+=q[pe]*he,he*=256;return se},U.readUintLE=function k(Z,q,ne){if(void 0===ne&&(ne=0),Z%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(Z/8>q.length-ne)throw new Error("readUintLE: array is too short for the given bitLength");for(var se=0,he=1,pe=ne;pe=se;pe--)ne[pe]=q/he&255,he*=256;return ne},U.writeUintLE=function j(Z,q,ne,se){if(void 0===ne&&(ne=new Uint8Array(Z/8)),void 0===se&&(se=0),Z%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!y.isSafeInteger(q))throw new Error("writeUintLE value must be an integer");for(var he=1,pe=se;pe{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(4502),l=x(9815);function w(f,d,b){for(var S=1634760805,E=857760878,v=2036477234,p=1797285236,I=b[3]<<24|b[2]<<16|b[1]<<8|b[0],A=b[7]<<24|b[6]<<16|b[5]<<8|b[4],P=b[11]<<24|b[10]<<16|b[9]<<8|b[8],D=b[15]<<24|b[14]<<16|b[13]<<8|b[12],T=b[19]<<24|b[18]<<16|b[17]<<8|b[16],M=b[23]<<24|b[22]<<16|b[21]<<8|b[20],k=b[27]<<24|b[26]<<16|b[25]<<8|b[24],F=b[31]<<24|b[30]<<16|b[29]<<8|b[28],j=d[3]<<24|d[2]<<16|d[1]<<8|d[0],C=d[7]<<24|d[6]<<16|d[5]<<8|d[4],O=d[11]<<24|d[10]<<16|d[9]<<8|d[8],V=d[15]<<24|d[14]<<16|d[13]<<8|d[12],L=S,K=E,re=v,G=p,te=I,Z=A,q=P,ne=D,se=T,he=M,pe=k,Le=F,Se=j,Ne=C,be=O,je=V,H=0;H<20;H+=2)te=(te^=se=se+(Se=(Se^=L=L+te|0)>>>16|Se<<16)|0)>>>20|te<<12,Z=(Z^=he=he+(Ne=(Ne^=K=K+Z|0)>>>16|Ne<<16)|0)>>>20|Z<<12,q=(q^=pe=pe+(be=(be^=re=re+q|0)>>>16|be<<16)|0)>>>20|q<<12,ne=(ne^=Le=Le+(je=(je^=G=G+ne|0)>>>16|je<<16)|0)>>>20|ne<<12,q=(q^=pe=pe+(be=(be^=re=re+q|0)>>>24|be<<8)|0)>>>25|q<<7,ne=(ne^=Le=Le+(je=(je^=G=G+ne|0)>>>24|je<<8)|0)>>>25|ne<<7,Z=(Z^=he=he+(Ne=(Ne^=K=K+Z|0)>>>24|Ne<<8)|0)>>>25|Z<<7,te=(te^=se=se+(Se=(Se^=L=L+te|0)>>>24|Se<<8)|0)>>>25|te<<7,Z=(Z^=pe=pe+(je=(je^=L=L+Z|0)>>>16|je<<16)|0)>>>20|Z<<12,q=(q^=Le=Le+(Se=(Se^=K=K+q|0)>>>16|Se<<16)|0)>>>20|q<<12,ne=(ne^=se=se+(Ne=(Ne^=re=re+ne|0)>>>16|Ne<<16)|0)>>>20|ne<<12,te=(te^=he=he+(be=(be^=G=G+te|0)>>>16|be<<16)|0)>>>20|te<<12,ne=(ne^=se=se+(Ne=(Ne^=re=re+ne|0)>>>24|Ne<<8)|0)>>>25|ne<<7,te=(te^=he=he+(be=(be^=G=G+te|0)>>>24|be<<8)|0)>>>25|te<<7,q=(q^=Le=Le+(Se=(Se^=K=K+q|0)>>>24|Se<<8)|0)>>>25|q<<7,Z=(Z^=pe=pe+(je=(je^=L=L+Z|0)>>>24|je<<8)|0)>>>25|Z<<7;y.writeUint32LE(L+S|0,f,0),y.writeUint32LE(K+E|0,f,4),y.writeUint32LE(re+v|0,f,8),y.writeUint32LE(G+p|0,f,12),y.writeUint32LE(te+I|0,f,16),y.writeUint32LE(Z+A|0,f,20),y.writeUint32LE(q+P|0,f,24),y.writeUint32LE(ne+D|0,f,28),y.writeUint32LE(se+T|0,f,32),y.writeUint32LE(he+M|0,f,36),y.writeUint32LE(pe+k|0,f,40),y.writeUint32LE(Le+F|0,f,44),y.writeUint32LE(Se+j|0,f,48),y.writeUint32LE(Ne+C|0,f,52),y.writeUint32LE(be+O|0,f,56),y.writeUint32LE(je+V|0,f,60)}function m(f,d,b,S,E){if(void 0===E&&(E=0),32!==f.length)throw new Error("ChaCha: key size must be 32 bytes");if(S.length>>=8,d++;if(S>0)throw new Error("ChaCha: counter overflow")}U.streamXOR=m,U.stream=function h(f,d,b,S){return void 0===S&&(S=0),l.wipe(b),m(f,d,b,b,S)}},5876:(Y,U,x)=>{"use strict";var l=x(4484),g=x(314),w=x(9815),m=x(4502),h=x(9976);U.Cv=32,U.WH=12,U.pg=16;var c=new Uint8Array(16),f=function(){function d(b){if(this.nonceLength=U.WH,this.tagLength=U.pg,b.length!==U.Cv)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(b)}return d.prototype.seal=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var p=new Uint8Array(16);p.set(b,p.length-b.length);var I=new Uint8Array(32);l.stream(this._key,p,I,4);var P,A=S.length+this.tagLength;if(v){if(v.length!==A)throw new Error("ChaCha20Poly1305: incorrect destination length");P=v}else P=new Uint8Array(A);return l.streamXOR(this._key,p,S,P,4),this._authenticate(P.subarray(P.length-this.tagLength,P.length),I,P.subarray(0,P.length-this.tagLength),E),w.wipe(p),P},d.prototype.open=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(S.length0&&p.update(c.subarray(v.length%16))),p.update(E),E.length%16>0&&p.update(c.subarray(E.length%16));var I=new Uint8Array(8);v&&m.writeUint64LE(v.length,I),p.update(I),m.writeUint64LE(E.length,I),p.update(I);for(var A=p.digest(),P=0;P{"use strict";function l(w,m){if(w.length!==m.length)return 0;for(var h=0,c=0;c>>8}Object.defineProperty(U,"__esModule",{value:!0}),U.select=function x(w,m,h){return~(w-1)&m|w-1&h},U.lessOrEqual=function y(w,m){return(0|w)-(0|m)-1>>>31&1},U.compare=l,U.equal=function g(w,m){return 0!==w.length&&0!==m.length&&0!==l(w,m)}},5571:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.isSerializableHash=function x(y){return typeof y.saveState<"u"&&typeof y.restoreState<"u"&&typeof y.cleanSavedState<"u"}},5705:(Y,U,x)=>{"use strict";var l=x(4193),g=x(9815),w=function(){function m(h,c,f,d){void 0===f&&(f=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=h,this._info=d;var b=l.hmac(this._hash,f,c);this._hmac=new l.HMAC(h,b),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return m.prototype._fillBuffer=function(){this._counter[0]++;var h=this._counter[0];if(0===h)throw new Error("hkdf: cannot expand more");this._hmac.reset(),h>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},m.prototype.expand=function(h){for(var c=new Uint8Array(h),f=0;f{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(5571),l=x(9976),g=x(9815),w=function(){function h(c,f){this._finished=!1,this._inner=new c,this._outer=new c,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var d=new Uint8Array(this.blockSize);f.length>this.blockSize?this._inner.update(f).finish(d).clean():d.set(f);for(var b=0;b{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.mul=Math.imul||function x(h,c){var d=65535&h,S=65535&c;return d*S+((h>>>16&65535)*S+d*(c>>>16&65535)<<16>>>0)|0},U.add=function y(h,c){return h+c|0},U.sub=function l(h,c){return h-c|0},U.rotl=function g(h,c){return h<>>32-c},U.rotr=function w(h,c){return h<<32-c|h>>>c},U.isInteger=Number.isInteger||function m(h){return"number"==typeof h&&isFinite(h)&&Math.floor(h)===h},U.MAX_SAFE_INTEGER=9007199254740991,U.isSafeInteger=function(h){return U.isInteger(h)&&h>=-U.MAX_SAFE_INTEGER&&h<=U.MAX_SAFE_INTEGER}},314:(Y,U,x)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(9976),l=x(9815);U.DIGEST_LENGTH=16;var g=function(){function h(c){this.digestLength=U.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var f=c[0]|c[1]<<8;this._r[0]=8191&f;var d=c[2]|c[3]<<8;this._r[1]=8191&(f>>>13|d<<3);var b=c[4]|c[5]<<8;this._r[2]=7939&(d>>>10|b<<6);var S=c[6]|c[7]<<8;this._r[3]=8191&(b>>>7|S<<9);var E=c[8]|c[9]<<8;this._r[4]=255&(S>>>4|E<<12),this._r[5]=E>>>1&8190;var v=c[10]|c[11]<<8;this._r[6]=8191&(E>>>14|v<<2);var p=c[12]|c[13]<<8;this._r[7]=8065&(v>>>11|p<<5);var I=c[14]|c[15]<<8;this._r[8]=8191&(p>>>8|I<<8),this._r[9]=I>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return h.prototype._blocks=function(c,f,d){for(var b=this._fin?0:2048,S=this._h[0],E=this._h[1],v=this._h[2],p=this._h[3],I=this._h[4],A=this._h[5],P=this._h[6],D=this._h[7],T=this._h[8],M=this._h[9],k=this._r[0],F=this._r[1],j=this._r[2],C=this._r[3],O=this._r[4],V=this._r[5],L=this._r[6],K=this._r[7],re=this._r[8],G=this._r[9];d>=16;){var te=c[f+0]|c[f+1]<<8,Z=c[f+2]|c[f+3]<<8,q=c[f+4]|c[f+5]<<8,ne=c[f+6]|c[f+7]<<8,se=c[f+8]|c[f+9]<<8,he=c[f+10]|c[f+11]<<8,pe=c[f+12]|c[f+13]<<8,Le=c[f+14]|c[f+15]<<8,Se=0,Ne=Se;Ne+=(S+=8191&te)*k,Ne+=(E+=8191&(te>>>13|Z<<3))*(5*G),Ne+=(v+=8191&(Z>>>10|q<<6))*(5*re),Ne+=(p+=8191&(q>>>7|ne<<9))*(5*K),Se=(Ne+=(I+=8191&(ne>>>4|se<<12))*(5*L))>>>13,Ne&=8191,Ne+=(A+=se>>>1&8191)*(5*V),Ne+=(P+=8191&(se>>>14|he<<2))*(5*O),Ne+=(D+=8191&(he>>>11|pe<<5))*(5*C),Ne+=(T+=8191&(pe>>>8|Le<<8))*(5*j);var be=Se+=(Ne+=(M+=Le>>>5|b)*(5*F))>>>13;be+=S*F,be+=E*k,be+=v*(5*G),be+=p*(5*re),Se=(be+=I*(5*K))>>>13,be&=8191,be+=A*(5*L),be+=P*(5*V),be+=D*(5*O),be+=T*(5*C),Se+=(be+=M*(5*j))>>>13,be&=8191;var je=Se;je+=S*j,je+=E*F,je+=v*k,je+=p*(5*G),Se=(je+=I*(5*re))>>>13,je&=8191,je+=A*(5*K),je+=P*(5*L),je+=D*(5*V),je+=T*(5*O);var H=Se+=(je+=M*(5*C))>>>13;H+=S*C,H+=E*j,H+=v*F,H+=p*k,Se=(H+=I*(5*G))>>>13,H&=8191,H+=A*(5*re),H+=P*(5*K),H+=D*(5*L),H+=T*(5*V);var Ee=Se+=(H+=M*(5*O))>>>13;Ee+=S*O,Ee+=E*C,Ee+=v*j,Ee+=p*F,Se=(Ee+=I*k)>>>13,Ee&=8191,Ee+=A*(5*G),Ee+=P*(5*re),Ee+=D*(5*K),Ee+=T*(5*L);var Ie=Se+=(Ee+=M*(5*V))>>>13;Ie+=S*V,Ie+=E*O,Ie+=v*C,Ie+=p*j,Se=(Ie+=I*F)>>>13,Ie&=8191,Ie+=A*k,Ie+=P*(5*G),Ie+=D*(5*re),Ie+=T*(5*K);var Re=Se+=(Ie+=M*(5*L))>>>13;Re+=S*L,Re+=E*V,Re+=v*O,Re+=p*C,Se=(Re+=I*j)>>>13,Re&=8191,Re+=A*F,Re+=P*k,Re+=D*(5*G),Re+=T*(5*re);var He=Se+=(Re+=M*(5*K))>>>13;He+=S*K,He+=E*L,He+=v*V,He+=p*O,Se=(He+=I*C)>>>13,He&=8191,He+=A*j,He+=P*F,He+=D*k,He+=T*(5*G);var We=Se+=(He+=M*(5*re))>>>13;We+=S*re,We+=E*K,We+=v*L,We+=p*V,Se=(We+=I*O)>>>13,We&=8191,We+=A*C,We+=P*j,We+=D*F,We+=T*k;var Je=Se+=(We+=M*(5*G))>>>13;Je+=S*G,Je+=E*re,Je+=v*K,Je+=p*L,Se=(Je+=I*V)>>>13,Je&=8191,Je+=A*O,Je+=P*C,Je+=D*j,Je+=T*F,S=Ne=8191&(Se=(Se=((Se+=(Je+=M*k)>>>13)<<2)+Se|0)+(Ne&=8191)|0),E=be+=Se>>>=13,v=je&=8191,p=H&=8191,I=Ee&=8191,A=Ie&=8191,P=Re&=8191,D=He&=8191,T=We&=8191,M=Je&=8191,f+=16,d-=16}this._h[0]=S,this._h[1]=E,this._h[2]=v,this._h[3]=p,this._h[4]=I,this._h[5]=A,this._h[6]=P,this._h[7]=D,this._h[8]=T,this._h[9]=M},h.prototype.finish=function(c,f){void 0===f&&(f=0);var b,S,E,v,d=new Uint16Array(10);if(this._leftover){for(v=this._leftover,this._buffer[v++]=1;v<16;v++)this._buffer[v]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(b=this._h[1]>>>13,this._h[1]&=8191,v=2;v<10;v++)this._h[v]+=b,b=this._h[v]>>>13,this._h[v]&=8191;for(this._h[0]+=5*b,b=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=b,b=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=b,d[0]=this._h[0]+5,b=d[0]>>>13,d[0]&=8191,v=1;v<10;v++)d[v]=this._h[v]+b,b=d[v]>>>13,d[v]&=8191;for(d[9]-=8192,S=(1^b)-1,v=0;v<10;v++)d[v]&=S;for(S=~S,v=0;v<10;v++)this._h[v]=this._h[v]&S|d[v];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),this._h[0]=65535&(E=this._h[0]+this._pad[0]),v=1;v<8;v++)this._h[v]=65535&(E=(this._h[v]+this._pad[v]|0)+(E>>>16)|0);return c[f+0]=this._h[0]>>>0,c[f+1]=this._h[0]>>>8,c[f+2]=this._h[1]>>>0,c[f+3]=this._h[1]>>>8,c[f+4]=this._h[2]>>>0,c[f+5]=this._h[2]>>>8,c[f+6]=this._h[3]>>>0,c[f+7]=this._h[3]>>>8,c[f+8]=this._h[4]>>>0,c[f+9]=this._h[4]>>>8,c[f+10]=this._h[5]>>>0,c[f+11]=this._h[5]>>>8,c[f+12]=this._h[6]>>>0,c[f+13]=this._h[6]>>>8,c[f+14]=this._h[7]>>>0,c[f+15]=this._h[7]>>>8,this._finished=!0,this},h.prototype.update=function(c){var b,f=0,d=c.length;if(this._leftover){(b=16-this._leftover)>d&&(b=d);for(var S=0;S=16&&(this._blocks(c,f,b=d-d%16),f+=b,d-=b),d){for(S=0;S{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.randomStringForEntropy=U.randomString=U.randomUint32=U.randomBytes=U.defaultRandomSource=void 0;const y=x(9753),l=x(4502),g=x(9815);function w(d,b=U.defaultRandomSource){return b.randomBytes(d)}U.defaultRandomSource=new y.SystemRandomSource,U.randomBytes=w,U.randomUint32=function m(d=U.defaultRandomSource){const b=w(4,d),S=(0,l.readUint32LE)(b);return(0,g.wipe)(b),S};const h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(d,b=h,S=U.defaultRandomSource){if(b.length<2)throw new Error("randomString charset is too short");if(b.length>256)throw new Error("randomString charset is too long");let E="";const v=b.length,p=256-256%v;for(;d>0;){const I=w(Math.ceil(256*d/p),S);for(let A=0;A0;A++){const P=I[A];P{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.BrowserRandomSource=void 0,U.BrowserRandomSource=class y{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const g=typeof self<"u"?self.crypto||self.msCrypto:null;g&&void 0!==g.getRandomValues&&(this._crypto=g,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(g){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const w=new Uint8Array(g);for(let m=0;m{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.NodeRandomSource=void 0;const y=x(9815);U.NodeRandomSource=class l{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const w=x(5883);w&&w.randomBytes&&(this._crypto=w,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(w){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let m=this._crypto.randomBytes(w);if(m.length!==w)throw new Error("NodeRandomSource: got fewer bytes than requested");const h=new Uint8Array(w);for(let c=0;c{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.SystemRandomSource=void 0;const y=x(7170),l=x(1382);U.SystemRandomSource=class g{constructor(){return this.isAvailable=!1,this.name="",this._source=new y.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new l.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(m){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(m)}}},893:(Y,U,x)=>{"use strict";var l=x(4502),g=x(9815);U.k=32,U.cn=64;var w=function(){function f(){this.digestLength=U.k,this.blockSize=U.cn,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){g.wipe(this._buffer),g.wipe(this._temp),this.reset()},f.prototype.update=function(d,b){if(void 0===b&&(b=d.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var S=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=d[S++],b--;this._bufferLength===this.blockSize&&(h(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(S=h(this._temp,this._state,d,S,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=d[S++],b--;return this},f.prototype.finish=function(d){if(!this._finished){var b=this._bytesHashed,S=this._bufferLength,E=b/536870912|0,v=b<<3,p=b%64<56?64:128;this._buffer[S]=128;for(var I=S+1;I0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(d){return this._state.set(d.state),this._bufferLength=d.bufferLength,d.buffer&&this._buffer.set(d.buffer),this._bytesHashed=d.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(d){g.wipe(d.state),d.buffer&&g.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},f}();U.mE=w;var m=new Int32Array([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 h(f,d,b,S,E){for(;E>=64;){for(var v=d[0],p=d[1],I=d[2],A=d[3],P=d[4],D=d[5],T=d[6],M=d[7],k=0;k<16;k++)f[k]=l.readUint32BE(b,S+4*k);for(k=16;k<64;k++){var j=f[k-2];f[k]=((C=(j>>>17|j<<15)^(j>>>19|j<<13)^j>>>10)+f[k-7]|0)+((O=((j=f[k-15])>>>7|j<<25)^(j>>>18|j<<14)^j>>>3)+f[k-16]|0)}for(k=0;k<64;k++){var C=(((P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7))+(P&D^~P&T)|0)+(M+(m[k]+f[k]|0)|0)|0,O=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&p^v&I^p&I)|0;M=T,T=D,D=P,P=A+C|0,A=I,I=p,p=v,v=C+O|0}d[0]+=v,d[1]+=p,d[2]+=I,d[3]+=A,d[4]+=P,d[5]+=D,d[6]+=T,d[7]+=M,S+=64,E-=64}return S}U.vp=function c(f){var d=new w;d.update(f);var b=d.digest();return d.clean(),b}},9815:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.wipe=function x(y){for(var l=0;l{"use strict";U.gi=U.Au=U._w=U.KS=U.kz=void 0;const l=x(5784),g=x(9815);function w(k){const F=new Float64Array(16);if(k)for(let j=0;j=0;--ne){const se=j[ne>>>3]>>>(7&ne)&1;f(O,V,se),f(L,K,se),S(re,O,L),E(O,O,L),S(L,V,K),E(V,V,K),p(K,re),p(G,O),v(O,L,O),v(L,V,re),S(re,O,L),E(O,O,L),p(V,O),E(L,K,G),v(O,L,h),S(O,O,K),v(L,L,O),v(O,K,G),v(K,V,C),p(V,re),f(O,V,se),f(L,K,se)}for(let ne=0;ne<16;ne++)C[ne+16]=O[ne],C[ne+32]=L[ne],C[ne+48]=V[ne],C[ne+64]=K[ne];const te=C.subarray(32),Z=C.subarray(16);(function I(k,F){const j=w();for(let C=0;C<16;C++)j[C]=F[C];for(let C=253;C>=0;C--)p(j,j),2!==C&&4!==C&&v(j,j,F);for(let C=0;C<16;C++)k[C]=j[C]})(te,te),v(Z,Z,te);const q=new Uint8Array(32);return function d(k,F){const j=w(),C=w();for(let O=0;O<16;O++)C[O]=F[O];c(C),c(C),c(C);for(let O=0;O<2;O++){j[0]=C[0]-65517;for(let L=1;L<15;L++)j[L]=C[L]-65535-(j[L-1]>>16&1),j[L-1]&=65535;j[15]=C[15]-32767-(j[14]>>16&1);const V=j[15]>>16&1;j[14]&=65535,f(C,j,1-V)}for(let O=0;O<16;O++)k[2*O]=255&C[O],k[2*O+1]=C[O]>>8}(q,Z),q}function P(k){return A(k,m)}function D(k){if(k.length!==U.KS)throw new Error(`x25519: seed must be ${U.KS} bytes`);const F=new Uint8Array(k);return{publicKey:P(F),secretKey:F}}U._w=D,U.Au=function T(k){const F=(0,l.randomBytes)(32,k),j=D(F);return(0,g.wipe)(F),j},U.gi=function M(k,F,j=!1){if(k.length!==U.kz)throw new Error("X25519: incorrect secret key length");if(F.length!==U.kz)throw new Error("X25519: incorrect public key length");const C=A(k,F);if(j){let O=0;for(let V=0;V{function U(x){const y=new globalThis.AbortController;function l(){y.abort();for(const g of x)!g||!g.removeEventListener||g.removeEventListener("abort",l)}for(const g of x)if(g&&g.addEventListener){if(g.aborted){l();break}g.addEventListener("abort",l)}return y.signal}Y.exports=U,Y.exports.anySignal=U},3210:Y=>{var U=1e3,x=60*U,y=60*x,l=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Y.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*l;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*U;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=l?f(d,b,l,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=U?f(d,b,U,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=l?Math.round(d/l)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=U?Math.round(d/U)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},1455:(Y,U,x)=>{U.formatArgs=function l(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+Y.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;c.splice(1,0,f,"color: inherit");let d=0,b=0;c[0].replace(/%[a-zA-Z%]/g,S=>{"%%"!==S&&(d++,"%c"===S&&(b=d))}),c.splice(b,0,f)},U.save=function g(c){try{c?U.storage.setItem("debug",c):U.storage.removeItem("debug")}catch{}},U.load=function w(){let c;try{c=U.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c},U.useColors=function y(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},U.storage=function m(){try{return localStorage}catch{}}(),U.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),U.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],U.log=console.debug||console.log||(()=>{}),Y.exports=x(3283)(U);const{formatters:h}=Y.exports;h.j=function(c){try{return JSON.stringify(c)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}},3283:(Y,U,x)=>{Y.exports=function y(l){function w(E){let v,I,A,p=null;function P(...D){if(!P.enabled)return;const T=P,M=Number(new Date);T.diff=M-(v||M),T.prev=v,T.curr=M,v=M,D[0]=w.coerce(D[0]),"string"!=typeof D[0]&&D.unshift("%O");let F=0;D[0]=D[0].replace(/%([a-zA-Z%])/g,(C,O)=>{if("%%"===C)return"%";F++;const V=w.formatters[O];return"function"==typeof V&&(C=V.call(T,D[F]),D.splice(F,1),F--),C}),w.formatArgs.call(T,D),(T.log||w.log).apply(T,D)}return P.namespace=E,P.useColors=w.useColors(),P.color=w.selectColor(E),P.extend=m,P.destroy=w.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==p?p:(I!==w.namespaces&&(I=w.namespaces,A=w.enabled(E)),A),set:D=>{p=D}}),"function"==typeof w.init&&w.init(P),P}function m(E,v){const p=w(this.namespace+(typeof v>"u"?":":v)+E);return p.log=this.log,p}function d(E){return E.toString().substring(2,E.toString().length-2).replace(/\.\*\?$/,"*")}return w.debug=w,w.default=w,w.coerce=function b(E){return E instanceof Error?E.stack||E.message:E},w.disable=function c(){const E=[...w.names.map(d),...w.skips.map(d).map(v=>"-"+v)].join(",");return w.enable(""),E},w.enable=function h(E){let v;w.save(E),w.namespaces=E,w.names=[],w.skips=[];const p=("string"==typeof E?E:"").split(/[\s,]+/),I=p.length;for(v=0;v{w[E]=l[E]}),w.names=[],w.skips=[],w.formatters={},w.selectColor=function g(E){let v=0;for(let p=0;p{"use strict";function U(x,l){l=l||{},this._head=0,this._tail=0,this._capacity=l.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(x)&&this._fromArray(x)}U.prototype.peekAt=function(y){var l=y;if(l===(0|l)){var g=this.size();if(!(l>=g||l<-g))return l<0&&(l+=g),this._list[l=this._head+l&this._capacityMask]}},U.prototype.get=function(y){return this.peekAt(y)},U.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},U.prototype.peekFront=function(){return this.peek()},U.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(U.prototype,"length",{get:function(){return this.size()}}),U.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),l}},U.prototype.push=function(y){if(void 0===y)return this.size();var l=this._tail;return this._list[l]=y,this._tail=l+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&y<=l>>>2&&this._shrinkArray(),g}},U.prototype.removeOne=function(y){var l=y;if(l===(0|l)&&this._head!==this._tail){var g=this.size(),w=this._list.length;if(!(l>=g||l<-g)){l<0&&(l+=g);var h,m=this._list[l=this._head+l&this._capacityMask];if(y0;h--)this._list[l]=this._list[l=l-1+w&this._capacityMask];this._list[l]=void 0,this._head=this._head+1+w&this._capacityMask}else{for(h=g-1-y;h>0;h--)this._list[l]=this._list[l=l+1+w&this._capacityMask];this._list[l]=void 0,this._tail=this._tail-1+w&this._capacityMask}return m}}},U.prototype.remove=function(y,l){var w,g=y,m=l;if(g===(0|g)&&this._head!==this._tail){var h=this.size(),c=this._list.length;if(!(g>=h||g<-h||l<1)){if(g<0&&(g+=h),1===l||!l)return(w=new Array(1))[0]=this.removeOne(g),w;if(0===g&&g+l>=h)return w=this.toArray(),this.clear(),w;var f;for(g+l>h&&(l=h-g),w=new Array(l),f=0;f0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(0===y){for(this._head=this._head+l+c&this._capacityMask,f=l-1;f>0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(g0;f--)this.unshift(this._list[g=g-1+c&this._capacityMask]);for(g=this._head-1+c&this._capacityMask;m>0;)this._list[g=g-1+c&this._capacityMask]=void 0,m--;y<0&&(this._tail=g)}else{for(this._tail=g,g=g+l+c&this._capacityMask,f=h-(l+y);f>0;f--)this.push(this._list[g++]);for(g=this._tail;m>0;)this._list[g=g+1+c&this._capacityMask]=void 0,m--}return this._head<2&&this._tail>1e4&&this._tail<=c>>>2&&this._shrinkArray(),w}}},U.prototype.splice=function(y,l){var g=y;if(g===(0|g)){var w=this.size();if(g<0&&(g+=w),!(g>w)){if(arguments.length>2){var m,h,c,f=arguments.length,d=this._list.length,b=2;if(!w||g0&&(this._head=this._head+g+d&this._capacityMask)):(c=this.remove(g,l),this._head=this._head+g+d&this._capacityMask);f>b;)this.unshift(arguments[--f]);for(m=g;m>0;m--)this.unshift(h[m-1])}else{var S=(h=new Array(w-(g+l))).length;for(m=0;mthis._tail){for(m=this._head;m>>=1,this._capacityMask>>>=1},Y.exports=U},2535:Y=>{"use strict";function U(y,l){for(const g in l)Object.defineProperty(y,g,{value:l[g],enumerable:!0,configurable:!0});return y}Y.exports=function x(y,l,g){if(!y||"string"==typeof y)throw new TypeError("Please pass an Error to err-code");g||(g={}),"object"==typeof l&&(g=l,l=""),l&&(g.code=l);try{return U(y,g)}catch{g.message=y.message,g.stack=y.stack;const m=function(){};return m.prototype=Object.create(Object.getPrototypeOf(y)),U(new m,g)}}},3676:(Y,U,x)=>{"use strict";const l=x(649);U.zN=l.EventIterator},649:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});class x{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(g){if(this.isStopped)return;const w={value:g,done:!1};if(this.pullQueue.length){const m=this.pullQueue.shift();m&&m.resolve(w)}else this.pushQueue.push(Promise.resolve(w)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const g of this.pullQueue)g.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(g){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const w of this.pullQueue)w.reject(g);this.pullQueue.length=0}else{const w=Promise.reject(g);w.catch(()=>{}),this.pushQueue.push(w)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:g=>{const w=this.pushQueue.shift();return w?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),w):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((m,h)=>{this.pullQueue.push({resolve:m,reject:h})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class y{constructor(g,{highWaterMark:w=100,lowWaterMark:m=1}={}){const h=new x;h.highWaterMark=w,h.lowWaterMark=m,h.removeCallback=g({push:c=>h.push(c),stop:()=>h.stop(),fail:c=>h.fail(c),on:(c,f)=>{h.eventHandlers[c]=f}})||(()=>{}),this[Symbol.asyncIterator]=()=>h[Symbol.asyncIterator](),Object.freeze(this)}}U.EventIterator=y,U.default=y},2005:Y=>{"use strict";var U=Object.prototype.hasOwnProperty,x="~";function y(){}function l(h,c,f){this.fn=h,this.context=c,this.once=f||!1}function g(h,c,f,d,b){if("function"!=typeof f)throw new TypeError("The listener must be a function");var S=new l(f,d||h,b),E=x?x+c:c;return h._events[E]?h._events[E].fn?h._events[E]=[h._events[E],S]:h._events[E].push(S):(h._events[E]=S,h._eventsCount++),h}function w(h,c){0==--h._eventsCount?h._events=new y:delete h._events[c]}function m(){this._events=new y,this._eventsCount=0}Object.create&&(y.prototype=Object.create(null),(new y).__proto__||(x=!1)),m.prototype.eventNames=function(){var f,d,c=[];if(0===this._eventsCount)return c;for(d in f=this._events)U.call(f,d)&&c.push(x?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(f)):c},m.prototype.listeners=function(c){var d=this._events[x?x+c:c];if(!d)return[];if(d.fn)return[d.fn];for(var b=0,S=d.length,E=new Array(S);b{"use strict";var y,U="object"==typeof Reflect?Reflect:null,x=U&&"function"==typeof U.apply?U.apply:function(M,k,F){return Function.prototype.apply.call(M,k,F)};y=U&&"function"==typeof U.ownKeys?U.ownKeys:Object.getOwnPropertySymbols?function(M){return Object.getOwnPropertyNames(M).concat(Object.getOwnPropertySymbols(M))}:function(M){return Object.getOwnPropertyNames(M)};var g=Number.isNaN||function(M){return M!=M};function w(){w.init.call(this)}Y.exports=w,Y.exports.once=function A(T,M){return new Promise(function(k,F){function j(O){T.removeListener(M,C),F(O)}function C(){"function"==typeof T.removeListener&&T.removeListener("error",j),k([].slice.call(arguments))}D(T,M,C,{once:!0}),"error"!==M&&function P(T,M,k){"function"==typeof T.on&&D(T,"error",M,k)}(T,j,{once:!0})})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var m=10;function h(T){if("function"!=typeof T)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof T)}function c(T){return void 0===T._maxListeners?w.defaultMaxListeners:T._maxListeners}function f(T,M,k,F){var j,C,O;if(h(k),void 0===(C=T._events)?(C=T._events=Object.create(null),T._eventsCount=0):(void 0!==C.newListener&&(T.emit("newListener",M,k.listener?k.listener:k),C=T._events),O=C[M]),void 0===O)O=C[M]=k,++T._eventsCount;else if("function"==typeof O?O=C[M]=F?[k,O]:[O,k]:F?O.unshift(k):O.push(k),(j=c(T))>0&&O.length>j&&!O.warned){O.warned=!0;var V=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(M)+" listeners added. Use emitter.setMaxListeners() to increase limit");V.name="MaxListenersExceededWarning",V.emitter=T,V.type=M,V.count=O.length,function l(T){console&&console.warn&&console.warn(T)}(V)}return T}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function b(T,M,k){var F={fired:!1,wrapFn:void 0,target:T,type:M,listener:k},j=d.bind(F);return j.listener=k,F.wrapFn=j,j}function S(T,M,k){var F=T._events;if(void 0===F)return[];var j=F[M];return void 0===j?[]:"function"==typeof j?k?[j.listener||j]:[j]:k?function I(T){for(var M=new Array(T.length),k=0;k0&&(O=k[0]),O instanceof Error)throw O;var V=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw V.context=O,V}var L=C[M];if(void 0===L)return!1;if("function"==typeof L)x(L,this,k);else{var K=L.length,re=v(L,K);for(F=0;F=0;O--)if(F[O]===k||F[O].listener===k){V=F[O].listener,C=O;break}if(C<0)return this;0===C?F.shift():function p(T,M){for(;M+1=0;j--)this.removeListener(M,k[j]);return this},w.prototype.listeners=function(M){return S(this,M,!0)},w.prototype.rawListeners=function(M){return S(this,M,!1)},w.listenerCount=function(T,M){return"function"==typeof T.listenerCount?T.listenerCount(M):E.call(T,M)},w.prototype.listenerCount=E,w.prototype.eventNames=function(){return this._eventsCount>0?y(this._events):[]}},3111:Y=>{Y.exports=class{constructor(x){if(!(x>0)||0!=(x-1&x))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(x),this.mask=x-1,this.top=0,this.btm=0,this.next=null}push(x){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=x,this.top=this.top+1&this.mask,!0)}shift(){const x=this.buffer[this.btm];if(void 0!==x)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,x}peek(){return this.buffer[this.btm]}isEmpty(){return void 0===this.buffer[this.btm]}}},1159:(Y,U,x)=>{const y=x(3111);Y.exports=class{constructor(g){this.hwm=g||16,this.head=new y(this.hwm),this.tail=this.head}push(g){this.head.push(g)||(this.head=this.head.next=new y(2*this.head.buffer.length),this.head.push(g))}shift(){const g=this.tail.shift();if(void 0===g&&this.tail.next){const w=this.tail.next;return this.tail.next=null,this.tail=w,this.tail.shift()}return g}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}},5550:Y=>{Y.exports=function(U){if(!U)throw Error("hashlru must have a max value, of type number, greater than 0");var x=0,y=Object.create(null),l=Object.create(null);function g(w,m){y[w]=m,++x>=U&&(x=0,l=y,y=Object.create(null))}return{has:function(w){return void 0!==y[w]||void 0!==l[w]},remove:function(w){void 0!==y[w]&&(y[w]=void 0),void 0!==l[w]&&(l[w]=void 0)},get:function(w){var m=y[w];return void 0!==m?m:void 0!==(m=l[w])?(g(w,m),m):void 0},set:function(w,m){void 0!==y[w]?y[w]=m:g(w,m)},clear:function(){y=Object.create(null),l=Object.create(null)}}}},4066:Y=>{"use strict";const U="[a-fA-F\\d:]",x=f=>f&&f.includeBoundaries?`(?:(?<=\\s|^)(?=${U})|(?<=${U})(?=\\s|$))`:"",y="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",l="[a-fA-F\\d]{1,4}",g=`\n(?:\n(?:${l}:){7}(?:${l}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${l}:){6}(?:${y}|:${l}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${l}:){5}(?::${y}|(?::${l}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${l}:){4}(?:(?::${l}){0,1}:${y}|(?::${l}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${l}:){3}(?:(?::${l}){0,2}:${y}|(?::${l}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${l}:){2}(?:(?::${l}){0,3}:${y}|(?::${l}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${l}:){1}(?:(?::${l}){0,4}:${y}|(?::${l}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${l}){0,5}:${y}|(?::${l}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),w=new RegExp(`(?:^${y}$)|(?:^${g}$)`),m=new RegExp(`^${y}$`),h=new RegExp(`^${g}$`),c=f=>f&&f.exact?w:new RegExp(`(?:${x(f)}${y}${x(f)})|(?:${x(f)}${g}${x(f)})`,"g");c.v4=f=>f&&f.exact?m:new RegExp(`${x(f)}${y}${x(f)}`,"g"),c.v6=f=>f&&f.exact?h:new RegExp(`${x(f)}${g}${x(f)}`,"g"),Y.exports=c},1396:function(Y){!function(U){"use strict";const x="(0?\\d+|0x[a-f0-9]+)",y={fourOctet:new RegExp(`^${x}\\.${x}\\.${x}\\.${x}$`,"i"),threeOctet:new RegExp(`^${x}\\.${x}\\.${x}$`,"i"),twoOctet:new RegExp(`^${x}\\.${x}$`,"i"),longValue:new RegExp(`^${x}$`,"i")},l=new RegExp("^0[0-7]+$","i"),g=new RegExp("^0x[a-f0-9]+$","i"),w="%[0-9a-z]{1,}",m="(?:[0-9a-f]+::?)+",h={zoneIndex:new RegExp(w,"i"),native:new RegExp(`^(::)?(${m})?([0-9a-f]+)?(::)?(${w})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${x}\\.${x}\\.${x}\\.${x}(${w})?)$`,"i"),transitional:new RegExp(`^((?:${m})|(?:::)(?:${m})?)${x}\\.${x}\\.${x}\\.${x}(${w})?$`,"i")};function c(E,v){if(E.indexOf("::")!==E.lastIndexOf("::"))return null;let P,D,p=0,I=-1,A=(E.match(h.zoneIndex)||[])[0];for(A&&(A=A.substring(1),E=E.replace(/%.+$/,""));(I=E.indexOf(":",I+1))>=0;)p++;if("::"===E.substr(0,2)&&p--,"::"===E.substr(-2,2)&&p--,p>v)return null;for(D=v-p,P=":";D--;)P+="0:";return":"===(E=E.replace("::",P))[0]&&(E=E.slice(1)),":"===E[E.length-1]&&(E=E.slice(0,-1)),{parts:v=function(){const T=E.split(":"),M=[];for(let k=0;k0;){if(P=p-I,P<0&&(P=0),E[A]>>P!=v[A]>>P)return!1;I-=p,A+=1}return!0}function d(E){if(g.test(E))return parseInt(E,16);if("0"===E[0]&&!isNaN(parseInt(E[1],10))){if(l.test(E))return parseInt(E,8);throw new Error(`ipaddr: cannot parse ${E} as octal`)}return parseInt(E,10)}function b(E,v){for(;E.length=0;A-=1){if(P=this.octets[A],!(P in I))return null;if(D=I[P],p&&0!==D)return null;8!==D&&(p=!0),v+=D}return 32-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){return this.octets.slice(0)},E.prototype.toIPv4MappedAddress=function(){return S.IPv6.parse(`::ffff:${this.toString()}`)},E.prototype.toNormalizedString=function(){return this.toString()},E.prototype.toString=function(){return this.octets.join(".")},E}(),S.IPv4.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<4;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.isIPv4=function(E){return null!==this.parser(E)},S.IPv4.isValid=function(E){try{return new this(this.parser(E)),!0}catch{return!1}},S.IPv4.isValidFourPartDecimal=function(E){return!(!S.IPv4.isValid(E)||!E.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},S.IPv4.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<4;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.parse=function(E){const v=this.parser(E);if(null===v)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(v)},S.IPv4.parseCIDR=function(E){let v;if(v=E.match(/^(.+)\/(\d+)$/)){const p=parseInt(v[2]);if(p>=0&&p<=32){const I=[this.parse(v[1]),p];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},S.IPv4.parser=function(E){let v,p,I;if(v=E.match(y.fourOctet))return function(){const A=v.slice(1,6),P=[];for(let D=0;D4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const A=[];let P;for(P=0;P<=24;P+=8)A.push(I>>P&255);return A}().reverse()}return(v=E.match(y.twoOctet))?function(){const A=v.slice(1,4),P=[];if(I=d(A[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(I>>16&255),P.push(I>>8&255),P.push(255&I),P}():(v=E.match(y.threeOctet))?function(){const A=v.slice(1,5),P=[];if(I=d(A[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(d(A[1])),P.push(I>>8&255),P.push(255&I),P}():null},S.IPv4.subnetMaskFromPrefixLength=function(E){if((E=parseInt(E))<0||E>32)throw new Error("ipaddr: invalid IPv4 prefix length");const v=[0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p=0;D-=1){if(A=this.parts[D],!(A in I))return null;if(P=I[A],p&&0!==P)return null;16!==P&&(p=!0),v+=P}return 128-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){let v;const p=[],I=this.parts;for(let A=0;A>8),p.push(255&v);return p},E.prototype.toFixedLengthString=function(){const v=function(){const I=[];for(let A=0;A>8,255&p,I>>8,255&I])},E.prototype.toNormalizedString=function(){const v=function(){const I=[];for(let A=0;AA&&(I=P.index,A=P[0].length);return A<0?p:`${p.substring(0,I)}::${p.substring(I+A)}`},E.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},E}(),S.IPv6.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<16;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch(v){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${v})`)}},S.IPv6.isIPv6=function(E){return null!==this.parser(E)},S.IPv6.isValid=function(E){if("string"==typeof E&&-1===E.indexOf(":"))return!1;try{const v=this.parser(E);return new this(v.parts,v.zoneId),!0}catch{return!1}},S.IPv6.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<16;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch(D){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${D})`)}},S.IPv6.parse=function(E){const v=this.parser(E);if(null===v.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(v.parts,v.zoneId)},S.IPv6.parseCIDR=function(E){let v,p,I;if((p=E.match(/^(.+)\/(\d+)$/))&&(v=parseInt(p[2]),v>=0&&v<=128))return I=[this.parse(p[1]),v],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},S.IPv6.parser=function(E){let v,p,I,A,P,D;if(I=E.match(h.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(h.native.test(E))return c(E,8);if((I=E.match(h.transitional))&&(D=I[6]||"",v=c(I[1].slice(0,-1)+D,6),v.parts)){for(P=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],p=0;p128)throw new Error("ipaddr: invalid IPv6 prefix length");const v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p{Y.exports=function U(){return typeof window<"u"&&"object"==typeof window.process&&"renderer"===window.process.type||typeof process<"u"&&"object"==typeof process.versions&&!!process.versions.electron||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0}},7494:Y=>{"use strict";Y.exports=U=>{if("[object Object]"!==Object.prototype.toString.call(U))return!1;const x=Object.getPrototypeOf(U);return null===x||x===Object.prototype}},8596:(Y,U,x)=>{"use strict";const{URLWithLegacySupport:y,format:l,URLSearchParams:g,defaultBase:w}=x(5695),m=x(340);Y.exports={URL:y,URLSearchParams:g,format:l,relative:m,defaultBase:w}},340:(Y,U,x)=>{"use strict";const{URLWithLegacySupport:y,format:l}=x(5695);Y.exports=(g,w={},m={},h)=>{let f,c=w.protocol?w.protocol.replace(":",""):"http";c=(m[c]||h||c)+":";try{f=new y(g)}catch{f={}}const d=Object.assign({},w,{protocol:c||f.protocol,host:w.host||f.host});return new y(g,l(d)).toString()}},5695:Y=>{"use strict";const U=typeof navigator<"u"&&"ReactNative"===navigator.product,y=self.URL,l=function x(){return U?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}();Y.exports={URLWithLegacySupport:class g{constructor(h="",c=l){this.super=new y(h,c),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(h){this.super.hash=h}set host(h){this.super.host=h}set hostname(h){this.super.hostname=h}set href(h){this.super.href=h}set password(h){this.super.password=h}set pathname(h){this.super.pathname=h}set port(h){this.super.port=h}set protocol(h){this.super.protocol=h}set search(h){this.super.search=h}set username(h){this.super.username=h}static createObjectURL(h){return y.createObjectURL(h)}static revokeObjectURL(h){y.revokeObjectURL(h)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:l,format:function w(m){if("string"==typeof m)return new y(m).toString();if(!(m instanceof y)){const c=m.auth?m.auth+"@":"",f=m.port?":"+m.port:"",S=m.hostname||"",E=m.search||(m.query?"?"+m.query:""),p=m.pathname||"";return`${m.protocol?m.protocol+"//":""}${(m.username&&m.password?`${m.username}:${m.password}@`:"")||c}${m.host||S+f}${m.path||p+E}${m.hash||""}`}}}},5357:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8237).default;Y.exports=function(){var w=y(function*(m){const h=[];var d,c=!1,f=!1;try{for(var S,b=l(m);c=!(S=yield b.next()).done;c=!1)h.push(S.value)}catch(E){f=!0,d=E}finally{try{c&&null!=b.return&&(yield b.return())}finally{if(f)throw d}}return h});return function(h){return w.apply(this,arguments)}}()},7414:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8237).default;Y.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var d=l(m);h=!(yield d.next()).done;h=!1);}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},6225:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;(yield y(c(v)))&&(yield v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},4943:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8237).default;Y.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var b,d=l(m);h=!(b=yield d.next()).done;h=!1)return b.value}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},1349:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield y(c(v)),yield v}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},6930:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield c(v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},5061:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8186).default,g=x(6737).default,w=x(8237).default,m=x(8131).default;const h=x(6343);Y.exports=function(){var f=l(function*(...d){const b=h();setTimeout(y(function*(){try{yield Promise.all(d.map(function(){var S=y(function*(E){var I,v=!1,p=!1;try{for(var P,A=w(E);v=!(P=yield A.next()).done;v=!1)b.push(P.value)}catch(D){p=!0,I=D}finally{try{v&&null!=A.return&&(yield A.return())}finally{if(p)throw I}}});return function(E){return S.apply(this,arguments)}}())),b.end()}catch(S){b.end(S)}}),0),yield*m(w(b),g)});return function(){return f.apply(this,arguments)}}()},6343:(Y,U,x)=>{const y=x(1159);Y.exports=l=>{let g;"function"==typeof(l=l||{})?(g=l,l={}):g=l.onEnd;let m,h,c,w=new y;const d=A=>h?h(A):(w.push(A),m),S=A=>c?m:d({done:!1,value:A}),E=A=>c?m:(c=!0,A?(A=>(w=new y,h?h({error:A}):(w.push({error:A}),m)))(A):d({done:!0}));if(m={[Symbol.asyncIterator](){return this},next:()=>{if(!w.isEmpty()){if(l.writev){let P;const D=[];for(;!w.isEmpty();){if(P=w.shift(),P.error)throw P.error;D.push(P.value)}return{done:P.done,value:D}}const A=w.shift();if(A.error)throw A.error;return A}return c?{done:!0}:new Promise((A,P)=>{h=D=>(h=null,D.error?P(D.error):A(l.writev&&!D.done?{done:D.done,value:[D.value]}:D),m)})},return:()=>(w=new y,E(),{done:!0}),throw:A=>(E(A),{done:!0}),push:S,end:E},!g)return m;const I=m;return m={[Symbol.asyncIterator](){return this},next:()=>I.next(),throw:A=>(I.throw(A),g&&(g(A),g=null),{done:!0}),return:()=>(I.return(),g&&(g(),g=null),{done:!0}),push:S,end:A=>(I.end(A),g&&(g(A),g=null),m)},m}},4297:(Y,U,x)=>{"use strict";var y=x(8186).default,l=x(6737).default,g=x(8237).default,w=x(8131).default;const m=x(5357);Y.exports=function(){var c=y(function*(f,d){const b=yield l(m(f));yield*w(g(b.sort(d)),l)});return function(d,b){return c.apply(this,arguments)}}()},0:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){let f=0;if(!(c<1)){var S,d=!1,b=!1;try{for(var v,E=g(h);d=!(v=yield y(E.next())).done;d=!1)if(yield v.value,f++,f===c)return}catch(p){b=!0,S=p}finally{try{d&&null!=E.return&&(yield y(E.return()))}finally{if(b)throw S}}}});return function(c,f){return m.apply(this,arguments)}}()},4237:(Y,U,x)=>{var y;!function(){"use strict";var l="input is invalid type",w="object"==typeof window,m=w?window:{};m.JS_SHA3_NO_WINDOW&&(w=!1);var h=!w&&"object"==typeof self;!m.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?m=global:h&&(m=self);var f=!m.JS_SHA3_NO_COMMON_JS&&Y.exports,d=x.amdO,b=!m.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",S="0123456789abcdef".split(""),v=[4,1024,262144,67108864],A=[0,8,16,24],P=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],D=[224,256,384,512],T=[128,256],M=["hex","buffer","arrayBuffer","array","digest"],k={128:168,256:136};(m.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(H){return"[object Array]"===Object.prototype.toString.call(H)}),b&&(m.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(H){return"object"==typeof H&&H.buffer&&H.buffer.constructor===ArrayBuffer});for(var F=function(H,Ee,Ie){return function(Re){return new Ne(H,Ee,H).update(Re)[Ie]()}},j=function(H,Ee,Ie){return function(Re,He){return new Ne(H,Ee,He).update(Re)[Ie]()}},C=function(H,Ee,Ie){return function(Re,He,We,Je){return Z["cshake"+H].update(Re,He,We,Je)[Ie]()}},O=function(H,Ee,Ie){return function(Re,He,We,Je){return Z["kmac"+H].update(Re,He,We,Je)[Ie]()}},V=function(H,Ee,Ie,Re){for(var He=0;He>5,this.byteCount=this.blockCount<<2,this.outputBlocks=Ie>>5,this.extraBytes=(31&Ie)>>3;for(var Re=0;Re<50;++Re)this.s[Re]=0}function be(H,Ee,Ie){Ne.call(this,H,Ee,Ie)}Ne.prototype.update=function(H){if(this.finalized)throw new Error("finalize already called");var Ee,Ie=typeof H;if("string"!==Ie){if("object"!==Ie)throw new Error(l);if(null===H)throw new Error(l);if(b&&H.constructor===ArrayBuffer)H=new Uint8Array(H);else if(!(Array.isArray(H)||b&&ArrayBuffer.isView(H)))throw new Error(l);Ee=!0}for(var pt,_t,Re=this.blocks,He=this.byteCount,We=H.length,Je=this.blockCount,Xe=0,Nt=this.s;Xe>2]|=H[Xe]<>2]|=_t<>2]|=(192|_t>>6)<>2]|=(128|63&_t)<=57344?(Re[pt>>2]|=(224|_t>>12)<>2]|=(128|_t>>6&63)<>2]|=(128|63&_t)<>2]|=(240|_t>>18)<>2]|=(128|_t>>12&63)<>2]|=(128|_t>>6&63)<>2]|=(128|63&_t)<=He){for(this.start=pt-He,this.block=Re[Je],pt=0;pt>=8);Ie>0;)He.unshift(Ie),Ie=255&(H>>=8),++Re;return Ee?He.push(Re):He.unshift(Re),this.update(He),He.length},Ne.prototype.encodeString=function(H){var Ee,Ie=typeof H;if("string"!==Ie){if("object"!==Ie)throw new Error(l);if(null===H)throw new Error(l);if(b&&H.constructor===ArrayBuffer)H=new Uint8Array(H);else if(!(Array.isArray(H)||b&&ArrayBuffer.isView(H)))throw new Error(l);Ee=!0}var Re=0;if(Ee)Re=H.length;else for(var We=0;We=57344?Re+=3:(Je=65536+((1023&Je)<<10|1023&H.charCodeAt(++We)),Re+=4)}return Re+=this.encode(8*Re),this.update(H),Re},Ne.prototype.bytepad=function(H,Ee){for(var Ie=this.encode(Ee),Re=0;Re>2]|=this.padding[3&Ee],this.lastByteIndex===this.byteCount)for(H[0]=H[Ie],Ee=1;Ee>4&15]+S[15&Xe]+S[Xe>>12&15]+S[Xe>>8&15]+S[Xe>>20&15]+S[Xe>>16&15]+S[Xe>>28&15]+S[Xe>>24&15];We%H==0&&(je(Ee),He=0)}return Re&&(Je+=S[(Xe=Ee[He])>>4&15]+S[15&Xe],Re>1&&(Je+=S[Xe>>12&15]+S[Xe>>8&15]),Re>2&&(Je+=S[Xe>>20&15]+S[Xe>>16&15])),Je},Ne.prototype.buffer=Ne.prototype.arrayBuffer=function(){this.finalize();var Xe,H=this.blockCount,Ee=this.s,Ie=this.outputBlocks,Re=this.extraBytes,He=0,We=0,Je=this.outputBits>>3;Xe=Re?new ArrayBuffer(Ie+1<<2):new ArrayBuffer(Je);for(var Nt=new Uint32Array(Xe);We>8&255,Je[Xe+2]=Nt>>16&255,Je[Xe+3]=Nt>>24&255;We%H==0&&je(Ee)}return Re&&(Je[Xe=We<<2]=255&(Nt=Ee[He]),Re>1&&(Je[Xe+1]=Nt>>8&255),Re>2&&(Je[Xe+2]=Nt>>16&255)),Je},(be.prototype=new Ne).finalize=function(){return this.encode(this.outputBits,!0),Ne.prototype.finalize.call(this)};var je=function(H){var Ee,Ie,Re,He,We,Je,Xe,Nt,pt,_t,Or,pr,Hr,ie,fe,ye,me,_e,Me,Qe,qe,it,nt,$e,we,ge,De,Fe,Be,dt,xt,vt,et,An,Bt,gn,tn,ft,fn,st,Kt,wt,er,Pr,kn,En,cr,Zn,bn,Ft,ct,ce,ve,mt,Dt,yn,ze,Ye,Ae,Ge,ht,Et,ut;for(Re=0;Re<48;Re+=2)He=H[0]^H[10]^H[20]^H[30]^H[40],We=H[1]^H[11]^H[21]^H[31]^H[41],Nt=H[4]^H[14]^H[24]^H[34]^H[44],pt=H[5]^H[15]^H[25]^H[35]^H[45],_t=H[6]^H[16]^H[26]^H[36]^H[46],Or=H[7]^H[17]^H[27]^H[37]^H[47],Ie=(Hr=H[9]^H[19]^H[29]^H[39]^H[49])^((Xe=H[3]^H[13]^H[23]^H[33]^H[43])<<1|(Je=H[2]^H[12]^H[22]^H[32]^H[42])>>>31),H[0]^=Ee=(pr=H[8]^H[18]^H[28]^H[38]^H[48])^(Je<<1|Xe>>>31),H[1]^=Ie,H[10]^=Ee,H[11]^=Ie,H[20]^=Ee,H[21]^=Ie,H[30]^=Ee,H[31]^=Ie,H[40]^=Ee,H[41]^=Ie,Ie=We^(pt<<1|Nt>>>31),H[2]^=Ee=He^(Nt<<1|pt>>>31),H[3]^=Ie,H[12]^=Ee,H[13]^=Ie,H[22]^=Ee,H[23]^=Ie,H[32]^=Ee,H[33]^=Ie,H[42]^=Ee,H[43]^=Ie,Ie=Xe^(Or<<1|_t>>>31),H[4]^=Ee=Je^(_t<<1|Or>>>31),H[5]^=Ie,H[14]^=Ee,H[15]^=Ie,H[24]^=Ee,H[25]^=Ie,H[34]^=Ee,H[35]^=Ie,H[44]^=Ee,H[45]^=Ie,Ie=pt^(Hr<<1|pr>>>31),H[6]^=Ee=Nt^(pr<<1|Hr>>>31),H[7]^=Ie,H[16]^=Ee,H[17]^=Ie,H[26]^=Ee,H[27]^=Ie,H[36]^=Ee,H[37]^=Ie,H[46]^=Ee,H[47]^=Ie,Ie=Or^(We<<1|He>>>31),H[8]^=Ee=_t^(He<<1|We>>>31),H[9]^=Ie,H[18]^=Ee,H[19]^=Ie,H[28]^=Ee,H[29]^=Ie,H[38]^=Ee,H[39]^=Ie,H[48]^=Ee,H[49]^=Ie,fe=H[1],En=H[11]<<4|H[10]>>>28,cr=H[10]<<4|H[11]>>>28,Fe=H[20]<<3|H[21]>>>29,Be=H[21]<<3|H[20]>>>29,Ge=H[31]<<9|H[30]>>>23,ht=H[30]<<9|H[31]>>>23,wt=H[40]<<18|H[41]>>>14,er=H[41]<<18|H[40]>>>14,An=H[2]<<1|H[3]>>>31,Bt=H[3]<<1|H[2]>>>31,me=H[12]<<12|H[13]>>>20,Zn=H[22]<<10|H[23]>>>22,bn=H[23]<<10|H[22]>>>22,dt=H[33]<<13|H[32]>>>19,xt=H[32]<<13|H[33]>>>19,Et=H[42]<<2|H[43]>>>30,ut=H[43]<<2|H[42]>>>30,mt=H[5]<<30|H[4]>>>2,Dt=H[4]<<30|H[5]>>>2,gn=H[14]<<6|H[15]>>>26,tn=H[15]<<6|H[14]>>>26,Me=H[24]<<11|H[25]>>>21,Ft=H[34]<<15|H[35]>>>17,ct=H[35]<<15|H[34]>>>17,vt=H[45]<<29|H[44]>>>3,et=H[44]<<29|H[45]>>>3,$e=H[6]<<28|H[7]>>>4,we=H[7]<<28|H[6]>>>4,yn=H[17]<<23|H[16]>>>9,ze=H[16]<<23|H[17]>>>9,ft=H[26]<<25|H[27]>>>7,fn=H[27]<<25|H[26]>>>7,Qe=H[36]<<21|H[37]>>>11,qe=H[37]<<21|H[36]>>>11,ce=H[47]<<24|H[46]>>>8,ve=H[46]<<24|H[47]>>>8,Pr=H[8]<<27|H[9]>>>5,kn=H[9]<<27|H[8]>>>5,ge=H[18]<<20|H[19]>>>12,De=H[19]<<20|H[18]>>>12,Ye=H[29]<<7|H[28]>>>25,Ae=H[28]<<7|H[29]>>>25,st=H[38]<<8|H[39]>>>24,Kt=H[39]<<8|H[38]>>>24,it=H[48]<<14|H[49]>>>18,nt=H[49]<<14|H[48]>>>18,H[0]=(ie=H[0])^~(ye=H[13]<<12|H[12]>>>20)&(_e=H[25]<<11|H[24]>>>21),H[1]=fe^~me&Me,H[10]=$e^~ge&Fe,H[11]=we^~De&Be,H[20]=An^~gn&ft,H[21]=Bt^~tn&fn,H[30]=Pr^~En&Zn,H[31]=kn^~cr&bn,H[40]=mt^~yn&Ye,H[41]=Dt^~ze&Ae,H[2]=ye^~_e&Qe,H[3]=me^~Me&qe,H[12]=ge^~Fe&dt,H[13]=De^~Be&xt,H[22]=gn^~ft&st,H[23]=tn^~fn&Kt,H[32]=En^~Zn&Ft,H[33]=cr^~bn&ct,H[42]=yn^~Ye&Ge,H[43]=ze^~Ae&ht,H[4]=_e^~Qe&it,H[5]=Me^~qe&nt,H[14]=Fe^~dt&vt,H[15]=Be^~xt&et,H[24]=ft^~st&wt,H[25]=fn^~Kt&er,H[34]=Zn^~Ft&ce,H[35]=bn^~ct&ve,H[44]=Ye^~Ge&Et,H[45]=Ae^~ht&ut,H[6]=Qe^~it&ie,H[7]=qe^~nt&fe,H[16]=dt^~vt&$e,H[17]=xt^~et&we,H[26]=st^~wt&An,H[27]=Kt^~er&Bt,H[36]=Ft^~ce&Pr,H[37]=ct^~ve&kn,H[46]=Ge^~Et&mt,H[47]=ht^~ut&Dt,H[8]=it^~ie&ye,H[9]=nt^~fe&me,H[18]=vt^~$e&ge,H[19]=et^~we&De,H[28]=wt^~An&gn,H[29]=er^~Bt&tn,H[38]=ce^~Pr&En,H[39]=ve^~kn&cr,H[48]=Et^~mt&yn,H[49]=ut^~Dt&ze,H[0]^=P[Re],H[1]^=P[Re+1]};if(f)Y.exports=Z;else{for(ne=0;neObject.defineProperty(p,I,{value:A,writable:!0,enumerable:!0,configurable:!0}),m=this,h={concatArrays:!1,ignoreUndefined:!1},c=p=>{const I=[];for(const A in p)l.call(p,A)&&I.push(A);if(Object.getOwnPropertySymbols){const A=Object.getOwnPropertySymbols(p);for(const P of A)g.call(p,P)&&I.push(P)}return I};function f(p){return Array.isArray(p)?function d(p){const I=p.slice(0,0);return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):y(p)?function b(p){const I=null===Object.getPrototypeOf(p)?Object.create(null):{};return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):p}const S=(p,I,A,P)=>(A.forEach(D=>{typeof I[D]>"u"&&P.ignoreUndefined||(D in p&&p[D]!==Object.getPrototypeOf(p)?w(p,D,v(p[D],I[D],P)):w(p,D,f(I[D])))}),p);function v(p,I,A){return A.concatArrays&&Array.isArray(p)&&Array.isArray(I)?((p,I,A)=>{let P=p.slice(0,0),D=0;return[p,I].forEach(T=>{const M=[];for(let k=0;k!M.includes(k)),A)}),P})(p,I,A):y(I)&&y(p)?S(p,I,c(I),A):f(I)}Y.exports=function(...p){const I=v(f(h),this!==m&&this||{},h);let A={_:{}};for(const P of p)if(void 0!==P){if(!y(P))throw new TypeError("`"+P+"` is not an Option Object");A=v(A,{_:P},I)}return A._}},4366:Y=>{var U=1e3,x=60*U,y=60*x,l=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Y.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*l;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*U;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=l?f(d,b,l,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=U?f(d,b,U,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=l?Math.round(d/l)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=U?Math.round(d/U)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},344:Y=>{"use strict";function U(x){if(Array.isArray(x)){for(var y=0,l=Array(x.length);y>>24,(f&255<<16)>>>16,(65280&f)>>>8,255&f].join(".")},h=function(f){var d,S,E,v,p;for(d=[],S=E=0;E<=3&&0!==f.length;S=++E){if(S>0){if("."!==f[0])throw new Error("Invalid IP");f=f.substring(1)}v=(p=y(f))[0],f=f.substring(p[1]),d.push(v)}if(0!==f.length)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},g=(l=function(f){return f.charCodeAt(0)})("0"),m=l("a"),w=l("A"),y=function(f){var d,b,S,E,v;for(E=0,d=10,b="9",S=0,f.length>1&&"0"===f[S]&&("x"===f[S+1]||"X"===f[S+1]?(S+=2,d=16):"0"<=f[S+1]&&f[S+1]<="9"&&(S++,d=8,b="7")),v=S;S>>0;else{if(16!==d)break;if("a"<=f[S]&&f[S]<="f")E=E*d+(10+l(f[S])-m)>>>0;else{if(!("A"<=f[S]&&f[S]<="F"))break;E=E*d+(10+l(f[S])-w)>>>0}}if(E>4294967295)throw new Error("too large");S++}if(S===v)throw new Error("empty octet");return[E,S]},x=function(){function f(d,b){var E,v,p;if("string"!=typeof d)throw new Error("Missing `net' parameter");if(b||(p=d.split("/",2),d=p[0],b=p[1]),b||(b=32),"string"==typeof b&&b.indexOf(".")>-1){try{this.maskLong=h(b)}catch(I){throw new Error("Invalid mask: "+b)}for(E=v=32;v>=0;E=--v)if(this.maskLong===4294967295<<32-E>>>0){this.bitmask=E;break}}else{if(!b&&0!==b)throw new Error("Invalid mask: empty");this.bitmask=parseInt(b,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(h(d)&this.maskLong)>>>0}catch(I){throw new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+b);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=c(this.bitmask<=30?this.netLong+this.size-2:this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return f.prototype.contains=function(d){return"string"==typeof d&&(d.indexOf("/")>0||4!==d.split(".").length)&&(d=new f(d)),d instanceof f?this.contains(d.base)&&this.contains(d.broadcast||d.last):(h(d)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},f.prototype.next=function(d){return null==d&&(d=1),new f(c(this.netLong+this.size*d),this.mask)},f.prototype.forEach=function(d){var b,S,E;for(E=h(this.first),S=h(this.last),b=0;E<=S;)d(c(E),E,b),b++,E++},f.prototype.toString=function(){return this.base+"/"+this.bitmask},f}(),U.ip2long=h,U.long2ip=c,U.Netmask=x}).call(this)},1298:(Y,U,x)=>{var y=x(8659);function l(p,I){y.cipher.registerAlgorithm(p,function(){return new y.aes.Algorithm(p,I)})}x(3311),x(3481),x(4747),Y.exports=y.aes=y.aes||{},y.aes.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P});return D.start(I),D},y.aes.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.aes.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P});return D.start(I),D},y.aes.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.aes.Algorithm=function(p,I){g||b();var A=this;A.name=p,A.mode=new I({blockSize:16,cipher:{encrypt:function(P,D){return E(A._w,P,D,!1)},decrypt:function(P,D){return E(A._w,P,D,!0)}}}),A._init=!1},y.aes.Algorithm.prototype.initialize=function(p){if(!this._init){var A,I=p.key;if("string"!=typeof I||16!==I.length&&24!==I.length&&32!==I.length){if(y.util.isArray(I)&&(16===I.length||24===I.length||32===I.length)){A=I,I=y.util.createBuffer();for(var P=0;P>>=2,P=0;P>8^255&k^99,h[k]=A,j=(F=p[k])<<24^k<<16^k<<8^k^F,C=((D=p[A])^(T=p[D])^(M=p[T]))<<24^(A^M)<<16^(A^T^M)<<8^A^D^M;for(var O=0;O<4;++O)f[O][A]=j,d[O][k]=C,j=j<<24|j>>>8,C=C<<24|C>>>8;0===A?A=P=1:(A=D^p[p[p[D^M]]],P^=p[p[P]])}}function S(p,I){for(var P,A=p.slice(0),D=1,T=A.length,k=4*(T+6+1),F=T;F>>16&255]<<24^m[P>>>8&255]<<16^m[255&P]<<8^m[P>>>24]^c[D]<<24,D++):T>6&&F%T==4&&(P=m[P>>>24]<<24^m[P>>>16&255]<<16^m[P>>>8&255]<<8^m[255&P]),A[F]=A[F-T]^P;if(I){for(var j,C=d[0],O=d[1],V=d[2],L=d[3],K=A.slice(0),re=(F=0,(k=A.length)-4);F>>24]]^O[m[j>>>16&255]]^V[m[j>>>8&255]]^L[m[255&j]];A=K}return A}function E(p,I,A,P){var T,M,k,F,j,C,O,V,L,K,re,G,D=p.length/4-1;P?(T=d[0],M=d[1],k=d[2],F=d[3],j=h):(T=f[0],M=f[1],k=f[2],F=f[3],j=m),C=I[0]^p[0],O=I[P?3:1]^p[1],V=I[2]^p[2],L=I[P?1:3]^p[3];for(var te=3,Z=1;Z>>24]^M[O>>>16&255]^k[V>>>8&255]^F[255&L]^p[++te],re=T[O>>>24]^M[V>>>16&255]^k[L>>>8&255]^F[255&C]^p[++te],G=T[V>>>24]^M[L>>>16&255]^k[C>>>8&255]^F[255&O]^p[++te],L=T[L>>>24]^M[C>>>16&255]^k[O>>>8&255]^F[255&V]^p[++te],C=K,O=re,V=G;A[0]=j[C>>>24]<<24^j[O>>>16&255]<<16^j[V>>>8&255]<<8^j[255&L]^p[++te],A[P?3:1]=j[O>>>24]<<24^j[V>>>16&255]<<16^j[L>>>8&255]<<8^j[255&C]^p[++te],A[2]=j[V>>>24]<<24^j[L>>>16&255]<<16^j[C>>>8&255]<<8^j[255&O]^p[++te],A[P?1:3]=j[L>>>24]<<24^j[C>>>16&255]<<16^j[O>>>8&255]<<8^j[255&V]^p[++te]}function v(p){var P,A="AES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},7791:(Y,U,x)=>{var y=x(8659);x(4747),x(6078);var l=Y.exports=y.asn1=y.asn1||{};function g(c,f,d){if(d>f){var b=new Error("Too few bytes to parse DER.");throw b.available=c.length(),b.remaining=f,b.requested=d,b}}function m(c,f,d,b){var S;g(c,f,2);var E=c.getByte();f--;var v=192&E,p=31&E;S=c.length();var I=function(c,f){var d=c.getByte();if(f--,128!==d){var b;if(128&d){var E=127&d;g(c,f,E),b=c.getInt(E<<3)}else b=d;if(b<0)throw new Error("Negative length: "+b);return b}}(c,f);if(f-=S-c.length(),void 0!==I&&I>f){if(b.strict){var A=new Error("Too few bytes to read ASN.1 value.");throw A.available=c.length(),A.remaining=f,A.requested=I,A}I=f}var P,D,T=32==(32&E);if(T)if(P=[],void 0===I)for(;;){if(g(c,f,2),c.bytes(2)===String.fromCharCode(0,0)){c.getBytes(2),f-=2;break}S=c.length(),P.push(m(c,f,d+1,b)),f-=S-c.length()}else for(;I>0;)S=c.length(),P.push(m(c,I,d+1,b)),f-=S-c.length(),I-=S-c.length();if(void 0===P&&v===l.Class.UNIVERSAL&&p===l.Type.BITSTRING&&(D=c.bytes(I)),void 0===P&&b.decodeBitStrings&&v===l.Class.UNIVERSAL&&p===l.Type.BITSTRING&&I>1){var M=c.read,k=f,F=0;if(p===l.Type.BITSTRING&&(g(c,f,1),F=c.getByte(),f--),0===F)try{S=c.length();var C=m(c,f,d+1,{strict:!0,decodeBitStrings:!0}),O=S-c.length();f-=O,p==l.Type.BITSTRING&&O++;var V=C.tagClass;O===I&&(V===l.Class.UNIVERSAL||V===l.Class.CONTEXT_SPECIFIC)&&(P=[C])}catch{}void 0===P&&(c.read=M,f=k)}if(void 0===P){if(void 0===I){if(b.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");I=f}if(p===l.Type.BMPSTRING)for(P="";I>0;I-=2)g(c,f,2),P+=String.fromCharCode(c.getInt16()),f-=2;else P=c.getBytes(I),f-=I}return l.create(v,p,T,P,void 0===D?null:{bitStringContents:D})}l.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},l.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},l.create=function(c,f,d,b,S){if(y.util.isArray(b)){for(var E=[],v=0;v1&&(0===c.value.charCodeAt(0)&&0==(128&c.value.charCodeAt(1))||255===c.value.charCodeAt(0)&&128==(128&c.value.charCodeAt(1)))?b.putBytes(c.value.substr(1)):b.putBytes(c.value);if(f.putByte(d),b.length()<=127)f.putByte(127&b.length());else{var v=b.length(),p="";do{p+=String.fromCharCode(255&v),v>>>=8}while(v>0);for(f.putByte(128|p.length),E=p.length-1;E>=0;--E)f.putByte(p.charCodeAt(E))}return f.putBuffer(b),f},l.oidToDer=function(c){var f=c.split("."),d=y.util.createBuffer();d.putByte(40*parseInt(f[0],10)+parseInt(f[1],10));for(var b,S,E,v,p=2;p>>=7,b||(v|=128),S.push(v),b=!1}while(E>0);for(var I=S.length-1;I>=0;--I)d.putByte(S[I])}return d},l.derToOid=function(c){var f;"string"==typeof c&&(c=y.util.createBuffer(c));var d=c.getByte();f=Math.floor(d/40)+"."+d%40;for(var b=0;c.length()>0;)b<<=7,128&(d=c.getByte())?b+=127&d:(f+="."+(b+d),b=0);return f},l.utcTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,2),10);d=d>=50?1900+d:2e3+d;var b=parseInt(c.substr(2,2),10)-1,S=parseInt(c.substr(4,2),10),E=parseInt(c.substr(6,2),10),v=parseInt(c.substr(8,2),10),p=0;if(c.length>11){var I=c.charAt(10),A=10;"+"!==I&&"-"!==I&&(p=parseInt(c.substr(10,2),10),A+=2)}if(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,0),A&&("+"===(I=c.charAt(A))||"-"===I)){var T=60*parseInt(c.substr(A+1,2),10)+parseInt(c.substr(A+4,2),10);T*=6e4,f.setTime("+"===I?+f-T:+f+T)}return f},l.generalizedTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,4),10),b=parseInt(c.substr(4,2),10)-1,S=parseInt(c.substr(6,2),10),E=parseInt(c.substr(8,2),10),v=parseInt(c.substr(10,2),10),p=parseInt(c.substr(12,2),10),I=0,A=0,P=!1;"Z"===c.charAt(c.length-1)&&(P=!0);var D=c.length-5,T=c.charAt(D);return"+"!==T&&"-"!==T||(A=60*parseInt(c.substr(D+1,2),10)+parseInt(c.substr(D+4,2),10),A*=6e4,"+"===T&&(A*=-1),P=!0),"."===c.charAt(14)&&(I=1e3*parseFloat(c.substr(14),10)),P?(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,I),f.setTime(+f+A)):(f.setFullYear(d,b,S),f.setHours(E,v,p,I)),f},l.dateToUtcTime=function(c){if("string"==typeof c)return c;var f="",d=[];d.push((""+c.getUTCFullYear()).substr(2)),d.push(""+(c.getUTCMonth()+1)),d.push(""+c.getUTCDate()),d.push(""+c.getUTCHours()),d.push(""+c.getUTCMinutes()),d.push(""+c.getUTCSeconds());for(var b=0;b=-128&&c<128)return f.putSignedInt(c,8);if(c>=-32768&&c<32768)return f.putSignedInt(c,16);if(c>=-8388608&&c<8388608)return f.putSignedInt(c,24);if(c>=-2147483648&&c<2147483648)return f.putSignedInt(c,32);var d=new Error("Integer too large; max is 32-bits.");throw d.integer=c,d},l.derToInteger=function(c){"string"==typeof c&&(c=y.util.createBuffer(c));var f=8*c.length();if(f>32)throw new Error("Integer too large; max is 32-bits.");return c.getSignedInt(f)},l.validate=function(c,f,d,b){var S=!1;if((c.tagClass===f.tagClass||typeof f.tagClass>"u")&&(c.type===f.type||typeof f.type>"u"))if(c.constructed===f.constructed||typeof f.constructed>"u"){if(S=!0,f.value&&y.util.isArray(f.value))for(var E=0,v=0;S&&v0&&(b+="\n");for(var S="",E=0;E1?"0x"+y.util.bytesToHex(c.value.slice(1)):"(none)",c.value.length>0){var A=c.value.charCodeAt(0);1==A?b+=" (1 unused bit shown)":A>1&&(b+=" ("+A+" unused bits shown)")}}else if(c.type===l.Type.OCTETSTRING)h.test(c.value)||(b+="("+c.value+") "),b+="0x"+y.util.bytesToHex(c.value);else if(c.type===l.Type.UTF8)try{b+=y.util.decodeUtf8(c.value)}catch(P){if("URI malformed"!==P.message)throw P;b+="0x"+y.util.bytesToHex(c.value)+" (malformed UTF8)"}else c.type===l.Type.PRINTABLESTRING||c.type===l.Type.IA5String?b+=c.value:h.test(c.value)?b+="0x"+y.util.bytesToHex(c.value):b+=0===c.value.length?"[null]":c.value}return b}},2020:Y=>{var U={};Y.exports=U;var x={};U.encode=function(l,g,w){if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');if(void 0!==w&&"number"!=typeof w)throw new TypeError('"maxline" must be a number.');var m="";if(l instanceof Uint8Array){var h=0,c=g.length,f=g.charAt(0),d=[0];for(h=0;h0;)d.push(S%c),S=S/c|0}for(h=0;0===l[h]&&h=0;--h)m+=g[d[h]]}else m=function y(l,g){var w=0,m=g.length,h=g.charAt(0),c=[0];for(w=0;w0;)c.push(d%m),d=d/m|0}var b="";for(w=0;0===l.at(w)&&w=0;--w)b+=g[c[w]];return b}(l,g);if(w){var E=new RegExp(".{1,"+w+"}","g");m=m.match(E).join("\r\n")}return m},U.decode=function(l,g){if("string"!=typeof l)throw new TypeError('"input" must be a string.');if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');var w=x[g];if(!w){w=x[g]=[];for(var m=0;m>=8;for(;S>0;)f.push(255&S),S>>=8}for(var E=0;l[E]===c&&E{var y=x(8659);x(4747),Y.exports=y.cipher=y.cipher||{},y.cipher.algorithms=y.cipher.algorithms||{},y.cipher.createCipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!1})},y.cipher.createDecipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!0})},y.cipher.registerAlgorithm=function(g,w){g=g.toUpperCase(),y.cipher.algorithms[g]=w},y.cipher.getAlgorithm=function(g){return(g=g.toUpperCase())in y.cipher.algorithms?y.cipher.algorithms[g]:null};var l=y.cipher.BlockCipher=function(g){this.algorithm=g.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=g.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=g.decrypt,this.algorithm.initialize(g)};l.prototype.start=function(g){g=g||{};var w={};for(var m in g)w[m]=g[m];w.decrypt=this._decrypt,this._finish=!1,this._input=y.util.createBuffer(),this.output=g.output||y.util.createBuffer(),this.mode.start(w)},l.prototype.update=function(g){for(g&&this._input.putBuffer(g);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},l.prototype.finish=function(g){g&&("ECB"===this.mode.name||"CBC"===this.mode.name)&&(this.mode.pad=function(m){return g(this.blockSize,m,!1)},this.mode.unpad=function(m){return g(this.blockSize,m,!0)});var w={};return w.decrypt=this._decrypt,w.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,w)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,w))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,w))}},3481:(Y,U,x)=>{var y=x(8659);x(4747),y.cipher=y.cipher||{};var l=Y.exports=y.cipher.modes=y.cipher.modes||{};function g(h,c){if("string"==typeof h&&(h=y.util.createBuffer(h)),y.util.isArray(h)&&h.length>4){var f=h;h=y.util.createBuffer();for(var d=0;d0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},l.cbc=function(h){h=h||{},this.name="CBC",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},l.cbc.prototype.start=function(h){if(null===h.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._prev=this._iv.slice(0)}},l.cbc.prototype.encrypt=function(h,c,f){if(h.length()0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},l.cfb=function(h){h=h||{},this.name="CFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},l.cfb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},l.cfb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},l.cfb.prototype.decrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},l.ofb=function(h){h=h||{},this.name="OFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},l.ofb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},l.ofb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===h.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},l.ofb.prototype.decrypt=l.ofb.prototype.encrypt,l.ctr=function(h){h=h||{},this.name="CTR",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},l.ctr.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},l.ctr.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&(h.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}w(this._inBlock)},l.ctr.prototype.decrypt=l.ctr.prototype.encrypt,l.gcm=function(h){h=h||{},this.name="GCM",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0,this._R=3774873600},l.gcm.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");var f,c=y.util.createBuffer(h.iv);if(this._cipherLength=0,f="additionalData"in h?y.util.createBuffer(h.additionalData):y.util.createBuffer(),this._tagLength="tagLength"in h?h.tagLength:128,this._tag=null,h.decrypt&&(this._tag=y.util.createBuffer(h.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var d=c.length();if(12===d)this._j0=[c.getInt32(),c.getInt32(),c.getInt32(),1];else{for(this._j0=[0,0,0,0];c.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[c.getInt32(),c.getInt32(),c.getInt32(),c.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(m(8*d)))}this._inBlock=this._j0.slice(0),w(this._inBlock),this._partialBytes=0,f=y.util.createBuffer(f),this._aDataLength=m(8*f.length());var b=f.length()%this.blockSize;for(b&&f.fillWithByte(0,this.blockSize-b),this._s=[0,0,0,0];f.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[f.getInt32(),f.getInt32(),f.getInt32(),f.getInt32()])},l.gcm.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return h.read-=this.blockSize,c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),w(this._inBlock)},l.gcm.prototype.decrypt=function(h,c,f){var d=h.length();if(d0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),w(this._inBlock),this._hashBlock[0]=h.getInt32(),this._hashBlock[1]=h.getInt32(),this._hashBlock[2]=h.getInt32(),this._hashBlock[3]=h.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var b=0;b0;--d)c[d]=h[d]>>>1|(1&h[d-1])<<31;c[0]=h[0]>>>1,f&&(c[0]^=this._R)},l.gcm.prototype.tableMultiply=function(h){for(var c=[0,0,0,0],f=0;f<32;++f){var S=this._m[f][h[f/8|0]>>>4*(7-f%8)&15];c[0]^=S[0],c[1]^=S[1],c[2]^=S[2],c[3]^=S[3]}return c},l.gcm.prototype.ghash=function(h,c,f){return c[0]^=f[0],c[1]^=f[1],c[2]^=f[2],c[3]^=f[3],this.tableMultiply(c)},l.gcm.prototype.generateHashTable=function(h,c){for(var f=8/c,d=4*f,b=16*f,S=new Array(b),E=0;E>>1,b=new Array(f);b[d]=h.slice(0);for(var S=d>>>1;S>0;)this.pow(b[2*S],b[S]=[]),S>>=1;for(S=2;S{var y=x(8659);function l(p,I){y.cipher.registerAlgorithm(p,function(){return new y.des.Algorithm(p,I)})}x(3311),x(3481),x(4747),Y.exports=y.des=y.des||{},y.des.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.des.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.des.Algorithm=function(p,I){var A=this;A.name=p,A.mode=new I({blockSize:8,cipher:{encrypt:function(P,D){return E(A._keys,P,D,!1)},decrypt:function(P,D){return E(A._keys,P,D,!0)}}}),A._init=!1},y.des.Algorithm.prototype.initialize=function(p){if(!this._init){var I=y.util.createBuffer(p.key);if(0===this.name.indexOf("3DES")&&24!==I.length())throw new Error("Invalid Triple-DES key size: "+8*I.length());this._keys=function S(p){for(var q,I=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],A=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],P=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],D=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],T=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],M=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],k=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],F=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],j=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],C=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],O=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],V=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],L=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],K=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],re=p.length()>8?3:1,G=[],te=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],Z=0,ne=0;ne>>4^he))<<4,se^=q=65535&((he^=q)>>>-16^se),se^=(q=858993459&(se>>>2^(he^=q<<-16)))<<2,se^=q=65535&((he^=q)>>>-16^se),se^=(q=1431655765&(se>>>1^(he^=q<<-16)))<<1,se^=q=16711935&((he^=q)>>>8^se),q=(se^=(q=1431655765&(se>>>1^(he^=q<<8)))<<1)<<8|(he^=q)>>>20&240,se=he<<24|he<<8&16711680|he>>>8&65280|he>>>24&240,he=q;for(var pe=0;pe>>26,he=he<<2|he>>>26):(se=se<<1|se>>>27,he=he<<1|he>>>27);var Le=I[(se&=-15)>>>28]|A[se>>>24&15]|P[se>>>20&15]|D[se>>>16&15]|T[se>>>12&15]|M[se>>>8&15]|k[se>>>4&15],Se=F[(he&=-15)>>>28]|j[he>>>24&15]|C[he>>>20&15]|O[he>>>16&15]|V[he>>>12&15]|L[he>>>8&15]|K[he>>>4&15];G[Z++]=Le^(q=65535&(Se>>>16^Le)),G[Z++]=Se^q<<16}}return G}(I),this._init=!0}},l("DES-ECB",y.cipher.modes.ecb),l("DES-CBC",y.cipher.modes.cbc),l("DES-CFB",y.cipher.modes.cfb),l("DES-OFB",y.cipher.modes.ofb),l("DES-CTR",y.cipher.modes.ctr),l("3DES-ECB",y.cipher.modes.ecb),l("3DES-CBC",y.cipher.modes.cbc),l("3DES-CFB",y.cipher.modes.cfb),l("3DES-OFB",y.cipher.modes.ofb),l("3DES-CTR",y.cipher.modes.ctr);var g=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],w=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],m=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],h=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],c=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],f=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],d=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],b=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function E(p,I,A,P){var T,D=32===p.length?3:9;T=3===D?P?[30,-2,-2]:[0,32,2]:P?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var M,k=I[0],F=I[1];k^=(M=252645135&(k>>>4^F))<<4,k^=(M=65535&(k>>>16^(F^=M)))<<16,k^=M=858993459&((F^=M)>>>2^k),k^=M=16711935&((F^=M<<2)>>>8^k),k=(k^=(M=1431655765&(k>>>1^(F^=M<<8)))<<1)<<1|k>>>31,F=(F^=M)<<1|F>>>31;for(var j=0;j>>4|F<<28)^p[V+1];M=k,k=F,F=M^(w[L>>>24&63]|h[L>>>16&63]|f[L>>>8&63]|b[63&L]|g[K>>>24&63]|m[K>>>16&63]|c[K>>>8&63]|d[63&K])}M=k,k=F,F=M}F=F>>>1|F<<31,F^=M=1431655765&((k=k>>>1|k<<31)>>>1^F),F^=(M=16711935&(F>>>8^(k^=M<<1)))<<8,F^=(M=858993459&(F>>>2^(k^=M)))<<2,F^=M=65535&((k^=M)>>>16^F),F^=M=252645135&((k^=M<<16)>>>4^F),A[0]=k^=M<<4,A[1]=F}function v(p){var P,A="DES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},8659:Y=>{Y.exports={options:{usePureJavaScript:!1}}},9032:(Y,U,x)=>{var y=x(8659);x(979),x(4747),(Y.exports=y.hmac=y.hmac||{}).create=function(){var g=null,w=null,m=null,h=null,c={start:function(f,d){if(null!==f)if("string"==typeof f){if(!((f=f.toLowerCase())in y.md.algorithms))throw new Error('Unknown hash algorithm "'+f+'"');w=y.md.algorithms[f].create()}else w=f;if(null===d)d=g;else{if("string"==typeof d)d=y.util.createBuffer(d);else if(y.util.isArray(d)){var b=d;d=y.util.createBuffer();for(var S=0;Sw.blockLength&&(w.start(),w.update(d.bytes()),d=w.digest()),m=y.util.createBuffer(),h=y.util.createBuffer(),E=d.length(),S=0;S{var l,y=x(8659);function m(W,Q,ee){this.data=[],null!=W&&("number"==typeof W?this.fromNumber(W,Q,ee):this.fromString(W,null==Q&&"string"!=typeof W?256:Q))}function h(){return new m(null)}function d(W,Q,ee,le,ke,Ve){for(var tt=16383&Q,Ze=Q>>14;--Ve>=0;){var sn=16383&this.data[W],gr=this.data[W++]>>14,di=Ze*sn+gr*tt;ke=((sn=tt*sn+((16383&di)<<14)+ee.data[le]+ke)>>28)+(di>>14)+Ze*gr,ee.data[le++]=268435455&sn}return ke}Y.exports=y.jsbn=y.jsbn||{},y.jsbn.BigInteger=m,typeof navigator>"u"?(m.prototype.am=d,l=28):"Microsoft Internet Explorer"==navigator.appName?(m.prototype.am=function f(W,Q,ee,le,ke,Ve){for(var tt=32767&Q,Ze=Q>>15;--Ve>=0;){var sn=32767&this.data[W],gr=this.data[W++]>>15,di=Ze*sn+gr*tt;ke=((sn=tt*sn+((32767&di)<<15)+ee.data[le]+(1073741823&ke))>>>30)+(di>>>15)+Ze*gr+(ke>>>30),ee.data[le++]=1073741823&sn}return ke},l=30):"Netscape"!=navigator.appName?(m.prototype.am=function c(W,Q,ee,le,ke,Ve){for(;--Ve>=0;){var tt=Q*this.data[W++]+ee.data[le]+ke;ke=Math.floor(tt/67108864),ee.data[le++]=67108863&tt}return ke},l=26):(m.prototype.am=d,l=28),m.prototype.DB=l,m.prototype.DM=(1<>>16)&&(W=ee,Q+=16),0!=(ee=W>>8)&&(W=ee,Q+=8),0!=(ee=W>>4)&&(W=ee,Q+=4),0!=(ee=W>>2)&&(W=ee,Q+=2),0!=(ee=W>>1)&&(W=ee,Q+=1),Q}function pe(W){this.m=W}function Ee(W){this.m=W,this.mp=W.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,Q+=16),0==(255&W)&&(W>>=8,Q+=8),0==(15&W)&&(W>>=4,Q+=4),0==(3&W)&&(W>>=2,Q+=2),0==(1&W)&&++Q,Q}function tn(W){for(var Q=0;0!=W;)W&=W-1,++Q;return Q}function ve(){}function mt(W){return W}function Ge(W){this.r2=h(),this.q3=h(),m.ONE.dlShiftTo(2*W.t,this.r2),this.mu=this.r2.divide(W),this.m=W}pe.prototype.convert=function Le(W){return W.s<0||W.compareTo(this.m)>=0?W.mod(this.m):W},pe.prototype.revert=function Se(W){return W},pe.prototype.reduce=function Ne(W){W.divRemTo(this.m,null,W)},pe.prototype.mulTo=function be(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},pe.prototype.sqrTo=function je(W,Q){W.squareTo(Q),this.reduce(Q)},Ee.prototype.convert=function Ie(W){var Q=h();return W.abs().dlShiftTo(this.m.t,Q),Q.divRemTo(this.m,null,Q),W.s<0&&Q.compareTo(m.ZERO)>0&&this.m.subTo(Q,Q),Q},Ee.prototype.revert=function Re(W){var Q=h();return W.copyTo(Q),this.reduce(Q),Q},Ee.prototype.reduce=function He(W){for(;W.t<=this.mt2;)W.data[W.t++]=0;for(var Q=0;Q>15)*this.mpl&this.um)<<15)&W.DM;for(W.data[ee=Q+this.m.t]+=this.m.am(0,le,W,Q,0,this.m.t);W.data[ee]>=W.DV;)W.data[ee]-=W.DV,W.data[++ee]++}W.clamp(),W.drShiftTo(this.m.t,W),W.compareTo(this.m)>=0&&W.subTo(this.m,W)},Ee.prototype.mulTo=function Je(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},Ee.prototype.sqrTo=function We(W,Q){W.squareTo(Q),this.reduce(Q)},m.prototype.copyTo=function P(W){for(var Q=this.t-1;Q>=0;--Q)W.data[Q]=this.data[Q];W.t=this.t,W.s=this.s},m.prototype.fromInt=function D(W){this.t=1,this.s=W<0?-1:0,W>0?this.data[0]=W:W<-1?this.data[0]=W+this.DV:this.t=0},m.prototype.fromString=function M(W,Q){var ee;if(16==Q)ee=4;else if(8==Q)ee=3;else if(256==Q)ee=8;else if(2==Q)ee=1;else if(32==Q)ee=5;else{if(4!=Q)return void this.fromRadix(W,Q);ee=2}this.t=0,this.s=0;for(var le=W.length,ke=!1,Ve=0;--le>=0;){var tt=8==ee?255&W[le]:A(W,le);tt<0?"-"==W.charAt(le)&&(ke=!0):(ke=!1,0==Ve?this.data[this.t++]=tt:Ve+ee>this.DB?(this.data[this.t-1]|=(tt&(1<>this.DB-Ve):this.data[this.t-1]|=tt<=this.DB&&(Ve-=this.DB))}8==ee&&0!=(128&W[0])&&(this.s=-1,Ve>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==W;)--this.t},m.prototype.dlShiftTo=function K(W,Q){var ee;for(ee=this.t-1;ee>=0;--ee)Q.data[ee+W]=this.data[ee];for(ee=W-1;ee>=0;--ee)Q.data[ee]=0;Q.t=this.t+W,Q.s=this.s},m.prototype.drShiftTo=function re(W,Q){for(var ee=W;ee=0;--Ze)Q.data[Ze+Ve+1]=this.data[Ze]>>le|tt,tt=(this.data[Ze]&ke)<=0;--Ze)Q.data[Ze]=0;Q.data[Ve]=tt,Q.t=this.t+Ve+1,Q.s=this.s,Q.clamp()},m.prototype.rShiftTo=function te(W,Q){Q.s=this.s;var ee=Math.floor(W/this.DB);if(ee>=this.t)Q.t=0;else{var le=W%this.DB,ke=this.DB-le,Ve=(1<>le;for(var tt=ee+1;tt>le;le>0&&(Q.data[this.t-ee-1]|=(this.s&Ve)<>=this.DB;if(W.t>=this.DB;le+=this.s}else{for(le+=this.s;ee>=this.DB;le-=W.s}Q.s=le<0?-1:0,le<-1?Q.data[ee++]=this.DV+le:le>0&&(Q.data[ee++]=le),Q.t=ee,Q.clamp()},m.prototype.multiplyTo=function q(W,Q){var ee=this.abs(),le=W.abs(),ke=ee.t;for(Q.t=ke+le.t;--ke>=0;)Q.data[ke]=0;for(ke=0;ke=0;)W.data[ee]=0;for(ee=0;ee=Q.DV&&(W.data[ee+Q.t]-=Q.DV,W.data[ee+Q.t+1]=1)}W.t>0&&(W.data[W.t-1]+=Q.am(ee,Q.data[ee],W,2*ee,0,1)),W.s=0,W.clamp()},m.prototype.divRemTo=function se(W,Q,ee){var le=W.abs();if(!(le.t<=0)){var ke=this.abs();if(ke.t0?(le.lShiftTo(sn,Ve),ke.lShiftTo(sn,ee)):(le.copyTo(Ve),ke.copyTo(ee));var gr=Ve.t,di=Ve.data[gr-1];if(0!=di){var ei=di*(1<1?Ve.data[gr-2]>>this.F2:0),ns=this.FV/ei,Io=(1<=0&&(ee.data[ee.t++]=1,ee.subTo(Li,ee)),m.ONE.dlShiftTo(gr,Li),Li.subTo(Ve,Ve);Ve.t=0;){var bu=ee.data[--ti]==di?this.DM:Math.floor(ee.data[ti]*ns+(ee.data[ti-1]+Jt)*Io);if((ee.data[ti]+=Ve.am(0,bu,ee,wn,0,gr))0&&ee.rShiftTo(sn,ee),tt<0&&m.ZERO.subTo(ee,ee)}}},m.prototype.invDigit=function H(){if(this.t<1)return 0;var W=this.data[0];if(0==(1&W))return 0;var Q=3&W;return(Q=(Q=(Q=(Q=Q*(2-(15&W)*Q)&15)*(2-(255&W)*Q)&255)*(2-((65535&W)*Q&65535))&65535)*(2-W*Q%this.DV)%this.DV)>0?this.DV-Q:-Q},m.prototype.isEven=function Xe(){return 0==(this.t>0?1&this.data[0]:this.s)},m.prototype.exp=function Nt(W,Q){if(W>4294967295||W<1)return m.ONE;var ee=h(),le=h(),ke=Q.convert(this),Ve=V(W)-1;for(ke.copyTo(ee);--Ve>=0;)if(Q.sqrTo(ee,le),(W&1<0)Q.mulTo(le,ke,ee);else{var tt=ee;ee=le,le=tt}return Q.revert(ee)},m.prototype.toString=function F(W){if(this.s<0)return"-"+this.negate().toString(W);var Q;if(16==W)Q=4;else if(8==W)Q=3;else if(2==W)Q=1;else if(32==W)Q=5;else{if(4!=W)return this.toRadix(W);Q=2}var le,ee=(1<0)for(Ze>Ze)>0&&(ke=!0,Ve=I(le));tt>=0;)Ze>(Ze+=this.DB-Q)):(le=this.data[tt]>>(Ze-=Q)&ee,Ze<=0&&(Ze+=this.DB,--tt)),le>0&&(ke=!0),ke&&(Ve+=I(le));return ke?Ve:"0"},m.prototype.negate=function j(){var W=h();return m.ZERO.subTo(this,W),W},m.prototype.abs=function C(){return this.s<0?this.negate():this},m.prototype.compareTo=function O(W){var Q=this.s-W.s;if(0!=Q)return Q;var ee=this.t;if(0!=(Q=ee-W.t))return this.s<0?-Q:Q;for(;--ee>=0;)if(0!=(Q=this.data[ee]-W.data[ee]))return Q;return 0},m.prototype.bitLength=function L(){return this.t<=0?0:this.DB*(this.t-1)+V(this.data[this.t-1]^this.s&this.DM)},m.prototype.mod=function he(W){var Q=h();return this.abs().divRemTo(W,null,Q),this.s<0&&Q.compareTo(m.ZERO)>0&&W.subTo(Q,Q),Q},m.prototype.modPowInt=function pt(W,Q){var ee;return ee=W<256||Q.isEven()?new pe(Q):new Ee(Q),this.exp(W,ee)},m.ZERO=T(0),m.ONE=T(1),ve.prototype.convert=mt,ve.prototype.revert=mt,ve.prototype.mulTo=function Dt(W,Q,ee){W.multiplyTo(Q,ee)},ve.prototype.sqrTo=function yn(W,Q){W.squareTo(Q)},Ge.prototype.convert=function ht(W){if(W.s<0||W.t>2*this.m.t)return W.mod(this.m);if(W.compareTo(this.m)<0)return W;var Q=h();return W.copyTo(Q),this.reduce(Q),Q},Ge.prototype.revert=function Et(W){return W},Ge.prototype.reduce=function ut(W){for(W.drShiftTo(this.m.t-1,this.r2),W.t>this.m.t+1&&(W.t=this.m.t+1,W.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);W.compareTo(this.r2)<0;)W.dAddOffset(1,this.m.t+1);for(W.subTo(this.r2,W);W.compareTo(this.m)>=0;)W.subTo(this.m,W)},Ge.prototype.mulTo=function $t(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},Ge.prototype.sqrTo=function St(W,Q){W.squareTo(Q),this.reduce(Q)};var Xn=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],ca=(1<<26)/Xn[Xn.length-1];m.prototype.chunkSize=function ie(W){return Math.floor(Math.LN2*this.DB/Math.log(W))},m.prototype.toRadix=function ye(W){if(null==W&&(W=10),0==this.signum()||W<2||W>36)return"0";var Q=this.chunkSize(W),ee=Math.pow(W,Q),le=T(ee),ke=h(),Ve=h(),tt="";for(this.divRemTo(le,ke,Ve);ke.signum()>0;)tt=(ee+Ve.intValue()).toString(W).substr(1)+tt,ke.divRemTo(le,ke,Ve);return Ve.intValue().toString(W)+tt},m.prototype.fromRadix=function me(W,Q){this.fromInt(0),null==Q&&(Q=10);for(var ee=this.chunkSize(Q),le=Math.pow(Q,ee),ke=!1,Ve=0,tt=0,Ze=0;Ze=ee&&(this.dMultiply(le),this.dAddOffset(tt,0),Ve=0,tt=0))}Ve>0&&(this.dMultiply(Math.pow(Q,Ve)),this.dAddOffset(tt,0)),ke&&m.ZERO.subTo(this,this)},m.prototype.fromNumber=function _e(W,Q,ee){if("number"==typeof Q)if(W<2)this.fromInt(1);else for(this.fromNumber(W,ee),this.testBit(W-1)||this.bitwiseTo(m.ONE.shiftLeft(W-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(Q);)this.dAddOffset(2,0),this.bitLength()>W&&this.subTo(m.ONE.shiftLeft(W-1),this);else{var le=new Array,ke=7&W;le.length=1+(W>>3),Q.nextBytes(le),ke>0?le[0]&=(1<>=this.DB;if(W.t>=this.DB;le+=this.s}else{for(le+=this.s;ee>=this.DB;le+=W.s}Q.s=le<0?-1:0,le>0?Q.data[ee++]=le:le<-1&&(Q.data[ee++]=this.DV+le),Q.t=ee,Q.clamp()},m.prototype.dMultiply=function ct(W){this.data[this.t]=this.am(0,W-1,this,0,0,this.t),++this.t,this.clamp()},m.prototype.dAddOffset=function ce(W,Q){if(0!=W){for(;this.t<=Q;)this.data[this.t++]=0;for(this.data[Q]+=W;this.data[Q]>=this.DV;)this.data[Q]-=this.DV,++Q>=this.t&&(this.data[this.t++]=0),++this.data[Q]}},m.prototype.multiplyLowerTo=function Ye(W,Q,ee){var ke,le=Math.min(this.t+W.t,Q);for(ee.s=0,ee.t=le;le>0;)ee.data[--le]=0;for(ke=ee.t-this.t;le=0;)ee.data[le]=0;for(le=Math.max(Q-this.t,0);le0)if(0==Q)ee=this.data[0]%W;else for(var le=this.t-1;le>=0;--le)ee=(Q*ee+this.data[le])%W;return ee},m.prototype.millerRabin=function af(W){var Q=this.subtract(m.ONE),ee=Q.getLowestSetBit();if(ee<=0)return!1;for(var Ve,le=Q.shiftRight(ee),ke=function ua(){return{nextBytes:function(W){for(var Q=0;Q=0);var Ze=Ve.modPow(le,this);if(0!=Ze.compareTo(m.ONE)&&0!=Ze.compareTo(Q)){for(var sn=1;sn++>24},m.prototype.shortValue=function Hr(){return 0==this.t?this.s:this.data[0]<<16>>16},m.prototype.signum=function fe(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},m.prototype.toByteArray=function Me(){var W=this.t,Q=new Array;Q[0]=this.s;var le,ee=this.DB-W*this.DB%8,ke=0;if(W-- >0)for(ee>ee)!=(this.s&this.DM)>>ee&&(Q[ke++]=le|this.s<=0;)ee<8?(le=(this.data[W]&(1<>(ee+=this.DB-8)):(le=this.data[W]>>(ee-=8)&255,ee<=0&&(ee+=this.DB,--W)),0!=(128&le)&&(le|=-256),0==ke&&(128&this.s)!=(128&le)&&++ke,(ke>0||le!=this.s)&&(Q[ke++]=le);return Q},m.prototype.equals=function Qe(W){return 0==this.compareTo(W)},m.prototype.min=function qe(W){return this.compareTo(W)<0?this:W},m.prototype.max=function it(W){return this.compareTo(W)>0?this:W},m.prototype.and=function we(W){var Q=h();return this.bitwiseTo(W,$e,Q),Q},m.prototype.or=function De(W){var Q=h();return this.bitwiseTo(W,ge,Q),Q},m.prototype.xor=function Be(W){var Q=h();return this.bitwiseTo(W,Fe,Q),Q},m.prototype.andNot=function xt(W){var Q=h();return this.bitwiseTo(W,dt,Q),Q},m.prototype.not=function vt(){for(var W=h(),Q=0;Q=this.t?0!=this.s:0!=(this.data[Q]&1<1){var di=h();for(Ve.sqrTo(tt[1],di);Ze<=gr;)tt[Ze]=h(),Ve.mulTo(di,tt[Ze-2],tt[Ze]),Ze+=2}var ns,ti,ei=W.t-1,Io=!0,Jt=h();for(ee=V(W.data[ei])-1;ei>=0;){for(ee>=sn?ns=W.data[ei]>>ee-sn&gr:(ns=(W.data[ei]&(1<0&&(ns|=W.data[ei-1]>>this.DB+ee-sn)),Ze=le;0==(1&ns);)ns>>=1,--Ze;if((ee-=Ze)<0&&(ee+=this.DB,--ei),Io)tt[ns].copyTo(ke),Io=!1;else{for(;Ze>1;)Ve.sqrTo(ke,Jt),Ve.sqrTo(Jt,ke),Ze-=2;Ze>0?Ve.sqrTo(ke,Jt):(ti=ke,ke=Jt,Jt=ti),Ve.mulTo(Jt,tt[ns],ke)}for(;ei>=0&&0==(W.data[ei]&1<=0?(ee.subTo(le,ee),Q&&ke.subTo(tt,ke),Ve.subTo(Ze,Ve)):(le.subTo(ee,le),Q&&tt.subTo(ke,tt),Ze.subTo(Ve,Ze))}return 0!=le.compareTo(m.ONE)?m.ZERO:Ze.compareTo(W)>=0?Ze.subtract(W):Ze.signum()<0?(Ze.addTo(W,Ze),Ze.signum()<0?Ze.add(W):Ze):Ze},m.prototype.pow=function ze(W){return this.exp(W,new ve)},m.prototype.gcd=function xn(W){var Q=this.s<0?this.negate():this.clone(),ee=W.s<0?W.negate():W.clone();if(Q.compareTo(ee)<0){var le=Q;Q=ee,ee=le}var ke=Q.getLowestSetBit(),Ve=ee.getLowestSetBit();if(Ve<0)return Q;for(ke0&&(Q.rShiftTo(Ve,Q),ee.rShiftTo(Ve,ee));Q.signum()>0;)(ke=Q.getLowestSetBit())>0&&Q.rShiftTo(ke,Q),(ke=ee.getLowestSetBit())>0&&ee.rShiftTo(ke,ee),Q.compareTo(ee)>=0?(Q.subTo(ee,Q),Q.rShiftTo(1,Q)):(ee.subTo(Q,ee),ee.rShiftTo(1,ee));return Ve>0&&ee.lShiftTo(Ve,ee),ee},m.prototype.isProbablePrime=function Co(W){var Q,ee=this.abs();if(1==ee.t&&ee.data[0]<=Xn[Xn.length-1]){for(Q=0;Q{var y=x(8659);Y.exports=y.md=y.md||{},y.md.algorithms=y.md.algorithms||{}},9386:(Y,U,x)=>{var y=x(8659);x(8449),Y.exports=y.mgf=y.mgf||{},y.mgf.mgf1=y.mgf1},8449:(Y,U,x)=>{var y=x(8659);x(4747),y.mgf=y.mgf||{},(Y.exports=y.mgf.mgf1=y.mgf1=y.mgf1||{}).create=function(g){return{generate:function(m,h){for(var c=new y.util.ByteBuffer,f=Math.ceil(h/g.digestLength),d=0;d{var y=x(8659);y.pki=y.pki||{};var l=Y.exports=y.pki.oids=y.oids=y.oids||{};function g(m,h){l[m]=h,l[h]=m}function w(m,h){l[m]=h}g("1.2.840.113549.1.1.1","rsaEncryption"),g("1.2.840.113549.1.1.4","md5WithRSAEncryption"),g("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),g("1.2.840.113549.1.1.7","RSAES-OAEP"),g("1.2.840.113549.1.1.8","mgf1"),g("1.2.840.113549.1.1.9","pSpecified"),g("1.2.840.113549.1.1.10","RSASSA-PSS"),g("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),g("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),g("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),g("1.3.101.112","EdDSA25519"),g("1.2.840.10040.4.3","dsa-with-sha1"),g("1.3.14.3.2.7","desCBC"),g("1.3.14.3.2.26","sha1"),g("1.3.14.3.2.29","sha1WithRSASignature"),g("2.16.840.1.101.3.4.2.1","sha256"),g("2.16.840.1.101.3.4.2.2","sha384"),g("2.16.840.1.101.3.4.2.3","sha512"),g("2.16.840.1.101.3.4.2.4","sha224"),g("2.16.840.1.101.3.4.2.5","sha512-224"),g("2.16.840.1.101.3.4.2.6","sha512-256"),g("1.2.840.113549.2.2","md2"),g("1.2.840.113549.2.5","md5"),g("1.2.840.113549.1.7.1","data"),g("1.2.840.113549.1.7.2","signedData"),g("1.2.840.113549.1.7.3","envelopedData"),g("1.2.840.113549.1.7.4","signedAndEnvelopedData"),g("1.2.840.113549.1.7.5","digestedData"),g("1.2.840.113549.1.7.6","encryptedData"),g("1.2.840.113549.1.9.1","emailAddress"),g("1.2.840.113549.1.9.2","unstructuredName"),g("1.2.840.113549.1.9.3","contentType"),g("1.2.840.113549.1.9.4","messageDigest"),g("1.2.840.113549.1.9.5","signingTime"),g("1.2.840.113549.1.9.6","counterSignature"),g("1.2.840.113549.1.9.7","challengePassword"),g("1.2.840.113549.1.9.8","unstructuredAddress"),g("1.2.840.113549.1.9.14","extensionRequest"),g("1.2.840.113549.1.9.20","friendlyName"),g("1.2.840.113549.1.9.21","localKeyId"),g("1.2.840.113549.1.9.22.1","x509Certificate"),g("1.2.840.113549.1.12.10.1.1","keyBag"),g("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),g("1.2.840.113549.1.12.10.1.3","certBag"),g("1.2.840.113549.1.12.10.1.4","crlBag"),g("1.2.840.113549.1.12.10.1.5","secretBag"),g("1.2.840.113549.1.12.10.1.6","safeContentsBag"),g("1.2.840.113549.1.5.13","pkcs5PBES2"),g("1.2.840.113549.1.5.12","pkcs5PBKDF2"),g("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),g("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),g("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),g("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),g("1.2.840.113549.2.7","hmacWithSHA1"),g("1.2.840.113549.2.8","hmacWithSHA224"),g("1.2.840.113549.2.9","hmacWithSHA256"),g("1.2.840.113549.2.10","hmacWithSHA384"),g("1.2.840.113549.2.11","hmacWithSHA512"),g("1.2.840.113549.3.7","des-EDE3-CBC"),g("2.16.840.1.101.3.4.1.2","aes128-CBC"),g("2.16.840.1.101.3.4.1.22","aes192-CBC"),g("2.16.840.1.101.3.4.1.42","aes256-CBC"),g("2.5.4.3","commonName"),g("2.5.4.4","surname"),g("2.5.4.5","serialNumber"),g("2.5.4.6","countryName"),g("2.5.4.7","localityName"),g("2.5.4.8","stateOrProvinceName"),g("2.5.4.9","streetAddress"),g("2.5.4.10","organizationName"),g("2.5.4.11","organizationalUnitName"),g("2.5.4.12","title"),g("2.5.4.13","description"),g("2.5.4.15","businessCategory"),g("2.5.4.17","postalCode"),g("2.5.4.42","givenName"),g("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),g("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),g("2.16.840.1.113730.1.1","nsCertType"),g("2.16.840.1.113730.1.13","nsComment"),w("2.5.29.1","authorityKeyIdentifier"),w("2.5.29.2","keyAttributes"),w("2.5.29.3","certificatePolicies"),w("2.5.29.4","keyUsageRestriction"),w("2.5.29.5","policyMapping"),w("2.5.29.6","subtreesConstraint"),w("2.5.29.7","subjectAltName"),w("2.5.29.8","issuerAltName"),w("2.5.29.9","subjectDirectoryAttributes"),w("2.5.29.10","basicConstraints"),w("2.5.29.11","nameConstraints"),w("2.5.29.12","policyConstraints"),w("2.5.29.13","basicConstraints"),g("2.5.29.14","subjectKeyIdentifier"),g("2.5.29.15","keyUsage"),w("2.5.29.16","privateKeyUsagePeriod"),g("2.5.29.17","subjectAltName"),g("2.5.29.18","issuerAltName"),g("2.5.29.19","basicConstraints"),w("2.5.29.20","cRLNumber"),w("2.5.29.21","cRLReason"),w("2.5.29.22","expirationDate"),w("2.5.29.23","instructionCode"),w("2.5.29.24","invalidityDate"),w("2.5.29.25","cRLDistributionPoints"),w("2.5.29.26","issuingDistributionPoint"),w("2.5.29.27","deltaCRLIndicator"),w("2.5.29.28","issuingDistributionPoint"),w("2.5.29.29","certificateIssuer"),w("2.5.29.30","nameConstraints"),g("2.5.29.31","cRLDistributionPoints"),g("2.5.29.32","certificatePolicies"),w("2.5.29.33","policyMappings"),w("2.5.29.34","policyConstraints"),g("2.5.29.35","authorityKeyIdentifier"),w("2.5.29.36","policyConstraints"),g("2.5.29.37","extKeyUsage"),w("2.5.29.46","freshestCRL"),w("2.5.29.54","inhibitAnyPolicy"),g("1.3.6.1.4.1.11129.2.4.2","timestampList"),g("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),g("1.3.6.1.5.5.7.3.1","serverAuth"),g("1.3.6.1.5.5.7.3.2","clientAuth"),g("1.3.6.1.5.5.7.3.3","codeSigning"),g("1.3.6.1.5.5.7.3.4","emailProtection"),g("1.3.6.1.5.5.7.3.8","timeStamping")},2158:(Y,U,x)=>{var y=x(8659);if(x(1298),x(7791),x(279),x(979),x(6078),x(7949),x(8604),x(8365),x(209),x(5517),x(4747),typeof l>"u")var l=y.jsbn.BigInteger;var g=y.asn1,w=y.pki=y.pki||{};Y.exports=w.pbe=y.pbe=y.pbe||{};var m=w.oids,h={name:"EncryptedPrivateKeyInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},c={name:"PBES2Algorithms",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},f={name:"pkcs-12PbeParams",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"iterations"}]};function d(v,p){return v.start().update(p).digest().getBytes()}function b(v){var p;if(v){if(!(p=w.oids[g.derToOid(v)])){var I=new Error("Unsupported PRF OID.");throw I.oid=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}}else p="hmacWithSHA1";return S(p)}function S(v){var p=y.md;switch(v){case"hmacWithSHA224":p=y.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":v=v.substr(8).toLowerCase();break;default:var I=new Error("Unsupported PRF algorithm.");throw I.algorithm=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}if(!p||!(v in p))throw new Error("Unknown hash algorithm: "+v);return p[v].create()}w.encryptPrivateKeyInfo=function(v,p,I){(I=I||{}).saltSize=I.saltSize||8,I.count=I.count||2048,I.algorithm=I.algorithm||"aes128",I.prfAlgorithm=I.prfAlgorithm||"sha1";var T,M,k,A=y.random.getBytesSync(I.saltSize),P=I.count,D=g.integerToDer(P);if(0===I.algorithm.indexOf("aes")||"des"===I.algorithm){var F,j,C;switch(I.algorithm){case"aes128":T=16,F=16,j=m["aes128-CBC"],C=y.aes.createEncryptionCipher;break;case"aes192":T=24,F=16,j=m["aes192-CBC"],C=y.aes.createEncryptionCipher;break;case"aes256":T=32,F=16,j=m["aes256-CBC"],C=y.aes.createEncryptionCipher;break;case"des":T=8,F=8,j=m.desCBC,C=y.des.createEncryptionCipher;break;default:throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O}var V="hmacWith"+I.prfAlgorithm.toUpperCase(),L=S(V),K=y.pkcs5.pbkdf2(p,A,P,T,L),re=y.random.getBytesSync(F);(G=C(K)).start(re),G.update(g.toDer(v)),G.finish(),k=G.output.getBytes();var te=function E(v,p,I,A){var P=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,v),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,p.getBytes())]);return"hmacWithSHA1"!==A&&P.value.push(g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,y.util.hexToBytes(I.toString(16))),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(w.oids[A]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")])),P}(A,D,T,V);M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBES2).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBKDF2).getBytes()),te]),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(j).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,re)])])])}else{var O;if("3des"!==I.algorithm)throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O;T=24;var G,Z=new y.util.ByteBuffer(A);K=w.pbe.generatePkcs12Key(p,Z,1,P,T),re=w.pbe.generatePkcs12Key(p,Z,2,P,T),(G=y.des.createEncryptionCipher(K)).start(re),G.update(g.toDer(v)),G.finish(),k=G.output.getBytes(),M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,A),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,D.getBytes())])])}return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[M,g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,k)])},w.decryptPrivateKeyInfo=function(v,p){var I=null,A={},P=[];if(!g.validate(v,h,A,P)){var D=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw D.errors=P,D}var T=g.derToOid(A.encryptionOid),M=w.pbe.getCipher(T,A.encryptionParams,p),k=y.util.createBuffer(A.encryptedData);return M.update(k),M.finish()&&(I=g.fromDer(M.output)),I},w.encryptedPrivateKeyToPem=function(v,p){var I={type:"ENCRYPTED PRIVATE KEY",body:g.toDer(v).getBytes()};return y.pem.encode(I,{maxline:p})},w.encryptedPrivateKeyFromPem=function(v){var p=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==p.type){var I=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw I.headerType=p.type,I}if(p.procType&&"ENCRYPTED"===p.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return g.fromDer(p.body)},w.encryptRsaPrivateKey=function(v,p,I){if(!(I=I||{}).legacy){var A=w.wrapRsaPrivateKey(w.privateKeyToAsn1(v));return A=w.encryptPrivateKeyInfo(A,p,I),w.encryptedPrivateKeyToPem(A)}var P,D,T,M;switch(I.algorithm){case"aes128":P="AES-128-CBC",T=16,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes192":P="AES-192-CBC",T=24,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes256":P="AES-256-CBC",T=32,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"3des":P="DES-EDE3-CBC",T=24,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;case"des":P="DES-CBC",T=8,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;default:var k=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+I.algorithm+'".');throw k.algorithm=I.algorithm,k}var j=M(y.pbe.opensslDeriveBytes(p,D.substr(0,8),T));j.start(D),j.update(g.toDer(w.privateKeyToAsn1(v))),j.finish();var C={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:P,parameters:y.util.bytesToHex(D).toUpperCase()},body:j.output.getBytes()};return y.pem.encode(C)},w.decryptRsaPrivateKey=function(v,p){var I=null,A=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==A.type&&"PRIVATE KEY"!==A.type&&"RSA PRIVATE KEY"!==A.type)throw(P=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=P,P;if(A.procType&&"ENCRYPTED"===A.procType.type){var D,T;switch(A.dekInfo.algorithm){case"DES-CBC":D=8,T=y.des.createDecryptionCipher;break;case"DES-EDE3-CBC":D=24,T=y.des.createDecryptionCipher;break;case"AES-128-CBC":D=16,T=y.aes.createDecryptionCipher;break;case"AES-192-CBC":D=24,T=y.aes.createDecryptionCipher;break;case"AES-256-CBC":D=32,T=y.aes.createDecryptionCipher;break;case"RC2-40-CBC":D=5,T=function(C){return y.rc2.createDecryptionCipher(C,40)};break;case"RC2-64-CBC":D=8,T=function(C){return y.rc2.createDecryptionCipher(C,64)};break;case"RC2-128-CBC":D=16,T=function(C){return y.rc2.createDecryptionCipher(C,128)};break;default:var P;throw(P=new Error('Could not decrypt private key; unsupported encryption algorithm "'+A.dekInfo.algorithm+'".')).algorithm=A.dekInfo.algorithm,P}var M=y.util.hexToBytes(A.dekInfo.parameters),F=T(y.pbe.opensslDeriveBytes(p,M.substr(0,8),D));if(F.start(M),F.update(y.util.createBuffer(A.body)),!F.finish())return I;I=F.output.getBytes()}else I=A.body;return null!==(I="ENCRYPTED PRIVATE KEY"===A.type?w.decryptPrivateKeyInfo(g.fromDer(I),p):g.fromDer(I))&&(I=w.privateKeyFromAsn1(I)),I},w.pbe.generatePkcs12Key=function(v,p,I,A,P,D){var T,M;if(typeof D>"u"||null===D){if(!("sha1"in y.md))throw new Error('"sha1" hash algorithm unavailable.');D=y.md.sha1.create()}var k=D.digestLength,F=D.blockLength,j=new y.util.ByteBuffer,C=new y.util.ByteBuffer;if(null!=v){for(M=0;M=0;M--)be>>=8,be+=pe.at(M)+Ne.at(M),Ne.setAt(M,255&be);Se.putBuffer(Ne)}Z=Se,j.putBuffer(se)}return j.truncate(j.length()-P),j},w.pbe.getCipher=function(v,p,I){switch(v){case w.oids.pkcs5PBES2:return w.pbe.getCipherForPBES2(v,p,I);case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case w.oids["pbewithSHAAnd40BitRC2-CBC"]:return w.pbe.getCipherForPKCS12PBE(v,p,I);default:var A=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw A.oid=v,A.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],A}},w.pbe.getCipherForPBES2=function(v,p,I){var D,A={},P=[];if(!g.validate(p,c,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;if((v=g.derToOid(A.kdfOid))!==w.oids.pkcs5PBKDF2)throw(D=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=v,D.supportedOids=["pkcs5PBKDF2"],D;if((v=g.derToOid(A.encOid))!==w.oids["aes128-CBC"]&&v!==w.oids["aes192-CBC"]&&v!==w.oids["aes256-CBC"]&&v!==w.oids["des-EDE3-CBC"]&&v!==w.oids.desCBC)throw(D=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=v,D.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],D;var k,F,T=A.kdfSalt,M=y.util.createBuffer(A.kdfIterationCount);switch(M=M.getInt(M.length()<<3),w.oids[v]){case"aes128-CBC":k=16,F=y.aes.createDecryptionCipher;break;case"aes192-CBC":k=24,F=y.aes.createDecryptionCipher;break;case"aes256-CBC":k=32,F=y.aes.createDecryptionCipher;break;case"des-EDE3-CBC":k=24,F=y.des.createDecryptionCipher;break;case"desCBC":k=8,F=y.des.createDecryptionCipher}var j=b(A.prfOid),C=y.pkcs5.pbkdf2(I,T,M,k,j),O=A.encIv,V=F(C);return V.start(O),V},w.pbe.getCipherForPKCS12PBE=function(v,p,I){var A={},P=[];if(!g.validate(p,f,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;var k,F,j,T=y.util.createBuffer(A.salt),M=y.util.createBuffer(A.iterations);switch(M=M.getInt(M.length()<<3),v){case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:k=24,F=8,j=y.des.startDecrypting;break;case w.oids["pbewithSHAAnd40BitRC2-CBC"]:k=5,F=8,j=function(K,re){var G=y.rc2.createDecryptionCipher(K,40);return G.start(re,null),G};break;default:var D;throw(D=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=v,D}var C=b(A.prfOid),O=w.pbe.generatePkcs12Key(I,T,1,M,k,C);return C.start(),j(O,w.pbe.generatePkcs12Key(I,T,2,M,F,C))},w.pbe.opensslDeriveBytes=function(v,p,I,A){if(typeof A>"u"||null===A){if(!("md5"in y.md))throw new Error('"md5" hash algorithm unavailable.');A=y.md.md5.create()}null===p&&(p="");for(var P=[d(A,v+p)],D=16,T=1;D{var y=x(8659);x(9032),x(979),x(4747);var g,l=y.pkcs5=y.pkcs5||{};y.util.isNodejs&&!y.options.usePureJavaScript&&(g=x(5819)),Y.exports=y.pbkdf2=l.pbkdf2=function(w,m,h,c,f,d){if("function"==typeof f&&(d=f,f=null),y.util.isNodejs&&!y.options.usePureJavaScript&&g.pbkdf2&&(null===f||"object"!=typeof f)&&(g.pbkdf2Sync.length>4||!f||"sha1"===f))return"string"!=typeof f&&(f="sha1"),w=Buffer.from(w,"binary"),m=Buffer.from(m,"binary"),d?4===g.pbkdf2Sync.length?g.pbkdf2(w,m,h,c,function(j,C){if(j)return d(j);d(null,C.toString("binary"))}):g.pbkdf2(w,m,h,c,f,function(j,C){if(j)return d(j);d(null,C.toString("binary"))}):4===g.pbkdf2Sync.length?g.pbkdf2Sync(w,m,h,c).toString("binary"):g.pbkdf2Sync(w,m,h,c,f).toString("binary");if((typeof f>"u"||null===f)&&(f="sha1"),"string"==typeof f){if(!(f in y.md.algorithms))throw new Error("Unknown hash algorithm: "+f);f=y.md[f].create()}var b=f.digestLength;if(c>4294967295*b){var S=new Error("Derived key is too long.");if(d)return d(S);throw S}var E=Math.ceil(c/b),v=c-(E-1)*b,p=y.hmac.create();p.start(f,w);var A,P,D,I="";if(!d){for(var T=1;T<=E;++T){p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes();for(var M=2;M<=h;++M)p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P;I+=TE)return d(null,I);p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes(),M=2,F()}function F(){if(M<=h)return p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P,++M,y.util.setImmediate(F);I+=T{var y=x(8659);x(4747);var l=Y.exports=y.pem=y.pem||{};function g(m){for(var h=m.name+": ",c=[],f=function(v,p){return" "+p},d=0;d65&&-1!==S){var E=h[S];","===E?(++S,h=h.substr(0,S)+"\r\n "+h.substr(S)):h=h.substr(0,S)+"\r\n"+E+h.substr(S+1),b=d-S-1,S=-1,++d}else(" "===h[d]||"\t"===h[d]||","===h[d])&&(S=d);return h}function w(m){return m.replace(/^\s+/,"")}l.encode=function(m,h){h=h||{};var f,c="-----BEGIN "+m.type+"-----\r\n";if(m.procType&&(c+=g(f={name:"Proc-Type",values:[String(m.procType.version),m.procType.type]})),m.contentDomain&&(c+=g(f={name:"Content-Domain",values:[m.contentDomain]})),m.dekInfo&&(f={name:"DEK-Info",values:[m.dekInfo.algorithm]},m.dekInfo.parameters&&f.values.push(m.dekInfo.parameters),c+=g(f)),m.headers)for(var d=0;d{var y=x(8659);x(4747),x(8365),x(7690);var l=Y.exports=y.pkcs1=y.pkcs1||{};function g(w,m,h){h||(h=y.md.sha1.create());for(var c="",f=Math.ceil(m/h.digestLength),d=0;d>24&255,d>>16&255,d>>8&255,255&d);h.start(),h.update(w+b),c+=h.digest().getBytes()}return c.substring(0,m)}l.encode_rsa_oaep=function(w,m,h){var c,f,d,b;"string"==typeof h?(c=h,f=arguments[3]||void 0,d=arguments[4]||void 0):h&&(c=h.label||void 0,f=h.seed||void 0,d=h.md||void 0,h.mgf1&&h.mgf1.md&&(b=h.mgf1.md)),d?d.start():d=y.md.sha1.create(),b||(b=d);var S=Math.ceil(w.n.bitLength()/8),E=S-2*d.digestLength-2;if(m.length>E)throw(v=new Error("RSAES-OAEP input message length is too long.")).length=m.length,v.maxLength=E,v;c||(c=""),d.update(c,"raw");for(var p=d.digest(),I="",A=E-m.length,P=0;P{var y=x(8659);x(1298),x(7791),x(279),x(6078),x(8604),x(4957),x(8365),x(4747),x(5911);var l=y.asn1,g=Y.exports=y.pkcs7=y.pkcs7||{};function w(A){var P={},D=[];if(!l.validate(A,g.asn1.recipientInfoValidator,P,D)){var T=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw T.errors=D,T}return{version:P.version.charCodeAt(0),issuer:y.pki.RDNAttributesAsArray(P.issuer),serialNumber:y.util.createBuffer(P.serial).toHex(),encryptedContent:{algorithm:l.derToOid(P.encAlgorithm),parameter:P.encParameter?P.encParameter.value:void 0,content:P.encKey}}}function m(A){return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(A.version).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[y.pki.distinguishedNameToAsn1({attributes:A.issuer}),l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,y.util.hexToBytes(A.serialNumber))]),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(A.encryptedContent.algorithm).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")]),l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,A.encryptedContent.content)])}function c(A){for(var P=[],D=0;D0){for(var D=l.create(l.Class.CONTEXT_SPECIFIC,1,!0,[]),T=0;T=D&&M0&&F.value[0].value.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!0,T)),k.length>0&&F.value[0].value.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,k)),F.value[0].value.push(l.create(l.Class.UNIVERSAL,l.Type.SET,!0,A.signerInfos)),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(A.type).getBytes()),F])},addSigner:function(T){var M=T.issuer,k=T.serialNumber;if(T.certificate){var F=T.certificate;"string"==typeof F&&(F=y.pki.certificateFromPem(F)),M=F.issuer.attributes,k=F.serialNumber}var j=T.key;if(!j)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof j&&(j=y.pki.privateKeyFromPem(j));var C=T.digestAlgorithm||y.pki.oids.sha1;switch(C){case y.pki.oids.sha1:case y.pki.oids.sha256:case y.pki.oids.sha384:case y.pki.oids.sha512:case y.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+C)}var O=T.authenticatedAttributes||[];if(O.length>0){for(var V=!1,L=!1,K=0;K{var y=x(8659);x(7791),x(4747);var l=y.asn1,g=Y.exports=y.pkcs7asn1=y.pkcs7asn1||{};y.pkcs7=y.pkcs7||{},y.pkcs7.asn1=g;var w={name:"ContentInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};g.contentInfoValidator=w;var m={name:"EncryptedContentInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:l.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};g.envelopedDataValidator={name:"EnvelopedData",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(m)},g.encryptedDataValidator={name:"EncryptedData",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"}].concat(m)},g.signedDataValidator={name:"SignedData",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},w,{name:"SignedData.Certificates",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,capture:"signerInfos",optional:!0,value:[{name:"SignerInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:l.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:l.Class.UNIVERSAL,type:l.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]}]}]},g.recipientInfoValidator={name:"RecipientInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:l.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:l.Class.UNIVERSAL,type:l.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},9709:(Y,U,x)=>{var y=x(8659);x(4747),x(730),x(8365),function(){if(y.prime)Y.exports=y.prime;else{var l=Y.exports=y.prime=y.prime||{},g=y.jsbn.BigInteger,w=[6,4,2,4,2,4,6,2],m=new g(null);m.fromInt(30);var h=function(v,p){return v|p};l.generateProbablePrime=function(v,p,I){"function"==typeof p&&(I=p,p={});var A=(p=p||{}).algorithm||"PRIMEINC";"string"==typeof A&&(A={name:A}),A.options=A.options||{};var P=p.prng||y.random;if("PRIMEINC"===A.name)return function c(v,p,I,A){return"workers"in I?function b(v,p,I,A){if(typeof Worker>"u")return f(v,p,I,A);var P=S(v,p),D=I.workers,T=I.workLoad||100,M=30*T/8,k=I.workerScript||"forge/prime.worker.js";if(-1===D)return y.util.estimateCores(function(j,C){j&&(C=2),D=C-1,F()});function F(){D=Math.max(1,D);for(var j=[],C=0;Cv&&(P=S(v,p));var te=P.toString(16);K.target.postMessage({hex:te,workLoad:T}),P.dAddOffset(M,0)}}}F()}(v,p,I,A):f(v,p,I,A)}(v,{nextBytes:function(T){for(var M=P.getBytesSync(T.length),k=0;kp&&(v=S(p,I)),v.isProbablePrime(P))return T(null,v);v.dAddOffset(w[A++%8],0)}while(D<0||+new Date-M{var y=x(8659);x(4747);var l=null;y.util.isNodejs&&!y.options.usePureJavaScript&&!process.versions["node-webkit"]&&(l=x(5819)),(Y.exports=y.prng=y.prng||{}).create=function(w){for(var m={plugin:w,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},h=w.md,c=new Array(32),f=0;f<32;++f)c[f]=h.create();function b(){if(m.pools[0].messageLength>=32)return S();m.collect(m.seedFileSync(32-m.pools[0].messageLength<<5)),S()}function S(){m.reseeds=4294967295===m.reseeds?0:m.reseeds+1;var v=m.plugin.md.create();v.update(m.keyBytes);for(var p=1,I=0;I<32;++I)m.reseeds%p==0&&(v.update(m.pools[I].digest().getBytes()),m.pools[I].start()),p<<=1;m.keyBytes=v.digest().getBytes(),v.start(),v.update(m.keyBytes);var A=v.digest().getBytes();m.key=m.plugin.formatKey(m.keyBytes),m.seed=m.plugin.formatSeed(A),m.generated=0}function E(v){var p=null,I=y.util.globalScope,A=I.crypto||I.msCrypto;A&&A.getRandomValues&&(p=function(O){return A.getRandomValues(O)});var P=y.util.createBuffer();if(p)for(;P.length()>16)))<<16,C=4294967295&(F=(2147483647&(F+=k>>15))+(F>>31)),M=0;M<3;++M)j=C>>>(M<<3),j^=Math.floor(256*Math.random()),P.putByte(255&j);return P.getBytes(v)}return m.pools=c,m.pool=0,m.generate=function(v,p){if(!p)return m.generateSync(v);var I=m.plugin.cipher,A=m.plugin.increment,P=m.plugin.formatKey,D=m.plugin.formatSeed,T=y.util.createBuffer();m.key=null,function M(k){if(k)return p(k);if(T.length()>=v)return p(null,T.getBytes(v));if(m.generated>1048575&&(m.key=null),null===m.key)return y.util.nextTick(function(){!function d(v){if(m.pools[0].messageLength>=32)return S(),v();m.seedFile(32-m.pools[0].messageLength<<5,function(I,A){if(I)return v(I);m.collect(A),S(),v()})}(M)});var F=I(m.key,m.seed);m.generated+=F.length,T.putBytes(F),m.key=P(I(m.key,A(m.seed))),m.seed=D(I(m.key,m.seed)),y.util.setImmediate(M)}()},m.generateSync=function(v){var p=m.plugin.cipher,I=m.plugin.increment,A=m.plugin.formatKey,P=m.plugin.formatSeed;m.key=null;for(var D=y.util.createBuffer();D.length()1048575&&(m.key=null),null===m.key&&b();var T=p(m.key,m.seed);m.generated+=T.length,D.putBytes(T),m.key=A(p(m.key,I(m.seed))),m.seed=P(p(m.key,m.seed))}return D.getBytes(v)},l?(m.seedFile=function(v,p){l.randomBytes(v,function(I,A){if(I)return p(I);p(null,A.toString())})},m.seedFileSync=function(v){return l.randomBytes(v).toString()}):(m.seedFile=function(v,p){try{p(null,E(v))}catch(I){p(I)}},m.seedFileSync=E),m.collect=function(v){for(var p=v.length,I=0;I>A&255);m.collect(I)},m.registerWorker=function(v){v===self?m.seedFile=function(I,A){self.addEventListener("message",function P(D){var T=D.data;T.forge&&T.forge.prng&&(self.removeEventListener("message",P),A(T.forge.prng.err,T.forge.prng.bytes))}),self.postMessage({forge:{prng:{needed:I}}})}:v.addEventListener("message",function(I){var A=I.data;A.forge&&A.forge.prng&&m.seedFile(A.forge.prng.needed,function(P,D){v.postMessage({forge:{prng:{err:P,bytes:D}}})})})},m}},7256:(Y,U,x)=>{var y=x(8659);x(8365),x(4747),(Y.exports=y.pss=y.pss||{}).create=function(g){3===arguments.length&&(g={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var f,w=g.md,m=g.mgf,h=w.digestLength,c=g.salt||null;if("string"==typeof c&&(c=y.util.createBuffer(c)),"saltLength"in g)f=g.saltLength;else{if(null===c)throw new Error("Salt length not specified or specific salt not given.");f=c.length()}if(null!==c&&c.length()!==f)throw new Error("Given salt length does not match length of given salt.");var d=g.prng||y.random,b={encode:function(S,E){var v,P,p=E-1,I=Math.ceil(p/8),A=S.digest().getBytes();if(I>8*I-p&255;return(C=String.fromCharCode(C.charCodeAt(0)&~O)+C.substr(1))+T+String.fromCharCode(188)},verify:function(S,E,v){var p,I=v-1,A=Math.ceil(I/8);if(E=E.substr(-A),A>8*A-I&255;if(0!=(D.charCodeAt(0)&M))throw new Error("Bits beyond keysize not zero as expected.");var k=m.generate(T,P),F="";for(p=0;p{var y=x(8659);x(1298),x(1594),x(4473),x(4747),y.random&&y.random.getBytes?Y.exports=y.random:function(l){var g={},w=new Array(4),m=y.util.createBuffer();function h(){var v=y.prng.create(g);return v.getBytes=function(p,I){return v.generate(p,I)},v.getBytesSync=function(p){return v.generate(p)},v}g.formatKey=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),y.aes._expandKey(v,!1)},g.formatSeed=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),v},g.cipher=function(v,p){return y.aes._updateBlock(v,p,w,!1),m.putInt32(w[0]),m.putInt32(w[1]),m.putInt32(w[2]),m.putInt32(w[3]),m.getBytes()},g.increment=function(v){return++v[3],v},g.md=y.md.sha256;var c=h(),f=null,d=y.util.globalScope,b=d.crypto||d.msCrypto;if(b&&b.getRandomValues&&(f=function(v){return b.getRandomValues(v)}),y.options.usePureJavaScript||!y.util.isNodejs&&!f){if(typeof window>"u"||window,c.collectInt(+new Date,32),typeof navigator<"u"){var S="";for(var E in navigator)try{"string"==typeof navigator[E]&&(S+=navigator[E])}catch{}c.collect(S),S=null}l&&(l().mousemove(function(v){c.collectInt(v.clientX,16),c.collectInt(v.clientY,16)}),l().keypress(function(v){c.collectInt(v.charCode,8)}))}if(y.random)for(var E in c)y.random[E]=c[E];else y.random=c;y.random.createInstance=h,Y.exports=y.random}(typeof jQuery<"u"?jQuery:null)},209:(Y,U,x)=>{var y=x(8659);x(4747);var l=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],g=[1,2,3,5],w=function(c,f){return c<>16-f},m=function(c,f){return(65535&c)>>f|c<<16-f&65535};Y.exports=y.rc2=y.rc2||{},y.rc2.expandKey=function(c,f){"string"==typeof c&&(c=y.util.createBuffer(c)),f=f||128;var p,d=c,b=c.length(),S=f,E=Math.ceil(S/8),v=255>>(7&S);for(p=b;p<128;p++)d.putByte(l[d.at(p-1)+d.at(p-b)&255]);for(d.setAt(128-E,l[d.at(128-E)&v]),p=127-E;p>=0;p--)d.setAt(p,l[d.at(p+1)^d.at(p+E)]);return d};var h=function(c,f,d){var p,I,A,P,b=!1,S=null,E=null,v=null,D=[];for(c=y.rc2.expandKey(c,f),A=0;A<64;A++)D.push(c.getInt16Le());d?(p=function(k){for(A=0;A<4;A++)k[A]+=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),k[A]=w(k[A],g[A]),P++},I=function(k){for(A=0;A<4;A++)k[A]+=D[63&k[(A+3)%4]]}):(p=function(k){for(A=3;A>=0;A--)k[A]=m(k[A],g[A]),k[A]-=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),P--},I=function(k){for(A=3;A>=0;A--)k[A]-=D[63&k[(A+3)%4]]});var T=function(k){var F=[];for(A=0;A<4;A++){var j=S.getInt16Le();null!==v&&(d?j^=v.getInt16Le():v.putInt16Le(j)),F.push(65535&j)}P=d?0:63;for(var C=0;C=8;)T([[5,p],[1,I],[6,p],[1,I],[5,p]])},finish:function(k){var F=!0;if(d)if(k)F=k(8,S,!d);else{var j=8===S.length()?8:8-S.length();S.fillWithByte(j,j)}if(F&&(b=!0,M.update()),!d&&(F=0===S.length()))if(k)F=k(8,E,!d);else{var C=E.length(),O=E.at(C-1);O>C?F=!1:E.truncate(O)}return F}}};y.rc2.startEncrypting=function(c,f,d){var b=y.rc2.createEncryptionCipher(c,128);return b.start(f,d),b},y.rc2.createEncryptionCipher=function(c,f){return h(c,f,!0)},y.rc2.startDecrypting=function(c,f,d){var b=y.rc2.createDecryptionCipher(c,128);return b.start(f,d),b},y.rc2.createDecryptionCipher=function(c,f){return h(c,f,!1)}},5517:(Y,U,x)=>{var y=x(8659);if(x(7791),x(730),x(6078),x(7246),x(9709),x(8365),x(4747),typeof l>"u")var l=y.jsbn.BigInteger;var g=y.util.isNodejs?x(5819):null,w=y.asn1,m=y.util;y.pki=y.pki||{},Y.exports=y.pki.rsa=y.rsa=y.rsa||{};var h=y.pki,c=[6,4,2,4,2,4,6,2],f={name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},d={name:"RSAPrivateKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},b={name:"RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},S=y.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},E={name:"DigestInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:w.Class.UNIVERSAL,type:w.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},v=function(L){if(!(L.algorithm in h.oids)){var re=new Error("Unknown message digest algorithm.");throw re.algorithm=L.algorithm,re}var G=w.oidToDer(h.oids[L.algorithm]).getBytes(),te=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]),Z=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]);Z.value.push(w.create(w.Class.UNIVERSAL,w.Type.OID,!1,G)),Z.value.push(w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,""));var q=w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,L.digest().getBytes());return te.value.push(Z),te.value.push(q),w.toDer(te).getBytes()},p=function(L,K,re){if(re)return L.modPow(K.e,K.n);if(!K.p||!K.q)return L.modPow(K.d,K.n);var G;K.dP||(K.dP=K.d.mod(K.p.subtract(l.ONE))),K.dQ||(K.dQ=K.d.mod(K.q.subtract(l.ONE))),K.qInv||(K.qInv=K.q.modInverse(K.p));do{G=new l(y.util.bytesToHex(y.random.getBytes(K.n.bitLength()/8)),16)}while(G.compareTo(K.n)>=0||!G.gcd(K.n).equals(l.ONE));for(var te=(L=L.multiply(G.modPow(K.e,K.n)).mod(K.n)).mod(K.p).modPow(K.dP,K.p),Z=L.mod(K.q).modPow(K.dQ,K.q);te.compareTo(Z)<0;)te=te.add(K.p);var q=te.subtract(Z).multiply(K.qInv).mod(K.p).multiply(K.q).add(Z);return q.multiply(G.modInverse(K.n)).mod(K.n)};function I(L,K,re){var G=y.util.createBuffer(),te=Math.ceil(K.n.bitLength()/8);if(L.length>te-11){var Z=new Error("Message is too long for PKCS#1 v1.5 padding.");throw Z.length=L.length,Z.max=te-11,Z}G.putByte(0),G.putByte(re);var ne,q=te-3-L.length;if(0===re||1===re){ne=0===re?0:255;for(var se=0;se0;){var he=0,pe=y.random.getBytes(q);for(se=0;se"u")throw new Error("Encryption block is invalid.");var se=0;if(0===ne){se=te-3-G;for(var he=0;he1;){if(255!==Z.getByte()){--Z.read;break}++se}else if(2===ne)for(se=0;Z.length()>1;){if(0===Z.getByte()){--Z.read;break}++se}if(0!==Z.getByte()||se!==te-3-Z.length())throw new Error("Encryption block is invalid.");return Z.getBytes()}function P(L,K,re){"function"==typeof K&&(re=K,K={});var G={algorithm:{name:(K=K||{}).algorithm||"PRIMEINC",options:{workers:K.workers||2,workLoad:K.workLoad||100,workerScript:K.workerScript}}};function te(){Z(L.pBits,function(ne,se){return ne?re(ne):(L.p=se,null!==L.q?q(ne,L.q):void Z(L.qBits,q))})}function Z(ne,se){y.prime.generateProbablePrime(ne,G,se)}function q(ne,se){if(ne)return re(ne);if(L.q=se,L.p.compareTo(L.q)<0){var he=L.p;L.p=L.q,L.q=he}if(0!==L.p.subtract(l.ONE).gcd(L.e).compareTo(l.ONE))return L.p=null,void te();if(0!==L.q.subtract(l.ONE).gcd(L.e).compareTo(l.ONE))return L.q=null,void Z(L.qBits,q);if(L.p1=L.p.subtract(l.ONE),L.q1=L.q.subtract(l.ONE),L.phi=L.p1.multiply(L.q1),0!==L.phi.gcd(L.e).compareTo(l.ONE))return L.p=L.q=null,void te();if(L.n=L.p.multiply(L.q),L.n.bitLength()!==L.bits)return L.q=null,void Z(L.qBits,q);var pe=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,pe,L.p,L.q,pe.mod(L.p1),pe.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)},re(null,L.keys)}"prng"in K&&(G.prng=K.prng),te()}function D(L){var K=L.toString(16);K[0]>="8"&&(K="00"+K);var re=y.util.hexToBytes(K);return re.length>1&&(0===re.charCodeAt(0)&&0==(128&re.charCodeAt(1))||255===re.charCodeAt(0)&&128==(128&re.charCodeAt(1)))?re.substr(1):re}function T(L){return L<=100?27:L<=150?18:L<=200?15:L<=250?12:L<=300?9:L<=350?8:L<=400?7:L<=500?6:L<=600?5:L<=800?4:L<=1250?3:2}function M(L){return y.util.isNodejs&&"function"==typeof g[L]}function k(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.crypto&&"object"==typeof m.globalScope.crypto.subtle&&"function"==typeof m.globalScope.crypto.subtle[L]}function F(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.msCrypto&&"object"==typeof m.globalScope.msCrypto.subtle&&"function"==typeof m.globalScope.msCrypto.subtle[L]}function j(L){for(var K=y.util.hexToBytes(L.toString(16)),re=new Uint8Array(K.length),G=0;G0;)he.putByte(0),--pe;return he.putBytes(y.util.hexToBytes(se)),he.getBytes()},h.rsa.decrypt=function(L,K,re,G){var te=Math.ceil(K.n.bitLength()/8);if(L.length!==te){var Z=new Error("Encrypted message length is invalid.");throw Z.length=L.length,Z.expected=te,Z}var q=new l(y.util.createBuffer(L).toHex(),16);if(q.compareTo(K.n)>=0)throw new Error("Encrypted message is invalid.");for(var se=p(q,K,re).toString(16),he=y.util.createBuffer(),pe=te-Math.ceil(se.length/2);pe>0;)he.putByte(0),--pe;return he.putBytes(y.util.hexToBytes(se)),!1!==G?A(he.getBytes(),K,re):he.getBytes()},h.rsa.createKeyPairGenerationState=function(L,K,re){"string"==typeof L&&(L=parseInt(L,10)),L=L||2048;var q,G=(re=re||{}).prng||y.random,te={nextBytes:function(ne){for(var se=G.getBytesSync(ne.length),he=0;he>1,pBits:L-(L>>1),pqState:0,num:null,keys:null}).e.fromInt(q.eInt),q},h.rsa.stepKeyPairGenerationState=function(L,K){"algorithm"in L||(L.algorithm="PRIMEINC");var re=new l(null);re.fromInt(30);for(var q,G=0,te=function(Le,Se){return Le|Se},Z=+new Date,ne=0;null===L.keys&&(K<=0||nese?L.pqState=0:L.num.isProbablePrime(T(L.num.bitLength()))?++L.pqState:L.num.dAddOffset(c[G++%8],0):2===L.pqState?L.pqState=0===L.num.subtract(l.ONE).gcd(L.e).compareTo(l.ONE)?3:0:3===L.pqState&&(L.pqState=0,null===L.p?L.p=L.num:L.q=L.num,null!==L.p&&null!==L.q&&++L.state,L.num=null)}else if(1===L.state)L.p.compareTo(L.q)<0&&(L.num=L.p,L.p=L.q,L.q=L.num),++L.state;else if(2===L.state)L.p1=L.p.subtract(l.ONE),L.q1=L.q.subtract(l.ONE),L.phi=L.p1.multiply(L.q1),++L.state;else if(3===L.state)0===L.phi.gcd(L.e).compareTo(l.ONE)?++L.state:(L.p=null,L.q=null,L.state=0);else if(4===L.state)L.n=L.p.multiply(L.q),L.n.bitLength()===L.bits?++L.state:(L.q=null,L.state=0);else if(5===L.state){var pe=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,pe,L.p,L.q,pe.mod(L.p1),pe.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)}}ne+=(q=+new Date)-Z,Z=q}return null!==L.keys},h.rsa.generateKeyPair=function(L,K,re,G){if(1===arguments.length?"object"==typeof L?(re=L,L=void 0):"function"==typeof L&&(G=L,L=void 0):2===arguments.length?"number"==typeof L?"function"==typeof K?(G=K,K=void 0):"number"!=typeof K&&(re=K,K=void 0):(re=L,G=K,L=void 0,K=void 0):3===arguments.length&&("number"==typeof K?"function"==typeof re&&(G=re,re=void 0):(G=re,re=K,K=void 0)),re=re||{},void 0===L&&(L=re.bits||2048),void 0===K&&(K=re.e||65537),!y.options.usePureJavaScript&&!re.prng&&L>=256&&L<=16384&&(65537===K||3===K))if(G){if(M("generateKeyPair"))return g.generateKeyPair("rsa",{modulusLength:L,publicExponent:K,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(ne,se,he){if(ne)return G(ne);G(null,{privateKey:h.privateKeyFromPem(he),publicKey:h.publicKeyFromPem(se)})});if(k("generateKey")&&k("exportKey"))return m.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:j(K),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(ne){return m.globalScope.crypto.subtle.exportKey("pkcs8",ne.privateKey)}).then(void 0,function(ne){G(ne)}).then(function(ne){if(ne){var se=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(ne)));G(null,{privateKey:se,publicKey:h.setRsaPublicKey(se.n,se.e)})}});if(F("generateKey")&&F("exportKey")){var te=m.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:j(K),hash:{name:"SHA-256"}},!0,["sign","verify"]);return te.oncomplete=function(ne){var he=m.globalScope.msCrypto.subtle.exportKey("pkcs8",ne.target.result.privateKey);he.oncomplete=function(pe){var Se=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(pe.target.result)));G(null,{privateKey:Se,publicKey:h.setRsaPublicKey(Se.n,Se.e)})},he.onerror=function(pe){G(pe)}},void(te.onerror=function(ne){G(ne)})}}else if(M("generateKeyPairSync")){var Z=g.generateKeyPairSync("rsa",{modulusLength:L,publicExponent:K,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:h.privateKeyFromPem(Z.privateKey),publicKey:h.publicKeyFromPem(Z.publicKey)}}var q=h.rsa.createKeyPairGenerationState(L,K,re);if(!G)return h.rsa.stepKeyPairGenerationState(q,0),q.keys;P(q,re,G)},h.setRsaPublicKey=h.rsa.setPublicKey=function(L,K){var re={n:L,e:K,encrypt:function(G,te,Z){if("string"==typeof te?te=te.toUpperCase():void 0===te&&(te="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===te)te={encode:function(ne,se,he){return I(ne,se,2).getBytes()}};else if("RSA-OAEP"===te||"RSAES-OAEP"===te)te={encode:function(ne,se){return y.pkcs1.encode_rsa_oaep(se,ne,Z)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(te))te={encode:function(ne){return ne}};else if("string"==typeof te)throw new Error('Unsupported encryption scheme: "'+te+'".');var q=te.encode(G,re,!0);return h.rsa.encrypt(q,re,!0)},verify:function(G,te,Z,q){"string"==typeof Z?Z=Z.toUpperCase():void 0===Z&&(Z="RSASSA-PKCS1-V1_5"),void 0===q&&(q={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in q||(q._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===Z?Z={verify:function(se,he){he=A(he,re,!0);var pe=w.fromDer(he,{parseAllBytes:q._parseAllDigestBytes}),Le={},Se=[];if(!w.validate(pe,E,Le,Se))throw(Ne=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=Se,Ne;var Ne,be=w.derToOid(Le.algorithmIdentifier);if(be!==y.oids.md2&&be!==y.oids.md5&&be!==y.oids.sha1&&be!==y.oids.sha224&&be!==y.oids.sha256&&be!==y.oids.sha384&&be!==y.oids.sha512&&be!==y.oids["sha512-224"]&&be!==y.oids["sha512-256"])throw(Ne=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=be,Ne;if((be===y.oids.md2||be===y.oids.md5)&&!("parameters"in Le))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return se===Le.digest}}:("NONE"===Z||"NULL"===Z||null===Z)&&(Z={verify:function(se,he){return se===A(he,re,!0)}});var ne=h.rsa.decrypt(te,re,!0,!1);return Z.verify(G,ne,re.n.bitLength())}};return re},h.setRsaPrivateKey=h.rsa.setPrivateKey=function(L,K,re,G,te,Z,q,ne){var se={n:L,e:K,d:re,p:G,q:te,dP:Z,dQ:q,qInv:ne,decrypt:function(he,pe,Le){"string"==typeof pe?pe=pe.toUpperCase():void 0===pe&&(pe="RSAES-PKCS1-V1_5");var Se=h.rsa.decrypt(he,se,!1,!1);if("RSAES-PKCS1-V1_5"===pe)pe={decode:A};else if("RSA-OAEP"===pe||"RSAES-OAEP"===pe)pe={decode:function(Ne,be){return y.pkcs1.decode_rsa_oaep(be,Ne,Le)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(pe))throw new Error('Unsupported encryption scheme: "'+pe+'".');pe={decode:function(Ne){return Ne}}}return pe.decode(Se,se,!1)},sign:function(he,pe){var Le=!1;"string"==typeof pe&&(pe=pe.toUpperCase()),void 0===pe||"RSASSA-PKCS1-V1_5"===pe?(pe={encode:v},Le=1):("NONE"===pe||"NULL"===pe||null===pe)&&(pe={encode:function(){return he}},Le=1);var Se=pe.encode(he,se.n.bitLength());return h.rsa.encrypt(Se,se,Le)}};return se},h.wrapRsaPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,w.toDer(L).getBytes())])},h.privateKeyFromAsn1=function(L){var te,Z,q,ne,se,he,pe,Le,K={},re=[];if(w.validate(L,f,K,re)&&(L=w.fromDer(y.util.createBuffer(K.privateKey))),!w.validate(L,d,K={},re=[])){var G=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw G.errors=re,G}return te=y.util.createBuffer(K.privateKeyModulus).toHex(),Z=y.util.createBuffer(K.privateKeyPublicExponent).toHex(),q=y.util.createBuffer(K.privateKeyPrivateExponent).toHex(),ne=y.util.createBuffer(K.privateKeyPrime1).toHex(),se=y.util.createBuffer(K.privateKeyPrime2).toHex(),he=y.util.createBuffer(K.privateKeyExponent1).toHex(),pe=y.util.createBuffer(K.privateKeyExponent2).toHex(),Le=y.util.createBuffer(K.privateKeyCoefficient).toHex(),h.setRsaPrivateKey(new l(te,16),new l(Z,16),new l(q,16),new l(ne,16),new l(se,16),new l(he,16),new l(pe,16),new l(Le,16))},h.privateKeyToAsn1=h.privateKeyToRSAPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.d)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.p)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.q)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dP)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dQ)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.qInv))])},h.publicKeyFromAsn1=function(L){var K={},re=[];if(w.validate(L,S,K,re)){var te,G=w.derToOid(K.publicKeyOid);if(G!==h.oids.rsaEncryption)throw(te=new Error("Cannot read public key. Unknown OID.")).oid=G,te;L=K.rsaPublicKey}if(!w.validate(L,b,K,re=[]))throw(te=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=re,te;var Z=y.util.createBuffer(K.publicKeyModulus).toHex(),q=y.util.createBuffer(K.publicKeyExponent).toHex();return h.setRsaPublicKey(new l(Z,16),new l(q,16))},h.publicKeyToAsn1=h.publicKeyToSubjectPublicKeyInfo=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.BITSTRING,!1,[h.publicKeyToRSAPublicKey(L)])])},h.publicKeyToRSAPublicKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e))])}},7690:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var l=Y.exports=y.sha1=y.sha1||{};y.md.sha1=y.md.algorithms.sha1=l,l.create=function(){w||function m(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),w=!0}();var c=null,f=y.util.createBuffer(),d=new Array(80),b={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){b.messageLength=0,b.fullMessageLength=b.messageLength64=[];for(var S=b.messageLengthSize/4,E=0;E>>0,v>>>0];for(var p=b.fullMessageLength.length-1;p>=0;--p)b.fullMessageLength[p]+=v[1],v[1]=v[0]+(b.fullMessageLength[p]/4294967296>>>0),b.fullMessageLength[p]=b.fullMessageLength[p]>>>0,v[0]=v[1]/4294967296>>>0;return f.putBytes(S),h(c,d,f),(f.read>2048||0===f.length())&&f.compact(),b},b.digest=function(){var S=y.util.createBuffer();S.putBytes(f.bytes()),S.putBytes(g.substr(0,b.blockLength-(b.fullMessageLength[b.fullMessageLength.length-1]+b.messageLengthSize&b.blockLength-1)));for(var p,A=8*b.fullMessageLength[0],P=0;P>>0)>>>0),A=p>>>0;S.putInt32(A);var D={h0:c.h0,h1:c.h1,h2:c.h2,h3:c.h3,h4:c.h4};h(D,d,S);var T=y.util.createBuffer();return T.putInt32(D.h0),T.putInt32(D.h1),T.putInt32(D.h2),T.putInt32(D.h3),T.putInt32(D.h4),T},b};var g=null,w=!1;function h(c,f,d){for(var b,S,E,v,p,I,P,D=d.length();D>=64;){for(S=c.h0,E=c.h1,v=c.h2,p=c.h3,I=c.h4,P=0;P<16;++P)b=d.getInt32(),f[P]=b,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<20;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<32;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<40;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<60;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E&v|p&(E^v))+I+2400959708+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<80;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+3395469782+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;c.h0=c.h0+S|0,c.h1=c.h1+E|0,c.h2=c.h2+v|0,c.h3=c.h3+p|0,c.h4=c.h4+I|0,D-=64}}},1594:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var l=Y.exports=y.sha256=y.sha256||{};y.md.sha256=y.md.algorithms.sha256=l,l.create=function(){w||function h(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),m=[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],w=!0}();var f=null,d=y.util.createBuffer(),b=new Array(64),S={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){S.messageLength=0,S.fullMessageLength=S.messageLength64=[];for(var E=S.messageLengthSize/4,v=0;v>>0,p>>>0];for(var I=S.fullMessageLength.length-1;I>=0;--I)S.fullMessageLength[I]+=p[1],p[1]=p[0]+(S.fullMessageLength[I]/4294967296>>>0),S.fullMessageLength[I]=S.fullMessageLength[I]>>>0,p[0]=p[1]/4294967296>>>0;return d.putBytes(E),c(f,b,d),(d.read>2048||0===d.length())&&d.compact(),S},S.digest=function(){var E=y.util.createBuffer();E.putBytes(d.bytes()),E.putBytes(g.substr(0,S.blockLength-(S.fullMessageLength[S.fullMessageLength.length-1]+S.messageLengthSize&S.blockLength-1)));for(var I,P=8*S.fullMessageLength[0],D=0;D>>0)>>>0),P=I>>>0;E.putInt32(P);var T={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4,h5:f.h5,h6:f.h6,h7:f.h7};c(T,b,E);var M=y.util.createBuffer();return M.putInt32(T.h0),M.putInt32(T.h1),M.putInt32(T.h2),M.putInt32(T.h3),M.putInt32(T.h4),M.putInt32(T.h5),M.putInt32(T.h6),M.putInt32(T.h7),M},S};var g=null,w=!1,m=null;function c(f,d,b){for(var S,E,A,P,D,T,M,k,F,j,C,O,V=b.length();V>=64;){for(P=0;P<16;++P)d[P]=b.getInt32();for(;P<64;++P)d[P]=(S=((S=d[P-2])>>>17|S<<15)^(S>>>19|S<<13)^S>>>10)+d[P-7]+(E=((E=d[P-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3)+d[P-16]|0;for(D=f.h0,T=f.h1,M=f.h2,k=f.h3,F=f.h4,j=f.h5,C=f.h6,O=f.h7,P=0;P<64;++P)A=D&T|M&(D^T),S=O+((F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7))+(C^F&(j^C))+m[P]+d[P],O=C,C=j,j=F,F=k+S>>>0,k=M,M=T,T=D,D=S+(E=((D>>>2|D<<30)^(D>>>13|D<<19)^(D>>>22|D<<10))+A)>>>0;f.h0=f.h0+D|0,f.h1=f.h1+T|0,f.h2=f.h2+M|0,f.h3=f.h3+k|0,f.h4=f.h4+F|0,f.h5=f.h5+j|0,f.h6=f.h6+C|0,f.h7=f.h7+O|0,V-=64}}},8985:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var l=Y.exports=y.sha512=y.sha512||{};y.md.sha512=y.md.algorithms.sha512=l;var g=y.sha384=y.sha512.sha384=y.sha512.sha384||{};g.create=function(){return l.create("SHA-384")},y.md.sha384=y.md.algorithms.sha384=g,y.sha512.sha256=y.sha512.sha256||{create:function(){return l.create("SHA-512/256")}},y.md["sha512/256"]=y.md.algorithms["sha512/256"]=y.sha512.sha256,y.sha512.sha224=y.sha512.sha224||{create:function(){return l.create("SHA-512/224")}},y.md["sha512/224"]=y.md.algorithms["sha512/224"]=y.sha512.sha224,l.create=function(b){if(m||function f(){w=String.fromCharCode(128),w+=y.util.fillString(String.fromCharCode(0),128),h=[[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]],(c={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],m=!0}(),typeof b>"u"&&(b="SHA-512"),!(b in c))throw new Error("Invalid SHA-512 algorithm: "+b);for(var S=c[b],E=null,v=y.util.createBuffer(),p=new Array(80),I=0;I<80;++I)p[I]=new Array(2);var A=64;switch(b){case"SHA-384":A=48;break;case"SHA-512/256":A=32;break;case"SHA-512/224":A=28}var P={algorithm:b.replace("-","").toLowerCase(),blockLength:128,digestLength:A,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){P.messageLength=0,P.fullMessageLength=P.messageLength128=[];for(var D=P.messageLengthSize/4,T=0;T>>0,M>>>0];for(var k=P.fullMessageLength.length-1;k>=0;--k)P.fullMessageLength[k]+=M[1],M[1]=M[0]+(P.fullMessageLength[k]/4294967296>>>0),P.fullMessageLength[k]=P.fullMessageLength[k]>>>0,M[0]=M[1]/4294967296>>>0;return v.putBytes(D),d(E,p,v),(v.read>2048||0===v.length())&&v.compact(),P},P.digest=function(){var D=y.util.createBuffer();D.putBytes(v.bytes()),D.putBytes(w.substr(0,P.blockLength-(P.fullMessageLength[P.fullMessageLength.length-1]+P.messageLengthSize&P.blockLength-1)));for(var k,j=8*P.fullMessageLength[0],C=0;C>>0)>>>0),j=k>>>0;D.putInt32(j);var O=new Array(E.length);for(C=0;C=128;){for(be=0;be<16;++be)S[be][0]=E.getInt32()>>>0,S[be][1]=E.getInt32()>>>0;for(;be<80;++be)p=(((je=(Ee=S[be-2])[0])<<13|(H=Ee[1])>>>19)^(H<<3|je>>>29)^(je<<26|H>>>6))>>>0,S[be][0]=(v=((je>>>19|H<<13)^(H>>>29|je<<3)^je>>>6)>>>0)+(Ie=S[be-7])[0]+(I=(((je=(Re=S[be-15])[0])>>>1|(H=Re[1])<<31)^(je>>>8|H<<24)^je>>>7)>>>0)+(He=S[be-16])[0]+((H=p+Ie[1]+(A=((je<<31|H>>>1)^(je<<24|H>>>8)^(je<<25|H>>>7))>>>0)+He[1])/4294967296>>>0)>>>0,S[be][1]=H>>>0;for(O=b[0][0],V=b[0][1],L=b[1][0],K=b[1][1],re=b[2][0],G=b[2][1],te=b[3][0],Z=b[3][1],q=b[4][0],ne=b[4][1],se=b[5][0],he=b[5][1],pe=b[6][0],Le=b[6][1],Se=b[7][0],Ne=b[7][1],be=0;be<80;++be)v=Se+(((q>>>14|ne<<18)^(q>>>18|ne<<14)^(ne>>>9|q<<23))>>>0)+((pe^q&(se^pe))>>>0)+h[be][0]+S[be][0]+((H=Ne+(((q<<18|ne>>>14)^(q<<14|ne>>>18)^(ne<<23|q>>>9))>>>0)+((Le^ne&(he^Le))>>>0)+h[be][1]+S[be][1])/4294967296>>>0)>>>0,p=H>>>0,I=(((O>>>28|V<<4)^(V>>>2|O<<30)^(V>>>7|O<<25))>>>0)+((O&L|re&(O^L))>>>0)+((H=(((O<<4|V>>>28)^(V<<30|O>>>2)^(V<<25|O>>>7))>>>0)+((V&K|G&(V^K))>>>0))/4294967296>>>0)>>>0,A=H>>>0,Se=pe,Ne=Le,pe=se,Le=he,se=q,he=ne,q=te+v+((H=Z+p)/4294967296>>>0)>>>0,ne=H>>>0,te=re,Z=G,re=L,G=K,L=O,K=V,O=v+I+((H=p+A)/4294967296>>>0)>>>0,V=H>>>0;b[0][0]=b[0][0]+O+((H=b[0][1]+V)/4294967296>>>0)>>>0,b[0][1]=H>>>0,b[1][0]=b[1][0]+L+((H=b[1][1]+K)/4294967296>>>0)>>>0,b[1][1]=H>>>0,b[2][0]=b[2][0]+re+((H=b[2][1]+G)/4294967296>>>0)>>>0,b[2][1]=H>>>0,b[3][0]=b[3][0]+te+((H=b[3][1]+Z)/4294967296>>>0)>>>0,b[3][1]=H>>>0,b[4][0]=b[4][0]+q+((H=b[4][1]+ne)/4294967296>>>0)>>>0,b[4][1]=H>>>0,b[5][0]=b[5][0]+se+((H=b[5][1]+he)/4294967296>>>0)>>>0,b[5][1]=H>>>0,b[6][0]=b[6][0]+pe+((H=b[6][1]+Le)/4294967296>>>0)>>>0,b[6][1]=H>>>0,b[7][0]=b[7][0]+Se+((H=b[7][1]+Ne)/4294967296>>>0)>>>0,b[7][1]=H>>>0,We-=128}}},4747:(Y,U,x)=>{var y=x(8659),l=x(2020),g=Y.exports=y.util=y.util||{};function w(D){if(8!==D&&16!==D&&24!==D&&32!==D)throw new Error("Only 8, 16, 24, or 32 bits supported: "+D)}function m(D){if(this.data="",this.read=0,"string"==typeof D)this.data=D;else if(g.isArrayBuffer(D)||g.isArrayBufferView(D))if(typeof Buffer<"u"&&D instanceof Buffer)this.data=D.toString("binary");else{var T=new Uint8Array(D);try{this.data=String.fromCharCode.apply(null,T)}catch{for(var M=0;M15?(M=Date.now(),j(V)):(T.push(V),1===T.length&&F.setAttribute("a",k=!k))}}g.nextTick=g.setImmediate})(),g.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,g.globalScope=g.isNodejs?global:typeof self>"u"?window:self,g.isArray=Array.isArray||function(D){return"[object Array]"===Object.prototype.toString.call(D)},g.isArrayBuffer=function(D){return typeof ArrayBuffer<"u"&&D instanceof ArrayBuffer},g.isArrayBufferView=function(D){return D&&g.isArrayBuffer(D.buffer)&&void 0!==D.byteLength},g.ByteBuffer=m,g.ByteStringBuffer=m,g.ByteStringBuffer.prototype._optimizeConstructedString=function(D){this._constructedStringLength+=D,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},g.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},g.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},g.ByteStringBuffer.prototype.putByte=function(D){return this.putBytes(String.fromCharCode(D))},g.ByteStringBuffer.prototype.fillWithByte=function(D,T){D=String.fromCharCode(D);for(var M=this.data;T>0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return this.data=M,this._optimizeConstructedString(T),this},g.ByteStringBuffer.prototype.putBytes=function(D){return this.data+=D,this._optimizeConstructedString(D.length),this},g.ByteStringBuffer.prototype.putString=function(D){return this.putBytes(g.encodeUtf8(D))},g.ByteStringBuffer.prototype.putInt16=function(D){return this.putBytes(String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt24=function(D){return this.putBytes(String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt32=function(D){return this.putBytes(String.fromCharCode(D>>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt16Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255))},g.ByteStringBuffer.prototype.putInt24Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255))},g.ByteStringBuffer.prototype.putInt32Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>24&255))},g.ByteStringBuffer.prototype.putInt=function(D,T){w(T);var M="";do{T-=8,M+=String.fromCharCode(D>>T&255)}while(T>0);return this.putBytes(M)},g.ByteStringBuffer.prototype.putSignedInt=function(D,T){return D<0&&(D+=2<0);return T},g.ByteStringBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.ByteStringBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.ByteStringBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.ByteStringBuffer.prototype.at=function(D){return this.data.charCodeAt(this.read+D)},g.ByteStringBuffer.prototype.setAt=function(D,T){return this.data=this.data.substr(0,this.read+D)+String.fromCharCode(T)+this.data.substr(this.read+D+1),this},g.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},g.ByteStringBuffer.prototype.copy=function(){var D=g.createBuffer(this.data);return D.read=this.read,D},g.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},g.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},g.ByteStringBuffer.prototype.truncate=function(D){var T=Math.max(0,this.length()-D);return this.data=this.data.substr(this.read,T),this.read=0,this},g.ByteStringBuffer.prototype.toHex=function(){for(var D="",T=this.read;T=D)return this;T=Math.max(T||this.growSize,D);var M=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),k=new Uint8Array(this.length()+T);return k.set(M),this.data=new DataView(k.buffer),this},g.DataBuffer.prototype.putByte=function(D){return this.accommodate(1),this.data.setUint8(this.write++,D),this},g.DataBuffer.prototype.fillWithByte=function(D,T){this.accommodate(T);for(var M=0;M>8&65535),this.data.setInt8(this.write,D>>16&255),this.write+=3,this},g.DataBuffer.prototype.putInt32=function(D){return this.accommodate(4),this.data.setInt32(this.write,D),this.write+=4,this},g.DataBuffer.prototype.putInt16Le=function(D){return this.accommodate(2),this.data.setInt16(this.write,D,!0),this.write+=2,this},g.DataBuffer.prototype.putInt24Le=function(D){return this.accommodate(3),this.data.setInt8(this.write,D>>16&255),this.data.setInt16(this.write,D>>8&65535,!0),this.write+=3,this},g.DataBuffer.prototype.putInt32Le=function(D){return this.accommodate(4),this.data.setInt32(this.write,D,!0),this.write+=4,this},g.DataBuffer.prototype.putInt=function(D,T){w(T),this.accommodate(T/8);do{T-=8,this.data.setInt8(this.write++,D>>T&255)}while(T>0);return this},g.DataBuffer.prototype.putSignedInt=function(D,T){return w(T),this.accommodate(T/8),D<0&&(D+=2<0);return T},g.DataBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.DataBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.DataBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.DataBuffer.prototype.at=function(D){return this.data.getUint8(this.read+D)},g.DataBuffer.prototype.setAt=function(D,T){return this.data.setUint8(D,T),this},g.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},g.DataBuffer.prototype.copy=function(){return new g.DataBuffer(this)},g.DataBuffer.prototype.compact=function(){if(this.read>0){var D=new Uint8Array(this.data.buffer,this.read),T=new Uint8Array(D.byteLength);T.set(D),this.data=new DataView(T),this.write-=this.read,this.read=0}return this},g.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},g.DataBuffer.prototype.truncate=function(D){return this.write=Math.max(0,this.length()-D),this.read=Math.min(this.read,this.write),this},g.DataBuffer.prototype.toHex=function(){for(var D="",T=this.read;T0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return M},g.xorBytes=function(D,T,M){for(var k="",F="",j="",C=0,O=0;M>0;--M,++C)F=D.charCodeAt(C)^T.charCodeAt(C),O>=10&&(k+=j,j="",O=0),j+=String.fromCharCode(F),++O;return k+j},g.hexToBytes=function(D){var T="",M=0;for(!0&D.length&&(M=1,T+=String.fromCharCode(parseInt(D[0],16)));M>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D)};var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";g.encode64=function(D,T){for(var F,j,C,M="",k="",O=0;O>2),M+=f.charAt((3&F)<<4|j>>4),isNaN(j)?M+="==":(M+=f.charAt((15&j)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.decode64=function(D){D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var M,k,F,j,T="",C=0;C>4),64!==F&&(T+=String.fromCharCode((15&k)<<4|F>>2),64!==j&&(T+=String.fromCharCode((3&F)<<6|j)));return T},g.encodeUtf8=function(D){return unescape(encodeURIComponent(D))},g.decodeUtf8=function(D){return decodeURIComponent(escape(D))},g.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:l.encode,decode:l.decode}},g.binary.raw.encode=function(D){return String.fromCharCode.apply(null,D)},g.binary.raw.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,j=0;j>2),M+=f.charAt((3&F)<<4|j>>4),isNaN(j)?M+="==":(M+=f.charAt((15&j)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.binary.base64.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(3*Math.ceil(D.length/4))),D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var F,j,C,O,V=0,L=M=M||0;V>4,64!==C&&(k[L++]=(15&j)<<4|C>>2,64!==O&&(k[L++]=(3&C)<<6|O));return T?L-M:k.subarray(0,L)},g.binary.base58.encode=function(D,T){return g.binary.baseN.encode(D,b,T)},g.binary.base58.decode=function(D,T){return g.binary.baseN.decode(D,b,T)},g.text={utf8:{},utf16:{}},g.text.utf8.encode=function(D,T,M){D=g.encodeUtf8(D);var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,j=0;j"u"&&(M=["web","flash"]);var F,j=!1,C=null;for(var O in M){F=M[O];try{if("flash"===F||"both"===F){if(null===T[0])throw new Error("Flash local storage not available.");k=D.apply(this,T),j="flash"===F}("web"===F||"both"===F)&&(T[0]=localStorage,k=D.apply(this,T),j=!0)}catch(V){C=V}if(j)break}if(!j)throw C;return k};g.setItem=function(D,T,M,k,F){P(v,arguments,F)},g.getItem=function(D,T,M,k){return P(p,arguments,k)},g.removeItem=function(D,T,M,k){P(I,arguments,k)},g.clearItems=function(D,T,M){P(A,arguments,M)},g.isEmpty=function(D){for(var T in D)if(D.hasOwnProperty(T))return!1;return!0},g.format=function(D){for(var M,k,T=/%./g,F=0,j=[],C=0;M=T.exec(D);){(k=D.substring(C,T.lastIndex-2)).length>0&&j.push(k),C=T.lastIndex;var O=M[0][1];switch(O){case"s":case"o":j.push(F");break;case"%":j.push("%");break;default:j.push("<%"+O+"?>")}}return j.push(D.substring(C)),j.join("")},g.formatNumber=function(D,T,M,k){var F=D,j=isNaN(T=Math.abs(T))?2:T,C=void 0===M?",":M,O=void 0===k?".":k,V=F<0?"-":"",L=parseInt(F=Math.abs(+F||0).toFixed(j),10)+"",K=L.length>3?L.length%3:0;return V+(K?L.substr(0,K)+O:"")+L.substr(K).replace(/(\d{3})(?=\d)/g,"$1"+O)+(j?C+Math.abs(F-L).toFixed(j).slice(2):"")},g.formatSize=function(D){return D>=1073741824?g.formatNumber(D/1073741824,2,".","")+" GiB":D>=1048576?g.formatNumber(D/1048576,2,".","")+" MiB":D>=1024?g.formatNumber(D/1024,0)+" KiB":g.formatNumber(D,0)+" bytes"},g.bytesFromIP=function(D){return-1!==D.indexOf(".")?g.bytesFromIPv4(D):-1!==D.indexOf(":")?g.bytesFromIPv6(D):null},g.bytesFromIPv4=function(D){if(4!==(D=D.split(".")).length)return null;for(var T=g.createBuffer(),M=0;MM[k].end-M[k].start&&(k=M.length-1)):M.push({start:O,end:O})}T.push(j)}if(M.length>0){var V=M[k];V.end-V.start>0&&(T.splice(V.start,V.end-V.start+1,""),0===V.start&&T.unshift(""),7===V.end&&T.push(""))}return T.join(":")},g.estimateCores=function(D,T){if("function"==typeof D&&(T=D,D={}),D=D||{},"cores"in g&&!D.update)return T(null,g.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return g.cores=navigator.hardwareConcurrency,T(null,g.cores);if(typeof Worker>"u")return g.cores=1,T(null,g.cores);if(typeof Blob>"u")return g.cores=2,T(null,g.cores);var M=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(C){for(var O=Date.now(),V=O+4;Date.now()te.st&&K.stK.st&&te.st{var y=x(8659);x(1298),x(7791),x(279),x(979),x(9386),x(6078),x(8604),x(7256),x(5517),x(4747);var l=y.asn1,g=Y.exports=y.pki=y.pki||{},w=g.oids,m={};m.CN=w.commonName,m.commonName="CN",m.C=w.countryName,m.countryName="C",m.L=w.localityName,m.localityName="L",m.ST=w.stateOrProvinceName,m.stateOrProvinceName="ST",m.O=w.organizationName,m.organizationName="O",m.OU=w.organizationalUnitName,m.organizationalUnitName="OU",m.E=w.emailAddress,m.emailAddress="E";var h=y.pki.rsa.publicKeyValidator,c={name:"Certificate",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:l.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:l.Class.UNIVERSAL,type:l.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:l.Class.UNIVERSAL,type:l.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:l.Class.UNIVERSAL,type:l.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:l.Class.UNIVERSAL,type:l.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},h,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:l.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:l.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:l.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},f={name:"rsapss",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:l.Class.UNIVERSAL,type:l.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:l.Class.UNIVERSAL,type:l.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:l.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:l.Class.UNIVERSAL,type:l.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:l.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:l.Class.UNIVERSAL,type:l.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},b={name:"CertificationRequest",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[{name:"CertificationRequestInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},h,{name:"CertificationRequestInfo.attributes",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,constructed:!0}]}]}]},{name:"CertificationRequest.signatureAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:l.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function S(C,O){"string"==typeof O&&(O={shortName:O});for(var L,V=null,K=0;null===V&&K"u"&&(O.type&&O.type in g.oids?O.name=g.oids[O.type]:O.shortName&&O.shortName in m&&(O.name=g.oids[m[O.shortName]])),typeof O.type>"u"){if(!O.name||!(O.name in g.oids))throw(L=new Error("Attribute type not specified.")).attribute=O,L;O.type=g.oids[O.name]}if(typeof O.shortName>"u"&&O.name&&O.name in m&&(O.shortName=m[O.name]),O.type===w.extensionRequest&&(O.valueConstructed=!0,O.valueTagClass=l.Type.SEQUENCE,!O.value&&O.extensions)){O.value=[];for(var K=0;K"u")throw(L=new Error("Attribute value not specified.")).attribute=O,L}}function D(C,O){if(O=O||{},typeof C.name>"u"&&C.id&&C.id in g.oids&&(C.name=g.oids[C.id]),typeof C.id>"u"){if(!C.name||!(C.name in g.oids))throw(V=new Error("Extension ID not specified.")).extension=C,V;C.id=g.oids[C.name]}if(typeof C.value<"u")return C;if("keyUsage"===C.name){var L=0,K=0,re=0;C.digitalSignature&&(K|=128,L=7),C.nonRepudiation&&(K|=64,L=6),C.keyEncipherment&&(K|=32,L=5),C.dataEncipherment&&(K|=16,L=4),C.keyAgreement&&(K|=8,L=3),C.keyCertSign&&(K|=4,L=2),C.cRLSign&&(K|=2,L=1),C.encipherOnly&&(K|=1,L=0),C.decipherOnly&&(re|=128,L=7);var G=String.fromCharCode(L);0!==re?G+=String.fromCharCode(K)+String.fromCharCode(re):0!==K&&(G+=String.fromCharCode(K)),C.value=l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,G)}else if("basicConstraints"===C.name)C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),C.cA&&C.value.value.push(l.create(l.Class.UNIVERSAL,l.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in C&&C.value.value.push(l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(C.pathLenConstraint).getBytes()));else if("extKeyUsage"===C.name){C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);var te=C.value.value;for(var Z in C)!0===C[Z]&&(Z in w?te.push(l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(w[Z]).getBytes())):-1!==Z.indexOf(".")&&te.push(l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(Z).getBytes())))}else if("nsCertType"===C.name)L=0,K=0,C.client&&(K|=128,L=7),C.server&&(K|=64,L=6),C.email&&(K|=32,L=5),C.objsign&&(K|=16,L=4),C.reserved&&(K|=8,L=3),C.sslCA&&(K|=4,L=2),C.emailCA&&(K|=2,L=1),C.objCA&&(K|=1,L=0),G=String.fromCharCode(L),0!==K&&(G+=String.fromCharCode(K)),C.value=l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,G);else if("subjectAltName"===C.name||"issuerAltName"===C.name){C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);for(var ne=0;ne128)throw new Error('Invalid "nsComment" content.');C.value=l.create(l.Class.UNIVERSAL,l.Type.IA5STRING,!1,C.comment)}else if("subjectKeyIdentifier"===C.name&&O.cert){var se=O.cert.generateSubjectKeyIdentifier();C.subjectKeyIdentifier=se.toHex(),C.value=l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,se.getBytes())}else if("authorityKeyIdentifier"===C.name&&O.cert){if(C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),te=C.value.value,C.keyIdentifier){var he=!0===C.keyIdentifier?O.cert.generateSubjectKeyIdentifier().getBytes():C.keyIdentifier;te.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!1,he))}if(C.authorityCertIssuer){var pe=[l.create(l.Class.CONTEXT_SPECIFIC,4,!0,[I(!0===C.authorityCertIssuer?O.cert.issuer:C.authorityCertIssuer)])];te.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,pe))}if(C.serialNumber){var Le=y.util.hexToBytes(!0===C.serialNumber?O.cert.serialNumber:C.serialNumber);te.push(l.create(l.Class.CONTEXT_SPECIFIC,2,!1,Le))}}else if("cRLDistributionPoints"===C.name){C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),te=C.value.value;var q,Se=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),Ne=l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[]);for(ne=0;ne"u")throw(V=new Error("Extension value not specified.")).extension=C,V;return C}function T(C,O){if(C===w["RSASSA-PSS"]){var V=[];return void 0!==O.hash.algorithmOid&&V.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(O.hash.algorithmOid).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")])])),void 0!==O.mgf.algorithmOid&&V.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,[l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(O.mgf.algorithmOid).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(O.mgf.hash.algorithmOid).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")])])])),void 0!==O.saltLength&&V.push(l.create(l.Class.CONTEXT_SPECIFIC,2,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(O.saltLength).getBytes())])),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,V)}return l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")}function M(C){var O=l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===C.attributes.length)return O;for(var V=C.attributes,L=0;L2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(Z.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(G.validity.notBefore=Z[0],G.validity.notAfter=Z[1],G.tbsCertificate=V.tbsCertificate,O){G.md=v({signatureOid:G.signatureOid,type:"certificate"});var q=l.toDer(G.tbsCertificate);G.md.update(q.getBytes())}var ne=y.md.sha1.create(),se=l.toDer(V.certIssuer);ne.update(se.getBytes()),G.issuer.getField=function(Le){return S(G.issuer,Le)},G.issuer.addField=function(Le){P([Le]),G.issuer.attributes.push(Le)},G.issuer.attributes=g.RDNAttributesAsArray(V.certIssuer),V.certIssuerUniqueId&&(G.issuer.uniqueId=V.certIssuerUniqueId),G.issuer.hash=ne.digest().toHex();var he=y.md.sha1.create(),pe=l.toDer(V.certSubject);return he.update(pe.getBytes()),G.subject.getField=function(Le){return S(G.subject,Le)},G.subject.addField=function(Le){P([Le]),G.subject.attributes.push(Le)},G.subject.attributes=g.RDNAttributesAsArray(V.certSubject),V.certSubjectUniqueId&&(G.subject.uniqueId=V.certSubjectUniqueId),G.subject.hash=he.digest().toHex(),G.extensions=V.certExtensions?g.certificateExtensionsFromAsn1(V.certExtensions):[],G.publicKey=g.publicKeyFromAsn1(V.subjectPublicKeyInfo),G},g.certificateExtensionsFromAsn1=function(C){for(var O=[],V=0;V1&&(L=V.value.charCodeAt(1),K=V.value.length>2?V.value.charCodeAt(2):0),O.digitalSignature=128==(128&L),O.nonRepudiation=64==(64&L),O.keyEncipherment=32==(32&L),O.dataEncipherment=16==(16&L),O.keyAgreement=8==(8&L),O.keyCertSign=4==(4&L),O.cRLSign=2==(2&L),O.encipherOnly=1==(1&L),O.decipherOnly=128==(128&K)}else if("basicConstraints"===O.name){var V=l.fromDer(O.value);O.cA=V.value.length>0&&V.value[0].type===l.Type.BOOLEAN&&0!==V.value[0].value.charCodeAt(0);var re=null;V.value.length>0&&V.value[0].type===l.Type.INTEGER?re=V.value[0].value:V.value.length>1&&(re=V.value[1].value),null!==re&&(O.pathLenConstraint=l.derToInteger(re))}else if("extKeyUsage"===O.name){V=l.fromDer(O.value);for(var G=0;G1&&(L=V.value.charCodeAt(1)),O.client=128==(128&L),O.server=64==(64&L),O.email=32==(32&L),O.objsign=16==(16&L),O.reserved=8==(8&L),O.sslCA=4==(4&L),O.emailCA=2==(2&L),O.objCA=1==(1&L);else if("subjectAltName"===O.name||"issuerAltName"===O.name){O.altNames=[],V=l.fromDer(O.value);for(var Z,q=0;q=k&&C0&&L.value.push(g.certificateExtensionsToAsn1(C.extensions)),L},g.getCertificationRequestInfo=function(C){return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(C.version).getBytes()),I(C.subject),g.publicKeyToAsn1(C.publicKey),M(C)])},g.distinguishedNameToAsn1=function(C){return I(C)},g.certificateToAsn1=function(C){var O=C.tbsCertificate||g.getTBSCertificate(C);return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[O,l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(C.signatureOid).getBytes()),T(C.signatureOid,C.signatureParameters)]),l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,String.fromCharCode(0)+C.signature)])},g.certificateExtensionsToAsn1=function(C){var O=l.create(l.Class.CONTEXT_SPECIFIC,3,!0,[]),V=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);O.value.push(V);for(var L=0;L"u"&&(K=new Date);var re=!0,G=null,te=0;do{var Z=O.shift(),q=null,ne=!1;if(K&&(KZ.validity.notAfter)&&(G={message:"Certificate is not valid yet or has expired.",error:g.certificateError.certificate_expired,notBefore:Z.validity.notBefore,notAfter:Z.validity.notAfter,now:K}),null===G){if(null===(q=O[0]||C.getIssuer(Z))&&Z.isIssuer(Z)&&(ne=!0,q=Z),q){var se=q;y.util.isArray(se)||(se=[se]);for(var he=!1;!he&&se.length>0;){q=se.shift();try{he=q.verify(Z)}catch{}}he||(G={message:"Certificate signature is invalid.",error:g.certificateError.bad_certificate})}null===G&&(!q||ne)&&!C.hasCertificate(Z)&&(G={message:"Certificate is not trusted.",error:g.certificateError.unknown_ca})}if(null===G&&q&&!Z.isIssuer(q)&&(G={message:"Certificate issuer is invalid.",error:g.certificateError.bad_certificate}),null===G)for(var pe={keyUsage:!0,basicConstraints:!0},Le=0;null===G&&LeNe.pathLenConstraint&&(G={message:"Certificate basicConstraints pathLenConstraint violated.",error:g.certificateError.bad_certificate})}var H=null===G||G.error,Ee=V.verify?V.verify(H,te,L):H;if(!0!==Ee)throw!0===H&&(G={message:"The application rejected the certificate.",error:g.certificateError.bad_certificate}),(Ee||0===Ee)&&("object"!=typeof Ee||y.util.isArray(Ee)?"string"==typeof Ee&&(G.error=Ee):(Ee.message&&(G.message=Ee.message),Ee.error&&(G.error=Ee.error))),G;G=null,re=!1,++te}while(O.length>0);return!0}},8614:(Y,U,x)=>{const y=x(1159),l=x(281);Y.exports=class{constructor(){this._buffer=new y,this._waitingConsumers=new y}push(w){const{promise:m,resolve:h}=l();return this._buffer.push({chunk:w,resolve:h}),this._consume(),m}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const w=this._waitingConsumers.shift(),m=this._buffer.shift();w.resolve(m.chunk),m.resolve()}}shift(){const{promise:w,resolve:m}=l();return this._waitingConsumers.push({resolve:m}),this._consume(),w}isEmpty(){return this._buffer.isEmpty()}}},281:Y=>{"use strict";Y.exports=()=>{const x={};return x.promise=new Promise((y,l)=>{x.resolve=y,x.reject=l}),x}},4108:(Y,U,x)=>{"use strict";Y.exports=x(8777).default},8777:function(Y,U,x){"use strict";var y=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(U,"__esModule",{value:!0});const l=x(7910),g=y(x(4066)),w=y(x(382)),m=x(1396),c=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map(b=>new l.Netmask(b));function d(b){return/^::$/.test(b)||/^::1$/.test(b)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(b)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(b)||/^ff([0-9a-fA-F]{2,2}):/i.test(b)}U.default=b=>{if((0,m.isValid)(b)){const S=(0,m.parse)(b);if("ipv4"===S.kind())return function f(b){for(let S of c)if(S.contains(b))return!0;return!1}(S.toNormalizedString());if("ipv6"===S.kind())return d(b)}else if((0,w.default)(b)&&g.default.v6().test(b))return d(b)}},382:(Y,U,x)=>{"use strict";const y=x(4066),l=g=>y({exact:!0}).test(g);l.v4=g=>y.v4({exact:!0}).test(g),l.v6=g=>y.v6({exact:!0}).test(g),l.version=g=>l(g)?l.v4(g)?4:6:void 0,Y.exports=l},3863:(Y,U,x)=>{"use strict";Y.exports=x(2540)},4599:Y=>{"use strict";Y.exports=x;var y,U=/\/|\./;function x(l,g){U.test(l)||(l="google/protobuf/"+l+".proto",g={nested:{google:{nested:{protobuf:{nested:g}}}}}),x[l]=g}x("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),x("duration",{Duration:y={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),x("timestamp",{Timestamp:y}),x("empty",{Empty:{fields:{}}}),x("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),x("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),x("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),x.get=function(g){return x[g]||null}},6533:(Y,U,x)=>{"use strict";var y=U,l=x(4269),g=x(8572);function w(h,c,f,d){var b=!1;if(c.resolvedType)if(c.resolvedType instanceof l){h("switch(d%s){",d);for(var S=c.resolvedType.values,E=Object.keys(S),v=0;v>>0",d,d);break;case"int32":case"sint32":case"sfixed32":h("m%s=d%s|0",d,d);break;case"uint64":p=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",d,d,p)('else if(typeof d%s==="string")',d)("m%s=parseInt(d%s,10)",d,d)('else if(typeof d%s==="number")',d)("m%s=d%s",d,d)('else if(typeof d%s==="object")',d)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",d,d,d,p?"true":"");break;case"bytes":h('if(typeof d%s==="string")',d)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",d,d,d)("else if(d%s.length >= 0)",d)("m%s=d%s",d,d);break;case"string":h("m%s=String(d%s)",d,d);break;case"bool":h("m%s=Boolean(d%s)",d,d)}}return h}function m(h,c,f,d){if(c.resolvedType)c.resolvedType instanceof l?h("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",d,f,d,d,f,d,d):h("d%s=types[%i].toObject(m%s,o)",d,f,d);else{var b=!1;switch(c.type){case"double":case"float":h("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",d,d,d,d);break;case"uint64":b=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h('if(typeof m%s==="number")',d)("d%s=o.longs===String?String(m%s):m%s",d,d,d)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",d,d,d,d,b?"true":"",d);break;case"bytes":h("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",d,d,d,d,d);break;default:h("d%s=m%s",d,d)}}return h}y.fromObject=function(c){var f=c.fieldsArray,d=g.codegen(["d"],c.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!f.length)return d("return new this.ctor");d("var m=new this.ctor");for(var b=0;b{"use strict";Y.exports=function m(h){var c=g.codegen(["r","l"],h.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(h.fieldsArray.filter(function(v){return v.map}).length?",k,value":""))("while(r.pos>>3){");for(var f=0;f>>3){")("case 1: k=r.%s(); break",d.keyType)("case 2:"),void 0===l.basic[b]?c("value=types[%i].decode(r,r.uint32())",f):c("value=r.%s()",b),c("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),c(void 0!==l.long[d.keyType]?'%s[typeof k==="object"?util.longToHash(k):k]=value':"%s[k]=value",S)):d.repeated?(c("if(!(%s&&%s.length))",S,S)("%s=[]",S),void 0!==l.packed[b]&&c("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";Y.exports=function m(h){for(var d,c=g.codegen(["m","w"],h.name+"$encode")("if(!w)")("w=Writer.create()"),b=h.fieldsArray.slice().sort(g.compareFieldsById),f=0;f>>0,8|l.mapKey[S.keyType],S.keyType),void 0===p?c("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",E,d):c(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|p,v,d),c("}")("}")):S.repeated?(c("if(%s!=null&&%s.length){",d,d),S.packed&&void 0!==l.packed[v]?c("w.uint32(%i).fork()",(S.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",d)("w.%s(%s[i])",v,d)("w.ldelim()"):(c("for(var i=0;i<%s.length;++i)",d),void 0===p?w(c,S,E,d+"[i]"):c("w.uint32(%i).%s(%s[i])",(S.id<<3|p)>>>0,v,d)),c("}")):(S.optional&&c("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",d,S.name),void 0===p?w(c,S,E,d):c("w.uint32(%i).%s(%s)",(S.id<<3|p)>>>0,v,d))}return c("return w")};var y=x(4269),l=x(688),g=x(8572);function w(h,c,f,d){return c.resolvedType.group?h("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",f,d,(c.id<<3|3)>>>0,(c.id<<3|4)>>>0):h("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",f,d,(c.id<<3|2)>>>0)}},4269:(Y,U,x)=>{"use strict";Y.exports=w;var y=x(9487);((w.prototype=Object.create(y.prototype)).constructor=w).className="Enum";var l=x(326),g=x(8572);function w(m,h,c,f,d,b){if(y.call(this,m,c),h&&"object"!=typeof h)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=f,this.comments=d||{},this.valuesOptions=b,this.reserved=void 0,h)for(var S=Object.keys(h),E=0;E{"use strict";Y.exports=c;var y=x(9487);((c.prototype=Object.create(y.prototype)).constructor=c).className="Field";var m,l=x(4269),g=x(688),w=x(8572),h=/^required|optional|repeated$/;function c(f,d,b,S,E,v,p){if(w.isObject(S)?(p=E,v=S,S=E=void 0):w.isObject(E)&&(p=v,v=E,E=void 0),y.call(this,f,v),!w.isInteger(d)||d<0)throw TypeError("id must be a non-negative integer");if(!w.isString(b))throw TypeError("type must be a string");if(void 0!==S&&!h.test(S=S.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==E&&!w.isString(E))throw TypeError("extend must be a string");"proto3_optional"===S&&(S="optional"),this.rule=S&&"optional"!==S?S:void 0,this.type=b,this.id=d,this.extend=E||void 0,this.required="required"===S,this.optional=!this.required,this.repeated="repeated"===S,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!w.Long&&void 0!==g.long[b],this.bytes="bytes"===b,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=p}c.fromJSON=function(d,b){return new c(d,b.id,b.type,b.rule,b.extend,b.options,b.comment)},Object.defineProperty(c.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),c.prototype.setOption=function(d,b,S){return"packed"===d&&(this._packed=null),y.prototype.setOption.call(this,d,b,S)},c.prototype.toJSON=function(d){var b=!!d&&Boolean(d.keepComments);return w.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",b?this.comment:void 0])},c.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=g.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.typeDefault=this.resolvedType instanceof m?null:this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof l&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&((!0===this.options.packed||void 0!==this.options.packed&&this.resolvedType&&!(this.resolvedType instanceof l))&&delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=w.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var d;w.base64.test(this.typeDefault)?w.base64.decode(this.typeDefault,d=w.newBuffer(w.base64.length(this.typeDefault)),0):w.utf8.write(this.typeDefault,d=w.newBuffer(w.utf8.length(this.typeDefault)),0),this.typeDefault=d}return this.defaultValue=this.map?w.emptyObject:this.repeated?w.emptyArray:this.typeDefault,this.parent instanceof m&&(this.parent.ctor.prototype[this.name]=this.defaultValue),y.prototype.resolve.call(this)},c.d=function(d,b,S,E){return"function"==typeof b?b=w.decorateType(b).name:b&&"object"==typeof b&&(b=w.decorateEnum(b).name),function(p,I){w.decorateType(p.constructor).add(new c(I,d,b,S,{default:E}))}},c._configure=function(d){m=d}},5803:(Y,U,x)=>{"use strict";var y=Y.exports=x(95);y.build="light",y.load=function l(w,m,h){return"function"==typeof m?(h=m,m=new y.Root):m||(m=new y.Root),m.load(w,h)},y.loadSync=function g(w,m){return m||(m=new y.Root),m.loadSync(w)},y.encoder=x(133),y.decoder=x(225),y.verifier=x(8617),y.converter=x(6533),y.ReflectionObject=x(9487),y.Namespace=x(326),y.Root=x(5257),y.Enum=x(4269),y.Type=x(7845),y.Field=x(2986),y.OneOf=x(7397),y.MapField=x(9455),y.Service=x(9630),y.Method=x(1618),y.Message=x(1413),y.wrappers=x(761),y.types=x(688),y.util=x(8572),y.ReflectionObject._configure(y.Root),y.Namespace._configure(y.Type,y.Service,y.Enum),y.Root._configure(y.Type),y.Field._configure(y.Type)},95:(Y,U,x)=>{"use strict";var y=U;function l(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(1650),y.BufferWriter=x(813),y.Reader=x(7270),y.BufferReader=x(4354),y.util=x(7211),y.rpc=x(7830),y.roots=x(6671),y.configure=l,l()},2540:(Y,U,x)=>{"use strict";var y=Y.exports=x(5803);y.build="full",y.tokenize=x(691),y.parse=x(8992),y.common=x(4599),y.Root._configure(y.Type,y.parse,y.common)},9455:(Y,U,x)=>{"use strict";Y.exports=w;var y=x(2986);((w.prototype=Object.create(y.prototype)).constructor=w).className="MapField";var l=x(688),g=x(8572);function w(m,h,c,f,d,b){if(y.call(this,m,h,f,void 0,void 0,d,b),!g.isString(c))throw TypeError("keyType must be a string");this.keyType=c,this.resolvedKeyType=null,this.map=!0}w.fromJSON=function(h,c){return new w(h,c.id,c.keyType,c.type,c.options,c.comment)},w.prototype.toJSON=function(h){var c=!!h&&Boolean(h.keepComments);return g.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",c?this.comment:void 0])},w.prototype.resolve=function(){if(this.resolved)return this;if(void 0===l.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return y.prototype.resolve.call(this)},w.d=function(h,c,f){return"function"==typeof f?f=g.decorateType(f).name:f&&"object"==typeof f&&(f=g.decorateEnum(f).name),function(b,S){g.decorateType(b.constructor).add(new w(S,h,c,f))}}},1413:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(7211);function l(g){if(g)for(var w=Object.keys(g),m=0;m{"use strict";Y.exports=g;var y=x(9487);((g.prototype=Object.create(y.prototype)).constructor=g).className="Method";var l=x(8572);function g(w,m,h,c,f,d,b,S,E){if(l.isObject(f)?(b=f,f=d=void 0):l.isObject(d)&&(b=d,d=void 0),void 0!==m&&!l.isString(m))throw TypeError("type must be a string");if(!l.isString(h))throw TypeError("requestType must be a string");if(!l.isString(c))throw TypeError("responseType must be a string");y.call(this,w,b),this.type=m||"rpc",this.requestType=h,this.requestStream=!!f||void 0,this.responseType=c,this.responseStream=!!d||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=S,this.parsedOptions=E}g.fromJSON=function(m,h){return new g(m,h.type,h.requestType,h.responseType,h.requestStream,h.responseStream,h.options,h.comment,h.parsedOptions)},g.prototype.toJSON=function(m){var h=!!m&&Boolean(m.keepComments);return l.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",h?this.comment:void 0,"parsedOptions",this.parsedOptions])},g.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),y.prototype.resolve.call(this))}},326:(Y,U,x)=>{"use strict";Y.exports=d;var y=x(9487);((d.prototype=Object.create(y.prototype)).constructor=d).className="Namespace";var m,h,c,l=x(2986),g=x(8572),w=x(7397);function f(S,E){if(S&&S.length){for(var v={},p=0;pv)return!0;return!1},d.isReservedName=function(E,v){if(E)for(var p=0;p0;){var I=E.shift();if(p.nested&&p.nested[I]){if(!((p=p.nested[I])instanceof d))throw Error("path conflicts with non-namespace objects")}else p.add(p=new d(I))}return v&&p.addJSON(v),p},d.prototype.resolveAll=function(){for(var E=this.nestedArray,v=0;v-1)return I}else if(I instanceof d&&(I=I.lookup(E.slice(1),v,!0)))return I}else for(var A=0;A{"use strict";Y.exports=g,g.className="ReflectionObject";var l,y=x(8572);function g(w,m){if(!y.isString(w))throw TypeError("name must be a string");if(m&&!y.isObject(m))throw TypeError("options must be an object");this.options=m,this.parsedOptions=null,this.name=w,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(g.prototype,{root:{get:function(){for(var w=this;null!==w.parent;)w=w.parent;return w}},fullName:{get:function(){for(var w=[this.name],m=this.parent;m;)w.unshift(m.name),m=m.parent;return w.join(".")}}}),g.prototype.toJSON=function(){throw Error()},g.prototype.onAdd=function(m){this.parent&&this.parent!==m&&this.parent.remove(this),this.parent=m,this.resolved=!1;var h=m.root;h instanceof l&&h._handleAdd(this)},g.prototype.onRemove=function(m){var h=m.root;h instanceof l&&h._handleRemove(this),this.parent=null,this.resolved=!1},g.prototype.resolve=function(){return this.resolved||this.root instanceof l&&(this.resolved=!0),this},g.prototype.getOption=function(m){if(this.options)return this.options[m]},g.prototype.setOption=function(m,h,c){return(!c||!this.options||void 0===this.options[m])&&((this.options||(this.options={}))[m]=h),this},g.prototype.setParsedOption=function(m,h,c){this.parsedOptions||(this.parsedOptions=[]);var f=this.parsedOptions;if(c){var d=f.find(function(E){return Object.prototype.hasOwnProperty.call(E,m)});d?y.setProperty(d[m],c,h):((d={})[m]=y.setProperty({},c,h),f.push(d))}else{var S={};S[m]=h,f.push(S)}return this},g.prototype.setOptions=function(m,h){if(m)for(var c=Object.keys(m),f=0;f{"use strict";Y.exports=w;var y=x(9487);((w.prototype=Object.create(y.prototype)).constructor=w).className="OneOf";var l=x(2986),g=x(8572);function w(h,c,f,d){if(Array.isArray(c)||(f=c,c=void 0),y.call(this,h,f),void 0!==c&&!Array.isArray(c))throw TypeError("fieldNames must be an Array");this.oneof=c||[],this.fieldsArray=[],this.comment=d}function m(h){if(h.parent)for(var c=0;c-1&&this.oneof.splice(f,1),c.partOf=null,this},w.prototype.onAdd=function(c){y.prototype.onAdd.call(this,c);for(var d=0;d{"use strict";Y.exports=F,F.filename=null,F.defaults={keepCase:!1};var y=x(691),l=x(5257),g=x(7845),w=x(2986),m=x(9455),h=x(7397),c=x(4269),f=x(9630),d=x(1618),b=x(688),S=x(8572),E=/^[1-9][0-9]*$/,v=/^-?[1-9][0-9]*$/,p=/^0[x][0-9a-fA-F]+$/,I=/^-?0[x][0-9a-fA-F]+$/,A=/^0[0-7]+$/,P=/^-?0[0-7]+$/,D=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,T=/^[a-zA-Z_][a-zA-Z_0-9]*$/,M=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,k=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function F(j,C,O){C instanceof l||(O=C,C=new l),O||(O=F.defaults);var ne,se,he,pe,$e,V=O.preferTrailingComment||!1,L=y(j,O.alternateCommentMode||!1),K=L.next,re=L.push,G=L.peek,te=L.skip,Z=L.cmnt,q=!0,Le=!1,Se=C,Ne=O.keepCase?function(we){return we}:S.camelCase;function be(we,ge,De){var Fe=F.filename;return De||(F.filename=null),Error("illegal "+(ge||"token")+" '"+we+"' ("+(Fe?Fe+", ":"")+"line "+L.line+")")}function je(){var ge,we=[];do{if('"'!==(ge=K())&&"'"!==ge)throw be(ge);we.push(K()),te(ge),ge=G()}while('"'===ge||"'"===ge);return we.join("")}function H(we){var ge=K();switch(ge){case"'":case'"':return re(ge),je();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function Ie(we,ge){var De=1;switch("-"===we.charAt(0)&&(De=-1,we=we.substring(1)),we){case"inf":case"INF":case"Inf":return De*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(E.test(we))return De*parseInt(we,10);if(p.test(we))return De*parseInt(we,16);if(A.test(we))return De*parseInt(we,8);if(D.test(we))return De*parseFloat(we);throw be(we,"number",ge)}(ge,!0)}catch{if(we&&M.test(ge))return ge;throw be(ge,"value")}}function Ee(we,ge){var De,Fe;do{!ge||'"'!==(De=G())&&"'"!==De?we.push([Fe=Re(K()),te("to",!0)?Re(K()):Fe]):we.push(je())}while(te(",",!0));te(";")}function Re(we,ge){switch(we){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!ge&&"-"===we.charAt(0))throw be(we,"id");if(v.test(we))return parseInt(we,10);if(I.test(we))return parseInt(we,16);if(P.test(we))return parseInt(we,8);throw be(we,"id")}function He(){if(void 0!==ne)throw be("package");if(ne=K(),!M.test(ne))throw be(ne,"name");Se=Se.define(ne),te(";")}function We(){var ge,we=G();switch(we){case"weak":ge=he||(he=[]),K();break;case"public":K();default:ge=se||(se=[])}we=je(),te(";"),ge.push(we)}function Je(){if(te("="),pe=je(),!(Le="proto3"===pe)&&"proto2"!==pe)throw be(pe,"syntax");te(";")}function Xe(we,ge){switch(ge){case"option":return ye(we,ge),te(";"),!0;case"message":return pt(we,ge),!0;case"enum":return ie(we,ge),!0;case"service":return function qe(we,ge){if(!T.test(ge=K()))throw be(ge,"service name");var De=new f(ge);Nt(De,function(Be){if(!Xe(De,Be)){if("rpc"!==Be)throw be(Be);!function it(we,ge){var De=Z(),Fe=ge;if(!T.test(ge=K()))throw be(ge,"name");var dt,xt,vt,et,Be=ge;if(te("("),te("stream",!0)&&(xt=!0),!M.test(ge=K())||(dt=ge,te(")"),te("returns"),te("("),te("stream",!0)&&(et=!0),!M.test(ge=K())))throw be(ge);vt=ge,te(")");var An=new d(Be,Fe,dt,vt,xt,et);An.comment=De,Nt(An,function(gn){if("option"!==gn)throw be(gn);ye(An,gn),te(";")}),we.add(An)}(De,Be)}}),we.add(De)}(we,ge),!0;case"extend":return function nt(we,ge){if(!M.test(ge=K()))throw be(ge,"reference");var De=ge;Nt(null,function(Be){switch(Be){case"required":case"repeated":_t(we,Be,De);break;case"optional":_t(we,Le?"proto3_optional":"optional",De);break;default:if(!Le||!M.test(Be))throw be(Be);re(Be),_t(we,"optional",De)}})}(we,ge),!0}return!1}function Nt(we,ge,De){var Fe=L.line;if(we&&("string"!=typeof we.comment&&(we.comment=Z()),we.filename=F.filename),te("{",!0)){for(var Be;"}"!==(Be=K());)ge(Be);te(";",!0)}else De&&De(),te(";"),we&&("string"!=typeof we.comment||V)&&(we.comment=Z(Fe)||we.comment)}function pt(we,ge){if(!T.test(ge=K()))throw be(ge,"type name");var De=new g(ge);Nt(De,function(Be){if(!Xe(De,Be))switch(Be){case"map":!function pr(we){te("<");var ge=K();if(void 0===b.mapKey[ge])throw be(ge,"type");te(",");var De=K();if(!M.test(De))throw be(De,"type");te(">");var Fe=K();if(!T.test(Fe))throw be(Fe,"name");te("=");var Be=new m(Ne(Fe),Re(K()),ge,De);Nt(Be,function(xt){if("option"!==xt)throw be(xt);ye(Be,xt),te(";")},function(){Qe(Be)}),we.add(Be)}(De);break;case"required":case"repeated":_t(De,Be);break;case"optional":_t(De,Le?"proto3_optional":"optional");break;case"oneof":!function Hr(we,ge){if(!T.test(ge=K()))throw be(ge,"name");var De=new h(Ne(ge));Nt(De,function(Be){"option"===Be?(ye(De,Be),te(";")):(re(Be),_t(De,"optional"))}),we.add(De)}(De,Be);break;case"extensions":Ee(De.extensions||(De.extensions=[]));break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:if(!Le||!M.test(Be))throw be(Be);re(Be),_t(De,"optional")}}),we.add(De)}function _t(we,ge,De){var Fe=K();if("group"!==Fe){if(!M.test(Fe))throw be(Fe,"type");var Be=K();if(!T.test(Be))throw be(Be,"name");Be=Ne(Be),te("=");var dt=new w(Be,Re(K()),Fe,ge,De);if(Nt(dt,function(et){if("option"!==et)throw be(et);ye(dt,et),te(";")},function(){Qe(dt)}),"proto3_optional"===ge){var xt=new h("_"+Be);dt.setOption("proto3_optional",!0),xt.add(dt),we.add(xt)}else we.add(dt);!Le&&dt.repeated&&(void 0!==b.packed[Fe]||void 0===b.basic[Fe])&&dt.setOption("packed",!1,!0)}else!function Or(we,ge){var De=K();if(!T.test(De))throw be(De,"name");var Fe=S.lcFirst(De);De===Fe&&(De=S.ucFirst(De)),te("=");var Be=Re(K()),dt=new g(De);dt.group=!0;var xt=new w(Fe,Be,De,ge);xt.filename=F.filename,Nt(dt,function(et){switch(et){case"option":ye(dt,et),te(";");break;case"required":case"repeated":_t(dt,et);break;case"optional":_t(dt,Le?"proto3_optional":"optional");break;case"message":pt(dt,et);break;case"enum":ie(dt,et);break;default:throw be(et)}}),we.add(dt).add(xt)}(we,ge)}function ie(we,ge){if(!T.test(ge=K()))throw be(ge,"name");var De=new c(ge);Nt(De,function(Be){switch(Be){case"option":ye(De,Be),te(";");break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:!function fe(we,ge){if(!T.test(ge))throw be(ge,"name");te("=");var De=Re(K(),!0),Fe={options:void 0,setOption:function(Be,dt){void 0===this.options&&(this.options={}),this.options[Be]=dt}};Nt(Fe,function(dt){if("option"!==dt)throw be(dt);ye(Fe,dt),te(";")},function(){Qe(Fe)}),we.add(ge,De,Fe.comment,Fe.options)}(De,Be)}}),we.add(De)}function ye(we,ge){var De=te("(",!0);if(!M.test(ge=K()))throw be(ge,"name");var dt,Fe=ge,Be=Fe;De&&(te(")"),Be=Fe="("+Fe+")",ge=G(),k.test(ge)&&(dt=ge.slice(1),Fe+=ge,K())),te("="),function Me(we,ge,De,Fe){we.setParsedOption&&we.setParsedOption(ge,De,Fe)}(we,Be,me(we,Fe),dt)}function me(we,ge){if(te("{",!0)){for(var De={};!te("}",!0);){if(!T.test($e=K()))throw be($e,"name");var Fe,Be=$e;if(te(":",!0),"{"===G())Fe=me(we,ge+"."+$e);else if("["===G()){var dt;if(Fe=[],te("[",!0)){do{dt=H(!0),Fe.push(dt)}while(te(",",!0));te("]"),typeof dt<"u"&&_e(we,ge+"."+$e,dt)}}else Fe=H(!0),_e(we,ge+"."+$e,Fe);var xt=De[Be];xt&&(Fe=[].concat(xt).concat(Fe)),De[Be]=Fe,te(",",!0),te(";",!0)}return De}var vt=H(!0);return _e(we,ge,vt),vt}function _e(we,ge,De){we.setOption&&we.setOption(ge,De)}function Qe(we){if(te("[",!0)){do{ye(we,"option")}while(te(",",!0));te("]")}return we}for(;null!==($e=K());)switch($e){case"package":if(!q)throw be($e);He();break;case"import":if(!q)throw be($e);We();break;case"syntax":if(!q)throw be($e);Je();break;case"option":ye(Se,$e),te(";");break;default:if(Xe(Se,$e)){q=!1;continue}throw be($e)}return F.filename=null,{package:ne,imports:se,weakImports:he,syntax:pe,root:C}}},7270:(Y,U,x)=>{"use strict";Y.exports=h;var l,y=x(7211),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new l(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){l=E,h.create=f(),l._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},4354:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(7270);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(7211);function g(w){y.call(this,w)}g._configure=function(){l.Buffer&&(g.prototype._slice=l.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},5257:(Y,U,x)=>{"use strict";Y.exports=d;var y=x(326);((d.prototype=Object.create(y.prototype)).constructor=d).className="Root";var h,c,f,l=x(2986),g=x(4269),w=x(7397),m=x(8572);function d(v){y.call(this,"",v),this.deferred=[],this.files=[]}function b(){}d.fromJSON=function(p,I){return I||(I=new d),p.options&&I.setOptions(p.options),I.addJSON(p.nested)},d.prototype.resolvePath=m.path.resolve,d.prototype.fetch=m.fetch,d.prototype.load=function v(p,I,A){"function"==typeof I&&(A=I,I=void 0);var P=this;if(!A)return m.asPromise(v,P,p,I);var D=A===b;function T(V,L){if(A){var K=A;if(A=null,D)throw V;K(V,L)}}function M(V){var L=V.lastIndexOf("google/protobuf/");if(L>-1){var K=V.substring(L);if(K in f)return K}return null}function k(V,L){try{if(m.isString(L)&&"{"===L.charAt(0)&&(L=JSON.parse(L)),m.isString(L)){c.filename=V;var re,K=c(L,P,I),G=0;if(K.imports)for(;G-1)){if(P.files.push(V),V in f)return void(D?k(V,f[V]):(++j,setTimeout(function(){--j,k(V,f[V])})));if(D){var K;try{K=m.fs.readFileSync(V).toString("utf8")}catch(re){return void(L||T(re))}k(V,K)}else++j,P.fetch(V,function(re,G){if(--j,A){if(re)return void(L?j||T(null,P):T(re));k(V,G)}})}}var j=0;m.isString(p)&&(p=[p]);for(var O,C=0;C-1&&this.deferred.splice(I,1)}}else if(p instanceof g)S.test(p.name)&&delete p.parent[p.name];else if(p instanceof y){for(var A=0;A{"use strict";Y.exports={}},7830:(Y,U,x)=>{"use strict";U.Service=x(6346)},6346:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(7211);function l(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(l.prototype=Object.create(y.EventEmitter.prototype)).constructor=l,l.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},l.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},9630:(Y,U,x)=>{"use strict";Y.exports=m;var y=x(326);((m.prototype=Object.create(y.prototype)).constructor=m).className="Service";var l=x(1618),g=x(8572),w=x(7830);function m(c,f){y.call(this,c,f),this.methods={},this._methodsArray=null}function h(c){return c._methodsArray=null,c}m.fromJSON=function(f,d){var b=new m(f,d.options);if(d.methods)for(var S=Object.keys(d.methods),E=0;E{"use strict";Y.exports=d;var U=/[\s{}=;:[\],'"()<>]/g,x=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,y=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,l=/^ *[*/]+ */,g=/^\s*\*?\/*/,w=/\n/g,m=/\s/,h=/\\(.?)/g,c={0:"\0",r:"\r",n:"\n",t:"\t"};function f(b){return b.replace(h,function(S,E){switch(E){case"\\":case"":return E;default:return c[E]||""}})}function d(b,S){b=b.toString();var E=0,v=b.length,p=1,I=0,A={},P=[],D=null;function T(G){return Error("illegal "+G+" (line "+p+")")}function k(G){return b.charAt(G)}function F(G,te,Z){var he,q={type:b.charAt(G++),lineEmpty:!1,leading:Z},se=G-(S?2:3);do{if(--se<0||"\n"===(he=b.charAt(se))){q.lineEmpty=!0;break}}while(" "===he||"\t"===he);for(var pe=b.substring(G,te).split(w),Le=0;Le0)return P.shift();if(D)return function M(){var G="'"===D?y:x;G.lastIndex=E-1;var te=G.exec(b);if(!te)throw T("string");return E=G.lastIndex,V(D),D=null,f(te[1])}();var G,te,Z,q,ne,se=0===E;do{if(E===v)return null;for(G=!1;m.test(Z=k(E));)if("\n"===Z&&(se=!0,++p),++E===v)return null;if("/"===k(E)){if(++E===v)throw T("comment");if("/"===k(E))if(S){if(q=E,ne=!1,j(E)){ne=!0;do{if((E=C(E))===v||(E++,!se))break}while(j(E))}else E=Math.min(v,C(E)+1);ne&&(F(q,E,se),se=!0),p++,G=!0}else{for(ne="/"===k(q=E+1);"\n"!==k(++E);)if(E===v)return null;++E,ne&&(F(q,E-1,se),se=!0),++p,G=!0}else{if("*"!==(Z=k(E)))return"/";q=E+1,ne=S||"*"===k(q);do{if("\n"===Z&&++p,++E===v)throw T("comment");te=Z,Z=k(E)}while("*"!==te||"/"!==Z);++E,ne&&(F(q,E-2,se),se=!0),G=!0}}}while(G);var he=E;if(U.lastIndex=0,!U.test(k(he++)))for(;he{"use strict";Y.exports=A;var y=x(326);((A.prototype=Object.create(y.prototype)).constructor=A).className="Type";var l=x(4269),g=x(7397),w=x(2986),m=x(9455),h=x(9630),c=x(1413),f=x(7270),d=x(1650),b=x(8572),S=x(133),E=x(225),v=x(8617),p=x(6533),I=x(761);function A(D,T){y.call(this,D,T),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function P(D){return D._fieldsById=D._fieldsArray=D._oneofsArray=null,delete D.encode,delete D.decode,delete D.verify,D}Object.defineProperties(A.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var D=Object.keys(this.fields),T=0;T{"use strict";var y=U,l=x(8572),g=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function w(m,h){var c=0,f={};for(h|=0;c{"use strict";var g,w,y=Y.exports=x(7211),l=x(6671);y.codegen=x(9749),y.fetch=x(8832),y.path=x(1311),y.fs=y.inquire("fs"),y.toArray=function(b){if(b){for(var S=Object.keys(b),E=new Array(S.length),v=0;v0)p[P]=v(p[P]||{},I,A);else{var D=p[P];D&&(A=[].concat(D).concat(A)),p[P]=A}return p}(b,S=S.split("."),E)},Object.defineProperty(y,"decorateRoot",{get:function(){return l.decorated||(l.decorated=new(x(5257)))}})},942:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(7211);function l(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=l.zero=new l(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=l.zeroHash="\0\0\0\0\0\0\0\0";l.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new l(d,b)},l.from=function(c){if("number"==typeof c)return l.fromNumber(c);if(y.isString(c)){if(!y.Long)return l.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new l(c.low>>>0,c.high>>>0):g},l.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},l.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;l.fromHash=function(c){return c===w?g:new l((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},l.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},l.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},l.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},l.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},7211:function(Y,U,x){"use strict";var y=U;function l(w,m,h){for(var c=Object.keys(m),f=0;fw,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),m}y.asPromise=x(1280),y.base64=x(9039),y.EventEmitter=x(9889),y.float=x(530),y.inquire=x(716),y.utf8=x(7768),y.pool=x(4479),y.LongBits=x(942),y.isNode=Boolean(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),y.global=y.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||this,y.emptyArray=Object.freeze?Object.freeze([]):[],y.emptyObject=Object.freeze?Object.freeze({}):{},y.isInteger=Number.isInteger||function(m){return"number"==typeof m&&isFinite(m)&&Math.floor(m)===m},y.isString=function(m){return"string"==typeof m||m instanceof String},y.isObject=function(m){return m&&"object"==typeof m},y.isset=y.isSet=function(m,h){var c=m[h];return!(null==c||!m.hasOwnProperty(h))&&("object"!=typeof c||(Array.isArray(c)?c.length:Object.keys(c).length)>0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=l,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Y.exports=function h(c){var f=l.codegen(["m"],c.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),b={};c.oneofsArray.length&&f("var p={}");for(var S=0;S{"use strict";var y=U,l=x(1413);y[".google.protobuf.Any"]={fromObject:function(g){if(g&&g["@type"]){var w=g["@type"].substring(g["@type"].lastIndexOf("/")+1),m=this.lookup(w);if(m){var h="."===g["@type"].charAt(0)?g["@type"].slice(1):g["@type"];return-1===h.indexOf("/")&&(h="/"+h),this.create({type_url:h,value:m.encode(m.fromObject(g)).finish()})}}return this.fromObject(g)},toObject:function(g,w){var h="",c="";if(w&&w.json&&g.type_url&&g.value){c=g.type_url.substring(g.type_url.lastIndexOf("/")+1),h=g.type_url.substring(0,g.type_url.lastIndexOf("/")+1);var f=this.lookup(c);f&&(g=f.decode(g.value))}if(!(g instanceof this.ctor)&&g instanceof l){var d=g.$type.toObject(g,w),b="."===g.$type.fullName[0]?g.$type.fullName.slice(1):g.$type.fullName;return""===h&&(h="type.googleapis.com/"),d["@type"]=c=h+b,d}return this.toObject(g,w)}}},1650:(Y,U,x)=>{"use strict";Y.exports=d;var l,y=x(7211),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new l})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){l=P,d.create=b(),l._configure()}},813:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(1650);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(7211);function g(){y.call(this)}function w(m,h,c){m.length<40?l.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=l._Buffer_allocUnsafe,g.writeBytesBuffer=l.Buffer&&l.Buffer.prototype instanceof Uint8Array&&"set"===l.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=l.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},7813:(Y,U,x)=>{const y=x(9301),l=x(6217),g=x(7840),w=x(939),{RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c}=x(9644),f=x(4849),d=x(6492),b=x(5936),S=x(8592),E=x(2816),v=x(9062),p=x(9658);Y.exports={RateLimiterRedis:y,RateLimiterMongo:l,RateLimiterMySQL:g,RateLimiterPostgres:w,RateLimiterMemory:f,RateLimiterMemcache:d,RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c,RLWrapperBlackAndWhite:b,RateLimiterUnion:S,RateLimiterQueue:E,BurstyRateLimiter:v,RateLimiterRes:p}},9062:(Y,U,x)=>{const y=x(9658);Y.exports=class{constructor(g,w){this._rateLimiter=g,this._burstLimiter=w}_combineRes(g,w){return new y(g.remainingPoints,Math.min(g.msBeforeNext,w.msBeforeNext),g.consumedPoints,g.isFirstInDuration)}consume(g,w=1,m={}){return this._rateLimiter.consume(g,w,m).catch(h=>h instanceof y?this._burstLimiter.consume(g,w,m).then(c=>Promise.resolve(this._combineRes(h,c))).catch(c=>Promise.reject(c instanceof y?this._combineRes(h,c):c)):Promise.reject(h))}get(g){return Promise.all([this._rateLimiter.get(g),this._burstLimiter.get(g)]).then(([w,m])=>this._combineRes(w,m))}get points(){return this._rateLimiter.points}}},5936:(Y,U,x)=>{const y=x(9658);Y.exports=class{constructor(g={}){this.limiter=g.limiter,this.blackList=g.blackList,this.whiteList=g.whiteList,this.isBlackListed=g.isBlackListed,this.isWhiteListed=g.isWhiteListed,this.runActionAnyway=g.runActionAnyway}get limiter(){return this._limiter}set limiter(g){if(typeof g>"u")throw new Error("limiter is not set");this._limiter=g}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(g){this._runActionAnyway=!(typeof g>"u")&&g}get blackList(){return this._blackList}set blackList(g){this._blackList=Array.isArray(g)?g:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isBlackListed must be function");this._isBlackListed=g}get whiteList(){return this._whiteList}set whiteList(g){this._whiteList=Array.isArray(g)?g:[]}get isWhiteListed(){return this._isWhiteListed}set isWhiteListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isWhiteListed must be function");this._isWhiteListed=g}isBlackListedSomewhere(g){return this.blackList.indexOf(g)>=0||this.isBlackListed(g)}isWhiteListedSomewhere(g){return this.whiteList.indexOf(g)>=0||this.isWhiteListed(g)}getBlackRes(){return new y(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new y(Number.MAX_SAFE_INTEGER,0,0,!1)}rejectBlack(){return Promise.reject(this.getBlackRes())}resolveBlack(){return Promise.resolve(this.getBlackRes())}resolveWhite(){return Promise.resolve(this.getWhiteRes())}consume(g,w=1){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.rejectBlack()),typeof m>"u"?this.limiter.consume(g,w):(this.runActionAnyway&&this.limiter.consume(g,w).catch(()=>{}),m)}block(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.block(g,w):(this.runActionAnyway&&this.limiter.block(g,w).catch(()=>{}),m)}penalty(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.penalty(g,w):(this.runActionAnyway&&this.limiter.penalty(g,w).catch(()=>{}),m)}reward(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.reward(g,w):(this.runActionAnyway&&this.limiter.reward(g,w).catch(()=>{}),m)}get(g){let w;return this.isWhiteListedSomewhere(g)?w=this.resolveWhite():this.isBlackListedSomewhere(g)&&(w=this.resolveBlack()),typeof w>"u"||this.runActionAnyway?this.limiter.get(g):w}delete(g){return this.limiter.delete(g)}}},6953:Y=>{Y.exports=class{constructor(x={}){this.points=x.points,this.duration=x.duration,this.blockDuration=x.blockDuration,this.execEvenly=x.execEvenly,this.execEvenlyMinDelayMs=x.execEvenlyMinDelayMs,this.keyPrefix=x.keyPrefix}get points(){return this._points}set points(x){this._points=x>=0?x:4}get duration(){return this._duration}set duration(x){this._duration=typeof x>"u"?1:x}get msDuration(){return 1e3*this.duration}get blockDuration(){return this._blockDuration}set blockDuration(x){this._blockDuration=typeof x>"u"?0:x}get msBlockDuration(){return 1e3*this.blockDuration}get execEvenly(){return this._execEvenly}set execEvenly(x){this._execEvenly=!(typeof x>"u")&&Boolean(x)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(x){this._execEvenlyMinDelayMs=typeof x>"u"?Math.ceil(this.msDuration/this.points):x}get keyPrefix(){return this._keyPrefix}set keyPrefix(x){if(typeof x>"u"&&(x="rlflx"),"string"!=typeof x)throw new Error("keyPrefix must be string");this._keyPrefix=x}_getKeySecDuration(x={}){return x&&x.customDuration>=0?x.customDuration:this.duration}getKey(x){return this.keyPrefix.length>0?`${this.keyPrefix}:${x}`:x}parseKey(x){return x.substring(this.keyPrefix.length)}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}},9644:(Y,U,x)=>{const y=x(1265),l=x(5539),g=x(6953),w=x(4849),m=x(9658),h="rate_limiter_flexible";let c=null;const f=function(D,T,M,k){let F;F=null===k||!0===k||!1===k?k:{remainingPoints:k.remainingPoints,msBeforeNext:k.msBeforeNext,consumedPoints:k.consumedPoints,isFirstInDuration:k.isFirstInDuration},D.send({channel:h,keyPrefix:T.keyPrefix,promiseId:T.promiseId,type:M,data:F})},d=function(D){setTimeout(()=>{this._initiated?process.send(D):typeof this._promises[D.promiseId]<"u"&&d.call(this,D)},30)},b=function(D,T,M,k,F){const j={channel:h,keyPrefix:this.keyPrefix,func:D,promiseId:T,data:{key:M,arg:k,opts:F}};this._initiated?process.send(j):d.call(this,j)},S=function(D,T){if(!T||T.channel!==h||typeof this._rateLimiters[T.keyPrefix]>"u")return!1;let M;switch(T.func){case"consume":M=this._rateLimiters[T.keyPrefix].consume(T.data.key,T.data.arg,T.data.opts);break;case"penalty":M=this._rateLimiters[T.keyPrefix].penalty(T.data.key,T.data.arg,T.data.opts);break;case"reward":M=this._rateLimiters[T.keyPrefix].reward(T.data.key,T.data.arg,T.data.opts);break;case"block":M=this._rateLimiters[T.keyPrefix].block(T.data.key,T.data.arg,T.data.opts);break;case"get":M=this._rateLimiters[T.keyPrefix].get(T.data.key,T.data.opts);break;case"delete":M=this._rateLimiters[T.keyPrefix].delete(T.data.key,T.data.opts);break;default:return!1}M&&M.then(k=>{f(D,T,"resolve",k)}).catch(k=>{f(D,T,"reject",k)})},E=function(D){if(!D||D.channel!==h||D.keyPrefix!==this.keyPrefix)return!1;if(this._promises[D.promiseId]){let T;switch(clearTimeout(this._promises[D.promiseId].timeoutId),T=null===D.data||!0===D.data||!1===D.data?D.data:new m(D.data.remainingPoints,D.data.msBeforeNext,D.data.consumedPoints,D.data.isFirstInDuration),D.type){case"resolve":this._promises[D.promiseId].resolve(T);break;case"reject":this._promises[D.promiseId].reject(T);break;default:throw new Error(`RateLimiterCluster: no such message type '${D.type}'`)}delete this._promises[D.promiseId]}},v=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},p=function(D,T){const M=process.hrtime();let k=M[0].toString()+M[1].toString();return typeof this._promises[k]<"u"&&(k+=l.randomBytes(12).toString("base64")),this._promises[k]={resolve:D,reject:T,timeoutId:setTimeout(()=>{delete this._promises[k],T(new Error("RateLimiterCluster timeout: no answer from master in time"))},this.timeoutMs)},k};Y.exports={RateLimiterClusterMaster:class I{constructor(){if(c)return c;this._rateLimiters={},y.setMaxListeners(0),y.on("message",(T,M)=>{M&&M.channel===h&&"init"===M.type?(typeof this._rateLimiters[M.opts.keyPrefix]>"u"&&(this._rateLimiters[M.opts.keyPrefix]=new w(M.opts)),T.send({channel:h,type:"init",keyPrefix:M.opts.keyPrefix})):S.call(this,T,M)}),c=this}},RateLimiterClusterMasterPM2:class A{constructor(T){if(c)return c;this._rateLimiters={},T.launchBus((M,k)=>{k.on("process:msg",F=>{const j=F.raw;j&&j.channel===h&&"init"===j.type?(typeof this._rateLimiters[j.opts.keyPrefix]>"u"&&(this._rateLimiters[j.opts.keyPrefix]=new w(j.opts)),T.sendDataToProcessId(F.process.pm_id,{data:{},topic:h,channel:h,type:"init",keyPrefix:j.opts.keyPrefix},(C,O)=>{C&&console.log(C,O)})):S.call(this,{send:O=>{const V=O;V.topic=h,typeof V.data>"u"&&(V.data={}),T.sendDataToProcessId(F.process.pm_id,V,(L,K)=>{L&&console.log(L,K)})}},j)})}),c=this}},RateLimiterCluster:class P extends g{get timeoutMs(){return this._timeoutMs}set timeoutMs(T){this._timeoutMs=typeof T>"u"?5e3:Math.abs(parseInt(T))}constructor(T={}){super(T),process.setMaxListeners(0),this.timeoutMs=T.timeoutMs,this._initiated=!1,process.on("message",M=>{M&&M.channel===h&&"init"===M.type&&M.keyPrefix===this.keyPrefix?this._initiated=!0:E.call(this,M)}),process.send({channel:h,type:"init",opts:v.call(this)}),this._promises={}}consume(T,M=1,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"consume",C,T,M,k)})}penalty(T,M=1,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"penalty",C,T,M,k)})}reward(T,M=1,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"reward",C,T,M,k)})}block(T,M,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"block",C,T,M,k)})}get(T,M={}){return new Promise((k,F)=>{const j=p.call(this,k,F);b.call(this,"get",j,T,M)})}delete(T,M={}){return new Promise((k,F)=>{const j=p.call(this,k,F);b.call(this,"delete",j,T,M)})}}}},6492:(Y,U,x)=>{const y=x(3129),l=x(9658);Y.exports=class g extends y{constructor(m){super(m),this.client=m.storeClient}_getRateLimiterRes(m,h,c){const f=new l;return f.consumedPoints=parseInt(c.consumedPoints),f.isFirstInDuration=c.consumedPoints===h,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=c.msBeforeNext,f}_upsert(m,h,c,f=!1,d={}){return new Promise((b,S)=>{const E=Date.now(),v=Math.floor(c/1e3);f?this.client.set(m,h,v,p=>{p?S(p):this.client.set(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.incr(m,h,(p,I)=>{p||!1===I?this.client.add(m,h,v,(A,P)=>{if(A||!P)if(typeof d.attemptNumber>"u"||d.attemptNumber<3){const D=Object.assign({},d);D.attemptNumber=D.attemptNumber?D.attemptNumber+1:1,this._upsert(m,h,c,f,D).then(T=>b(T)).catch(T=>S(T))}else S(new Error("Can not add key"));else this.client.add(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.get(`${m}_expire`,(A,P)=>{if(A)S(A);else{const D=!1===P?0:P,T={consumedPoints:I,msBeforeNext:D>=0?Math.max(D-E,0):-1};b(T)}})})})}_get(m){return new Promise((h,c)=>{const f=Date.now();this.client.get(m,(d,b)=>{b?this.client.get(`${m}_expire`,(S,E)=>{if(S)c(S);else{const v=!1===E?0:E,p={consumedPoints:b,msBeforeNext:v>=0?Math.max(v-f,0):-1};h(p)}}):h(null)})})}_delete(m){return new Promise((h,c)=>{this.client.del(m,(f,d)=>{f?c(f):!1===d?h(d):this.client.del(`${m}_expire`,b=>{b?c(b):h(d)})})})}}},4849:(Y,U,x)=>{const y=x(6953),l=x(6216),g=x(9658);Y.exports=class w extends y{constructor(h={}){super(h),this._memoryStorage=new l}consume(h,c=1,f={}){return new Promise((d,b)=>{const S=this.getKey(h),E=this._getKeySecDuration(f);let v=this._memoryStorage.incrby(S,c,E);if(v.remainingPoints=Math.max(this.points-v.consumedPoints,0),v.consumedPoints>this.points)this.blockDuration>0&&v.consumedPoints<=this.points+c&&(v=this._memoryStorage.set(S,v.consumedPoints,this.blockDuration)),b(v);else if(this.execEvenly&&v.msBeforeNext>0&&!v.isFirstInDuration){let p=Math.ceil(v.msBeforeNext/(v.remainingPoints+2));p{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}reward(h,c=1,f={}){const d=this.getKey(h);return new Promise(b=>{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,-c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}block(h,c){const f=1e3*c,d=this.points+1;return this._memoryStorage.set(this.getKey(h),d,c),Promise.resolve(new g(0,0===f?-1:f,d))}set(h,c,f){const d=1e3*(f>=0?f:this.duration);return this._memoryStorage.set(this.getKey(h),c,f),Promise.resolve(new g(0,0===d?-1:d,c))}get(h){const c=this._memoryStorage.get(this.getKey(h));return null!==c&&(c.remainingPoints=Math.max(this.points-c.consumedPoints,0)),Promise.resolve(c)}delete(h){return Promise.resolve(this._memoryStorage.delete(this.getKey(h)))}}},6217:(Y,U,x)=>{const y=x(3129),l=x(9658);function g(m){try{const h=m.client?m.client:m,{version:c}=h.topology.s.options.metadata.driver,f=c.split(".").map(d=>parseInt(d));return{major:f[0],feature:f[1],patch:f[2]}}catch{return{major:0,feature:0,patch:0}}}class w extends y{constructor(h){super(h),this.dbName=h.dbName,this.tableName=h.tableName,this.indexKeyPrefix=h.indexKeyPrefix,this.client=h.mongo?h.mongo:h.storeClient,"function"==typeof this.client.then?this.client.then(c=>{this.client=c,this._initCollection(),this._driverVersion=g(this.client)}):(this._initCollection(),this._driverVersion=g(this.client))}get dbName(){return this._dbName}set dbName(h){this._dbName=typeof h>"u"?w.getDbName():h}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(h){this._tableName=typeof h>"u"?this.keyPrefix:h}get client(){return this._client}set client(h){if(typeof h>"u")throw new Error("mongo is not set");this._client=h}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(h){this._indexKeyPrefix=h||{}}_initCollection(){const c=("function"==typeof this.client.db?this.client.db(this.dbName):this.client).collection(this.tableName);c.createIndex({expire:-1},{expireAfterSeconds:0}),c.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=c}_getRateLimiterRes(h,c,f){const d=new l;let b;return b=typeof f.value>"u"?f:f.value,d.isFirstInDuration=b.points===c,d.consumedPoints=b.points,d.remainingPoints=Math.max(this.points-d.consumedPoints,0),d.msBeforeNext=null!==b.expire?Math.max(new Date(b.expire).getTime()-Date.now(),0):-1,d}_upsert(h,c,f,d=!1,b={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const S=b.attrs||{};let E,v;d?(E={key:h},E=Object.assign(E,S),v={$set:{key:h,points:c,expire:f>0?new Date(Date.now()+f):null}},v.$set=Object.assign(v.$set,S)):(E={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:h},E=Object.assign(E,S),v={$setOnInsert:{key:h,expire:f>0?new Date(Date.now()+f):null},$inc:{points:c}},v.$setOnInsert=Object.assign(v.$setOnInsert,S));const p={upsert:!0};return this._driverVersion.major>=4||3===this._driverVersion.major&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?p.returnDocument="after":p.returnOriginal=!1,new Promise((I,A)=>{this._collection.findOneAndUpdate(E,v,p).then(P=>{I(P)}).catch(P=>{if(P&&11e3===P.code){const D=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:h},S),T={$set:Object.assign({key:h,points:c,expire:f>0?new Date(Date.now()+f):null},S)};this._collection.findOneAndUpdate(D,T,p).then(M=>{I(M)}).catch(M=>{M&&11e3===M.code?this._upsert(h,c,f,d).then(k=>I(k)).catch(k=>A(k)):A(M)})}else A(P)})})}_get(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const f=c.attrs||{},d=Object.assign({key:h,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},f);return this._collection.findOne(d)}_delete(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const d=Object.assign({key:h},c.attrs||{});return this._collection.deleteOne(d).then(b=>b.deletedCount>0)}}Y.exports=w},7840:(Y,U,x)=>{const y=x(3129),l=x(9658);Y.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.dbName=m.dbName,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()):this._createDbAndTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._getConnection().then(c=>{c.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,m],()=>{this._releaseConnection(c),h()})}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise((m,h)=>{this.client.getConnection((c,f)=>{if(c)return h(c);m(f)})});case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(m){switch(this.clientType){case"pool":return m.release();case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m);default:return!0}}_createDbAndTable(){return new Promise((m,h)=>{this._getConnection().then(c=>{c.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`,f=>{if(f)return this._releaseConnection(c),h(f);c.query(this._getCreateTableStmt(),d=>{if(d)return this._releaseConnection(c),h(d);this._releaseConnection(c),m()})})}).catch(c=>{h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${this.tableName}\` (\`key\` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\`points\` INT(9) NOT NULL default 0,\`expire\` BIGINT UNSIGNED,PRIMARY KEY (\`key\`)) ENGINE = INNODB;`}get clientType(){return this._clientType}set clientType(m){if(typeof m>"u")if("Connection"===this.client.constructor.name)m="connection";else if("Pool"===this.client.constructor.name)m="pool";else{if("Sequelize"!==this.client.constructor.name)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get dbName(){return this._dbName}set dbName(m){this._dbName=typeof m>"u"?"rtlmtrflx":m}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new l,[d]=c;return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_upsertTransaction(m,h,c,f,d){return new Promise((b,S)=>{m.query("BEGIN",E=>{if(E)return m.rollback(),S(E);const v=Date.now(),p=f>0?v+f:null;let I,A;d?(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = ?, \n expire = ?;",A=[this.dbName,this.tableName,h,c,p,c,p]):(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = IF(expire <= ?, ?, points + (?)), \n expire = IF(expire <= ?, ?, expire);",A=[this.dbName,this.tableName,h,c,p,v,c,c,v,p]),m.query(I,A,P=>{if(P)return m.rollback(),S(P);m.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,h],(D,T)=>{if(D)return m.rollback(),S(D);m.query("COMMIT",M=>{if(M)return m.rollback(),S(M);b(T)})})})})})}_upsert(m,h,c,f=!1){return this.tableCreated?new Promise((d,b)=>{this._getConnection().then(S=>{this._upsertTransaction(S,m,h,c,f).then(E=>{d(E),this._releaseConnection(S)}).catch(E=>{b(E),this._releaseConnection(S)})}).catch(S=>{b(S)})}):Promise.reject(Error("Table is not created yet"))}_get(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)",[this.dbName,this.tableName,m,Date.now()],(d,b)=>{d?c(d):h(0===b.length?null:b),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("DELETE FROM ??.?? WHERE `key` = ?",[this.dbName,this.tableName,m],(d,b)=>{d?c(d):h(b.affectedRows>0),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}}},939:(Y,U,x)=>{const y=x(3129),l=x(9658);Y.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?"function"==typeof h&&h():this._createTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._query({name:"rlflx-clear-expired",text:`DELETE FROM ${this.tableName} WHERE expire < $1`,values:[m]}).then(()=>{h()}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":default:return Promise.resolve(this.client);case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();case"typeorm":return Promise.resolve(this.client.driver.master)}}_releaseConnection(m){switch(this.clientType){case"pool":case"typeorm":default:return!0;case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m)}}_createTable(){return new Promise((m,h)=>{this._query({text:this._getCreateTableStmt()}).then(()=>{m()}).catch(c=>{"23505"===c.code?m():h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS ${this.tableName} ( \n key varchar(255) PRIMARY KEY,\n points integer NOT NULL DEFAULT 0,\n expire bigint\n );`}get clientType(){return this._clientType}set clientType(m){const h=this.client.constructor.name;if(typeof m>"u")if("Client"===h)m="client";else if("Pool"===h||"BoundPool"===h)m="pool";else{if("Sequelize"!==h)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new l,d=c.rows[0];return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_query(m){const c={name:`${this.tableName.toLowerCase()}:${m.name}`,text:m.text,values:m.values};return new Promise((f,d)=>{this._getConnection().then(b=>{b.query(c).then(S=>{f(S),this._releaseConnection(b)}).catch(S=>{d(S),this._releaseConnection(b)})}).catch(b=>{d(b)})})}_upsert(m,h,c,f=!1){if(!this.tableCreated)return Promise.reject(Error("Table is not created yet"));const d=c>0?Date.now()+c:null;return this._query({name:f?"rlflx-upsert-force":"rlflx-upsert",text:`\n INSERT INTO ${this.tableName} VALUES ($1, $2, $3)\n ON CONFLICT(key) DO UPDATE SET\n points = CASE\n WHEN (${this.tableName}.expire <= $4 OR 1=${f?1:0}) THEN $2\n ELSE ${this.tableName}.points + ($2)\n END,\n expire = ${f?" $3 ":` CASE\n WHEN ${this.tableName}.expire <= $4 THEN $3\n ELSE ${this.tableName}.expire\n END `}\n RETURNING points, expire;`,values:[m,h,d,Date.now()]})}_get(m){return this.tableCreated?new Promise((h,c)=>{this._query({name:"rlflx-get",text:`\n SELECT points, expire FROM ${this.tableName} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,values:[m,Date.now()]}).then(f=>{0===f.rowCount&&(f=null),h(f)}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?this._query({name:"rlflx-delete",text:`DELETE FROM ${this.tableName} WHERE key = $1`,values:[m]}).then(h=>h.rowCount>0):Promise.reject(Error("Table is not created yet"))}}},2816:(Y,U,x)=>{const y=x(2047),l=4294967295,g="limiter";Y.exports=class{constructor(h,c={maxQueueSize:l}){this._queueLimiters={KEY_DEFAULT:new w(h,c)},this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(h=g){return this._queueLimiters[h]?this._queueLimiters[h].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(h,c=g){return this._queueLimiters[c]||(this._queueLimiters[c]=new w(this._limiterFlexible,{key:c,maxQueueSize:this._maxQueueSize})),this._queueLimiters[c].removeTokens(h)}};class w{constructor(h,c={maxQueueSize:l,key:g}){this._key=c.key,this._waitTimeout=null,this._queue=[],this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(){return this._limiterFlexible.get(this._key).then(h=>null!==h?h.remainingPoints:this._limiterFlexible.points)}removeTokens(h){const c=this;return new Promise((f,d)=>{h>c._limiterFlexible.points?d(new y(`Requested tokens ${h} exceeds maximum ${c._limiterFlexible.points} tokens per interval`)):c._queue.length>0?c._queueRequest.call(c,f,d,h):c._limiterFlexible.consume(c._key,h).then(b=>{f(b.remainingPoints)}).catch(b=>{b instanceof Error?d(b):(c._queueRequest.call(c,f,d,h),null===c._waitTimeout&&(c._waitTimeout=setTimeout(c._processFIFO.bind(c),b.msBeforeNext)))})})}_queueRequest(h,c,f){const d=this;d._queue.length{c.resolve(f.remainingPoints),h._processFIFO.call(h)}).catch(f=>{f instanceof Error?(c.reject(f),h._processFIFO.call(h)):(h._queue.unshift(c),null===h._waitTimeout&&(h._waitTimeout=setTimeout(h._processFIFO.bind(h),f.msBeforeNext)))})}}},9301:(Y,U,x)=>{const y=x(3129),l=x(9658),g="redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') local consumed = redis.call('incrby', KEYS[1], ARGV[1]) local ttl = redis.call('pttl', KEYS[1]) if ttl == -1 then redis.call('expire', KEYS[1], ARGV[2]) ttl = 1000 * ARGV[2] end return {consumed, ttl} ";Y.exports=class w extends y{constructor(h){super(h),this.client=h.redis?h.redis:h.storeClient,"function"==typeof this.client.defineCommand&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:g})}_getRateLimiterRes(h,c,f){let[d,b]=f;Array.isArray(d)&&([,d]=d,[,b]=b);const S=new l;return S.consumedPoints=parseInt(d),S.isFirstInDuration=S.consumedPoints===c,S.remainingPoints=Math.max(this.points-S.consumedPoints,0),S.msBeforeNext=b,S}_upsert(h,c,f,d=!1){return new Promise((b,S)=>{const E=Math.floor(f/1e3),v=this.client.multi();if(d)E>0?v.set(h,c,"EX",E):v.set(h,c),v.pttl(h).exec((p,I)=>p?S(p):b(I));else if(E>0){const p=function(I,A){return I?S(I):b(A)};"function"==typeof this.client.rlflxIncr?this.client.rlflxIncr(h,c,E,p):this.client.eval(g,1,h,c,E,p)}else v.incrby(h,c).pttl(h).exec((p,I)=>p?S(p):b(I))})}_get(h){return new Promise((c,f)=>{this.client.multi().get(h).pttl(h).exec((d,b)=>{if(d)f(d);else{const[S]=b;if(null===S)return c(null);c(b)}})})}_delete(h){return new Promise((c,f)=>{this.client.del(h,(d,b)=>{d?f(d):c(b>0)})})}}},9658:Y=>{Y.exports=class{constructor(x,y,l,g){this.remainingPoints=typeof x>"u"?0:x,this.msBeforeNext=typeof y>"u"?0:y,this.consumedPoints=typeof l>"u"?0:l,this.isFirstInDuration=!(typeof g>"u")&&g}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(x){return this._msBeforeNext=x,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(x){return this._remainingPoints=x,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(x){return this._consumedPoints=x,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(x){this._isFirstInDuration=Boolean(x)}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}},3129:(Y,U,x)=>{const y=x(6953),l=x(8442),g=x(9658);Y.exports=class extends y{constructor(m={}){super(m),this.inmemoryBlockOnConsumed=m.inmemoryBlockOnConsumed,this.inmemoryBlockDuration=m.inmemoryBlockDuration,this.insuranceLimiter=m.insuranceLimiter,this._inmemoryBlockedKeys=new l}get client(){return this._client}set client(m){if(typeof m>"u")throw new Error("storeClient is not set");this._client=m}_afterConsume(m,h,c,f,d,b={}){const S=this._getRateLimiterRes(c,f,d);if(this.inmemoryBlockOnConsumed>0&&!(this.inmemoryBlockDuration>0)&&S.consumedPoints>=this.inmemoryBlockOnConsumed)return this._inmemoryBlockedKeys.addMs(c,S.msBeforeNext),S.consumedPoints>this.points?h(S):m(S);if(S.consumedPoints>this.points){let E=Promise.resolve();this.blockDuration>0&&S.consumedPoints<=this.points+f&&(S.msBeforeNext=this.msBlockDuration,E=this._block(c,S.consumedPoints,this.msBlockDuration,b)),this.inmemoryBlockOnConsumed>0&&S.consumedPoints>=this.inmemoryBlockOnConsumed&&(this._inmemoryBlockedKeys.add(c,this.inmemoryBlockDuration),S.msBeforeNext=this.msInmemoryBlockDuration),E.then(()=>{h(S)}).catch(v=>{h(v)})}else if(this.execEvenly&&S.msBeforeNext>0&&!S.isFirstInDuration){let E=Math.ceil(S.msBeforeNext/(S.remainingPoints+2));E{c(E)}).catch(E=>{f(E)}):f(m)}getInmemoryBlockMsBeforeExpire(m){return this.inmemoryBlockOnConsumed>0?this._inmemoryBlockedKeys.msBeforeExpire(m):0}get inmemoryBlockOnConsumed(){return this._inmemoryBlockOnConsumed}set inmemoryBlockOnConsumed(m){if(this._inmemoryBlockOnConsumed=m?parseInt(m):0,this.inmemoryBlockOnConsumed>0&&this.points>this.inmemoryBlockOnConsumed)throw new Error('inmemoryBlockOnConsumed option must be greater or equal "points" option')}get inmemoryBlockDuration(){return this._inmemoryBlockDuration}set inmemoryBlockDuration(m){if(this._inmemoryBlockDuration=m?parseInt(m):0,this.inmemoryBlockDuration>0&&0===this.inmemoryBlockOnConsumed)throw new Error("inmemoryBlockOnConsumed option must be set up")}get msInmemoryBlockDuration(){return 1e3*this._inmemoryBlockDuration}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(m){if(typeof m<"u"&&!(m instanceof y))throw new Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=m,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(m,h,c={}){const f=1e3*h;return this._block(this.getKey(m),this.points+1,f,c)}set(m,h,c,f={}){const d=1e3*(c>=0?c:this.duration);return this._block(this.getKey(m),h,d,f)}consume(m,h=1,c={}){return new Promise((f,d)=>{const b=this.getKey(m),S=this.getInmemoryBlockMsBeforeExpire(b);if(S>0)return d(new g(0,S));this._upsert(b,h,1e3*this._getKeySecDuration(c),!1,c).then(E=>{this._afterConsume(f,d,b,h,E)}).catch(E=>{this._handleError(E,"consume",f,d,m,h,c)})})}penalty(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,h,S))}).catch(S=>{this._handleError(S,"penalty",d,b,m,h,c)})})}reward(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,-h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,-h,S))}).catch(S=>{this._handleError(S,"reward",d,b,m,h,c)})})}get(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._get(c,h).then(b=>{f(null===b||typeof b>"u"?null:this._getRateLimiterRes(c,0,b))}).catch(b=>{this._handleError(b,"get",f,d,m,h)})})}delete(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._delete(c,h).then(b=>{this._inmemoryBlockedKeys.delete(c),f(b)}).catch(b=>{this._handleError(b,"delete",f,d,m,h)})})}deleteInMemoryBlockedAll(){this._inmemoryBlockedKeys.delete()}_getRateLimiterRes(m,h,c){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(m,h,c,f={}){return new Promise((d,b)=>{this._upsert(m,h,c,!0,f).then(()=>{d(new g(0,c>0?c:-1,h))}).catch(S=>{this._handleError(S,"block",d,b,this.parseKey(m),c/1e3,f)})})}_get(m,h={}){throw new Error("You have to implement the method '_get'!")}_delete(m,h={}){throw new Error("You have to implement the method '_delete'!")}_upsert(){throw new Error("You have to implement the method '_upsert'!")}}},8592:(Y,U,x)=>{const y=x(6953);Y.exports=class{constructor(...g){if(g.length<2)throw new Error("RateLimiterUnion: at least two limiters have to be set");g.forEach(w=>{if(!(w instanceof y))throw new Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")}),this._limiters=g}consume(g,w=1){return new Promise((m,h)=>{const c=[];this._limiters.forEach(f=>{c.push(f.consume(g,w).catch(d=>({rejected:!0,rej:d})))}),Promise.all(c).then(f=>{const d={};let b=!1;f.forEach(S=>{!0===S.rejected&&(b=!0)});for(let S=0;S{Y.exports=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){const x=Date.now();Object.keys(this._keys).forEach(y=>{this._keys[y]<=x&&delete this._keys[y]}),this._addedKeysAmount=Object.keys(this._keys).length}add(x,y){this.addMs(x,1e3*y)}addMs(x,y){this._keys[x]=Date.now()+y,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(x){const y=this._keys[x];if(y&&y>=Date.now()){this.collectExpired();const l=Date.now();return y>=l?y-l:0}return 0}delete(x){x?delete this._keys[x]:Object.keys(this._keys).forEach(y=>{delete this._keys[y]})}}},8442:(Y,U,x)=>{const y=x(2585);Y.exports=y},6216:(Y,U,x)=>{const y=x(7105),l=x(9658);Y.exports=class{constructor(){this._storage={}}incrby(w,m,h){if(this._storage[w]){const c=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return 0!==c?(this._storage[w].value=this._storage[w].value+m,new l(0,c,this._storage[w].value,!1)):this.set(w,m,h)}return this.set(w,m,h)}set(w,m,h){const c=1e3*h;return this._storage[w]&&this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),this._storage[w]=new y(m,c>0?new Date(Date.now()+c):null),c>0&&(this._storage[w].timeoutId=setTimeout(()=>{delete this._storage[w]},c),this._storage[w].timeoutId.unref&&this._storage[w].timeoutId.unref()),new l(0,0===c?-1:c,this._storage[w].value,!0)}get(w){if(this._storage[w]){const m=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return new l(0,m,this._storage[w].value,!1)}return null}delete(w){return!!this._storage[w]&&(this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),delete this._storage[w],!0)}}},7105:Y=>{Y.exports=class{constructor(x,y,l=null){this.value=x,this.expiresAt=y,this.timeoutId=l}get value(){return this._value}set value(x){this._value=parseInt(x)}get expiresAt(){return this._expiresAt}set expiresAt(x){!(x instanceof Date)&&Number.isInteger(x)&&(x=new Date(x)),this._expiresAt=x}get timeoutId(){return this._timeoutId}set timeoutId(x){this._timeoutId=x}}},2047:Y=>{Y.exports=class extends Error{constructor(x,y){super(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="CustomError",this.message=x,y&&(this.extra=y)}}},4033:(Y,U,x)=>{"use strict";Y.exports=m;var y=x(4366),l=m.prototype,g=new Date%1e9;function m(h){this.id=(h=h||{}).id||function w(){return(1e9*Math.random()>>>0)+g++}(),this.max=h.max||1/0,this.items=h.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(h.lastModified||new Date);for(var c,f,d=this.items.length;d--;)c=this.items[d],f=new Date(c.expires)-new Date,this._lookup[c.key]=c,f>0?this.expire(c.key,f):f<=0&&this.delete(c.key)}l.has=function(h){return h in this._lookup},l.get=function(h){if(!this.has(h))return null;var c=this._lookup[h];return c.refresh&&this.expire(h,c.refresh),this.items.splice(this.items.indexOf(c),1),this.items.push(c),c.value},l.meta=function(h){if(!this.has(h))return null;var c=this._lookup[h];return"meta"in c?c.meta:null},l.set=function(h,c,f){var d=this._lookup[h],b=this._lookup[h]={key:h,value:c};return this.lastModified=new Date,d?(clearTimeout(d.timeout),this.items.splice(this.items.indexOf(d),1,b)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(b),this.size++),f&&("ttl"in f&&this.expire(h,f.ttl),"meta"in f&&(b.meta=f.meta),f.refresh&&(b.refresh=f.ttl)),this},l.delete=function(h){var c=this._lookup[h];return!!c&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(c),1),clearTimeout(c.timeout),delete this._lookup[h],this.size--,this)},l.expire=function(h,c){var f=c||0,d=this._lookup[h];if(!d)return this;if("string"==typeof f&&(f=y(c)),"number"!=typeof f)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(d.timeout),d.timeout=setTimeout(this.delete.bind(this,d.key),f),d.expires=Number(new Date)+f,this},l.clear=function(){for(var h=this.items.length;h--;)this.delete(this.items[h].key);return this},l.toJSON=function(){for(var c,h=new Array(this.items.length),f=h.length;f--;)h[f]={key:(c=this.items[f]).key,meta:c.meta,value:c.value,expires:c.expires,refresh:c.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:h}}},2502:(Y,U,x)=>{"use strict";const y=x(7806);class l{constructor(m,h,c){const f=this;this._started=y(),this._rescheduled=0,this._scheduled=h,this._args=c,this._triggered=!1,this._timerWrapper=()=>{f._rescheduled>0?(f._scheduled=f._rescheduled-(y()-f._started),f._schedule(f._scheduled)):(f._triggered=!0,m.apply(null,f._args))},this._timer=setTimeout(this._timerWrapper,h)}reschedule(m){m||(m=this._scheduled);const h=y();h+m-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(m)):this._triggered?this._schedule(m):(this._started=h,this._rescheduled=m)}_schedule(m){this._triggered=!1,this._started=y(),this._rescheduled=0,this._scheduled=m,this._timer=setTimeout(this._timerWrapper,m)}clear(){clearTimeout(this._timer)}}Y.exports=function g(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");let w;if(arguments.length>0){w=new Array(arguments.length-2);for(var m=0;m{"use strict";Y.exports=function(){return Date.now()}},9014:(Y,U,x)=>{"use strict";var y=x(9942),l=/[\/\?<>\\:\*\|"]/g,g=/[\x00-\x1f\x80-\x9f]/g,w=/^\.+$/,m=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,h=/[\. ]+$/;function c(f,d){if("string"!=typeof f)throw new Error("Input must be string");var b=f.replace(l,d).replace(g,d).replace(w,d).replace(m,d).replace(h,d);return y(b,255)}Y.exports=function(f,d){var b=d&&d.replacement||"",S=c(f,b);return""===b?S:c(S,"")}},1466:(Y,U,x)=>{"use strict";var y=x(7156).default;const l=new Map;function m(){return(m=y(function*(f,d,b){for(;l.get(b);){try{yield f()}catch(S){setTimeout(()=>{throw S},1);break}if(!l.get(b))break;yield new Promise(S=>{const E=setTimeout(S,d);l.set(b,E)})}})).apply(this,arguments)}Y.exports={setDelayedInterval:function h(f,d,b){b=b||d;const S=`${Date.now()}:${Math.floor(1e6*Math.random())}`,E=setTimeout(()=>{!function w(f,d,b){m.apply(this,arguments)}(f,d,S)},b);return l.set(S,E),S},clearDelayedInterval:function c(f){const d=l.get(f);d&&(clearTimeout(d),l.delete(f))}}},1420:(Y,U,x)=>{"use strict";const{AbortController:y}=globalThis,l=x(2502);class g extends y{constructor(m){super(),this._ms=m,this._timer=l(()=>this.abort(),m),Object.setPrototypeOf(this,g.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=l(()=>this.abort(),this._ms)}}Y.exports={TimeoutController:g}},9942:(Y,U,x)=>{"use strict";var y=x(8831),l=x(8871);Y.exports=y.bind(null,l)},8831:Y=>{"use strict";function x(y){return y>=56320&&y<=57343}Y.exports=function(l,g,w){if("string"!=typeof g)throw new Error("Input must be string");for(var c,f,m=g.length,h=0,d=0;d=55296&&y<=56319&&x(g.charCodeAt(d+1))&&(f+=g[d+=1]),(h+=l(f))===w)return g.slice(0,d+1);if(h>w)return g.slice(0,d-f.length+1)}var y;return g}},8871:Y=>{"use strict";function U(y){return y>=55296&&y<=56319}Y.exports=function(l){if("string"!=typeof l)throw new Error("Input must be string");for(var g=l.length,w=0,m=null,h=null,c=0;c=56320&&y<=57343?null!=h&&U(h)?w+=1:w+=3:m<=127?w+=1:m>=128&&m<=2047?w+=2:m>=2048&&m<=65535&&(w+=3),h=m;var y;return w}},3004:Y=>{Y.exports=function y(l,m){var f,w=0,h=0,c=m=m||0,d=l.length;do{if(c>=d||h>49)throw y.bytes=0,new RangeError("Could not decode varint");f=l[c++],w+=h<28?(127&f)<=128);return y.bytes=c-m,w}},5723:Y=>{Y.exports=function g(w,m,h){if(Number.MAX_SAFE_INTEGER&&w>Number.MAX_SAFE_INTEGER)throw g.bytes=0,new RangeError("Could not encode varint");m=m||[];for(var c=h=h||0;w>=l;)m[h++]=255&w|128,w/=128;for(;-128&w;)m[h++]=255&w|128,w>>>=7;return m[h]=0|w,g.bytes=h-c+1,m};var l=Math.pow(2,31)},1732:(Y,U,x)=>{Y.exports={encode:x(5723),decode:x(3004),encodingLength:x(4036)}},4036:Y=>{var U=Math.pow(2,7),x=Math.pow(2,14),y=Math.pow(2,21),l=Math.pow(2,28),g=Math.pow(2,35),w=Math.pow(2,42),m=Math.pow(2,49),h=Math.pow(2,56),c=Math.pow(2,63);Y.exports=function(f){return f{"use strict";!function(ie){const fe=ie.performance;function ye(Ft){fe&&fe.mark&&fe.mark(Ft)}function me(Ft,ct){fe&&fe.measure&&fe.measure(Ft,ct)}ye("Zone");const _e=ie.__Zone_symbol_prefix||"__zone_symbol__";function Me(Ft){return _e+Ft}const Qe=!0===ie[Me("forceDuplicateZoneCheck")];if(ie.Zone){if(Qe||"function"!=typeof ie.Zone.__symbol__)throw new Error("Zone already loaded.");return ie.Zone}let qe=(()=>{class Ft{constructor(ce,ve){this._parent=ce,this._name=ve?ve.name||"unnamed":"",this._properties=ve&&ve.properties||{},this._zoneDelegate=new nt(this,this._parent&&this._parent._zoneDelegate,ve)}static assertZonePatched(){if(ie.Promise!==Pr.ZoneAwarePromise)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")}static get root(){let ce=Ft.current;for(;ce.parent;)ce=ce.parent;return ce}static get current(){return En.zone}static get currentTask(){return cr}static __load_patch(ce,ve,mt=!1){if(Pr.hasOwnProperty(ce)){if(!mt&&Qe)throw Error("Already loaded patch: "+ce)}else if(!ie["__Zone_disable_"+ce]){const Dt="Zone:"+ce;ye(Dt),Pr[ce]=ve(ie,Ft,kn),me(Dt,Dt)}}get parent(){return this._parent}get name(){return this._name}get(ce){const ve=this.getZoneWith(ce);if(ve)return ve._properties[ce]}getZoneWith(ce){let ve=this;for(;ve;){if(ve._properties.hasOwnProperty(ce))return ve;ve=ve._parent}return null}fork(ce){if(!ce)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,ce)}wrap(ce,ve){if("function"!=typeof ce)throw new Error("Expecting function got: "+ce);const mt=this._zoneDelegate.intercept(this,ce,ve),Dt=this;return function(){return Dt.runGuarded(mt,this,arguments,ve)}}run(ce,ve,mt,Dt){En={parent:En,zone:this};try{return this._zoneDelegate.invoke(this,ce,ve,mt,Dt)}finally{En=En.parent}}runGuarded(ce,ve=null,mt,Dt){En={parent:En,zone:this};try{try{return this._zoneDelegate.invoke(this,ce,ve,mt,Dt)}catch(yn){if(this._zoneDelegate.handleError(this,yn))throw yn}}finally{En=En.parent}}runTask(ce,ve,mt){if(ce.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(ce.zone||An).name+"; Execution: "+this.name+")");if(ce.state===Bt&&(ce.type===er||ce.type===wt))return;const Dt=ce.state!=ft;Dt&&ce._transitionTo(ft,tn),ce.runCount++;const yn=cr;cr=ce,En={parent:En,zone:this};try{ce.type==wt&&ce.data&&!ce.data.isPeriodic&&(ce.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,ce,ve,mt)}catch(ze){if(this._zoneDelegate.handleError(this,ze))throw ze}}finally{ce.state!==Bt&&ce.state!==st&&(ce.type==er||ce.data&&ce.data.isPeriodic?Dt&&ce._transitionTo(tn,ft):(ce.runCount=0,this._updateTaskCount(ce,-1),Dt&&ce._transitionTo(Bt,ft,Bt))),En=En.parent,cr=yn}}scheduleTask(ce){if(ce.zone&&ce.zone!==this){let mt=this;for(;mt;){if(mt===ce.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${ce.zone.name}`);mt=mt.parent}}ce._transitionTo(gn,Bt);const ve=[];ce._zoneDelegates=ve,ce._zone=this;try{ce=this._zoneDelegate.scheduleTask(this,ce)}catch(mt){throw ce._transitionTo(st,gn,Bt),this._zoneDelegate.handleError(this,mt),mt}return ce._zoneDelegates===ve&&this._updateTaskCount(ce,1),ce.state==gn&&ce._transitionTo(tn,gn),ce}scheduleMicroTask(ce,ve,mt,Dt){return this.scheduleTask(new $e(Kt,ce,ve,mt,Dt,void 0))}scheduleMacroTask(ce,ve,mt,Dt,yn){return this.scheduleTask(new $e(wt,ce,ve,mt,Dt,yn))}scheduleEventTask(ce,ve,mt,Dt,yn){return this.scheduleTask(new $e(er,ce,ve,mt,Dt,yn))}cancelTask(ce){if(ce.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(ce.zone||An).name+"; Execution: "+this.name+")");ce._transitionTo(fn,tn,ft);try{this._zoneDelegate.cancelTask(this,ce)}catch(ve){throw ce._transitionTo(st,fn),this._zoneDelegate.handleError(this,ve),ve}return this._updateTaskCount(ce,-1),ce._transitionTo(Bt,fn),ce.runCount=0,ce}_updateTaskCount(ce,ve){const mt=ce._zoneDelegates;-1==ve&&(ce._zoneDelegates=null);for(let Dt=0;DtFt.hasTask(ce,ve),onScheduleTask:(Ft,ct,ce,ve)=>Ft.scheduleTask(ce,ve),onInvokeTask:(Ft,ct,ce,ve,mt,Dt)=>Ft.invokeTask(ce,ve,mt,Dt),onCancelTask:(Ft,ct,ce,ve)=>Ft.cancelTask(ce,ve)};class nt{constructor(ct,ce,ve){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=ct,this._parentDelegate=ce,this._forkZS=ve&&(ve&&ve.onFork?ve:ce._forkZS),this._forkDlgt=ve&&(ve.onFork?ce:ce._forkDlgt),this._forkCurrZone=ve&&(ve.onFork?this.zone:ce._forkCurrZone),this._interceptZS=ve&&(ve.onIntercept?ve:ce._interceptZS),this._interceptDlgt=ve&&(ve.onIntercept?ce:ce._interceptDlgt),this._interceptCurrZone=ve&&(ve.onIntercept?this.zone:ce._interceptCurrZone),this._invokeZS=ve&&(ve.onInvoke?ve:ce._invokeZS),this._invokeDlgt=ve&&(ve.onInvoke?ce:ce._invokeDlgt),this._invokeCurrZone=ve&&(ve.onInvoke?this.zone:ce._invokeCurrZone),this._handleErrorZS=ve&&(ve.onHandleError?ve:ce._handleErrorZS),this._handleErrorDlgt=ve&&(ve.onHandleError?ce:ce._handleErrorDlgt),this._handleErrorCurrZone=ve&&(ve.onHandleError?this.zone:ce._handleErrorCurrZone),this._scheduleTaskZS=ve&&(ve.onScheduleTask?ve:ce._scheduleTaskZS),this._scheduleTaskDlgt=ve&&(ve.onScheduleTask?ce:ce._scheduleTaskDlgt),this._scheduleTaskCurrZone=ve&&(ve.onScheduleTask?this.zone:ce._scheduleTaskCurrZone),this._invokeTaskZS=ve&&(ve.onInvokeTask?ve:ce._invokeTaskZS),this._invokeTaskDlgt=ve&&(ve.onInvokeTask?ce:ce._invokeTaskDlgt),this._invokeTaskCurrZone=ve&&(ve.onInvokeTask?this.zone:ce._invokeTaskCurrZone),this._cancelTaskZS=ve&&(ve.onCancelTask?ve:ce._cancelTaskZS),this._cancelTaskDlgt=ve&&(ve.onCancelTask?ce:ce._cancelTaskDlgt),this._cancelTaskCurrZone=ve&&(ve.onCancelTask?this.zone:ce._cancelTaskCurrZone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const mt=ve&&ve.onHasTask;(mt||ce&&ce._hasTaskZS)&&(this._hasTaskZS=mt?ve:it,this._hasTaskDlgt=ce,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=ct,ve.onScheduleTask||(this._scheduleTaskZS=it,this._scheduleTaskDlgt=ce,this._scheduleTaskCurrZone=this.zone),ve.onInvokeTask||(this._invokeTaskZS=it,this._invokeTaskDlgt=ce,this._invokeTaskCurrZone=this.zone),ve.onCancelTask||(this._cancelTaskZS=it,this._cancelTaskDlgt=ce,this._cancelTaskCurrZone=this.zone))}fork(ct,ce){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,ct,ce):new qe(ct,ce)}intercept(ct,ce,ve){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,ct,ce,ve):ce}invoke(ct,ce,ve,mt,Dt){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,ct,ce,ve,mt,Dt):ce.apply(ve,mt)}handleError(ct,ce){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,ct,ce)}scheduleTask(ct,ce){let ve=ce;if(this._scheduleTaskZS)this._hasTaskZS&&ve._zoneDelegates.push(this._hasTaskDlgtOwner),ve=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,ct,ce),ve||(ve=ce);else if(ce.scheduleFn)ce.scheduleFn(ce);else{if(ce.type!=Kt)throw new Error("Task is missing scheduleFn.");vt(ce)}return ve}invokeTask(ct,ce,ve,mt){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,ct,ce,ve,mt):ce.callback.apply(ve,mt)}cancelTask(ct,ce){let ve;if(this._cancelTaskZS)ve=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,ct,ce);else{if(!ce.cancelFn)throw Error("Task is not cancelable");ve=ce.cancelFn(ce)}return ve}hasTask(ct,ce){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,ct,ce)}catch(ve){this.handleError(ct,ve)}}_updateTaskCount(ct,ce){const ve=this._taskCounts,mt=ve[ct],Dt=ve[ct]=mt+ce;if(Dt<0)throw new Error("More tasks executed then were scheduled.");0!=mt&&0!=Dt||this.hasTask(this.zone,{microTask:ve.microTask>0,macroTask:ve.macroTask>0,eventTask:ve.eventTask>0,change:ct})}}class $e{constructor(ct,ce,ve,mt,Dt,yn){if(this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=ct,this.source=ce,this.data=mt,this.scheduleFn=Dt,this.cancelFn=yn,!ve)throw new Error("callback is not defined");this.callback=ve;const ze=this;this.invoke=ct===er&&mt&&mt.useG?$e.invokeTask:function(){return $e.invokeTask.call(ie,ze,this,arguments)}}static invokeTask(ct,ce,ve){ct||(ct=this),Zn++;try{return ct.runCount++,ct.zone.runTask(ct,ce,ve)}finally{1==Zn&&et(),Zn--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(Bt,gn)}_transitionTo(ct,ce,ve){if(this._state!==ce&&this._state!==ve)throw new Error(`${this.type} '${this.source}': can not transition to '${ct}', expecting state '${ce}'${ve?" or '"+ve+"'":""}, was '${this._state}'.`);this._state=ct,ct==Bt&&(this._zoneDelegates=null)}toString(){return this.data&&typeof this.data.handleId<"u"?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const we=Me("setTimeout"),ge=Me("Promise"),De=Me("then");let dt,Fe=[],Be=!1;function xt(Ft){if(dt||ie[ge]&&(dt=ie[ge].resolve(0)),dt){let ct=dt[De];ct||(ct=dt.then),ct.call(dt,Ft)}else ie[we](Ft,0)}function vt(Ft){0===Zn&&0===Fe.length&&xt(et),Ft&&Fe.push(Ft)}function et(){if(!Be){for(Be=!0;Fe.length;){const Ft=Fe;Fe=[];for(let ct=0;ctEn,onUnhandledError:bn,microtaskDrainDone:bn,scheduleMicroTask:vt,showUncaughtError:()=>!qe[Me("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:bn,patchMethod:()=>bn,bindArguments:()=>[],patchThen:()=>bn,patchMacroTask:()=>bn,patchEventPrototype:()=>bn,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>bn,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>bn,wrapWithCurrentZone:()=>bn,filterProperties:()=>[],attachOriginToPatched:()=>bn,_redefineProperty:()=>bn,patchCallbacks:()=>bn,nativeScheduleMicroTask:xt};let En={parent:null,zone:new qe(null,null)},cr=null,Zn=0;function bn(){}me("Zone","Zone"),ie.Zone=qe}(typeof window<"u"&&window||typeof self<"u"&&self||global);const Y=Object.getOwnPropertyDescriptor,U=Object.defineProperty,x=Object.getPrototypeOf,y=Object.create,l=Array.prototype.slice,g="addEventListener",w="removeEventListener",m=Zone.__symbol__(g),h=Zone.__symbol__(w),c="true",f="false",d=Zone.__symbol__("");function b(ie,fe){return Zone.current.wrap(ie,fe)}function S(ie,fe,ye,me,_e){return Zone.current.scheduleMacroTask(ie,fe,ye,me,_e)}const E=Zone.__symbol__,v=typeof window<"u",p=v?window:void 0,I=v&&p||"object"==typeof self&&self||global;function P(ie,fe){for(let ye=ie.length-1;ye>=0;ye--)"function"==typeof ie[ye]&&(ie[ye]=b(ie[ye],fe+"_"+ye));return ie}function T(ie){return!ie||!1!==ie.writable&&!("function"==typeof ie.get&&typeof ie.set>"u")}const M=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,k=!("nw"in I)&&typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process),F=!k&&!M&&!(!v||!p.HTMLElement),j=typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process)&&!M&&!(!v||!p.HTMLElement),C={},O=function(ie){if(!(ie=ie||I.event))return;let fe=C[ie.type];fe||(fe=C[ie.type]=E("ON_PROPERTY"+ie.type));const ye=this||ie.target||I,me=ye[fe];let _e;if(F&&ye===p&&"error"===ie.type){const Me=ie;_e=me&&me.call(this,Me.message,Me.filename,Me.lineno,Me.colno,Me.error),!0===_e&&ie.preventDefault()}else _e=me&&me.apply(this,arguments),null!=_e&&!_e&&ie.preventDefault();return _e};function V(ie,fe,ye){let me=Y(ie,fe);if(!me&&ye&&Y(ye,fe)&&(me={enumerable:!0,configurable:!0}),!me||!me.configurable)return;const _e=E("on"+fe+"patched");if(ie.hasOwnProperty(_e)&&ie[_e])return;delete me.writable,delete me.value;const Me=me.get,Qe=me.set,qe=fe.slice(2);let it=C[qe];it||(it=C[qe]=E("ON_PROPERTY"+qe)),me.set=function(nt){let $e=this;!$e&&ie===I&&($e=I),$e&&("function"==typeof $e[it]&&$e.removeEventListener(qe,O),Qe&&Qe.call($e,null),$e[it]=nt,"function"==typeof nt&&$e.addEventListener(qe,O,!1))},me.get=function(){let nt=this;if(!nt&&ie===I&&(nt=I),!nt)return null;const $e=nt[it];if($e)return $e;if(Me){let we=Me.call(this);if(we)return me.set.call(this,we),"function"==typeof nt.removeAttribute&&nt.removeAttribute(fe),we}return null},U(ie,fe,me),ie[_e]=!0}function L(ie,fe,ye){if(fe)for(let me=0;mefunction(Qe,qe){const it=ye(Qe,qe);return it.cbIdx>=0&&"function"==typeof qe[it.cbIdx]?S(it.name,qe[it.cbIdx],it,_e):Me.apply(Qe,qe)})}function Z(ie,fe){ie[E("OriginalDelegate")]=fe}let q=!1,ne=!1;function he(){if(q)return ne;q=!0;try{const ie=p.navigator.userAgent;(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/")||-1!==ie.indexOf("Edge/"))&&(ne=!0)}catch{}return ne}Zone.__load_patch("ZoneAwarePromise",(ie,fe,ye)=>{const me=Object.getOwnPropertyDescriptor,_e=Object.defineProperty,Qe=ye.symbol,qe=[],it=!0===ie[Qe("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")],nt=Qe("Promise"),$e=Qe("then");ye.onUnhandledError=ze=>{if(ye.showUncaughtError()){const Ye=ze&&ze.rejection;Ye?console.error("Unhandled Promise rejection:",Ye instanceof Error?Ye.message:Ye,"; Zone:",ze.zone.name,"; Task:",ze.task&&ze.task.source,"; Value:",Ye,Ye instanceof Error?Ye.stack:void 0):console.error(ze)}},ye.microtaskDrainDone=()=>{for(;qe.length;){const ze=qe.shift();try{ze.zone.runGuarded(()=>{throw ze.throwOriginal?ze.rejection:ze})}catch(Ye){De(Ye)}}};const ge=Qe("unhandledPromiseRejectionHandler");function De(ze){ye.onUnhandledError(ze);try{const Ye=fe[ge];"function"==typeof Ye&&Ye.call(this,ze)}catch{}}function Fe(ze){return ze&&ze.then}function Be(ze){return ze}function dt(ze){return ce.reject(ze)}const xt=Qe("state"),vt=Qe("value"),et=Qe("finally"),An=Qe("parentPromiseValue"),Bt=Qe("parentPromiseState"),tn=null,fn=!1;function Kt(ze,Ye){return Ae=>{try{kn(ze,Ye,Ae)}catch(Ge){kn(ze,!1,Ge)}}}const wt=function(){let ze=!1;return function(Ae){return function(){ze||(ze=!0,Ae.apply(null,arguments))}}},Pr=Qe("currentTaskTrace");function kn(ze,Ye,Ae){const Ge=wt();if(ze===Ae)throw new TypeError("Promise resolved with itself");if(ze[xt]===tn){let ht=null;try{("object"==typeof Ae||"function"==typeof Ae)&&(ht=Ae&&Ae.then)}catch(Et){return Ge(()=>{kn(ze,!1,Et)})(),ze}if(Ye!==fn&&Ae instanceof ce&&Ae.hasOwnProperty(xt)&&Ae.hasOwnProperty(vt)&&Ae[xt]!==tn)cr(Ae),kn(ze,Ae[xt],Ae[vt]);else if(Ye!==fn&&"function"==typeof ht)try{ht.call(Ae,Ge(Kt(ze,Ye)),Ge(Kt(ze,!1)))}catch(Et){Ge(()=>{kn(ze,!1,Et)})()}else{ze[xt]=Ye;const Et=ze[vt];if(ze[vt]=Ae,ze[et]===et&&!0===Ye&&(ze[xt]=ze[Bt],ze[vt]=ze[An]),Ye===fn&&Ae instanceof Error){const ut=fe.currentTask&&fe.currentTask.data&&fe.currentTask.data.__creationTrace__;ut&&_e(Ae,Pr,{configurable:!0,enumerable:!1,writable:!0,value:ut})}for(let ut=0;ut{try{const St=ze[vt],$t=!!Ae&&et===Ae[et];$t&&(Ae[An]=St,Ae[Bt]=Et);const Ut=Ye.run(ut,void 0,$t&&ut!==dt&&ut!==Be?[]:[St]);kn(Ae,!0,Ut)}catch(St){kn(Ae,!1,St)}},Ae)}const Ft=function(){},ct=ie.AggregateError;class ce{static toString(){return"function ZoneAwarePromise() { [native code] }"}static resolve(Ye){return kn(new this(null),!0,Ye)}static reject(Ye){return kn(new this(null),fn,Ye)}static any(Ye){if(!Ye||"function"!=typeof Ye[Symbol.iterator])return Promise.reject(new ct([],"All promises were rejected"));const Ae=[];let Ge=0;try{for(let ut of Ye)Ge++,Ae.push(ce.resolve(ut))}catch{return Promise.reject(new ct([],"All promises were rejected"))}if(0===Ge)return Promise.reject(new ct([],"All promises were rejected"));let ht=!1;const Et=[];return new ce((ut,St)=>{for(let $t=0;$t{ht||(ht=!0,ut(Ut))},Ut=>{Et.push(Ut),Ge--,0===Ge&&(ht=!0,St(new ct(Et,"All promises were rejected")))})})}static race(Ye){let Ae,Ge,ht=new this((St,$t)=>{Ae=St,Ge=$t});function Et(St){Ae(St)}function ut(St){Ge(St)}for(let St of Ye)Fe(St)||(St=this.resolve(St)),St.then(Et,ut);return ht}static all(Ye){return ce.allWithCallback(Ye)}static allSettled(Ye){return(this&&this.prototype instanceof ce?this:ce).allWithCallback(Ye,{thenCallback:Ge=>({status:"fulfilled",value:Ge}),errorCallback:Ge=>({status:"rejected",reason:Ge})})}static allWithCallback(Ye,Ae){let Ge,ht,Et=new this((Ut,xn)=>{Ge=Ut,ht=xn}),ut=2,St=0;const $t=[];for(let Ut of Ye){Fe(Ut)||(Ut=this.resolve(Ut));const xn=St;try{Ut.then(Sn=>{$t[xn]=Ae?Ae.thenCallback(Sn):Sn,ut--,0===ut&&Ge($t)},Sn=>{Ae?($t[xn]=Ae.errorCallback(Sn),ut--,0===ut&&Ge($t)):ht(Sn)})}catch(Sn){ht(Sn)}ut++,St++}return ut-=2,0===ut&&Ge($t),Et}constructor(Ye){const Ae=this;if(!(Ae instanceof ce))throw new Error("Must be an instanceof Promise.");Ae[xt]=tn,Ae[vt]=[];try{const Ge=wt();Ye&&Ye(Ge(Kt(Ae,!0)),Ge(Kt(Ae,fn)))}catch(Ge){kn(Ae,!1,Ge)}}get[Symbol.toStringTag](){return"Promise"}get[Symbol.species](){return ce}then(Ye,Ae){var Ge;let ht=null===(Ge=this.constructor)||void 0===Ge?void 0:Ge[Symbol.species];(!ht||"function"!=typeof ht)&&(ht=this.constructor||ce);const Et=new ht(Ft),ut=fe.current;return this[xt]==tn?this[vt].push(ut,Et,Ye,Ae):Zn(this,ut,Et,Ye,Ae),Et}catch(Ye){return this.then(null,Ye)}finally(Ye){var Ae;let Ge=null===(Ae=this.constructor)||void 0===Ae?void 0:Ae[Symbol.species];(!Ge||"function"!=typeof Ge)&&(Ge=ce);const ht=new Ge(Ft);ht[et]=et;const Et=fe.current;return this[xt]==tn?this[vt].push(Et,ht,Ye,Ye):Zn(this,Et,ht,Ye,Ye),ht}}ce.resolve=ce.resolve,ce.reject=ce.reject,ce.race=ce.race,ce.all=ce.all;const ve=ie[nt]=ie.Promise;ie.Promise=ce;const mt=Qe("thenPatched");function Dt(ze){const Ye=ze.prototype,Ae=me(Ye,"then");if(Ae&&(!1===Ae.writable||!Ae.configurable))return;const Ge=Ye.then;Ye[$e]=Ge,ze.prototype.then=function(ht,Et){return new ce((St,$t)=>{Ge.call(this,St,$t)}).then(ht,Et)},ze[mt]=!0}return ye.patchThen=Dt,ve&&(Dt(ve),G(ie,"fetch",ze=>function yn(ze){return function(Ye,Ae){let Ge=ze.apply(Ye,Ae);if(Ge instanceof ce)return Ge;let ht=Ge.constructor;return ht[mt]||Dt(ht),Ge}}(ze))),Promise[fe.__symbol__("uncaughtPromiseErrors")]=qe,ce}),Zone.__load_patch("toString",ie=>{const fe=Function.prototype.toString,ye=E("OriginalDelegate"),me=E("Promise"),_e=E("Error"),Me=function(){if("function"==typeof this){const nt=this[ye];if(nt)return"function"==typeof nt?fe.call(nt):Object.prototype.toString.call(nt);if(this===Promise){const $e=ie[me];if($e)return fe.call($e)}if(this===Error){const $e=ie[_e];if($e)return fe.call($e)}}return fe.call(this)};Me[ye]=fe,Function.prototype.toString=Me;const Qe=Object.prototype.toString;Object.prototype.toString=function(){return"function"==typeof Promise&&this instanceof Promise?"[object Promise]":Qe.call(this)}});let pe=!1;if(typeof window<"u")try{const ie=Object.defineProperty({},"passive",{get:function(){pe=!0}});window.addEventListener("test",ie,ie),window.removeEventListener("test",ie,ie)}catch{pe=!1}const Le={useG:!0},Se={},Ne={},be=new RegExp("^"+d+"(\\w+)(true|false)$"),je=E("propagationStopped");function H(ie,fe){const ye=(fe?fe(ie):ie)+f,me=(fe?fe(ie):ie)+c,_e=d+ye,Me=d+me;Se[ie]={},Se[ie][f]=_e,Se[ie][c]=Me}function Ee(ie,fe,ye,me){const _e=me&&me.add||g,Me=me&&me.rm||w,Qe=me&&me.listeners||"eventListeners",qe=me&&me.rmAll||"removeAllListeners",it=E(_e),nt="."+_e+":",ge=function(vt,et,An){if(vt.isRemoved)return;const Bt=vt.callback;let gn;"object"==typeof Bt&&Bt.handleEvent&&(vt.callback=ft=>Bt.handleEvent(ft),vt.originalDelegate=Bt);try{vt.invoke(vt,et,[An])}catch(ft){gn=ft}const tn=vt.options;return tn&&"object"==typeof tn&&tn.once&&et[Me].call(et,An.type,vt.originalDelegate?vt.originalDelegate:vt.callback,tn),gn};function De(vt,et,An){if(!(et=et||ie.event))return;const Bt=vt||et.target||ie,gn=Bt[Se[et.type][An?c:f]];if(gn){const tn=[];if(1===gn.length){const ft=ge(gn[0],Bt,et);ft&&tn.push(ft)}else{const ft=gn.slice();for(let fn=0;fn{throw fn})}}}const Fe=function(vt){return De(this,vt,!1)},Be=function(vt){return De(this,vt,!0)};function dt(vt,et){if(!vt)return!1;let An=!0;et&&void 0!==et.useG&&(An=et.useG);const Bt=et&&et.vh;let gn=!0;et&&void 0!==et.chkDup&&(gn=et.chkDup);let tn=!1;et&&void 0!==et.rt&&(tn=et.rt);let ft=vt;for(;ft&&!ft.hasOwnProperty(_e);)ft=x(ft);if(!ft&&vt[_e]&&(ft=vt),!ft||ft[it])return!1;const fn=et&&et.eventNameToString,st={},Kt=ft[it]=ft[_e],wt=ft[E(Me)]=ft[Me],er=ft[E(Qe)]=ft[Qe],Pr=ft[E(qe)]=ft[qe];let kn;function En(Ae,Ge){return!pe&&"object"==typeof Ae&&Ae?!!Ae.capture:pe&&Ge?"boolean"==typeof Ae?{capture:Ae,passive:!0}:Ae?"object"==typeof Ae&&!1!==Ae.passive?Object.assign(Object.assign({},Ae),{passive:!0}):Ae:{passive:!0}:Ae}et&&et.prepend&&(kn=ft[E(et.prepend)]=ft[et.prepend]);const ce=An?function(Ae){if(!st.isExisting)return Kt.call(st.target,st.eventName,st.capture?Be:Fe,st.options)}:function(Ae){return Kt.call(st.target,st.eventName,Ae.invoke,st.options)},ve=An?function(Ae){if(!Ae.isRemoved){const Ge=Se[Ae.eventName];let ht;Ge&&(ht=Ge[Ae.capture?c:f]);const Et=ht&&Ae.target[ht];if(Et)for(let ut=0;utfunction(_e,Me){_e[je]=!0,me&&me.apply(_e,Me)})}function He(ie,fe,ye,me,_e){const Me=Zone.__symbol__(me);if(fe[Me])return;const Qe=fe[Me]=fe[me];fe[me]=function(qe,it,nt){return it&&it.prototype&&_e.forEach(function($e){const we=`${ye}.${me}::`+$e,ge=it.prototype;try{if(ge.hasOwnProperty($e)){const De=ie.ObjectGetOwnPropertyDescriptor(ge,$e);De&&De.value?(De.value=ie.wrapWithCurrentZone(De.value,we),ie._redefineProperty(it.prototype,$e,De)):ge[$e]&&(ge[$e]=ie.wrapWithCurrentZone(ge[$e],we))}else ge[$e]&&(ge[$e]=ie.wrapWithCurrentZone(ge[$e],we))}catch{}}),Qe.call(fe,qe,it,nt)},ie.attachOriginToPatched(fe[me],Qe)}function We(ie,fe,ye){if(!ye||0===ye.length)return fe;const me=ye.filter(Me=>Me.target===ie);if(!me||0===me.length)return fe;const _e=me[0].ignoreProperties;return fe.filter(Me=>-1===_e.indexOf(Me))}function Je(ie,fe,ye,me){ie&&L(ie,We(ie,fe,ye),me)}function Xe(ie){return Object.getOwnPropertyNames(ie).filter(fe=>fe.startsWith("on")&&fe.length>2).map(fe=>fe.substring(2))}Zone.__load_patch("util",(ie,fe,ye)=>{const me=Xe(ie);ye.patchOnProperties=L,ye.patchMethod=G,ye.bindArguments=P,ye.patchMacroTask=te;const _e=fe.__symbol__("BLACK_LISTED_EVENTS"),Me=fe.__symbol__("UNPATCHED_EVENTS");ie[Me]&&(ie[_e]=ie[Me]),ie[_e]&&(fe[_e]=fe[Me]=ie[_e]),ye.patchEventPrototype=Re,ye.patchEventTarget=Ee,ye.isIEOrEdge=he,ye.ObjectDefineProperty=U,ye.ObjectGetOwnPropertyDescriptor=Y,ye.ObjectCreate=y,ye.ArraySlice=l,ye.patchClass=re,ye.wrapWithCurrentZone=b,ye.filterProperties=We,ye.attachOriginToPatched=Z,ye._redefineProperty=Object.defineProperty,ye.patchCallbacks=He,ye.getGlobalObjects=()=>({globalSources:Ne,zoneSymbolEventNames:Se,eventNames:me,isBrowser:F,isMix:j,isNode:k,TRUE_STR:c,FALSE_STR:f,ZONE_SYMBOL_PREFIX:d,ADD_EVENT_LISTENER_STR:g,REMOVE_EVENT_LISTENER_STR:w})});const pt=E("zoneTask");function _t(ie,fe,ye,me){let _e=null,Me=null;ye+=me;const Qe={};function qe(nt){const $e=nt.data;return $e.args[0]=function(){return nt.invoke.apply(this,arguments)},$e.handleId=_e.apply(ie,$e.args),nt}function it(nt){return Me.call(ie,nt.data.handleId)}_e=G(ie,fe+=me,nt=>function($e,we){if("function"==typeof we[0]){const ge={isPeriodic:"Interval"===me,delay:"Timeout"===me||"Interval"===me?we[1]||0:void 0,args:we},De=we[0];we[0]=function(){try{return De.apply(this,arguments)}finally{ge.isPeriodic||("number"==typeof ge.handleId?delete Qe[ge.handleId]:ge.handleId&&(ge.handleId[pt]=null))}};const Fe=S(fe,we[0],ge,qe,it);if(!Fe)return Fe;const Be=Fe.data.handleId;return"number"==typeof Be?Qe[Be]=Fe:Be&&(Be[pt]=Fe),Be&&Be.ref&&Be.unref&&"function"==typeof Be.ref&&"function"==typeof Be.unref&&(Fe.ref=Be.ref.bind(Be),Fe.unref=Be.unref.bind(Be)),"number"==typeof Be||Be?Be:Fe}return nt.apply(ie,we)}),Me=G(ie,ye,nt=>function($e,we){const ge=we[0];let De;"number"==typeof ge?De=Qe[ge]:(De=ge&&ge[pt],De||(De=ge)),De&&"string"==typeof De.type?"notScheduled"!==De.state&&(De.cancelFn&&De.data.isPeriodic||0===De.runCount)&&("number"==typeof ge?delete Qe[ge]:ge&&(ge[pt]=null),De.zone.cancelTask(De)):nt.apply(ie,we)})}Zone.__load_patch("legacy",ie=>{const fe=ie[Zone.__symbol__("legacyPatch")];fe&&fe()}),Zone.__load_patch("queueMicrotask",(ie,fe,ye)=>{ye.patchMethod(ie,"queueMicrotask",me=>function(_e,Me){fe.current.scheduleMicroTask("queueMicrotask",Me[0])})}),Zone.__load_patch("timers",ie=>{const ye="clear";_t(ie,"set",ye,"Timeout"),_t(ie,"set",ye,"Interval"),_t(ie,"set",ye,"Immediate")}),Zone.__load_patch("requestAnimationFrame",ie=>{_t(ie,"request","cancel","AnimationFrame"),_t(ie,"mozRequest","mozCancel","AnimationFrame"),_t(ie,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(ie,fe)=>{const ye=["alert","prompt","confirm"];for(let me=0;mefunction(it,nt){return fe.current.run(Me,ie,nt,qe)})}),Zone.__load_patch("EventTarget",(ie,fe,ye)=>{(function Hr(ie,fe){fe.patchEventPrototype(ie,fe)})(ie,ye),function pr(ie,fe){if(Zone[fe.symbol("patchEventTarget")])return;const{eventNames:ye,zoneSymbolEventNames:me,TRUE_STR:_e,FALSE_STR:Me,ZONE_SYMBOL_PREFIX:Qe}=fe.getGlobalObjects();for(let it=0;it{re("MutationObserver"),re("WebKitMutationObserver")}),Zone.__load_patch("IntersectionObserver",(ie,fe,ye)=>{re("IntersectionObserver")}),Zone.__load_patch("FileReader",(ie,fe,ye)=>{re("FileReader")}),Zone.__load_patch("on_property",(ie,fe,ye)=>{!function Nt(ie,fe){if(k&&!j||Zone[ie.symbol("patchEvents")])return;const ye=fe.__Zone_ignore_on_properties;let me=[];if(F){const _e=window;me=me.concat(["Document","SVGElement","Element","HTMLElement","HTMLBodyElement","HTMLMediaElement","HTMLFrameSetElement","HTMLFrameElement","HTMLIFrameElement","HTMLMarqueeElement","Worker"]);const Me=function se(){try{const ie=p.navigator.userAgent;if(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/"))return!0}catch{}return!1}()?[{target:_e,ignoreProperties:["error"]}]:[];Je(_e,Xe(_e),ye&&ye.concat(Me),x(_e))}me=me.concat(["XMLHttpRequest","XMLHttpRequestEventTarget","IDBIndex","IDBRequest","IDBOpenDBRequest","IDBDatabase","IDBTransaction","IDBCursor","WebSocket"]);for(let _e=0;_e{!function Or(ie,fe){const{isBrowser:ye,isMix:me}=fe.getGlobalObjects();(ye||me)&&ie.customElements&&"customElements"in ie&&fe.patchCallbacks(fe,ie.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}(ie,ye)}),Zone.__load_patch("XHR",(ie,fe)=>{!function it(nt){const $e=nt.XMLHttpRequest;if(!$e)return;const we=$e.prototype;let De=we[m],Fe=we[h];if(!De){const st=nt.XMLHttpRequestEventTarget;if(st){const Kt=st.prototype;De=Kt[m],Fe=Kt[h]}}const Be="readystatechange",dt="scheduled";function xt(st){const Kt=st.data,wt=Kt.target;wt[Me]=!1,wt[qe]=!1;const er=wt[_e];De||(De=wt[m],Fe=wt[h]),er&&Fe.call(wt,Be,er);const Pr=wt[_e]=()=>{if(wt.readyState===wt.DONE)if(!Kt.aborted&&wt[Me]&&st.state===dt){const En=wt[fe.__symbol__("loadfalse")];if(0!==wt.status&&En&&En.length>0){const cr=st.invoke;st.invoke=function(){const Zn=wt[fe.__symbol__("loadfalse")];for(let bn=0;bnfunction(st,Kt){return st[me]=0==Kt[2],st[Qe]=Kt[1],An.apply(st,Kt)}),gn=E("fetchTaskAborting"),tn=E("fetchTaskScheduling"),ft=G(we,"send",()=>function(st,Kt){if(!0===fe.current[tn]||st[me])return ft.apply(st,Kt);{const wt={target:st,url:st[Qe],isPeriodic:!1,args:Kt,aborted:!1},er=S("XMLHttpRequest.send",vt,wt,xt,et);st&&!0===st[qe]&&!wt.aborted&&er.state===dt&&er.invoke()}}),fn=G(we,"abort",()=>function(st,Kt){const wt=function ge(st){return st[ye]}(st);if(wt&&"string"==typeof wt.type){if(null==wt.cancelFn||wt.data&&wt.data.aborted)return;wt.zone.cancelTask(wt)}else if(!0===fe.current[gn])return fn.apply(st,Kt)})}(ie);const ye=E("xhrTask"),me=E("xhrSync"),_e=E("xhrListener"),Me=E("xhrScheduled"),Qe=E("xhrURL"),qe=E("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",ie=>{ie.navigator&&ie.navigator.geolocation&&function D(ie,fe){const ye=ie.constructor.name;for(let me=0;me{const it=function(){return qe.apply(this,P(arguments,ye+"."+_e))};return Z(it,qe),it})(Me)}}}(ie.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(ie,fe)=>{function ye(me){return function(_e){Ie(ie,me).forEach(Qe=>{const qe=ie.PromiseRejectionEvent;if(qe){const it=new qe(me,{promise:_e.promise,reason:_e.rejection});Qe.invoke(it)}})}}ie.PromiseRejectionEvent&&(fe[E("unhandledPromiseRejectionHandler")]=ye("unhandledrejection"),fe[E("rejectionHandledHandler")]=ye("rejectionhandled"))})},7420:()=>{},5856:()=>{},5883:()=>{},6577:()=>{},5819:()=>{},1265:()=>{},5539:()=>{},8479:function(Y,U,x){"use strict";var l,g;l=[x(1873)],void 0!==(g=function(w){var m=w.Reader,h=w.Writer,c=w.util,f=w.roots.default||(w.roots.default={});return f.RPC=function(){function d(S){if(this.subscriptions=[],this.messages=[],S)for(var E=Object.keys(S),v=0;v>>3){case 1:I.subscriptions&&I.subscriptions.length||(I.subscriptions=[]),I.subscriptions.push(f.RPC.SubOpts.decode(E,E.uint32()));break;case 2:I.messages&&I.messages.length||(I.messages=[]),I.messages.push(f.RPC.Message.decode(E,E.uint32()));break;case 3:I.control=f.RPC.ControlMessage.decode(E,E.uint32());break;default:E.skipType(7&A)}}return I},d.fromObject=function(E){if(E instanceof f.RPC)return E;var v=new f.RPC;if(E.subscriptions){if(!Array.isArray(E.subscriptions))throw TypeError(".RPC.subscriptions: array expected");v.subscriptions=[];for(var p=0;p>>3){case 1:P.subscribe=p.bool();break;case 2:P.topic=p.string();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.SubOpts)return p;var I=new f.RPC.SubOpts;return null!=p.subscribe&&(I.subscribe=Boolean(p.subscribe)),null!=p.topic&&(I.topic=String(p.topic)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.subscribe&&p.hasOwnProperty("subscribe")&&(A.subscribe=p.subscribe,I.oneofs&&(A._subscribe="subscribe")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic,I.oneofs&&(A._topic="topic")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.Message=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.from=p.bytes();break;case 2:P.data=p.bytes();break;case 3:P.seqno=p.bytes();break;case 4:P.topic=p.string();break;case 5:P.signature=p.bytes();break;case 6:P.key=p.bytes();break;default:p.skipType(7&D)}}if(!P.hasOwnProperty("topic"))throw c.ProtocolError("missing required 'topic'",{instance:P});return P},S.fromObject=function(p){if(p instanceof f.RPC.Message)return p;var I=new f.RPC.Message;return null!=p.from&&("string"==typeof p.from?c.base64.decode(p.from,I.from=c.newBuffer(c.base64.length(p.from)),0):p.from.length&&(I.from=p.from)),null!=p.data&&("string"==typeof p.data?c.base64.decode(p.data,I.data=c.newBuffer(c.base64.length(p.data)),0):p.data.length&&(I.data=p.data)),null!=p.seqno&&("string"==typeof p.seqno?c.base64.decode(p.seqno,I.seqno=c.newBuffer(c.base64.length(p.seqno)),0):p.seqno.length&&(I.seqno=p.seqno)),null!=p.topic&&(I.topic=String(p.topic)),null!=p.signature&&("string"==typeof p.signature?c.base64.decode(p.signature,I.signature=c.newBuffer(c.base64.length(p.signature)),0):p.signature.length&&(I.signature=p.signature)),null!=p.key&&("string"==typeof p.key?c.base64.decode(p.key,I.key=c.newBuffer(c.base64.length(p.key)),0):p.key.length&&(I.key=p.key)),I},S.toObject=function(p,I){I||(I={});var A={};return I.defaults&&(A.topic=""),null!=p.from&&p.hasOwnProperty("from")&&(A.from=I.bytes===String?c.base64.encode(p.from,0,p.from.length):I.bytes===Array?Array.prototype.slice.call(p.from):p.from,I.oneofs&&(A._from="from")),null!=p.data&&p.hasOwnProperty("data")&&(A.data=I.bytes===String?c.base64.encode(p.data,0,p.data.length):I.bytes===Array?Array.prototype.slice.call(p.data):p.data,I.oneofs&&(A._data="data")),null!=p.seqno&&p.hasOwnProperty("seqno")&&(A.seqno=I.bytes===String?c.base64.encode(p.seqno,0,p.seqno.length):I.bytes===Array?Array.prototype.slice.call(p.seqno):p.seqno,I.oneofs&&(A._seqno="seqno")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic),null!=p.signature&&p.hasOwnProperty("signature")&&(A.signature=I.bytes===String?c.base64.encode(p.signature,0,p.signature.length):I.bytes===Array?Array.prototype.slice.call(p.signature):p.signature,I.oneofs&&(A._signature="signature")),null!=p.key&&p.hasOwnProperty("key")&&(A.key=I.bytes===String?c.base64.encode(p.key,0,p.key.length):I.bytes===Array?Array.prototype.slice.call(p.key):p.key,I.oneofs&&(A._key="key")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlMessage=function(){function S(E){if(this.ihave=[],this.iwant=[],this.graft=[],this.prune=[],E)for(var v=Object.keys(E),p=0;p>>3){case 1:A.ihave&&A.ihave.length||(A.ihave=[]),A.ihave.push(f.RPC.ControlIHave.decode(v,v.uint32()));break;case 2:A.iwant&&A.iwant.length||(A.iwant=[]),A.iwant.push(f.RPC.ControlIWant.decode(v,v.uint32()));break;case 3:A.graft&&A.graft.length||(A.graft=[]),A.graft.push(f.RPC.ControlGraft.decode(v,v.uint32()));break;case 4:A.prune&&A.prune.length||(A.prune=[]),A.prune.push(f.RPC.ControlPrune.decode(v,v.uint32()));break;default:v.skipType(7&P)}}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlMessage)return v;var p=new f.RPC.ControlMessage;if(v.ihave){if(!Array.isArray(v.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");p.ihave=[];for(var I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.messageIDs&&P.messageIDs.length||(P.messageIDs=[]),P.messageIDs.push(p.bytes());break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlIHave)return p;var I=new f.RPC.ControlIHave;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.messageIDs){if(!Array.isArray(p.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");I.messageIDs=[];for(var A=0;A>>3==1?(A.messageIDs&&A.messageIDs.length||(A.messageIDs=[]),A.messageIDs.push(v.bytes())):v.skipType(7&P)}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlIWant)return v;var p=new f.RPC.ControlIWant;if(v.messageIDs){if(!Array.isArray(v.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");p.messageIDs=[];for(var I=0;I>>3==1?P.topicID=p.string():p.skipType(7&D)}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlGraft)return p;var I=new f.RPC.ControlGraft;return null!=p.topicID&&(I.topicID=String(p.topicID)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlPrune=function(){function S(v){if(this.peers=[],v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.peers&&P.peers.length||(P.peers=[]),P.peers.push(f.RPC.PeerInfo.decode(p,p.uint32()));break;case 3:P.backoff=p.uint64();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlPrune)return p;var I=new f.RPC.ControlPrune;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.peers){if(!Array.isArray(p.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");I.peers=[];for(var A=0;A>>0,p.backoff.high>>>0).toNumber(!0))),I},S.toObject=function(p,I){I||(I={});var A={};if((I.arrays||I.defaults)&&(A.peers=[]),null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),p.peers&&p.peers.length){A.peers=[];for(var P=0;P>>0,p.backoff.high>>>0).toNumber(!0):p.backoff,I.oneofs&&(A._backoff="backoff")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.PeerInfo=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.peerID=p.bytes();break;case 2:P.signedPeerRecord=p.bytes();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.PeerInfo)return p;var I=new f.RPC.PeerInfo;return null!=p.peerID&&("string"==typeof p.peerID?c.base64.decode(p.peerID,I.peerID=c.newBuffer(c.base64.length(p.peerID)),0):p.peerID.length&&(I.peerID=p.peerID)),null!=p.signedPeerRecord&&("string"==typeof p.signedPeerRecord?c.base64.decode(p.signedPeerRecord,I.signedPeerRecord=c.newBuffer(c.base64.length(p.signedPeerRecord)),0):p.signedPeerRecord.length&&(I.signedPeerRecord=p.signedPeerRecord)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.peerID&&p.hasOwnProperty("peerID")&&(A.peerID=I.bytes===String?c.base64.encode(p.peerID,0,p.peerID.length):I.bytes===Array?Array.prototype.slice.call(p.peerID):p.peerID,I.oneofs&&(A._peerID="peerID")),null!=p.signedPeerRecord&&p.hasOwnProperty("signedPeerRecord")&&(A.signedPeerRecord=I.bytes===String?c.base64.encode(p.signedPeerRecord,0,p.signedPeerRecord.length):I.bytes===Array?Array.prototype.slice.call(p.signedPeerRecord):p.signedPeerRecord,I.oneofs&&(A._signedPeerRecord="signedPeerRecord")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d}(),f}.apply(U,l))&&(Y.exports=g)},4642:(Y,U,x)=>{var y=x(9805);function l(g){var w,m;function c(d,b){try{var S=g[d](b),E=S.value,v=E instanceof y;Promise.resolve(v?E.wrapped:E).then(function(p){v?c("return"===d?"return":"next",p):f(S.done?"return":"normal",p)},function(p){c("throw",p)})}catch(p){f("throw",p)}}function f(d,b){switch(d){case"return":w.resolve({value:b,done:!0});break;case"throw":w.reject(b);break;default:w.resolve({value:b,done:!1})}(w=w.next)?c(w.key,w.arg):m=null}this._invoke=function h(d,b){return new Promise(function(S,E){var v={key:d,arg:b,resolve:S,reject:E,next:null};m?m=m.next=v:(w=m=v,c(d,b))})},"function"!=typeof g.return&&(this.return=void 0)}l.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},l.prototype.next=function(g){return this._invoke("next",g)},l.prototype.throw=function(g){return this._invoke("throw",g)},l.prototype.return=function(g){return this._invoke("return",g)},Y.exports=l,Y.exports.__esModule=!0,Y.exports.default=Y.exports},9805:Y=>{Y.exports=function U(x){this.wrapped=x},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8131:Y=>{Y.exports=function U(x,y){var l={},g=!1;function w(m,h){return g=!0,h=new Promise(function(c){c(x[m](h))}),{done:!1,value:y(h)}}return l[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},l.next=function(m){return g?(g=!1,m):w("next",m)},"function"==typeof x.throw&&(l.throw=function(m){if(g)throw g=!1,m;return w("throw",m)}),"function"==typeof x.return&&(l.return=function(m){return g?(g=!1,m):w("return",m)}),l},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8237:Y=>{function x(y){function l(g){if(Object(g)!==g)return Promise.reject(new TypeError(g+" is not an object."));var w=g.done;return Promise.resolve(g.value).then(function(m){return{value:m,done:w}})}return(x=function(w){this.s=w,this.n=w.next}).prototype={s:null,n:null,next:function(){return l(this.n.apply(this.s,arguments))},return:function(w){var m=this.s.return;return void 0===m?Promise.resolve({value:w,done:!0}):l(m.apply(this.s,arguments))},throw:function(w){var m=this.s.return;return void 0===m?Promise.reject(w):l(m.apply(this.s,arguments))}},new x(y)}Y.exports=function U(y){var l,g,w,m=2;for(typeof Symbol<"u"&&(g=Symbol.asyncIterator,w=Symbol.iterator);m--;){if(g&&null!=(l=y[g]))return l.call(y);if(w&&null!=(l=y[w]))return new x(l.call(y));g="@@asyncIterator",w="@@iterator"}throw new TypeError("Object is not async iterable")},Y.exports.__esModule=!0,Y.exports.default=Y.exports},7156:Y=>{function U(y,l,g,w,m,h,c){try{var f=y[h](c),d=f.value}catch(b){return void g(b)}f.done?l(d):Promise.resolve(d).then(w,m)}Y.exports=function x(y){return function(){var l=this,g=arguments;return new Promise(function(w,m){var h=y.apply(l,g);function c(d){U(h,w,m,c,f,"next",d)}function f(d){U(h,w,m,c,f,"throw",d)}c(void 0)})}},Y.exports.__esModule=!0,Y.exports.default=Y.exports},6737:(Y,U,x)=>{var y=x(9805);Y.exports=function l(g){return new y(g)},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8186:(Y,U,x)=>{var y=x(4642);Y.exports=function l(g){return function(){return new y(g.apply(this,arguments))}},Y.exports.__esModule=!0,Y.exports.default=Y.exports}},Y=>{Y(Y.s=8487)}]); \ No newline at end of file